examples now use new shader creation system

refresh2
cosmonaut 2024-06-10 16:54:27 -07:00
parent ea7c1245bc
commit 512ef598d2
24 changed files with 330 additions and 232 deletions

7
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}

View File

@ -19,66 +19,66 @@ class BasicComputeExample : Example
Window.SetTitle("BasicCompute");
// Create the compute pipeline that writes texture data
Shader fillTextureComputeShader = new Shader(
// Create the compute pipeline that writes texture data
ComputePipeline fillTextureComputePipeline = new ComputePipeline(
GraphicsDevice,
TestUtils.GetShaderPath("FillTexture.comp"),
"main",
ShaderStage.Compute,
ShaderFormat.SPIRV
new ComputePipelineCreateInfo
{
ShaderFormat = ShaderFormat.SPIRV,
ReadWriteStorageTextureCount = 1,
ThreadCountX = 8,
ThreadCountY = 8,
ThreadCountZ = 1
}
);
ComputePipeline fillTextureComputePipeline = new ComputePipeline(
GraphicsDevice,
fillTextureComputeShader,
new ComputePipelineResourceInfo { ReadWriteStorageTextureCount = 1 }
);
fillTextureComputeShader.Dispose();
// Create the compute pipeline that calculates squares of numbers
Shader calculateSquaresComputeShader = new Shader(
// Create the compute pipeline that calculates squares of numbers
ComputePipeline calculateSquaresComputePipeline = new ComputePipeline(
GraphicsDevice,
TestUtils.GetShaderPath("CalculateSquares.comp"),
"main",
ShaderStage.Compute,
ShaderFormat.SPIRV
new ComputePipelineCreateInfo
{
ShaderFormat = ShaderFormat.SPIRV,
ReadWriteStorageBufferCount = 1,
ThreadCountX = 8,
ThreadCountY = 1,
ThreadCountZ = 1
}
);
ComputePipeline calculateSquaresComputePipeline = new ComputePipeline(
GraphicsDevice,
calculateSquaresComputeShader,
new ComputePipelineResourceInfo { ReadWriteStorageBufferCount = 1 }
);
calculateSquaresComputeShader.Dispose();
// Create the graphics pipeline
Shader vertShaderModule = new Shader(
Shader vertShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShaderModule = new Shader(
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1
}
);
GraphicsPipelineCreateInfo drawPipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
Window.SwapchainFormat,
vertShaderModule,
fragShaderModule
vertShader,
fragShader
);
drawPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
drawPipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo{
SamplerCount = 1
};
DrawPipeline = new GraphicsPipeline(
GraphicsDevice,

View File

@ -24,15 +24,21 @@ namespace MoonWorksGraphicsTests
GraphicsDevice,
TestUtils.GetShaderPath("PositionColor.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShaderModule = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
// Create the graphics pipelines

View File

@ -30,16 +30,22 @@ class BasicTriangleExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("RawTriangle.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShaderModule = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(

View File

@ -38,16 +38,23 @@ class CompressedTexturesExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShaderModule = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1
}
);
// Create the graphics pipeline
@ -57,10 +64,7 @@ class CompressedTexturesExample : Example
fragShaderModule
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1
};
Pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create sampler

View File

@ -21,25 +21,21 @@ class ComputeUniformsExample : Example
Uniforms.Time = 0;
// Create the compute pipeline that writes texture data
Shader gradientTextureComputeShader = new Shader(
GradientPipeline = new ComputePipeline(
GraphicsDevice,
TestUtils.GetShaderPath("GradientTexture.comp"),
"main",
ShaderStage.Compute,
ShaderFormat.SPIRV
);
GradientPipeline = new ComputePipeline(
GraphicsDevice,
gradientTextureComputeShader,
new ComputePipelineResourceInfo {
new ComputePipelineCreateInfo
{
ShaderFormat = ShaderFormat.SPIRV,
ReadWriteStorageTextureCount = 1,
UniformBufferCount = 1
UniformBufferCount = 1,
ThreadCountX = 8,
ThreadCountY = 8,
ThreadCountZ = 1
}
);
gradientTextureComputeShader.Dispose();
RenderTexture = Texture.CreateTexture2D(
GraphicsDevice,
Window.Width,

View File

@ -109,48 +109,71 @@ namespace MoonWorksGraphicsTests
GraphicsDevice,
TestUtils.GetShaderPath("PositionColorWithMatrix.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV,
UniformBufferCount = 1
}
);
Shader cubeFragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader skyboxVertShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("Skybox.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV,
UniformBufferCount = 1
}
);
Shader skyboxFragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("Skybox.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1
}
);
Shader blitVertShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader blitFragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedDepthQuad.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1,
UniformBufferCount = 1
}
);
DepthTexture = Texture.CreateTexture2D(
@ -209,10 +232,6 @@ namespace MoonWorksGraphicsTests
RasterizerState = RasterizerState.CW_CullBack,
MultisampleState = MultisampleState.None,
VertexShader = cubeVertShader,
VertexShaderResourceInfo = new GraphicsPipelineResourceInfo
{
UniformBufferCount = 1
},
FragmentShader = cubeFragShader
};
CubePipeline = new GraphicsPipeline(GraphicsDevice, cubePipelineCreateInfo);
@ -237,15 +256,7 @@ namespace MoonWorksGraphicsTests
RasterizerState = RasterizerState.CW_CullNone,
MultisampleState = MultisampleState.None,
VertexShader = skyboxVertShader,
VertexShaderResourceInfo = new GraphicsPipelineResourceInfo
{
UniformBufferCount = 1
},
FragmentShader = skyboxFragShader,
FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1
}
FragmentShader = skyboxFragShader
};
SkyboxPipeline = new GraphicsPipeline(GraphicsDevice, skyboxPipelineCreateInfo);
@ -260,11 +271,7 @@ namespace MoonWorksGraphicsTests
blitFragShader
);
blitPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
blitPipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1,
UniformBufferCount = 1
};
BlitPipeline = new GraphicsPipeline(GraphicsDevice, blitPipelineCreateInfo);
}

View File

@ -33,16 +33,22 @@ class CullFaceExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("PositionColor.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
// Create the graphics pipelines

View File

@ -43,16 +43,23 @@ class DepthMSAAExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("PositionColorWithMatrix.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV,
UniformBufferCount = 1
}
);
Shader cubeFragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
GraphicsPipelineCreateInfo pipelineCreateInfo = new GraphicsPipelineCreateInfo
@ -70,10 +77,6 @@ class DepthMSAAExample : Example
RasterizerState = RasterizerState.CW_CullBack,
MultisampleState = MultisampleState.None,
VertexShader = cubeVertShader,
VertexShaderResourceInfo = new GraphicsPipelineResourceInfo
{
UniformBufferCount = 1
},
FragmentShader = cubeFragShader
};

View File

@ -24,16 +24,22 @@ class DrawIndirectExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("PositionColor.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
// Create the graphics pipeline

View File

@ -29,16 +29,22 @@ class InstancingAndOffsetsExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("PositionColorInstanced.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
// Create the graphics pipeline

View File

@ -39,16 +39,22 @@ class MSAACubeExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("RawTriangle.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader triangleFragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
@ -67,16 +73,24 @@ class MSAACubeExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("Skybox.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV,
UniformBufferCount = 1
}
);
Shader cubemapFragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("Skybox.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1
}
);
pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
@ -85,14 +99,7 @@ class MSAACubeExample : Example
cubemapFragShader
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>();
pipelineCreateInfo.VertexShaderResourceInfo = new GraphicsPipelineResourceInfo
{
UniformBufferCount = 1
};
pipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1,
};
CubemapPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create the MSAA render targets

View File

@ -30,16 +30,22 @@ class MSAAExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("RawTriangle.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader triangleFragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(

View File

@ -41,16 +41,24 @@ class RenderTextureCubeExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("Skybox.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV,
UniformBufferCount = 1
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("Skybox.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1
}
);
// Create the graphics pipeline
@ -60,14 +68,7 @@ class RenderTextureCubeExample : Example
fragShader
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>();
pipelineCreateInfo.VertexShaderResourceInfo = new GraphicsPipelineResourceInfo
{
UniformBufferCount = 1
};
pipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1
};
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create samplers

View File

@ -60,16 +60,24 @@ class RenderTextureMipmapsExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuadWithMatrix.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV,
UniformBufferCount = 1
}
);
Shader fragShaderModule = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1
}
);
// Create the graphics pipeline
@ -79,14 +87,7 @@ class RenderTextureMipmapsExample : Example
fragShaderModule
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.VertexShaderResourceInfo = new GraphicsPipelineResourceInfo
{
UniformBufferCount = 1
};
pipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1
};
Pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create samplers

View File

@ -20,16 +20,22 @@ class StoreLoadExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("RawTriangle.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(

View File

@ -44,15 +44,23 @@ class Texture3DCopyExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad3D.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1,
UniformBufferCount = 1
}
);
// Create the graphics pipeline
@ -62,11 +70,7 @@ class Texture3DCopyExample : Example
fragShader
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1,
UniformBufferCount = 1
};
Pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create samplers

View File

@ -40,16 +40,24 @@ class Texture3DExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad3D.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1,
UniformBufferCount = 1
}
);
// Create the graphics pipeline
@ -59,11 +67,7 @@ class Texture3DExample : Example
fragShader
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1,
UniformBufferCount = 1
};
Pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create samplers

View File

@ -30,16 +30,24 @@ class TextureMipmapsExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuadWithMatrix.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV,
UniformBufferCount = 1
}
);
Shader fragShaderModule = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1
}
);
// Create the graphics pipeline
@ -49,14 +57,7 @@ class TextureMipmapsExample : Example
fragShaderModule
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.VertexShaderResourceInfo = new GraphicsPipelineResourceInfo
{
UniformBufferCount = 1
};
pipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1
};
Pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
Sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);

View File

@ -39,16 +39,25 @@ class TexturedAnimatedQuadExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuadWithMatrix.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV,
UniformBufferCount = 1
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuadWithMultiplyColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1,
UniformBufferCount = 1
}
);
// Create the graphics pipeline
@ -59,15 +68,7 @@ class TexturedAnimatedQuadExample : Example
);
pipelineCreateInfo.AttachmentInfo.ColorAttachmentDescriptions[0].BlendState = ColorAttachmentBlendState.AlphaBlend;
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.VertexShaderResourceInfo = new GraphicsPipelineResourceInfo
{
UniformBufferCount = 1
};
pipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1,
UniformBufferCount = 1
};
Pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
Sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);

View File

@ -62,16 +62,23 @@ class TexturedQuadExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("TexturedQuad.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1
}
);
// Create the graphics pipeline
@ -81,10 +88,7 @@ class TexturedQuadExample : Example
fragShader
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.FragmentShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1
};
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create samplers

View File

@ -22,15 +22,21 @@ class TriangleVertexBufferExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("PositionColor.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
// Create the graphics pipeline

View File

@ -21,33 +21,37 @@ class VertexSamplerExample : Example
Window.SetTitle("VertexSampler");
// Load the shaders
Shader vertShaderModule = new Shader(
Shader vertShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("PositionSampler.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV,
SamplerCount = 1
}
);
Shader fragShaderModule = new Shader(
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
// Create the graphics pipeline
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
Window.SwapchainFormat,
vertShaderModule,
fragShaderModule
vertShader,
fragShader
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.VertexShaderResourceInfo = new GraphicsPipelineResourceInfo
{
SamplerCount = 1
};
Pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create and populate the GPU resources

View File

@ -35,16 +35,22 @@ class WindowResizingExample : Example
GraphicsDevice,
TestUtils.GetShaderPath("RawTriangle.vert"),
"main",
ShaderStage.Vertex,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Vertex,
ShaderFormat = ShaderFormat.SPIRV
}
);
Shader fragShader = new Shader(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor.frag"),
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
new ShaderCreateInfo
{
ShaderStage = ShaderStage.Fragment,
ShaderFormat = ShaderFormat.SPIRV
}
);
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(