feat: cube from OBJ with depth buffer, no rotation
- Load Content/cube.obj via ObjLoader (36 vertices, 36 indices) - Depth buffer re-enabled: depth test + write, CompareOp=Less - Depth image transition + depth attachment in rendering info - Push constant angle=0 (no rotation) - Camera at z=-2, perspective FOV 45° - UINT32 index type (fixed in previous commit) - Face normals computed by ObjLoader (no vn in cube.obj) - 0 validation errors
This commit is contained in:
@@ -14,7 +14,7 @@ internal sealed unsafe class VulkanPipeline : IDisposable
|
||||
private readonly VkDevice _device;
|
||||
private bool _disposed;
|
||||
|
||||
public VulkanPipeline(VkDevice device, VkFormat colorFormat, byte[] vertSpv, byte[] fragSpv)
|
||||
public VulkanPipeline(VkDevice device, VkFormat colorFormat, VkFormat depthFormat, byte[] vertSpv, byte[] fragSpv)
|
||||
{
|
||||
_device = device;
|
||||
VertModule = CreateShaderModule(vertSpv);
|
||||
@@ -115,6 +115,16 @@ internal sealed unsafe class VulkanPipeline : IDisposable
|
||||
sampleShadingEnable = VkBool32.False,
|
||||
};
|
||||
|
||||
var depthStencilState = new VkPipelineDepthStencilStateCreateInfo
|
||||
{
|
||||
sType = VkStructureType.PipelineDepthStencilStateCreateInfo,
|
||||
depthTestEnable = VkBool32.True,
|
||||
depthWriteEnable = VkBool32.True,
|
||||
depthCompareOp = VkCompareOp.Less,
|
||||
depthBoundsTestEnable = VkBool32.False,
|
||||
stencilTestEnable = VkBool32.False,
|
||||
};
|
||||
|
||||
var blendAttachment = new VkPipelineColorBlendAttachmentState
|
||||
{
|
||||
blendEnable = VkBool32.False,
|
||||
@@ -169,6 +179,7 @@ internal sealed unsafe class VulkanPipeline : IDisposable
|
||||
sType = VkStructureType.PipelineRenderingCreateInfo,
|
||||
colorAttachmentCount = 1,
|
||||
pColorAttachmentFormats = &colorFormat,
|
||||
depthAttachmentFormat = depthFormat,
|
||||
};
|
||||
|
||||
var pipelineInfo = new VkGraphicsPipelineCreateInfo
|
||||
@@ -182,6 +193,7 @@ internal sealed unsafe class VulkanPipeline : IDisposable
|
||||
pViewportState = &viewportState,
|
||||
pRasterizationState = &rasterizationState,
|
||||
pMultisampleState = &multisampleState,
|
||||
pDepthStencilState = &depthStencilState,
|
||||
pColorBlendState = &colorBlendState,
|
||||
pDynamicState = &dynamicState,
|
||||
layout = PipelineLayout,
|
||||
|
||||
Reference in New Issue
Block a user