Module: Mesa
Branch: main
Commit: 48d510ac578c859ce2046f055d1e6dc37716a499
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=48d510ac578c859ce2046f055d1e6dc37716a499

Author: George Ouzounoudis <geothr...@gmail.com>
Date:   Thu Aug 10 23:02:50 2023 +0300

vulkan: Fix null pointer dereferencing on sample locations state

In the case both sample locations and rasterization samples is supported by a
driver as dynamic state, there is a case 
vk_multisample_sample_locations_state_init()
does not fill ms->sample_locations at all. In this case we need to check
this pointer when dereferencing it in vk_dynamic_graphics_state_init_ms().

Reviewed-by: Faith Ekstrand <faith.ekstr...@collabora.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkra...@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27025>

---

 src/vulkan/runtime/vk_graphics_state.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/vulkan/runtime/vk_graphics_state.c 
b/src/vulkan/runtime/vk_graphics_state.c
index d4f42c3083b..1b86e5a4d39 100644
--- a/src/vulkan/runtime/vk_graphics_state.c
+++ b/src/vulkan/runtime/vk_graphics_state.c
@@ -776,6 +776,9 @@ vk_multisample_sample_locations_state_init(
          ms->sample_locations =
             vk_standard_sample_locations_state(ms_info->rasterizationSamples);
       }
+      /* In the case that the rasterization samples are dynamic we cannot
+       * pre-populate with a specific set of standard sample locations
+       */
    }
 }
 
@@ -790,7 +793,7 @@ vk_dynamic_graphics_state_init_ms(struct 
vk_dynamic_graphics_state *dst,
    dst->ms.alpha_to_one_enable = ms->alpha_to_one_enable;
    dst->ms.sample_locations_enable = ms->sample_locations_enable;
 
-   if (IS_NEEDED(MS_SAMPLE_LOCATIONS))
+   if (IS_NEEDED(MS_SAMPLE_LOCATIONS) && ms->sample_locations)
       *dst->ms.sample_locations = *ms->sample_locations;
 }
 

Reply via email to