layers: Add support for VK_AMD_mixed_attachment_samples
authorMaciej Jesionowski <maciej.jesionowski@amd.com>
Wed, 6 Sep 2017 09:25:36 +0000 (11:25 +0200)
committerMark Lobodzinski <mark@lunarg.com>
Mon, 11 Sep 2017 22:58:17 +0000 (16:58 -0600)
Change-Id: I2ee0ab4c2ba7510316f190689fd3d81db27cb04f

layers/core_validation.cpp
layers/vk_validation_error_database.txt

index b0bc39b8b47405be84a3143bdd29413516291c26..78e72aaf8664b5acc04bfc6ddb94e6faf889af35 100644 (file)
@@ -1047,7 +1047,8 @@ static bool ValidatePipelineDrawtimeState(layer_data const *dev_data, LAST_BOUND
                 subpass_num_samples |= (unsigned)render_pass_info->pAttachments[attachment].samples;
             }
 
-            if (subpass_num_samples && static_cast<unsigned>(pso_num_samples) != subpass_num_samples) {
+            if (!dev_data->extensions.vk_amd_mixed_attachment_samples &&
+                ((subpass_num_samples & static_cast<unsigned>(pso_num_samples)) != subpass_num_samples)) {
                 skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
                                 HandleToUint64(pPipeline->pipeline), __LINE__, DRAWSTATE_NUM_SAMPLES_MISMATCH, "DS",
                                 "Num samples mismatch! At draw-time in Pipeline (0x%" PRIxLEAST64
@@ -1512,6 +1513,28 @@ static bool ValidatePipelineUnlocked(layer_data *dev_data, std::vector<std::uniq
         }
     }
 
+    if (dev_data->extensions.vk_amd_mixed_attachment_samples) {
+        VkSampleCountFlagBits max_sample_count = static_cast<VkSampleCountFlagBits>(0);
+        for (uint32_t i = 0; i < subpass_desc->colorAttachmentCount; ++i) {
+            if (subpass_desc->pColorAttachments[i].attachment != VK_ATTACHMENT_UNUSED) {
+                max_sample_count = std::max(max_sample_count, pPipeline->render_pass_ci.pAttachments[subpass_desc->pColorAttachments[i].attachment].samples);
+            }
+        }
+        if (subpass_desc->pDepthStencilAttachment && subpass_desc->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) {
+            max_sample_count = std::max(max_sample_count, pPipeline->render_pass_ci.pAttachments[subpass_desc->pDepthStencilAttachment->attachment].samples);
+        }
+        if (pPipeline->graphicsPipelineCI.pMultisampleState->rasterizationSamples != max_sample_count) {
+            skip |=
+                log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
+                        HandleToUint64(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_09600bc2, "DS",
+                        "vkCreateGraphicsPipelines: pCreateInfo[%d].pMultisampleState->rasterizationSamples (%s) != max attachment samples (%s) "
+                        "used in subpass %u. %s",
+                        pipelineIndex, string_VkSampleCountFlagBits(pPipeline->graphicsPipelineCI.pMultisampleState->rasterizationSamples),
+                        string_VkSampleCountFlagBits(max_sample_count), pPipeline->graphicsPipelineCI.subpass,
+                        validation_error_map[VALIDATION_ERROR_09600bc2]);
+        }
+    }
+
     return skip;
 }
 
@@ -7866,6 +7889,19 @@ static bool ValidateRenderpassAttachmentUsage(layer_data *dev_data, const VkRend
                                     i, j, color_desc.format, resolve_desc.format, validation_error_map[VALIDATION_ERROR_140006a4]);
                     }
                 }
+
+                if (dev_data->extensions.vk_amd_mixed_attachment_samples &&
+                    subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) {
+                    const auto depth_stencil_sample_count = pCreateInfo->pAttachments[subpass.pDepthStencilAttachment->attachment].samples;
+                    if (pCreateInfo->pAttachments[attachment].samples > depth_stencil_sample_count) {
+                        skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
+                                        __LINE__, VALIDATION_ERROR_14000bc4, "DS",
+                                        "CreateRenderPass:  Subpass %u pColorAttachments[%u] has %s which is larger than "
+                                        "depth/stencil attachment %s. %s",
+                                        i, j, string_VkSampleCountFlagBits(pCreateInfo->pAttachments[attachment].samples),
+                                        string_VkSampleCountFlagBits(depth_stencil_sample_count), validation_error_map[VALIDATION_ERROR_14000bc4]);
+                    }
+                }
             }
         }
 
@@ -7883,7 +7919,8 @@ static bool ValidateRenderpassAttachmentUsage(layer_data *dev_data, const VkRend
             skip |= ValidateAttachmentIndex(dev_data, attachment, pCreateInfo->attachmentCount, "Input");
         }
 
-        if (sample_count && !IsPowerOfTwo(sample_count)) {
+        if (!dev_data->extensions.vk_amd_mixed_attachment_samples &&
+            sample_count && !IsPowerOfTwo(sample_count)) {
             skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
                             __LINE__, VALIDATION_ERROR_0082b401, "DS",
                             "CreateRenderPass:  Subpass %u attempts to render to "
index d080a3d9afa819ec5298d74c0960c52f3316569a..a91e958d5730f067978922476300f3faffee6914 100644 (file)
@@ -542,7 +542,7 @@ VALIDATION_ERROR_096005f6~^~N~^~Unknown~^~vkCreateGraphicsPipelines~^~VUID-VkGra
 VALIDATION_ERROR_096005f8~^~N~^~Unknown~^~vkCreateGraphicsPipelines~^~VUID-VkGraphicsPipelineCreateInfo-flags-00764~^~(VK_KHX_device_group)~^~The spec valid usage text states 'flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE_KHX flag.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-flags-00764)~^~
 VALIDATION_ERROR_09600b06~^~N~^~None~^~VkGraphicsPipelineCreateInfo~^~VUID-VkGraphicsPipelineCreateInfo-subpass-01411~^~(VK_NV_framebuffer_mixed_samples)~^~The spec valid usage text states 'If subpass has a depth/stencil attachment and depth test, stencil test, or depth bounds test are enabled, then the rasterizationSamples member of pMultisampleState must be the same as the sample count of the depth/stencil attachment' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-subpass-01411)~^~
 VALIDATION_ERROR_09600b08~^~N~^~None~^~VkGraphicsPipelineCreateInfo~^~VUID-VkGraphicsPipelineCreateInfo-subpass-01412~^~(VK_NV_framebuffer_mixed_samples)~^~The spec valid usage text states 'If subpass has any color attachments, then the rasterizationSamples member of pMultisampleState must be greater than or equal to the sample count for those subpass attachments' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-subpass-01412)~^~
-VALIDATION_ERROR_09600bc2~^~N~^~None~^~VkGraphicsPipelineCreateInfo~^~VUID-VkGraphicsPipelineCreateInfo-subpass-01505~^~(VK_AMD_mixed_attachment_samples)~^~The spec valid usage text states 'If subpass uses color and/or depth/stencil attachments, then the rasterizationSamples member of pMultisampleState must equal the maximum of the sample counts of those subpass attachments' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-subpass-01505)~^~
+VALIDATION_ERROR_09600bc2~^~Y~^~None~^~VkGraphicsPipelineCreateInfo~^~VUID-VkGraphicsPipelineCreateInfo-subpass-01505~^~(VK_AMD_mixed_attachment_samples)~^~The spec valid usage text states 'If subpass uses color and/or depth/stencil attachments, then the rasterizationSamples member of pMultisampleState must equal the maximum of the sample counts of those subpass attachments' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-subpass-01505)~^~
 VALIDATION_ERROR_09600be2~^~N~^~None~^~VkGraphicsPipelineCreateInfo~^~VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01521~^~(VK_EXT_sample_locations)~^~The spec valid usage text states 'If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, and the sampleLocationsEnable member of a VkPipelineSampleLocationsStateCreateInfoEXT structure chained to the pNext chain of pMultisampleState is VK_TRUE, sampleLocationsInfo.sampleLocationGridSize.width must evenly divide VkMultisamplePropertiesEXT::sampleLocationGridSize.width as returned by vkGetPhysicalDeviceMultisamplePropertiesEXT with a samples parameter equaling rasterizationSamples' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01521)~^~
 VALIDATION_ERROR_09600be4~^~N~^~None~^~VkGraphicsPipelineCreateInfo~^~VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01522~^~(VK_EXT_sample_locations)~^~The spec valid usage text states 'If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, and the sampleLocationsEnable member of a VkPipelineSampleLocationsStateCreateInfoEXT structure chained to the pNext chain of pMultisampleState is VK_TRUE, sampleLocationsInfo.sampleLocationGridSize.height must evenly divide VkMultisamplePropertiesEXT::sampleLocationGridSize.height as returned by vkGetPhysicalDeviceMultisamplePropertiesEXT with a samples parameter equaling rasterizationSamples' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01522)~^~
 VALIDATION_ERROR_09600be6~^~N~^~None~^~VkGraphicsPipelineCreateInfo~^~VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01523~^~(VK_EXT_sample_locations)~^~The spec valid usage text states 'If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, and the sampleLocationsEnable member of a VkPipelineSampleLocationsStateCreateInfoEXT structure chained to the pNext chain of pMultisampleState is VK_TRUE, sampleLocationsInfo.sampleLocationsPerPixel must equal rasterizationSamples' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01523)~^~
@@ -1335,7 +1335,7 @@ VALIDATION_ERROR_140006ae~^~Y~^~CreateRenderPassAttachments~^~vkCreateRenderPass
 VALIDATION_ERROR_140006b0~^~N~^~Unknown~^~vkCreateRenderPass~^~VUID-VkSubpassDescription-flags-00856~^~(VK_NVX_multiview_per_view_attributes)~^~The spec valid usage text states 'If flags includes VK_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX, it must also include VK_SUBPASS_DESCRIPTION_PER_VIEW_ATTRIBUTES_BIT_NVX.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkSubpassDescription-flags-00856)~^~
 VALIDATION_ERROR_14000b12~^~N~^~None~^~VkSubpassDescription~^~VUID-VkSubpassDescription-pColorAttachments-01417~^~core~^~The spec valid usage text states 'All attachments in pColorAttachments that are not VK_ATTACHMENT_UNUSED must have the same sample count' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSubpassDescription-pColorAttachments-01417)~^~
 VALIDATION_ERROR_14000b14~^~N~^~None~^~VkSubpassDescription~^~VUID-VkSubpassDescription-pDepthStencilAttachment-01418~^~!(VK_AMD_mixed_attachment_samples)+!(VK_NV_framebuffer_mixed_samples)~^~The spec valid usage text states 'If pDepthStencilAttachment is not VK_ATTACHMENT_UNUSED and any attachments in pColorAttachments are not VK_ATTACHMENT_UNUSED, they must have the same sample count' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSubpassDescription-pDepthStencilAttachment-01418)~^~
-VALIDATION_ERROR_14000bc4~^~N~^~None~^~VkSubpassDescription~^~VUID-VkSubpassDescription-pColorAttachments-01506~^~(VK_AMD_mixed_attachment_samples)~^~The spec valid usage text states 'All attachments in pColorAttachments that are not VK_ATTACHMENT_UNUSED must have a sample count that is smaller than or equal to the sample count of pDepthStencilAttachment if it is not VK_ATTACHMENT_UNUSED' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkSubpassDescription-pColorAttachments-01506)~^~
+VALIDATION_ERROR_14000bc4~^~Y~^~None~^~VkSubpassDescription~^~VUID-VkSubpassDescription-pColorAttachments-01506~^~(VK_AMD_mixed_attachment_samples)~^~The spec valid usage text states 'All attachments in pColorAttachments that are not VK_ATTACHMENT_UNUSED must have a sample count that is smaller than or equal to the sample count of pDepthStencilAttachment if it is not VK_ATTACHMENT_UNUSED' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkSubpassDescription-pColorAttachments-01506)~^~
 VALIDATION_ERROR_14009001~^~Y~^~Unknown~^~vkCreateRenderPass~^~VUID-VkSubpassDescription-flags-parameter~^~core~^~The spec valid usage text states 'flags must be a valid combination of VkSubpassDescriptionFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSubpassDescription-flags-parameter)~^~implicit
 VALIDATION_ERROR_14011001~^~Y~^~Unknown~^~vkCreateRenderPass~^~VUID-VkSubpassDescription-pColorAttachments-parameter~^~core~^~The spec valid usage text states 'If colorAttachmentCount is not 0, pColorAttachments must be a pointer to an array of colorAttachmentCount valid VkAttachmentReference structures' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSubpassDescription-pColorAttachments-parameter)~^~implicit
 VALIDATION_ERROR_14012a01~^~N~^~Unknown~^~vkCreateRenderPass~^~VUID-VkSubpassDescription-pDepthStencilAttachment-parameter~^~core~^~The spec valid usage text states 'If pDepthStencilAttachment is not NULL, pDepthStencilAttachment must be a pointer to a valid VkAttachmentReference structure' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkSubpassDescription-pDepthStencilAttachment-parameter)~^~implicit