anv/cmd_buffer: Use the null surface state for ATTACHMENT_UNUSED
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 7 Apr 2017 17:33:25 +0000 (10:33 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 14 Apr 2017 21:20:42 +0000 (14:20 -0700)
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Cc: <mesa-stable@lists.freedesktop.org>
src/intel/vulkan/genX_cmd_buffer.c

index fcebd4d0069670730b8ccd170b5c4734f23f8d02..13baf76b7e5308d3c175d1cdd210751aa38f4e55 100644 (file)
@@ -1122,8 +1122,20 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
          assert(stage == MESA_SHADER_FRAGMENT);
          assert(binding->binding == 0);
          if (binding->index < subpass->color_count) {
-            const unsigned att = subpass->color_attachments[binding->index].attachment;
-            surface_state = cmd_buffer->state.attachments[att].color_rt_state;
+            const unsigned att =
+               subpass->color_attachments[binding->index].attachment;
+
+            /* From the Vulkan 1.0.46 spec:
+             *
+             *    "If any color or depth/stencil attachments are
+             *    VK_ATTACHMENT_UNUSED, then no writes occur for those
+             *    attachments."
+             */
+            if (att == VK_ATTACHMENT_UNUSED) {
+               surface_state = cmd_buffer->state.null_surface_state;
+            } else {
+               surface_state = cmd_buffer->state.attachments[att].color_rt_state;
+            }
          } else {
             surface_state = cmd_buffer->state.null_surface_state;
          }