[Mesa-dev] [PATCH 16/16] mesa: Expand the Mesa IR register index to a full int.
Eric Anholt
eric at anholt.net
Wed May 28 11:37:47 PDT 2014
With this, we can stop worrying about overflowing the tiny 4k temps we
used to be limited to.
---
src/mesa/program/ir_to_mesa.cpp | 1 -
src/mesa/program/prog_instruction.h | 25 ++++++++++---------------
src/mesa/program/program.c | 17 -----------------
src/mesa/program/program_parse.y | 9 ---------
4 files changed, 10 insertions(+), 42 deletions(-)
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 1777614..24ecccf 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2257,7 +2257,6 @@ mesa_src_reg_from_ir_src_reg(src_reg reg)
struct prog_src_register mesa_reg;
mesa_reg.File = reg.file;
- assert(reg.index < (1 << INST_INDEX_BITS));
mesa_reg.Index = reg.index;
mesa_reg.Swizzle = reg.swizzle;
mesa_reg.RelAddr = reg.reladdr != NULL;
diff --git a/src/mesa/program/prog_instruction.h b/src/mesa/program/prog_instruction.h
index fee1be7..b61451f 100644
--- a/src/mesa/program/prog_instruction.h
+++ b/src/mesa/program/prog_instruction.h
@@ -225,23 +225,20 @@ typedef enum prog_opcode {
MAX_OPCODE
} gl_inst_opcode;
-
-/**
- * Number of bits for the src/dst register Index field.
- * This limits the size of temp/uniform register files.
- */
-#define INST_INDEX_BITS 12
-
-
/**
* Instruction source register.
*/
struct prog_src_register
{
GLuint File:4; /**< One of the PROGRAM_* register file values. */
- GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit.
- * May be negative for relative addressing.
- */
+ /**
+ * Offset within the register file, or the offset from the address register
+ * within the register file, in the case of RelAddr being set.
+ *
+ * Note that the index can be negative for relative addressing.
+ */
+ int Index;
+
GLuint Swizzle:12;
GLuint RelAddr:1;
@@ -267,9 +264,7 @@ struct prog_src_register
*/
GLuint HasIndex2:1;
GLuint RelAddr2:1;
- GLint Index2:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit.
- * May be negative for relative
- * addressing. */
+ int Index2;
};
@@ -279,7 +274,7 @@ struct prog_src_register
struct prog_dst_register
{
GLuint File:4; /**< One of the PROGRAM_* register file values */
- GLuint Index:INST_INDEX_BITS; /**< Unsigned, never negative */
+ uint32_t Index;
GLuint WriteMask:4;
GLuint RelAddr:1;
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index ee6d8c0..8a564f6 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -52,26 +52,9 @@ struct gl_program _mesa_DummyProgram;
void
_mesa_init_program(struct gl_context *ctx)
{
- /*
- * If this assertion fails, we need to increase the field
- * size for register indexes (see INST_INDEX_BITS).
- */
- ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4
- <= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4
- <= (1 << INST_INDEX_BITS));
-
- ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps <= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams <= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTemps <= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams <= (1 << INST_INDEX_BITS));
-
ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents <= 4 * MAX_UNIFORMS);
ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents <= 4 * MAX_UNIFORMS);
- ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxAddressOffset <= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAddressOffset <= (1 << INST_INDEX_BITS));
-
/* If this fails, increase prog_instruction::TexSrcUnit size */
STATIC_ASSERT(MAX_TEXTURE_UNITS <= (1 << 5));
diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y
index d4263cb..41ce824 100644
--- a/src/mesa/program/program_parse.y
+++ b/src/mesa/program/program_parse.y
@@ -2337,12 +2337,9 @@ init_dst_reg(struct prog_dst_register *r)
void
set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index)
{
- const GLint maxIndex = 1 << INST_INDEX_BITS;
const GLint minIndex = 0;
ASSERT(index >= minIndex);
(void) minIndex;
- ASSERT(index <= maxIndex);
- (void) maxIndex;
ASSERT(file == PROGRAM_TEMPORARY ||
file == PROGRAM_ADDRESS ||
file == PROGRAM_OUTPUT);
@@ -2379,13 +2376,7 @@ void
set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index,
GLuint swizzle)
{
- const GLint maxIndex = (1 << INST_INDEX_BITS) - 1;
- const GLint minIndex = -(1 << INST_INDEX_BITS);
ASSERT(file < PROGRAM_FILE_MAX);
- ASSERT(index >= minIndex);
- (void) minIndex;
- ASSERT(index <= maxIndex);
- (void) maxIndex;
memset(r, 0, sizeof(*r));
r->Base.File = file;
r->Base.Index = index;
--
2.0.0.rc2
More information about the mesa-dev
mailing list