made rendering work

This commit is contained in:
2026-02-05 11:10:40 +02:00
parent faae0bdcc7
commit 4bfbcaa4a6
22 changed files with 737 additions and 483 deletions

View File

@@ -8,7 +8,7 @@
BEGIN_BUILD_PIPELINE_LIBRARY(VertexDescription)
library.flags = VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT;
VkPipelineVertexInputStateCreateInfo vertexInput = {};
VkPipelineInputAssemblyStateCreateInfo inputAssembly = {};
@@ -81,8 +81,8 @@ BEGIN_BUILD_PIPELINE_LIBRARY(VertexTransform)
inits[i].m_set.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
inits[i].m_set.bindingCount = inits[i].m_bindings.GetSize();
inits[i].m_set.pBindings = inits[i].m_bindings.GetData();
vkCreateDescriptorSetLayout(g_vkDevice, &inits[i].m_set, NULL, &m_setLayouts[i] );
vkCreateDescriptorSetLayout(m_hDevice, &inits[i].m_set, NULL, &m_setLayouts[i] );
}
for ( i = 0; i < SHADER_STAGE_COUNT; i++)
@@ -92,6 +92,7 @@ BEGIN_BUILD_PIPELINE_LIBRARY(VertexTransform)
CUtlBuffer<unsigned char> code = ShaderParser()->GetShaderCode(m_pShader, (EShaderStage)i);
// We may fail loading the specific stage
if (code.GetSize() == 0)
continue;
@@ -105,7 +106,7 @@ BEGIN_BUILD_PIPELINE_LIBRARY(VertexTransform)
shader.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shader.pName = "main";
shader.stage = VulkanGetShaderStage((EShaderStage)i);
spirvs.AppendTail(code);
stageShaders.AppendTail(mod);
stages.AppendTail(shader);
@@ -125,11 +126,13 @@ BEGIN_BUILD_PIPELINE_LIBRARY(VertexTransform)
stPipelineLayout.pSetLayouts = m_setLayouts;
*/
stPipelineLayout.flags = VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT ;
vkCreatePipelineLayout(g_vkDevice, &stPipelineLayout, NULL, &m_layout);
vkCreatePipelineLayout(m_hDevice, &stPipelineLayout, NULL, &m_layout);
rasterState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterState.polygonMode = VK_POLYGON_MODE_FILL;
rasterState.lineWidth = 1;
rasterState.cullMode = VK_CULL_MODE_NONE;
rasterState.frontFace = VK_FRONT_FACE_CLOCKWISE;
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
@@ -156,7 +159,7 @@ void CVkVertexTransformPipelineLibrary::SetShader( CCompiledShader *pShader )
BEGIN_BUILD_PIPELINE_LIBRARY(PixelShader)
printf("--- PixelShader ---\n");
VkPipelineDepthStencilStateCreateInfo depthStencil = {};
VkPipelineRenderingCreateInfo render = {};
int i = 0;
@@ -175,10 +178,10 @@ BEGIN_BUILD_PIPELINE_LIBRARY(PixelShader)
inits[i].m_set.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
inits[i].m_set.bindingCount = inits[i].m_bindings.GetSize();
inits[i].m_set.pBindings = inits[i].m_bindings.GetData();
vkCreateDescriptorSetLayout(g_vkDevice, &inits[i].m_set, NULL, &m_setLayouts[i] );
vkCreateDescriptorSetLayout(m_hDevice, &inits[i].m_set, NULL, &m_setLayouts[i] );
}
VkPipelineLayoutCreateInfo stPipelineLayout = {};
stPipelineLayout.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
/*
@@ -186,7 +189,7 @@ BEGIN_BUILD_PIPELINE_LIBRARY(PixelShader)
stPipelineLayout.pSetLayouts = m_setLayouts;
*/
stPipelineLayout.flags = VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT ;
vkCreatePipelineLayout(g_vkDevice, &stPipelineLayout, NULL, &m_layout);
vkCreatePipelineLayout(m_hDevice, &stPipelineLayout, NULL, &m_layout);
CUtlBuffer<unsigned char> spirv = {};
VkPipelineShaderStageCreateInfo shader = {};
@@ -204,8 +207,8 @@ BEGIN_BUILD_PIPELINE_LIBRARY(PixelShader)
inits[i].m_set.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
inits[i].m_set.bindingCount = inits[i].m_bindings.GetSize();
inits[i].m_set.pBindings = inits[i].m_bindings.GetData();
vkCreateDescriptorSetLayout(g_vkDevice, &inits[i].m_set, NULL, &m_setLayouts[i] );
vkCreateDescriptorSetLayout(m_hDevice, &inits[i].m_set, NULL, &m_setLayouts[i] );
}
spirv = ShaderParser()->GetShaderCode(m_pShader, SHADER_STAGE_PIXEL);
@@ -257,25 +260,20 @@ BEGIN_BUILD_PIPELINE_LIBRARY(PixelOutput)
render.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO;
render.colorAttachmentCount = m_eFormats.GetSize();
render.pColorAttachmentFormats = m_eFormats.GetData();
depthStencil.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
for ( auto e: m_eFormats )
{
VkPipelineColorBlendAttachmentState a = {};
a.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
a.blendEnable = VK_TRUE;
a.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
a.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
a.colorBlendOp = VK_BLEND_OP_ADD;
a.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
a.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
a.alphaBlendOp = VK_BLEND_OP_ADD;
a.blendEnable = VK_FALSE;
attachments.AppendTail(a);
}
blend.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
blend.attachmentCount = m_eFormats.GetSize();
blend.pAttachments = attachments.GetData();
blend.logicOp = VK_LOGIC_OP_COPY;
pipeline.pDepthStencilState = &depthStencil;
pipeline.pColorBlendState = &blend;
@@ -285,8 +283,8 @@ BEGIN_BUILD_PIPELINE_LIBRARY(PixelOutput)
library.flags = VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT;
END_BUILD_PIPELINE_LIBRARY()
void CVkPixelOutputPipelineLibrary::AddAttachment( EImageFormat eFormat )
{
m_eFormats.AppendTail(CVkImage::GetImageFormat(eFormat));
m_eFormats.AppendTail(CVkImage::GetImageFormat(eFormat));
}