-
Notifications
You must be signed in to change notification settings - Fork 6
Fix pipeline validation on Intel GPU #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,34 +136,45 @@ void Pipelines::init(VkDevice device, | |
| _drawImageDescriptorLayout = drawImageDescriptorLayout; | ||
| _drawImage = drawImage; | ||
|
|
||
| // Fix triangle pipeline configuration | ||
| // Triangle pipeline config | ||
| GraphicsPipeline::GraphicsPipelineConfig triangleConfig; | ||
| triangleConfig.vertexShaderPath = "./shaders/colored_triangle.vert.spv"; | ||
| triangleConfig.fragmentShaderPath = "./shaders/colored_triangle.frag.spv"; | ||
| triangleConfig.colorFormat = _drawImage.imageFormat; | ||
| triangleConfig.depthFormat = VK_FORMAT_UNDEFINED; // Explicitly undefined since we don't use depth | ||
| triangleConfig.depthFormat = VK_FORMAT_UNDEFINED; // No depth testing | ||
| triangleConfig.depthTest = false; | ||
| triangleConfig.cullMode = VK_CULL_MODE_NONE; | ||
| triangleConfig.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; | ||
|
|
||
| // Ensure blending and depth testing setup is consistent | ||
| triangleConfig.customPipelineSetup = [](PipelineBuilder& builder) { | ||
| builder.disable_blending(); | ||
| builder.disable_depthtest(); | ||
| builder.set_multisampling_none(); | ||
| builder.set_polygon_mode(VK_POLYGON_MODE_FILL); | ||
| }; | ||
|
|
||
| trianglePipeline = std::make_unique<GraphicsPipeline>(triangleConfig); | ||
| trianglePipeline->init(device); | ||
|
|
||
| // Fix mesh pipeline configuration | ||
| // Mesh pipeline config | ||
| GraphicsPipeline::GraphicsPipelineConfig meshConfig; | ||
| meshConfig.vertexShaderPath = "./shaders/colored_triangle_mesh.vert.spv"; | ||
| meshConfig.fragmentShaderPath = "./shaders/tex_image.frag.spv"; | ||
| meshConfig.colorFormat = _drawImage.imageFormat; | ||
|
|
||
| // Must use a valid depth format when depth testing is enabled | ||
| // Use engine's depth format instead of VK_FORMAT_UNDEFINED | ||
| VkFormat depthFormat = VK_FORMAT_D32_SFLOAT; // Use the standard depth format | ||
| meshConfig.depthFormat = depthFormat; | ||
| meshConfig.depthFormat = VK_FORMAT_D32_SFLOAT; | ||
| meshConfig.depthTest = true; | ||
| meshConfig.depthCompareOp = VK_COMPARE_OP_GREATER; | ||
| meshConfig.cullMode = VK_CULL_MODE_NONE; | ||
| meshConfig.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; | ||
|
|
||
| // Explicitly setup pipeline details via callback | ||
| meshConfig.customPipelineSetup = [](PipelineBuilder& builder) { | ||
|
||
| builder.enable_depthtest(true, VK_COMPARE_OP_GREATER); | ||
| builder.set_multisampling_none(); | ||
| builder.set_polygon_mode(VK_POLYGON_MODE_FILL); | ||
| }; | ||
|
|
||
| VkPushConstantRange bufferRange{}; | ||
| bufferRange.offset = 0; | ||
| bufferRange.size = sizeof(GPUDrawPushConstants); | ||
|
|
@@ -175,7 +186,7 @@ void Pipelines::init(VkDevice device, | |
| meshPipeline = std::make_unique<GraphicsPipeline>(meshConfig); | ||
| meshPipeline->init(device); | ||
|
|
||
| // Initialize gradient pipeline | ||
| // Compute pipeline | ||
| ComputePipeline::ComputePipelineConfig gradientConfig; | ||
| gradientConfig.descriptorSetLayout = _drawImageDescriptorLayout; | ||
| gradientConfig.shaderPath = "./shaders/gradient.comp.spv"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |||||||||
| #include <fmt/base.h> | ||||||||||
| #include <fstream> | ||||||||||
| #include <spdlog/spdlog.h> | ||||||||||
|
|
||||||||||
| #include "core/Logging.h" | ||||||||||
| #include "graphics/vulkan/vk_initializers.h" | ||||||||||
|
|
||||||||||
| bool vkutil::load_shader_module(const char* filePath, VkDevice device, | ||||||||||
|
|
@@ -60,96 +60,152 @@ bool vkutil::load_shader_module(const char* filePath, VkDevice device, | |||||||||
| } | ||||||||||
|
|
||||||||||
| void PipelineBuilder::clear() { | ||||||||||
| // clear all of the structs we need back to 0 with their correct stype | ||||||||||
|
|
||||||||||
| // Initialize input assembly with proper defaults | ||||||||||
| _inputAssembly = { | ||||||||||
| .sType = | ||||||||||
| VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO}; | ||||||||||
| .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, | ||||||||||
| .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, | ||||||||||
| .primitiveRestartEnable = VK_FALSE | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| // Initialize rasterizer with proper defaults | ||||||||||
| _rasterizer = { | ||||||||||
| .sType = | ||||||||||
| VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO}; | ||||||||||
|
|
||||||||||
| _colorBlendAttachment = {}; | ||||||||||
|
|
||||||||||
| .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, | ||||||||||
| .depthClampEnable = VK_FALSE, | ||||||||||
| .rasterizerDiscardEnable = VK_FALSE, | ||||||||||
| .polygonMode = VK_POLYGON_MODE_FILL, | ||||||||||
| .cullMode = VK_CULL_MODE_NONE, | ||||||||||
| .frontFace = VK_FRONT_FACE_CLOCKWISE, | ||||||||||
| .depthBiasEnable = VK_FALSE, | ||||||||||
| .depthBiasConstantFactor = 0.0f, | ||||||||||
| .depthBiasClamp = 0.0f, | ||||||||||
| .depthBiasSlopeFactor = 0.0f, | ||||||||||
| .lineWidth = 1.0f // CRITICAL: Must be 1.0f, not 0.0f | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| // Initialize color blend attachment with defaults | ||||||||||
| _colorBlendAttachment = { | ||||||||||
| .blendEnable = VK_FALSE, | ||||||||||
| .colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | | ||||||||||
| VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| // Initialize multisampling with proper defaults | ||||||||||
| _multisampling = { | ||||||||||
| .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO}; | ||||||||||
| .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, | ||||||||||
| .rasterizationSamples = VK_SAMPLE_COUNT_1_BIT, // CRITICAL: Must be valid sample count | ||||||||||
| .sampleShadingEnable = VK_FALSE, | ||||||||||
| .minSampleShading = 1.0f, | ||||||||||
| .pSampleMask = nullptr, | ||||||||||
| .alphaToCoverageEnable = VK_FALSE, | ||||||||||
| .alphaToOneEnable = VK_FALSE | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| _pipelineLayout = {}; | ||||||||||
|
|
||||||||||
| // Initialize depth-stencil with proper defaults | ||||||||||
| _depthStencil = { | ||||||||||
| .sType = | ||||||||||
| VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO}; | ||||||||||
|
|
||||||||||
| _renderInfo = {.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO}; | ||||||||||
| .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, | ||||||||||
| .depthTestEnable = VK_FALSE, | ||||||||||
| .depthWriteEnable = VK_FALSE, | ||||||||||
| .depthCompareOp = VK_COMPARE_OP_LESS, | ||||||||||
| .depthBoundsTestEnable = VK_FALSE, | ||||||||||
| .stencilTestEnable = VK_FALSE, | ||||||||||
| .minDepthBounds = 0.0f, | ||||||||||
| .maxDepthBounds = 1.0f | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| // Initialize rendering info with proper defaults | ||||||||||
| _renderInfo = { | ||||||||||
| .sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO, | ||||||||||
| .depthAttachmentFormat = VK_FORMAT_UNDEFINED | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| _shaderStages.clear(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| VkPipeline PipelineBuilder::build_pipeline(VkDevice device) const { | ||||||||||
| // Make local copies of struct members that we need to modify | ||||||||||
| VkPipelineRenderingCreateInfo renderInfo = _renderInfo; | ||||||||||
| VkPipelineRasterizationStateCreateInfo rasterizer = _rasterizer; | ||||||||||
| VkPipelineMultisampleStateCreateInfo multisampling = _multisampling; | ||||||||||
| VkPipelineInputAssemblyStateCreateInfo inputAssembly = _inputAssembly; | ||||||||||
|
|
||||||||||
| // Fix any uninitialized values | ||||||||||
| if (renderInfo.depthAttachmentFormat == 0) { | ||||||||||
| renderInfo.depthAttachmentFormat = VK_FORMAT_UNDEFINED; | ||||||||||
| } | ||||||||||
|
Comment on lines
+134
to
+136
|
||||||||||
| if (renderInfo.depthAttachmentFormat == 0) { | |
| renderInfo.depthAttachmentFormat = VK_FORMAT_UNDEFINED; | |
| } | |
| // Removed redundant check and assignment for depthAttachmentFormat. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider documenting the purpose of the
customPipelineSetupcallback parameter inGraphicsPipelineConfig, so future maintainers understand when and how to use it.