anv: descriptors: don't update immutables samplers with anything but their immutable...
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 18 Jan 2017 12:00:49 +0000 (12:00 +0000)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sat, 21 Jan 2017 19:22:27 +0000 (19:22 +0000)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_descriptor_set.c

index 4367c0ebe00f8bcc58fe838db66ac299fc9ce01c..a5e65afc489f66f8befea4effcc02b3624b407e3 100644 (file)
@@ -587,8 +587,13 @@ void anv_UpdateDescriptorSets(
       switch (write->descriptorType) {
       case VK_DESCRIPTOR_TYPE_SAMPLER:
          for (uint32_t j = 0; j < write->descriptorCount; j++) {
-            ANV_FROM_HANDLE(anv_sampler, sampler,
-                            write->pImageInfo[j].sampler);
+            /* If this descriptor has an immutable sampler, we don't want to
+             * stomp on it.
+             */
+            struct anv_sampler *sampler =
+               bind_layout->immutable_samplers ?
+               bind_layout->immutable_samplers[j] :
+               anv_sampler_from_handle(write->pImageInfo[j].sampler);
 
             desc[j] = (struct anv_descriptor) {
                .type = VK_DESCRIPTOR_TYPE_SAMPLER,
@@ -601,17 +606,19 @@ void anv_UpdateDescriptorSets(
          for (uint32_t j = 0; j < write->descriptorCount; j++) {
             ANV_FROM_HANDLE(anv_image_view, iview,
                             write->pImageInfo[j].imageView);
-            ANV_FROM_HANDLE(anv_sampler, sampler,
-                            write->pImageInfo[j].sampler);
-
-            desc[j].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
-            desc[j].image_view = iview;
-
-            /* If this descriptor has an immutable sampler, we don't want
-             * to stomp on it.
+            /* If this descriptor has an immutable sampler, we don't want to
+             * stomp on it.
              */
-            if (sampler)
-               desc[j].sampler = sampler;
+            struct anv_sampler *sampler =
+               bind_layout->immutable_samplers ?
+               bind_layout->immutable_samplers[j] :
+               anv_sampler_from_handle(write->pImageInfo[j].sampler);
+
+            desc[j] = (struct anv_descriptor) {
+               .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+               .image_view = iview,
+               .sampler = sampler,
+            };
          }
          break;