Compare commits

..

13 Commits

Author SHA1 Message Date
cosmonaut d612e8538a delete entire collision system 2023-02-03 11:51:35 -08:00
evan 1916415fb4 line test + improving AABB sweep 2023-02-03 11:51:35 -08:00
cosmonaut 72573219ed fix uniform scale check 2023-02-03 11:51:35 -08:00
cosmonaut 10db4f95c8 AABB transform shortcut + sweep test 2023-02-03 11:51:35 -08:00
cosmonaut 9704072ab2 rework spatial hash to store arbitrary data 2023-02-03 11:51:35 -08:00
cosmonaut c04d021237 fix spatial hash remove crash if key does not exist 2023-02-03 11:51:34 -08:00
cosmonaut b81780e258 garbage optimization changes 2023-02-03 11:51:34 -08:00
evan e52fe60657 update RefreshCS 2023-01-31 12:29:17 -08:00
TheSpydog b39526ca90 Textures now have a sample count, not render passes (#45)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #45
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-31 20:27:26 +00:00
TheSpydog 88d9119830 Remove warning from DrawInstancedPrimitives doc comment (#44)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #44
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-24 00:14:46 +00:00
TheSpydog 05de9a4066 Make video shaders optional and search for them in the root output directory (#42)
Whenever the video shaders change, they can be rebuilt with refreshc and distributed alongside the moonlibs.

Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #42
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-21 23:37:01 +00:00
TheSpydog b1d30a9e6c Remove isFixed param from AcquireCommandBuffer call (#41)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #41
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-14 18:04:53 +00:00
TheSpydog 030745361b Fix BC7 loading for textures without DDSD_CAPS/FMT (#40)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: #40
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-07 01:46:59 +00:00
13 changed files with 70 additions and 70 deletions

View File

@ -24,13 +24,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="src\Video\Shaders\Compiled\FullscreenVert.spv">
<LogicalName>MoonWorks.Shaders.FullscreenVert.spv</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="src\Video\Shaders\Compiled\YUV2RGBAFrag.spv">
<LogicalName>MoonWorks.Shaders.YUV2RGBAFrag.spv</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>

@ -1 +1 @@
Subproject commit 1643061386177f62b516ccaad0ea04607cae2333
Subproject commit 52d3355120cba2025fac67499ee3c669e5347809

View File

@ -71,7 +71,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfo.SampleCount;
currentSampleCount = colorAttachmentInfo.Texture.SampleCount;
colorFormatOne = colorAttachmentInfo.Texture.Format;
#endif
}
@ -111,7 +111,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
#endif
@ -159,7 +159,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -215,7 +215,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -285,7 +285,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfo.SampleCount;
currentSampleCount = colorAttachmentInfo.Texture.SampleCount;
colorFormatOne = colorAttachmentInfo.Texture.Format;
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
#endif
@ -332,7 +332,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
@ -387,7 +387,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -450,7 +450,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -1489,7 +1489,6 @@ namespace MoonWorks.Graphics
/// <summary>
/// Draws using instanced rendering.
/// It is an error to call this method unless two vertex buffers have been bound.
/// </summary>
/// <param name="baseVertex">The starting index offset for the vertex buffer.</param>
/// <param name="startIndex">The starting index offset for the index buffer.</param>
@ -2047,7 +2046,7 @@ namespace MoonWorks.Graphics
private void AssertSameSampleCount(ColorAttachmentInfo a, ColorAttachmentInfo b)
{
if (a.SampleCount != b.SampleCount)
if (a.Texture.SampleCount != b.Texture.SampleCount)
{
throw new System.ArgumentException("All color attachments in a render pass must have the same SampleCount!");
}

View File

@ -14,8 +14,6 @@ namespace MoonWorks.Graphics
public SDL2.SDL.SDL_WindowFlags WindowFlags => (SDL2.SDL.SDL_WindowFlags) windowFlags;
// Built-in video pipeline
private ShaderModule VideoVertexShader { get; }
private ShaderModule VideoFragmentShader { get; }
internal GraphicsPipeline VideoPipeline { get; }
public bool IsDisposed { get; private set; }
@ -25,8 +23,7 @@ namespace MoonWorks.Graphics
public GraphicsDevice(
Backend preferredBackend,
bool debugMode
)
{
) {
Backend = (Backend) Refresh.Refresh_SelectBackend((Refresh.Backend) preferredBackend, out windowFlags);
if (Backend == Backend.Invalid)
@ -38,25 +35,43 @@ namespace MoonWorks.Graphics
Conversions.BoolToByte(debugMode)
);
VideoVertexShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.FullscreenVert.spv"));
VideoFragmentShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.YUV2RGBAFrag.spv"));
// Check for optional video shaders
string basePath = SDL2.SDL.SDL_GetBasePath();
string videoVertPath = Path.Combine(basePath, "video_fullscreen.refresh");
string videoFragPath = Path.Combine(basePath, "video_yuv2rgba.refresh");
if (File.Exists(videoVertPath) && File.Exists(videoFragPath))
{
ShaderModule videoVertShader = new ShaderModule(this, videoVertPath);
ShaderModule videoFragShader = new ShaderModule(this, videoFragPath);
VideoPipeline = new GraphicsPipeline(
this,
new GraphicsPipelineCreateInfo
{
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
new ColorAttachmentDescription(TextureFormat.R8G8B8A8, ColorAttachmentBlendState.None)
),
DepthStencilState = DepthStencilState.Disable,
VertexShaderInfo = GraphicsShaderInfo.Create(VideoVertexShader, "main", 0),
FragmentShaderInfo = GraphicsShaderInfo.Create(VideoFragmentShader, "main", 3),
VertexInputState = VertexInputState.Empty,
RasterizerState = RasterizerState.CCW_CullNone,
PrimitiveType = PrimitiveType.TriangleList,
MultisampleState = MultisampleState.None
}
);
VideoPipeline = new GraphicsPipeline(
this,
new GraphicsPipelineCreateInfo
{
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
new ColorAttachmentDescription(
TextureFormat.R8G8B8A8,
ColorAttachmentBlendState.None
)
),
DepthStencilState = DepthStencilState.Disable,
VertexShaderInfo = GraphicsShaderInfo.Create(
videoVertShader,
"main",
0
),
FragmentShaderInfo = GraphicsShaderInfo.Create(
videoFragShader,
"main",
3
),
VertexInputState = VertexInputState.Empty,
RasterizerState = RasterizerState.CCW_CullNone,
PrimitiveType = PrimitiveType.TriangleList,
MultisampleState = MultisampleState.None
}
);
}
}
public bool ClaimWindow(Window window, PresentMode presentMode)
@ -102,7 +117,7 @@ namespace MoonWorks.Graphics
public CommandBuffer AcquireCommandBuffer()
{
return new CommandBuffer(this, Refresh.Refresh_AcquireCommandBuffer(Handle, 0));
return new CommandBuffer(this, Refresh.Refresh_AcquireCommandBuffer(Handle));
}
public unsafe void Submit(CommandBuffer commandBuffer)
@ -214,11 +229,6 @@ namespace MoonWorks.Graphics
}
}
private static Stream GetEmbeddedResource(string name)
{
return typeof(GraphicsDevice).Assembly.GetManifestResourceStream(name);
}
protected virtual void Dispose(bool disposing)
{
if (!IsDisposed)

View File

@ -181,7 +181,6 @@ namespace MoonWorks.Graphics
public uint Depth;
public uint Layer;
public uint Level;
public SampleCount SampleCount;
public Color ClearColor;
public LoadOp LoadOp;
public StoreOp StoreOp;
@ -189,15 +188,12 @@ namespace MoonWorks.Graphics
public ColorAttachmentInfo(
Texture texture,
Color clearColor,
SampleCount sampleCount = SampleCount.One,
StoreOp storeOp = StoreOp.Store
)
{
) {
Texture = texture;
Depth = 0;
Layer = 0;
Level = 0;
SampleCount = sampleCount;
ClearColor = clearColor;
LoadOp = LoadOp.Clear;
StoreOp = storeOp;
@ -206,15 +202,12 @@ namespace MoonWorks.Graphics
public ColorAttachmentInfo(
Texture texture,
LoadOp loadOp = LoadOp.DontCare,
SampleCount sampleCount = SampleCount.One,
StoreOp storeOp = StoreOp.Store
)
{
) {
Texture = texture;
Depth = 0;
Layer = 0;
Level = 0;
SampleCount = sampleCount;
ClearColor = Color.White;
LoadOp = loadOp;
StoreOp = storeOp;
@ -228,7 +221,6 @@ namespace MoonWorks.Graphics
depth = Depth,
layer = Layer,
level = Level,
sampleCount = (Refresh.SampleCount) SampleCount,
clearColor = new Refresh.Vec4
{
x = ClearColor.R / 255f,

View File

@ -5,7 +5,7 @@ using System.IO;
namespace MoonWorks.Graphics
{
/// <summary>
/// Shader modules expect input in SPIR-V bytecode format.
/// Shader modules expect input in Refresh bytecode format.
/// </summary>
public class ShaderModule : GraphicsResource
{

View File

@ -15,6 +15,7 @@ namespace MoonWorks.Graphics
public TextureFormat Format { get; internal set; }
public bool IsCube { get; }
public uint LevelCount { get; }
public SampleCount SampleCount { get; }
public TextureUsageFlags UsageFlags { get; }
// FIXME: this allocates a delegate instance
@ -39,13 +40,14 @@ namespace MoonWorks.Graphics
var byteCount = (uint) (width * height * channels);
TextureCreateInfo textureCreateInfo;
TextureCreateInfo textureCreateInfo = new TextureCreateInfo();
textureCreateInfo.Width = (uint) width;
textureCreateInfo.Height = (uint) height;
textureCreateInfo.Depth = 1;
textureCreateInfo.Format = TextureFormat.R8G8B8A8;
textureCreateInfo.IsCube = false;
textureCreateInfo.LevelCount = 1;
textureCreateInfo.SampleCount = SampleCount.One;
textureCreateInfo.UsageFlags = TextureUsageFlags.Sampler;
var texture = new Texture(device, textureCreateInfo);
@ -130,9 +132,9 @@ namespace MoonWorks.Graphics
uint height,
TextureFormat format,
TextureUsageFlags usageFlags,
uint levelCount = 1
)
{
uint levelCount = 1,
SampleCount sampleCount = SampleCount.One
) {
var textureCreateInfo = new TextureCreateInfo
{
Width = width,
@ -140,6 +142,7 @@ namespace MoonWorks.Graphics
Depth = 1,
IsCube = false,
LevelCount = levelCount,
SampleCount = sampleCount,
Format = format,
UsageFlags = usageFlags
};
@ -165,8 +168,7 @@ namespace MoonWorks.Graphics
TextureFormat format,
TextureUsageFlags usageFlags,
uint levelCount = 1
)
{
) {
var textureCreateInfo = new TextureCreateInfo
{
Width = width,
@ -195,8 +197,7 @@ namespace MoonWorks.Graphics
TextureFormat format,
TextureUsageFlags usageFlags,
uint levelCount = 1
)
{
) {
var textureCreateInfo = new TextureCreateInfo
{
Width = size,
@ -232,6 +233,7 @@ namespace MoonWorks.Graphics
Depth = textureCreateInfo.Depth;
IsCube = textureCreateInfo.IsCube;
LevelCount = textureCreateInfo.LevelCount;
SampleCount = textureCreateInfo.SampleCount;
UsageFlags = textureCreateInfo.UsageFlags;
}
@ -255,6 +257,7 @@ namespace MoonWorks.Graphics
Depth = 1;
IsCube = false;
LevelCount = 1;
SampleCount = SampleCount.One;
UsageFlags = TextureUsageFlags.ColorTarget;
}
@ -272,14 +275,12 @@ namespace MoonWorks.Graphics
const uint DDS_MAGIC = 0x20534444;
const uint DDS_HEADERSIZE = 124;
const uint DDS_PIXFMTSIZE = 32;
const uint DDSD_CAPS = 0x1;
const uint DDSD_HEIGHT = 0x2;
const uint DDSD_WIDTH = 0x4;
const uint DDSD_PITCH = 0x8;
const uint DDSD_FMT = 0x1000;
const uint DDSD_LINEARSIZE = 0x80000;
const uint DDSD_REQ = (
DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_FMT
DDSD_HEIGHT | DDSD_WIDTH
);
const uint DDSCAPS_MIPMAP = 0x400000;
const uint DDSCAPS_TEXTURE = 0x1000;

View File

@ -9,6 +9,7 @@ namespace MoonWorks.Graphics
public uint Depth;
public bool IsCube;
public uint LevelCount;
public SampleCount SampleCount;
public TextureFormat Format;
public TextureUsageFlags UsageFlags;
@ -21,6 +22,7 @@ namespace MoonWorks.Graphics
depth = Depth,
isCube = Conversions.BoolToByte(IsCube),
levelCount = LevelCount,
sampleCount = (Refresh.SampleCount) SampleCount,
format = (Refresh.TextureFormat) Format,
usageFlags = (Refresh.TextureUsageFlags) UsageFlags
};

View File

@ -50,6 +50,11 @@ namespace MoonWorks.Video
public VideoPlayer(GraphicsDevice graphicsDevice, AudioDevice audioDevice)
{
GraphicsDevice = graphicsDevice;
if (GraphicsDevice.VideoPipeline == null)
{
throw new InvalidOperationException("Missing video shaders!");
}
AudioDevice = audioDevice;
LinearSampler = new Sampler(graphicsDevice, SamplerCreateInfo.LinearClamp);