Skip fragment shader when discard is enabled

Fixes #1101
This commit is contained in:
Sascha Willems 2024-04-14 09:43:16 +02:00
parent 90054f660f
commit 035f299ed5

View file

@ -1,7 +1,7 @@
/* /*
* Vulkan Example - Retrieving pipeline statistics * Vulkan Example - Retrieving pipeline statistics
* *
* Copyright (C) 2017-2023 by Sascha Willems - www.saschawillems.de * Copyright (C) 2017-2024 by Sascha Willems - www.saschawillems.de
* *
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/ */
@ -297,16 +297,18 @@ public:
rasterizationState.polygonMode = VK_POLYGON_MODE_LINE; rasterizationState.polygonMode = VK_POLYGON_MODE_LINE;
} }
std::vector<VkPipelineShaderStageCreateInfo> shaderStages; std::vector<VkPipelineShaderStageCreateInfo> shaderStages{};
shaderStages.resize(tessellation ? 4 : 2); shaderStages.push_back(loadShader(getShadersPath() + "pipelinestatistics/scene.vert.spv", VK_SHADER_STAGE_VERTEX_BIT));
shaderStages[0] = loadShader(getShadersPath() + "pipelinestatistics/scene.vert.spv", VK_SHADER_STAGE_VERTEX_BIT); if (!discard) {
shaderStages[1] = loadShader(getShadersPath() + "pipelinestatistics/scene.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT); // When discard is enabled a pipeline must not contain a fragment shader
shaderStages.push_back(loadShader(getShadersPath() + "pipelinestatistics/scene.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT));
}
if (tessellation) { if (tessellation) {
inputAssemblyState.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; inputAssemblyState.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST;
pipelineCI.pTessellationState = &tessellationState; pipelineCI.pTessellationState = &tessellationState;
shaderStages[2] = loadShader(getShadersPath() + "pipelinestatistics/scene.tesc.spv", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT); shaderStages.push_back(loadShader(getShadersPath() + "pipelinestatistics/scene.tesc.spv", VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT));
shaderStages[3] = loadShader(getShadersPath() + "pipelinestatistics/scene.tese.spv", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT); shaderStages.push_back(loadShader(getShadersPath() + "pipelinestatistics/scene.tese.spv", VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT));
} }
pipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size()); pipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());