From 25db07869d73711fbd09e333109a3df4d2b13628 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 6 Apr 2016 11:21:28 +1200 Subject: layers: Insist on each shader's stage being unique in a pipeline Signed-off-by: Chris Forbes --- layers/core_validation.cpp | 11 +++++++++++ layers/core_validation.h | 30 ++++-------------------------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 0f49d207..c3768da6 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -3133,6 +3133,17 @@ static bool verifyPipelineCreateState(layer_data *my_data, const VkDevice device if (!validate_and_capture_pipeline_shader_state(my_data, pPipeline)) { skipCall = true; } + // Each shader's stage must be unique + if (pPipeline->duplicate_shaders) { + for (uint32_t stage = VK_SHADER_STAGE_VERTEX_BIT; stage & VK_SHADER_STAGE_ALL_GRAPHICS; stage <<= 1) { + if (pPipeline->duplicate_shaders & stage) { + skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, + __LINE__, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", + "Invalid Pipeline CreateInfo State: Multiple shaders provided for stage %s", + string_VkShaderStageFlagBits(VkShaderStageFlagBits(stage))); + } + } + } // VS is required if (!(pPipeline->active_shaders & VK_SHADER_STAGE_VERTEX_BIT)) { skipCall |= diff --git a/layers/core_validation.h b/layers/core_validation.h index ff9144d5..e4db2f7f 100644 --- a/layers/core_validation.h +++ b/layers/core_validation.h @@ -445,6 +445,7 @@ class PIPELINE_NODE { safe_VkComputePipelineCreateInfo computePipelineCI; // Flag of which shader stages are active for this pipeline uint32_t active_shaders; + uint32_t duplicate_shaders; // Capture which slots (set#->bindings) are actually used by the shaders of this pipeline unordered_map> active_slots; // Vtx input info (if any) @@ -454,7 +455,7 @@ class PIPELINE_NODE { bool blendConstantsEnabled; // Blend constants enabled for any attachments // Default constructor PIPELINE_NODE() - : pipeline{}, graphicsPipelineCI{}, computePipelineCI{}, active_shaders(0), active_slots(), vertexBindingDescriptions(), + : pipeline{}, graphicsPipelineCI{}, computePipelineCI{}, active_shaders(0), duplicate_shaders(0), active_slots(), vertexBindingDescriptions(), vertexAttributeDescriptions(), attachments(), blendConstantsEnabled(false) {} void initGraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateInfo) { @@ -464,31 +465,8 @@ class PIPELINE_NODE { computePipelineCI.initialize(&emptyComputeCI); for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) { const VkPipelineShaderStageCreateInfo *pPSSCI = &pCreateInfo->pStages[i]; - - switch (pPSSCI->stage) { - case VK_SHADER_STAGE_VERTEX_BIT: - this->active_shaders |= VK_SHADER_STAGE_VERTEX_BIT; - break; - case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT: - this->active_shaders |= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; - break; - case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT: - this->active_shaders |= VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; - break; - case VK_SHADER_STAGE_GEOMETRY_BIT: - this->active_shaders |= VK_SHADER_STAGE_GEOMETRY_BIT; - break; - case VK_SHADER_STAGE_FRAGMENT_BIT: - this->active_shaders |= VK_SHADER_STAGE_FRAGMENT_BIT; - break; - case VK_SHADER_STAGE_COMPUTE_BIT: - // TODO : Flag error, CS is specified through VkComputePipelineCreateInfo - this->active_shaders |= VK_SHADER_STAGE_COMPUTE_BIT; - break; - default: - // TODO : Flag error - break; - } + this->duplicate_shaders |= this->active_shaders & pPSSCI->stage; + this->active_shaders |= pPSSCI->stage; } if (pCreateInfo->pVertexInputState) { const VkPipelineVertexInputStateCreateInfo *pVICI = pCreateInfo->pVertexInputState; -- cgit v1.2.3