anv/pipeline: Don't assert on more than 32 samplers
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 15 Dec 2017 19:27:39 +0000 (11:27 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 24 Jan 2018 05:10:08 +0000 (21:10 -0800)
This prevents an assert when running one unreleased Vulkan game.

Tested-by: Józef Kucia <joseph.kucia@gmail.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Cc: "18.0" <mesa-stable@lists.freedesktop.org>
src/intel/vulkan/genX_pipeline.c

index cfc3bea4265f5c3e59fe89064b709b1c9d826c36..82fdf206a953ab9121d7561f7fa768c86cb576c6 100644 (file)
@@ -1081,7 +1081,13 @@ emit_3dstate_streamout(struct anv_pipeline *pipeline,
 static uint32_t
 get_sampler_count(const struct anv_shader_bin *bin)
 {
-   return DIV_ROUND_UP(bin->bind_map.sampler_count, 4);
+   uint32_t count_by_4 = DIV_ROUND_UP(bin->bind_map.sampler_count, 4);
+
+   /* We can potentially have way more than 32 samplers and that's ok.
+    * However, the 3DSTATE_XS packets only have 3 bits to specify how
+    * many to pre-fetch and all values above 4 are marked reserved.
+    */
+   return MIN2(count_by_4, 4);
 }
 
 static uint32_t