Update to new vertex input API

pull/1/head
Caleb Cornett 2023-01-06 15:38:30 -05:00
parent 0348b5a497
commit 34475c2b11
10 changed files with 31 additions and 57 deletions

View File

@ -51,11 +51,7 @@ namespace MoonWorks.Test
vertShaderModule, vertShaderModule,
fragShaderModule fragShaderModule
); );
drawPipelineCreateInfo.VertexInputState = new VertexInputState( drawPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
VertexBinding.Create<PositionTextureVertex>(),
VertexAttribute.Create<PositionTextureVertex>("Position", 0),
VertexAttribute.Create<PositionTextureVertex>("TexCoord", 1)
);
drawPipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1; drawPipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
drawPipeline = new GraphicsPipeline( drawPipeline = new GraphicsPipeline(

View File

@ -52,11 +52,7 @@ namespace MoonWorks.Test
vertShaderModule, vertShaderModule,
fragShaderModule fragShaderModule
); );
drawPipelineCreateInfo.VertexInputState = new VertexInputState( drawPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
VertexBinding.Create<PositionTextureVertex>(),
VertexAttribute.Create<PositionTextureVertex>("Position", 0),
VertexAttribute.Create<PositionTextureVertex>("TexCoord", 1)
);
drawPipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1; drawPipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
drawPipeline = new GraphicsPipeline( drawPipeline = new GraphicsPipeline(

View File

@ -165,11 +165,7 @@ namespace MoonWorks.Test
), ),
DepthStencilState = DepthStencilState.DepthReadWrite, DepthStencilState = DepthStencilState.DepthReadWrite,
VertexShaderInfo = GraphicsShaderInfo.Create<ViewProjectionUniforms>(cubeVertShaderModule, "main", 0), VertexShaderInfo = GraphicsShaderInfo.Create<ViewProjectionUniforms>(cubeVertShaderModule, "main", 0),
VertexInputState = new VertexInputState( VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>(),
VertexBinding.Create<PositionColorVertex>(),
VertexAttribute.Create<PositionColorVertex>("Position", 0),
VertexAttribute.Create<PositionColorVertex>("Color", 1)
),
PrimitiveType = PrimitiveType.TriangleList, PrimitiveType = PrimitiveType.TriangleList,
FragmentShaderInfo = GraphicsShaderInfo.Create(cubeFragShaderModule, "main", 0), FragmentShaderInfo = GraphicsShaderInfo.Create(cubeFragShaderModule, "main", 0),
RasterizerState = RasterizerState.CW_CullBack, RasterizerState = RasterizerState.CW_CullBack,
@ -193,10 +189,7 @@ namespace MoonWorks.Test
), ),
DepthStencilState = DepthStencilState.DepthReadWrite, DepthStencilState = DepthStencilState.DepthReadWrite,
VertexShaderInfo = GraphicsShaderInfo.Create<ViewProjectionUniforms>(skyboxVertShaderModule, "main", 0), VertexShaderInfo = GraphicsShaderInfo.Create<ViewProjectionUniforms>(skyboxVertShaderModule, "main", 0),
VertexInputState = new VertexInputState( VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>(),
VertexBinding.Create<PositionVertex>(),
VertexAttribute.Create<PositionVertex>("Position", 0)
),
PrimitiveType = PrimitiveType.TriangleList, PrimitiveType = PrimitiveType.TriangleList,
FragmentShaderInfo = GraphicsShaderInfo.Create(skyboxFragShaderModule, "main", 1), FragmentShaderInfo = GraphicsShaderInfo.Create(skyboxFragShaderModule, "main", 1),
RasterizerState = RasterizerState.CW_CullNone, RasterizerState = RasterizerState.CW_CullNone,
@ -214,11 +207,7 @@ namespace MoonWorks.Test
blitVertShaderModule, blitVertShaderModule,
blitFragShaderModule blitFragShaderModule
); );
blitPipelineCreateInfo.VertexInputState = new VertexInputState( blitPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
VertexBinding.Create<PositionTextureVertex>(),
VertexAttribute.Create<PositionTextureVertex>("Position", 0),
VertexAttribute.Create<PositionTextureVertex>("TexCoord", 1)
);
blitPipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<DepthUniforms>(blitFragShaderModule, "main", 1); blitPipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<DepthUniforms>(blitFragShaderModule, "main", 1);
blitPipeline = new GraphicsPipeline(GraphicsDevice, blitPipelineCreateInfo); blitPipeline = new GraphicsPipeline(GraphicsDevice, blitPipelineCreateInfo);
} }

View File

@ -31,11 +31,7 @@ namespace MoonWorks.Test
vertShaderModule, vertShaderModule,
fragShaderModule fragShaderModule
); );
pipelineCreateInfo.VertexInputState = new VertexInputState( pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>();
VertexBinding.Create<PositionColorVertex>(),
VertexAttribute.Create<PositionColorVertex>("Position", 0),
VertexAttribute.Create<PositionColorVertex>("Color", 1)
);
pipelineCreateInfo.RasterizerState = RasterizerState.CW_CullNone; pipelineCreateInfo.RasterizerState = RasterizerState.CW_CullNone;
CW_CullNonePipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); CW_CullNonePipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);

View File

@ -23,11 +23,7 @@ namespace MoonWorks.Test
vertShaderModule, vertShaderModule,
fragShaderModule fragShaderModule
); );
pipelineCreateInfo.VertexInputState = new VertexInputState( pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>();
VertexBinding.Create<PositionColorVertex>(),
VertexAttribute.Create<PositionColorVertex>("Position", 0),
VertexAttribute.Create<PositionColorVertex>("Color", 1)
);
graphicsPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); graphicsPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create and populate the vertex buffer // Create and populate the vertex buffer

View File

@ -45,11 +45,7 @@ namespace MoonWorks.Test
blitVertShaderModule, blitVertShaderModule,
blitFragShaderModule blitFragShaderModule
); );
pipelineCreateInfo.VertexInputState = new VertexInputState( pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
VertexBinding.Create<PositionTextureVertex>(),
VertexAttribute.Create<PositionTextureVertex>("Position", 0),
VertexAttribute.Create<PositionTextureVertex>("TexCoord", 1)
);
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1; pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
blitPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); blitPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);

View File

@ -5,7 +5,7 @@ using MoonWorks.Math.Float;
namespace MoonWorks.Test namespace MoonWorks.Test
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PositionVertex public struct PositionVertex : IVertexType
{ {
public Vector3 Position; public Vector3 Position;
@ -14,6 +14,11 @@ namespace MoonWorks.Test
Position = position; Position = position;
} }
public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[1]
{
VertexElementFormat.Vector3
};
public override string ToString() public override string ToString()
{ {
return Position.ToString(); return Position.ToString();
@ -21,7 +26,7 @@ namespace MoonWorks.Test
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PositionColorVertex public struct PositionColorVertex : IVertexType
{ {
public Vector3 Position; public Vector3 Position;
public Color Color; public Color Color;
@ -32,6 +37,12 @@ namespace MoonWorks.Test
Color = color; Color = color;
} }
public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[2]
{
VertexElementFormat.Vector3,
VertexElementFormat.Color
};
public override string ToString() public override string ToString()
{ {
return Position + " | " + Color; return Position + " | " + Color;
@ -39,7 +50,7 @@ namespace MoonWorks.Test
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct PositionTextureVertex public struct PositionTextureVertex : IVertexType
{ {
public Vector3 Position; public Vector3 Position;
public Vector2 TexCoord; public Vector2 TexCoord;
@ -50,6 +61,12 @@ namespace MoonWorks.Test
TexCoord = texCoord; TexCoord = texCoord;
} }
public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[2]
{
VertexElementFormat.Vector3,
VertexElementFormat.Vector2
};
public override string ToString() public override string ToString()
{ {
return Position + " | " + TexCoord; return Position + " | " + TexCoord;

View File

@ -50,11 +50,7 @@ namespace MoonWorks.Test
fragShaderModule fragShaderModule
); );
pipelineCreateInfo.AttachmentInfo.ColorAttachmentDescriptions[0].BlendState = ColorAttachmentBlendState.AlphaBlend; pipelineCreateInfo.AttachmentInfo.ColorAttachmentDescriptions[0].BlendState = ColorAttachmentBlendState.AlphaBlend;
pipelineCreateInfo.VertexInputState = new VertexInputState( pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
VertexBinding.Create<PositionTextureVertex>(),
VertexAttribute.Create<PositionTextureVertex>("Position", 0),
VertexAttribute.Create<PositionTextureVertex>("TexCoord", 1)
);
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<VertexUniforms>(vertShaderModule, "main", 0); pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<VertexUniforms>(vertShaderModule, "main", 0);
pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<FragmentUniforms>(fragShaderModule, "main", 1); pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<FragmentUniforms>(fragShaderModule, "main", 1);
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);

View File

@ -38,11 +38,7 @@ namespace MoonWorks.Test
vertShaderModule, vertShaderModule,
fragShaderModule fragShaderModule
); );
pipelineCreateInfo.VertexInputState = new VertexInputState( pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
VertexBinding.Create<PositionTextureVertex>(),
VertexAttribute.Create<PositionTextureVertex>("Position", 0),
VertexAttribute.Create<PositionTextureVertex>("TexCoord", 1)
);
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1; pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);

View File

@ -21,11 +21,7 @@ namespace MoonWorks.Test
vertShaderModule, vertShaderModule,
fragShaderModule fragShaderModule
); );
pipelineCreateInfo.VertexInputState = new VertexInputState( pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>();
VertexBinding.Create<PositionColorVertex>(),
VertexAttribute.Create<PositionColorVertex>("Position", 0),
VertexAttribute.Create<PositionColorVertex>("Color", 1)
);
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create and populate the vertex buffer // Create and populate the vertex buffer