#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
struct translate_key {
unsigned output_stride;
unsigned nr_elements;
- struct translate_element element[PIPE_MAX_ATTRIBS + 1];
+ struct translate_element element[TRANSLATE_MAX_ATTRIBS];
};
static INLINE unsigned translate_hash_key_size(struct translate_key *key)
{
unsigned size = sizeof(struct translate_key) -
- sizeof(struct translate_element) * (PIPE_MAX_ATTRIBS - key->nr_elements);
+ sizeof(struct translate_element) * (TRANSLATE_MAX_ATTRIBS - key->nr_elements);
return size;
}
*/
int copy_size;
- } attrib[PIPE_MAX_ATTRIBS];
+ } attrib[TRANSLATE_MAX_ATTRIBS];
unsigned nr_attrib;
};
if (tg == NULL)
return NULL;
+ assert(key->nr_elements <= TRANSLATE_MAX_ATTRIBS);
+
tg->translate.key = *key;
tg->translate.release = generic_release;
tg->translate.set_buffer = generic_set_buffer;
int8_t reg_to_const[16];
int8_t const_to_reg[NUM_CONSTS];
- struct translate_buffer buffer[PIPE_MAX_ATTRIBS];
+ struct translate_buffer buffer[TRANSLATE_MAX_ATTRIBS];
unsigned nr_buffers;
/* Multiple buffer variants can map to a single buffer. */
- struct translate_buffer_variant buffer_variant[PIPE_MAX_ATTRIBS];
+ struct translate_buffer_variant buffer_variant[TRANSLATE_MAX_ATTRIBS];
unsigned nr_buffer_variants;
/* Multiple elements can map to a single buffer variant. */
- unsigned element_to_buffer_variant[PIPE_MAX_ATTRIBS];
+ unsigned element_to_buffer_variant[TRANSLATE_MAX_ATTRIBS];
boolean use_instancing;
unsigned instance_id;
p->translate.release = translate_sse_release;
p->translate.set_buffer = translate_sse_set_buffer;
+ assert(key->nr_elements <= TRANSLATE_MAX_ATTRIBS);
+
for (i = 0; i < key->nr_elements; i++) {
if (key->element[i].type == TRANSLATE_ELEMENT_NORMAL) {
unsigned j;