summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/translate/translate.h
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2014-03-03 23:09:58 -0500
committerZack Rusin <[email protected]>2014-03-04 15:56:04 -0500
commit1dd84357ec8d6894ec6bbd7040a8e8328015cd16 (patch)
treec60fe0c84816a98afa14c095267fac3b79bcc39c /src/gallium/auxiliary/translate/translate.h
parent08f174daa41b89c41a87c350f407307e2ba258eb (diff)
translate: fix buffer overflows
Because in draw we always inject position at slot 0 whenever fragment shader would take the maximum number of inputs (32) it meant that we had PIPE_MAX_ATTRIBS + 1 slots to translate, which meant that we were crashing with fragment shaders that took the maximum number of attributes as inputs. The actual max number of attributes we need to translate thus is PIPE_MAX_ATTRIBS + 1. Signed-off-by: Zack Rusin <[email protected]> Reviewed-by: José Fonseca <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Matthew McClure <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/translate/translate.h')
-rw-r--r--src/gallium/auxiliary/translate/translate.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h
index d5f23b83905..7fe8ff8145f 100644
--- a/src/gallium/auxiliary/translate/translate.h
+++ b/src/gallium/auxiliary/translate/translate.h
@@ -44,6 +44,14 @@
#include "pipe/p_format.h"
#include "pipe/p_state.h"
+/**
+ * Translate has to work on one more attribute because
+ * the draw module has to be able to pass the vertex
+ * position even if the fragment shader already consumes
+ * PIPE_MAX_ATTRIBS inputs.
+ */
+#define TRANSLATE_MAX_ATTRIBS (PIPE_MAX_ATTRIBS + 1)
+
enum translate_element_type {
TRANSLATE_ELEMENT_NORMAL,
TRANSLATE_ELEMENT_INSTANCE_ID
@@ -64,7 +72,7 @@ struct translate_element
struct translate_key {
unsigned output_stride;
unsigned nr_elements;
- struct translate_element element[PIPE_MAX_ATTRIBS + 1];
+ struct translate_element element[TRANSLATE_MAX_ATTRIBS];
};