layers: Set up disable for shader validation
authorMark Lobodzinski <mark@lunarg.com>
Sat, 4 Feb 2017 17:55:12 +0000 (10:55 -0700)
committerMark Lobodzinski <mark@lunarg.com>
Mon, 6 Feb 2017 16:26:34 +0000 (09:26 -0700)
Added a disable flag for shader validation.

Change-Id: I6b0a563a1350d988740ea111ec6d7f007702c595

layers/core_validation.cpp
layers/core_validation_types.h

index e23e1d0..ac73a7d 100644 (file)
@@ -3158,7 +3158,8 @@ static bool verifyPipelineCreateState(layer_data *my_data, std::vector<PIPELINE_
                              validation_error_map[VALIDATION_ERROR_02122]);
     }
 
-    if (!validate_and_capture_pipeline_shader_state(my_data->report_data, pPipeline, &my_data->enabled_features,
+    if (!GetDisables(my_data)->shader_validation &&
+        !validate_and_capture_pipeline_shader_state(my_data->report_data, pPipeline, &my_data->enabled_features,
                                                     my_data->shaderModuleMap)) {
         skip_call = true;
     }
@@ -9907,27 +9908,29 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateShaderModule(VkDevice device, const VkShade
     layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
     bool skip_call = false;
 
-    // Use SPIRV-Tools validator to try and catch any issues with the module itself
-    spv_context ctx = spvContextCreate(SPV_ENV_VULKAN_1_0);
-    spv_const_binary_t binary{pCreateInfo->pCode, pCreateInfo->codeSize / sizeof(uint32_t)};
-    spv_diagnostic diag = nullptr;
+    if (!GetDisables(dev_data)->shader_validation) {
+        // Use SPIRV-Tools validator to try and catch any issues with the module itself
+        spv_context ctx = spvContextCreate(SPV_ENV_VULKAN_1_0);
+        spv_const_binary_t binary{pCreateInfo->pCode, pCreateInfo->codeSize / sizeof(uint32_t)};
+        spv_diagnostic diag = nullptr;
 
-    auto result = spvValidate(ctx, &binary, &diag);
-    if (result != SPV_SUCCESS) {
-        skip_call |=
-            log_msg(dev_data->report_data, result == SPV_WARNING ? VK_DEBUG_REPORT_WARNING_BIT_EXT : VK_DEBUG_REPORT_ERROR_BIT_EXT,
-                    VkDebugReportObjectTypeEXT(0), 0, __LINE__, SHADER_CHECKER_INCONSISTENT_SPIRV, "SC",
-                    "SPIR-V module not valid: %s", diag && diag->error ? diag->error : "(no error text)");
-    }
+        auto result = spvValidate(ctx, &binary, &diag);
+        if (result != SPV_SUCCESS) {
+            skip_call |= log_msg(dev_data->report_data,
+                                 result == SPV_WARNING ? VK_DEBUG_REPORT_WARNING_BIT_EXT : VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                 VkDebugReportObjectTypeEXT(0), 0, __LINE__, SHADER_CHECKER_INCONSISTENT_SPIRV, "SC",
+                                 "SPIR-V module not valid: %s", diag && diag->error ? diag->error : "(no error text)");
+        }
 
-    spvDiagnosticDestroy(diag);
-    spvContextDestroy(ctx);
+        spvDiagnosticDestroy(diag);
+        spvContextDestroy(ctx);
 
-    if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT;
+        if (skip_call) return VK_ERROR_VALIDATION_FAILED_EXT;
+    }
 
     VkResult res = dev_data->dispatch_table.CreateShaderModule(device, pCreateInfo, pAllocator, pShaderModule);
 
-    if (res == VK_SUCCESS) {
+    if (res == VK_SUCCESS && !GetDisables(dev_data)->shader_validation) {
         std::lock_guard<std::mutex> lock(global_lock);
         dev_data->shaderModuleMap[*pShaderModule] = unique_ptr<shader_module>(new shader_module(pCreateInfo));
     }
index 56e5c77..98d6991 100644 (file)
@@ -705,6 +705,7 @@ struct CHECK_DISABLED {
     bool destroy_query_pool;
     bool get_query_pool_results;
     bool destroy_buffer;
+    bool shader_validation;         // Skip validation for shaders
 };
 
 struct MT_FB_ATTACHMENT_INFO {