Module: Mesa
Branch: master
Commit: 7628585dd709f3ffb18c7ca134fff1f375ad7b6a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7628585dd709f3ffb18c7ca134fff1f375ad7b6a

Author: Jason Ekstrand <[email protected]>
Date:   Wed Apr 22 10:47:00 2020 -0500

anv: Refactor setting descriptors with immutable sampler

Don't call anv_sampler_from_handle if the handle may be invalid.

Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4690>

---

 src/intel/vulkan/anv_descriptor_set.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/intel/vulkan/anv_descriptor_set.c 
b/src/intel/vulkan/anv_descriptor_set.c
index d4676b23416..11d6a9cfa87 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -1152,12 +1152,16 @@ anv_descriptor_set_write_image_view(struct anv_device 
*device,
 
    switch (type) {
    case VK_DESCRIPTOR_TYPE_SAMPLER:
-      sampler = anv_sampler_from_handle(info->sampler);
+      sampler = bind_layout->immutable_samplers ?
+                bind_layout->immutable_samplers[element] :
+                anv_sampler_from_handle(info->sampler);
       break;
 
    case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
       image_view = anv_image_view_from_handle(info->imageView);
-      sampler = anv_sampler_from_handle(info->sampler);
+      sampler = bind_layout->immutable_samplers ?
+                bind_layout->immutable_samplers[element] :
+                anv_sampler_from_handle(info->sampler);
       break;
 
    case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
@@ -1170,13 +1174,6 @@ anv_descriptor_set_write_image_view(struct anv_device 
*device,
       unreachable("invalid descriptor type");
    }
 
-   /* If this descriptor has an immutable sampler, we don't want to stomp on
-    * it.
-    */
-   sampler = bind_layout->immutable_samplers ?
-             bind_layout->immutable_samplers[element] :
-             sampler;
-
    *desc = (struct anv_descriptor) {
       .type = type,
       .layout = info->imageLayout,

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to