summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2017-07-21 10:26:31 +0200
committerIago Toral Quiroga <[email protected]>2017-08-11 10:41:44 +0200
commit81615ad444ba970d144eeffbe60a7f70adc30b5b (patch)
treea30b57712acdc65817ce9e8a2e825021c9d952cb /src/intel
parent9d41ec21826b1c19da69a183b3c0ce535bfd7b10 (diff)
intel/compiler: properly size attribute wa_flags array for Vulkan
Mesa will map user defined vertex input attributes to slots starting at VERT_ATTRIB_GENERIC0 which gives us room for only 16 slots (up to GL_VERT_ATTRIB_MAX). This sufficient for GL, where we expose exactly 16 vertex attributes for user defined inputs, but in Vulkan we can expose up to 28 (which are also mapped from VERT_ATTRIB_GENERIC0 onwards) so we need to account for this when we scope the size of the array of attribute workaround flags that is used during the brw_vertex_workarounds NIR pass. This prevents out-of-bounds accesses in that array for NIR shaders that use more than 16 vertex input attributes. Fixes: dEQP-VK.pipeline.vertex_input.max_attributes.* Acked-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/compiler/brw_compiler.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index bebd2447361..66d6a6f5ee8 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -188,6 +188,15 @@ struct brw_sampler_prog_key_data {
#define BRW_ATTRIB_WA_SIGN 32 /* interpret as signed in shader */
#define BRW_ATTRIB_WA_SCALE 64 /* interpret as scaled in shader */
+/**
+ * OpenGL attribute slots fall in [0, VERT_ATTRIB_MAX - 1] with the range
+ * [VERT_ATTRIB_GENERIC0, VERT_ATTRIB_MAX - 1] reserved for up to 16 user
+ * input vertex attributes. In Vulkan, we expose up to 28 user vertex input
+ * attributes that are mapped to slots also starting at VERT_ATTRIB_GENERIC0.
+ */
+#define MAX_GL_VERT_ATTRIB VERT_ATTRIB_MAX
+#define MAX_VK_VERT_ATTRIB (VERT_ATTRIB_GENERIC0 + 28)
+
/** The program key for Vertex Shaders. */
struct brw_vs_prog_key {
unsigned program_string_id;
@@ -196,8 +205,15 @@ struct brw_vs_prog_key {
* Per-attribute workaround flags
*
* For each attribute, a combination of BRW_ATTRIB_WA_*.
+ *
+ * For OpenGL, where we expose a maximum of 16 user input atttributes
+ * we only need up to VERT_ATTRIB_MAX slots, however, in Vulkan
+ * slots preceding VERT_ATTRIB_GENERIC0 are unused and we can
+ * expose up to 28 user input vertex attributes that are mapped to slots
+ * starting at VERT_ATTRIB_GENERIC0, so this array needs to be large
+ * enough to hold this many slots.
*/
- uint8_t gl_attrib_wa_flags[VERT_ATTRIB_MAX];
+ uint8_t gl_attrib_wa_flags[MAX2(MAX_GL_VERT_ATTRIB, MAX_VK_VERT_ATTRIB)];
bool copy_edgeflag:1;