aboutsummaryrefslogtreecommitdiff
path: root/layers
diff options
context:
space:
mode:
authorChris Forbes <chrisf@ijw.co.nz>2015-06-12 11:16:41 +1200
committerChris Forbes <chrisf@ijw.co.nz>2015-06-15 08:15:51 +1200
commite059c074fedba82aa52bd8741712ac5da37be65f (patch)
tree06eeb188d6d228cff17a7426c5899cb12dae418f /layers
parent300a45e8fb5f1d83d726fecd2705a9c6a798ac4d (diff)
downloadusermoji-e059c074fedba82aa52bd8741712ac5da37be65f.tar.xz
shader_checker: Check for duplicate VI binding descriptions.
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz> Reviewed-by: Tobin Ehlis <tobin@lunarg.com>
Diffstat (limited to 'layers')
-rw-r--r--layers/shader_checker.cpp31
-rw-r--r--layers/shader_checker.h1
2 files changed, 32 insertions, 0 deletions
diff --git a/layers/shader_checker.cpp b/layers/shader_checker.cpp
index fef4512f..a576314a 100644
--- a/layers/shader_checker.cpp
+++ b/layers/shader_checker.cpp
@@ -644,6 +644,33 @@ get_fundamental_type(shader_source const *src, unsigned type)
static bool
+validate_vi_consistency(VkPipelineVertexInputCreateInfo const *vi)
+{
+ /* walk the binding descriptions, which describe the step rate and stride of each vertex buffer.
+ * each binding should be specified only once.
+ */
+ std::unordered_map<uint32_t, VkVertexInputBindingDescription const *> bindings;
+ char str[1024];
+ bool pass = true;
+
+ for (unsigned i = 0; i < vi->bindingCount; i++) {
+ auto desc = &vi->pVertexBindingDescriptions[i];
+ auto & binding = bindings[desc->binding];
+ if (binding) {
+ sprintf(str, "Duplicate vertex input binding descriptions for binding %d", desc->binding);
+ layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, SHADER_CHECKER_INCONSISTENT_VI, "SC", str);
+ pass = false;
+ }
+ else {
+ binding = desc;
+ }
+ }
+
+ return pass;
+}
+
+
+static bool
validate_vi_against_vs_inputs(VkPipelineVertexInputCreateInfo const *vi, shader_source const *vs)
{
std::map<uint32_t, interface_var> inputs;
@@ -834,6 +861,10 @@ validate_graphics_pipeline(VkGraphicsPipelineCreateInfo const *pCreateInfo)
}
}
+ if (vi) {
+ pass = validate_vi_consistency(vi) && pass;
+ }
+
if (shaders[VK_SHADER_STAGE_VERTEX] && shaders[VK_SHADER_STAGE_VERTEX]->is_spirv) {
pass = validate_vi_against_vs_inputs(vi, shaders[VK_SHADER_STAGE_VERTEX]) && pass;
}
diff --git a/layers/shader_checker.h b/layers/shader_checker.h
index 17692fb8..4ec8dea2 100644
--- a/layers/shader_checker.h
+++ b/layers/shader_checker.h
@@ -35,4 +35,5 @@ typedef enum _SHADER_CHECKER_ERROR
SHADER_CHECKER_NON_SPIRV_SHADER, /* Shader image is not SPIR-V */
SHADER_CHECKER_INCONSISTENT_SPIRV, /* General inconsistency within a SPIR-V module */
SHADER_CHECKER_UNKNOWN_STAGE, /* Stage is not supported by analysis */
+ SHADER_CHECKER_INCONSISTENT_VI, /* VI state contains conflicting binding or attrib descriptions */
} SHADER_CHECKER_ERROR;