layers: Validate fundamental type for input attachments
authorChris Forbes <chrisforbes@google.com>
Mon, 22 Aug 2016 04:11:22 +0000 (16:11 +1200)
committerChris Forbes <chrisforbes@google.com>
Tue, 23 Aug 2016 01:12:40 +0000 (13:12 +1200)
Signed-off-by: Chris Forbes <chrisforbes@google.com>
layers/core_validation.cpp
layers/core_validation_error_enums.h

index 80e0549..3cda648 100644 (file)
@@ -2801,8 +2801,16 @@ static bool validate_pipeline_shader_stage(debug_report_data *report_data,
                     pass = false;
                 }
             }
-
-            /* TODO: type match, etc */
+            else if (get_format_type(rpci->pAttachments[index].format) !=
+                    get_fundamental_type(module, use.second.type_id)) {
+                if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__,
+                            SHADER_CHECKER_INPUT_ATTACHMENT_TYPE_MISMATCH, "SC",
+                            "Subpass input attachment %u format of %s does not match type used in shader `%s`",
+                            use.first, string_VkFormat(rpci->pAttachments[index].format),
+                            describe_type(module, use.second.type_id).c_str())) {
+                    pass = false;
+                }
+            }
         }
     }
 
index 2ee0420..a10c6ac 100644 (file)
@@ -244,6 +244,7 @@ enum SHADER_CHECKER_ERROR {
     SHADER_CHECKER_FEATURE_NOT_ENABLED,                     // Shader uses capability requiring a feature not enabled on device
     SHADER_CHECKER_BAD_CAPABILITY,                          // Shader uses capability not supported by Vulkan (OpenCL features)
     SHADER_CHECKER_MISSING_INPUT_ATTACHMENT,   // Shader uses an input attachment but not declared in subpass
+    SHADER_CHECKER_INPUT_ATTACHMENT_TYPE_MISMATCH,          // Shader input attachment type does not match subpass format
 };
 
 // Device Limits ERROR codes