mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Cleaned up pipeline builder code
This commit is contained in:
@@ -449,43 +449,26 @@ void VkRenderer::InitTrianglePipeline()
|
||||
VkDescriptorSetLayout layouts[] = { CameraBufferDescriptorLayout, TriangleBufferDescriptorLayout };
|
||||
|
||||
VkPipelineLayoutCreateInfo pipeline_layout_info = VulkanInit::PipelineLayoutCreateInfo();
|
||||
//pipeline_layout_info.pPushConstantRanges = &bufferRange;
|
||||
pipeline_layout_info.pPushConstantRanges = &bufferRange;
|
||||
pipeline_layout_info.pushConstantRangeCount = 0;
|
||||
pipeline_layout_info.pSetLayouts = layouts;
|
||||
pipeline_layout_info.setLayoutCount = 2;
|
||||
|
||||
VK_CALL(vkCreatePipelineLayout(Device, &pipeline_layout_info, nullptr, &TrianglePipelineLayout));
|
||||
|
||||
PipelineBuilder pipelineBuilder;
|
||||
|
||||
//use the triangle layout we created
|
||||
PipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.PipelineLayout = TrianglePipelineLayout;
|
||||
//connecting the vertex and pixel shaders to the pipeline
|
||||
pipelineBuilder.SetShaders(TriangleVertShader->GetModule(), TriangleFragShader->GetModule());
|
||||
//it will draw triangles
|
||||
pipelineBuilder.SetInputTopology(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
|
||||
//filled triangles
|
||||
pipelineBuilder.SetPolygonMode(VK_POLYGON_MODE_FILL);
|
||||
//no backface culling
|
||||
pipelineBuilder.SetCullMode(VK_CULL_MODE_NONE, VK_FRONT_FACE_CLOCKWISE);
|
||||
//no multisampling
|
||||
pipelineBuilder.SetMultiSamplingNone();
|
||||
//no blending
|
||||
pipelineBuilder.DisableBlending();
|
||||
//no depth testing
|
||||
pipelineBuilder.DisableDepthTest();
|
||||
|
||||
//connect the image format we will draw into, from draw image
|
||||
pipelineBuilder.SetColorAttachment(static_cast<VkFormat>(DrawImage->GetFormat()));
|
||||
pipelineBuilder.SetDepthFormat(VK_FORMAT_UNDEFINED);
|
||||
|
||||
//finally build the pipeline
|
||||
TrianglePipeline = pipelineBuilder.BuildPipeline(Device);
|
||||
|
||||
//clean structures
|
||||
//vkDestroyShaderModule(Device, Triangl, nullptr);
|
||||
//vkDestroyShaderModule(Device, TriangleVertexShader, nullptr);
|
||||
|
||||
MainDeletionQueue.push_function([&]() {
|
||||
vkDestroyPipelineLayout(Device, TrianglePipelineLayout, nullptr);
|
||||
vkDestroyPipeline(Device, TrianglePipeline, nullptr);
|
||||
@@ -523,6 +506,8 @@ void VkRenderer::DrawGeometry(VkCommandBuffer cmd)
|
||||
|
||||
vkCmdSetScissor(cmd, 0, 1, &scissor);
|
||||
|
||||
|
||||
|
||||
vkCmdBindIndexBuffer(cmd, rectangle->GetIndexBuffer()->GetBuffer(), 0, VK_INDEX_TYPE_UINT32);
|
||||
|
||||
vkCmdDrawIndexed(cmd, 6, 1, 0, 0, 0);
|
||||
@@ -743,10 +728,10 @@ void VkRenderer::Draw()
|
||||
|
||||
// Transition rendering iamge to transfert onto swapchain images
|
||||
//VulkanUtil::TransitionImage(cmd, DrawImage->GetImage(), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
|
||||
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
|
||||
DrawGeometry(cmd);
|
||||
|
||||
VulkanUtil::TransitionImage(cmd, DrawImage->GetImage(), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||
|
||||
//draw imgui into the swapchain image
|
||||
|
||||
@@ -14,7 +14,8 @@ struct Vertex
|
||||
float uv_x;
|
||||
float3 normal;
|
||||
float uv_y;
|
||||
float4 color;
|
||||
float4 tangent;
|
||||
float4 bitangent;
|
||||
};
|
||||
|
||||
[[vk::binding(0, 1)]]
|
||||
@@ -44,7 +45,7 @@ VSOutput main(uint vertexIndex : SV_VertexID)
|
||||
|
||||
// Output the position of each vertex
|
||||
output.Position = mul(worldData.proj, mul(worldData.view, mul(worldData.model, float4(v.position, 1.0f))));
|
||||
output.Color = float3(v.color.xyz);
|
||||
output.Color = float3(v.normal.xyz);
|
||||
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user