aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorChris Forbes <chrisforbes@google.com>2016-06-29 15:12:29 +1200
committerChris Forbes <chrisforbes@google.com>2016-07-01 17:44:15 +1200
commite958d92cfb90249a55134853e0ab9ea0c5d257de (patch)
tree676755412ec2c76fb769b06dd6341bf11a967f70 /layers/core_validation.cpp
parent1b3858ea73cc192d610404fc4a78aa62c9031527 (diff)
downloadusermoji-e958d92cfb90249a55134853e0ab9ea0c5d257de.tar.xz
layers: Require subpass attachments' sample counts to be consistent
Signed-off-by: Chris Forbes <chrisforbes@google.com>
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index b5e5936f..dd13079f 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -8888,6 +8888,10 @@ static bool ValidateAttachmentIndex(layer_data *dev_data, uint32_t attachment, u
return skip_call;
}
+static bool IsPowerOfTwo(unsigned x) {
+ return x && !(x & (x-1));
+}
+
static bool ValidateRenderpassAttachmentUsage(layer_data *dev_data, const VkRenderPassCreateInfo *pCreateInfo) {
bool skip_call = false;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) {
@@ -8913,6 +8917,8 @@ static bool ValidateRenderpassAttachmentUsage(layer_data *dev_data, const VkRend
subpass.pResolveAttachments, subpass.pResolveAttachments + subpass.colorAttachmentCount,
[](VkAttachmentReference ref) { return ref.attachment != VK_ATTACHMENT_UNUSED; });
+ unsigned sample_count = 0;
+
for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) {
uint32_t attachment;
if (subpass.pResolveAttachments) {
@@ -8931,6 +8937,10 @@ static bool ValidateRenderpassAttachmentUsage(layer_data *dev_data, const VkRend
attachment = subpass.pColorAttachments[j].attachment;
skip_call |= ValidateAttachmentIndex(dev_data, attachment, pCreateInfo->attachmentCount, "Color");
+ if (!skip_call && attachment != VK_ATTACHMENT_UNUSED) {
+ sample_count |= (unsigned)pCreateInfo->pAttachments[attachment].samples;
+ }
+
if (!skip_call &&
subpass_performs_resolve &&
attachment != VK_ATTACHMENT_UNUSED &&
@@ -8945,11 +8955,23 @@ static bool ValidateRenderpassAttachmentUsage(layer_data *dev_data, const VkRend
if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) {
uint32_t attachment = subpass.pDepthStencilAttachment->attachment;
skip_call |= ValidateAttachmentIndex(dev_data, attachment, pCreateInfo->attachmentCount, "Depth stencil");
+
+ if (!skip_call && attachment != VK_ATTACHMENT_UNUSED) {
+ sample_count |= (unsigned)pCreateInfo->pAttachments[attachment].samples;
+ }
}
for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) {
uint32_t attachment = subpass.pInputAttachments[j].attachment;
skip_call |= ValidateAttachmentIndex(dev_data, attachment, pCreateInfo->attachmentCount, "Input");
}
+
+ if (sample_count && !IsPowerOfTwo(sample_count)) {
+ skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0,
+ __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS",
+ "CreateRenderPass: Subpass %u attempts to render to "
+ "attachments with inconsistent sample counts",
+ i);
+ }
}
return skip_call;
}