mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 22:49:13 +02:00
compiler: decrease STATE_LENGTH from 5 to 4
The rework of matrix state vars made the last element unused. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6946>
This commit is contained in:
parent
fdd3a448ae
commit
1755a5a384
13 changed files with 42 additions and 47 deletions
|
|
@ -194,10 +194,10 @@ static const struct gl_builtin_uniform_element gl_CurrentAttribFragMESA_elements
|
|||
|
||||
#define MATRIX(name, statevar) \
|
||||
static const struct gl_builtin_uniform_element name ## _elements[] = { \
|
||||
{ NULL, { statevar, 0, 0, 0, 0}, SWIZZLE_XYZW }, \
|
||||
{ NULL, { statevar, 0, 1, 1, 0}, SWIZZLE_XYZW }, \
|
||||
{ NULL, { statevar, 0, 2, 2, 0}, SWIZZLE_XYZW }, \
|
||||
{ NULL, { statevar, 0, 3, 3, 0}, SWIZZLE_XYZW }, \
|
||||
{ NULL, { statevar, 0, 0, 0}, SWIZZLE_XYZW }, \
|
||||
{ NULL, { statevar, 0, 1, 1}, SWIZZLE_XYZW }, \
|
||||
{ NULL, { statevar, 0, 2, 2}, SWIZZLE_XYZW }, \
|
||||
{ NULL, { statevar, 0, 3, 3}, SWIZZLE_XYZW }, \
|
||||
}
|
||||
|
||||
MATRIX(gl_ModelViewMatrix, STATE_MODELVIEW_MATRIX_TRANSPOSE);
|
||||
|
|
@ -221,11 +221,11 @@ MATRIX(gl_TextureMatrixTranspose, STATE_TEXTURE_MATRIX);
|
|||
MATRIX(gl_TextureMatrixInverseTranspose, STATE_TEXTURE_MATRIX_INVERSE);
|
||||
|
||||
static const struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = {
|
||||
{ NULL, { STATE_MODELVIEW_MATRIX_INVERSE, 0, 0, 0, 0},
|
||||
{ NULL, { STATE_MODELVIEW_MATRIX_INVERSE, 0, 0, 0},
|
||||
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z) },
|
||||
{ NULL, { STATE_MODELVIEW_MATRIX_INVERSE, 0, 1, 1, 0},
|
||||
{ NULL, { STATE_MODELVIEW_MATRIX_INVERSE, 0, 1, 1},
|
||||
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z) },
|
||||
{ NULL, { STATE_MODELVIEW_MATRIX_INVERSE, 0, 2, 2, 0},
|
||||
{ NULL, { STATE_MODELVIEW_MATRIX_INVERSE, 0, 2, 2},
|
||||
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z) },
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -663,7 +663,7 @@ nir_visitor::visit(ir_variable *ir)
|
|||
|
||||
ir_state_slot *state_slots = ir->get_state_slots();
|
||||
for (unsigned i = 0; i < var->num_state_slots; i++) {
|
||||
for (unsigned j = 0; j < 5; j++)
|
||||
for (unsigned j = 0; j < 4; j++)
|
||||
var->state_slots[i].tokens[j] = state_slots[i].tokens[j];
|
||||
var->state_slots[i].swizzle = state_slots[i].swizzle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ gl_shader_stage_is_callable(gl_shader_stage stage)
|
|||
* Number of STATE_* values we need to address any GL state.
|
||||
* Used to dimension arrays.
|
||||
*/
|
||||
#define STATE_LENGTH 5
|
||||
#define STATE_LENGTH 4
|
||||
|
||||
typedef short gl_state_index16; /* see enum gl_state_index */
|
||||
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ d3d12_lower_point_sprite(nir_shader *shader,
|
|||
unsigned point_coord_enable,
|
||||
uint64_t next_inputs_read)
|
||||
{
|
||||
const gl_state_index16 tokens[5] = { STATE_INTERNAL,
|
||||
const gl_state_index16 tokens[4] = { STATE_INTERNAL,
|
||||
STATE_INTERNAL_DRIVER,
|
||||
D3D12_STATE_VAR_PT_SPRITE };
|
||||
struct lower_state state;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ get_state_var(nir_builder *b,
|
|||
const struct glsl_type *var_type,
|
||||
nir_variable **out_var)
|
||||
{
|
||||
const gl_state_index16 tokens[5] = { STATE_INTERNAL, STATE_INTERNAL_DRIVER, var_enum };
|
||||
const gl_state_index16 tokens[STATE_LENGTH] = { STATE_INTERNAL, STATE_INTERNAL_DRIVER, var_enum };
|
||||
if (*out_var == NULL) {
|
||||
nir_variable *var = nir_variable_create(b->shader,
|
||||
nir_var_uniform,
|
||||
|
|
@ -521,7 +521,7 @@ d3d12_lower_state_vars(nir_shader *nir, struct d3d12_shader *shader)
|
|||
}
|
||||
}
|
||||
|
||||
const gl_state_index16 tokens[5] = { STATE_INTERNAL, STATE_INTERNAL_DRIVER };
|
||||
const gl_state_index16 tokens[STATE_LENGTH] = { STATE_INTERNAL, STATE_INTERNAL_DRIVER };
|
||||
const struct glsl_type *type = glsl_array_type(glsl_vec4_type(),
|
||||
shader->state_vars_size / 4, 0);
|
||||
nir_variable *ubo = nir_variable_create(nir, nir_var_mem_ubo, type,
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ brw_create_nir(struct brw_context *brw,
|
|||
|
||||
if (stage == MESA_SHADER_FRAGMENT) {
|
||||
static const struct nir_lower_wpos_ytransform_options wpos_options = {
|
||||
.state_tokens = {STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM, 0, 0, 0},
|
||||
.state_tokens = {STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM, 0, 0},
|
||||
.fs_coord_pixel_center_integer = 1,
|
||||
.fs_coord_origin_upper_left = 1,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ static GLboolean r200_translate_vertex_program(struct gl_context *ctx, struct r2
|
|||
if ((mesa_vp->info.outputs_written & (1 << VARYING_SLOT_FOGC)) &&
|
||||
!vp->fogpidx) {
|
||||
struct gl_program_parameter_list *paramList;
|
||||
gl_state_index16 tokens[STATE_LENGTH] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
|
||||
gl_state_index16 tokens[STATE_LENGTH] = { STATE_FOG_PARAMS, 0, 0, 0 };
|
||||
paramList = mesa_vp->Parameters;
|
||||
vp->fogpidx = _mesa_add_state_reference(paramList, tokens);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,12 +408,11 @@ static void release_temps( struct tnl_program *p )
|
|||
}
|
||||
|
||||
|
||||
static struct ureg register_param5(struct tnl_program *p,
|
||||
static struct ureg register_param4(struct tnl_program *p,
|
||||
GLint s0,
|
||||
GLint s1,
|
||||
GLint s2,
|
||||
GLint s3,
|
||||
GLint s4)
|
||||
GLint s3)
|
||||
{
|
||||
gl_state_index16 tokens[STATE_LENGTH];
|
||||
GLint idx;
|
||||
|
|
@ -421,16 +420,14 @@ static struct ureg register_param5(struct tnl_program *p,
|
|||
tokens[1] = s1;
|
||||
tokens[2] = s2;
|
||||
tokens[3] = s3;
|
||||
tokens[4] = s4;
|
||||
idx = _mesa_add_state_reference(p->state_params, tokens);
|
||||
return make_ureg(PROGRAM_STATE_VAR, idx);
|
||||
}
|
||||
|
||||
|
||||
#define register_param1(p,s0) register_param5(p,s0,0,0,0,0)
|
||||
#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0)
|
||||
#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0)
|
||||
#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0)
|
||||
#define register_param1(p,s0) register_param4(p,s0,0,0,0)
|
||||
#define register_param2(p,s0,s1) register_param4(p,s0,s1,0,0)
|
||||
#define register_param3(p,s0,s1,s2) register_param4(p,s0,s1,s2,0)
|
||||
|
||||
|
||||
|
||||
|
|
@ -504,7 +501,6 @@ static void register_matrix_param5( struct tnl_program *p,
|
|||
GLint s1, /* texture matrix number */
|
||||
GLint s2, /* first row */
|
||||
GLint s3, /* last row */
|
||||
GLint s4, /* inverse, transpose, etc */
|
||||
struct ureg *matrix )
|
||||
{
|
||||
GLint i;
|
||||
|
|
@ -513,7 +509,7 @@ static void register_matrix_param5( struct tnl_program *p,
|
|||
* matrix out in one go:
|
||||
*/
|
||||
for (i = 0; i <= s3 - s2; i++)
|
||||
matrix[i] = register_param5( p, s0, s1, i, i, s4 );
|
||||
matrix[i] = register_param4(p, s0, s1, i, i);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -718,13 +714,13 @@ static struct ureg get_eye_position( struct tnl_program *p )
|
|||
|
||||
if (p->mvp_with_dp4) {
|
||||
register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3,
|
||||
0, modelview );
|
||||
modelview );
|
||||
|
||||
emit_matrix_transform_vec4(p, p->eye_position, modelview, pos);
|
||||
}
|
||||
else {
|
||||
register_matrix_param5( p, STATE_MODELVIEW_MATRIX_TRANSPOSE, 0, 0, 3,
|
||||
0, modelview );
|
||||
modelview );
|
||||
|
||||
emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos);
|
||||
}
|
||||
|
|
@ -746,7 +742,7 @@ static struct ureg get_eye_position_z( struct tnl_program *p )
|
|||
p->eye_position_z = reserve_temp(p);
|
||||
|
||||
register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3,
|
||||
0, modelview );
|
||||
modelview );
|
||||
|
||||
emit_op2(p, OPCODE_DP4, p->eye_position_z, 0, pos, modelview[2]);
|
||||
}
|
||||
|
|
@ -784,7 +780,7 @@ static struct ureg get_transformed_normal( struct tnl_program *p )
|
|||
|
||||
if (p->state->need_eye_coords) {
|
||||
register_matrix_param5( p, STATE_MODELVIEW_MATRIX_INVTRANS, 0, 0, 2,
|
||||
0, mvinv );
|
||||
mvinv );
|
||||
|
||||
/* Transform to eye space:
|
||||
*/
|
||||
|
|
@ -824,12 +820,12 @@ static void build_hpos( struct tnl_program *p )
|
|||
|
||||
if (p->mvp_with_dp4) {
|
||||
register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3,
|
||||
0, mvp );
|
||||
mvp );
|
||||
emit_matrix_transform_vec4( p, hpos, mvp, pos );
|
||||
}
|
||||
else {
|
||||
register_matrix_param5( p, STATE_MVP_MATRIX_TRANSPOSE, 0, 0, 3,
|
||||
0, mvp );
|
||||
mvp );
|
||||
emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos );
|
||||
}
|
||||
}
|
||||
|
|
@ -1500,12 +1496,12 @@ static void build_texture_transform( struct tnl_program *p )
|
|||
register_input(p, VERT_ATTRIB_TEX0+i));
|
||||
if (p->mvp_with_dp4) {
|
||||
register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3,
|
||||
0, texmat );
|
||||
texmat );
|
||||
emit_matrix_transform_vec4( p, out, texmat, in );
|
||||
}
|
||||
else {
|
||||
register_matrix_param5( p, STATE_TEXTURE_MATRIX_TRANSPOSE, i, 0, 3,
|
||||
0, texmat );
|
||||
texmat );
|
||||
emit_transpose_matrix_transform_vec4( p, out, texmat, in );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ _mesa_add_sized_state_reference(struct gl_program_parameter_list *paramList,
|
|||
* PARAM ambient = state.material.front.ambient;
|
||||
*
|
||||
* \param paramList the parameter list
|
||||
* \param stateTokens an array of 5 (STATE_LENGTH) state tokens
|
||||
* \param stateTokens an array of STATE_LENGTH state tokens
|
||||
* \return index of the new parameter.
|
||||
*/
|
||||
GLint
|
||||
|
|
|
|||
|
|
@ -1159,7 +1159,6 @@ _mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH])
|
|||
/* state[1] = which texture matrix or program matrix */
|
||||
/* state[2] = first row to fetch */
|
||||
/* state[3] = last row to fetch */
|
||||
/* state[4] = transpose, inverse or invtrans */
|
||||
const gl_state_index mat = state[0];
|
||||
const GLuint index = (GLuint) state[1];
|
||||
const GLuint firstRow = (GLuint) state[2];
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ insert_mvp_dp4_code(struct gl_context *ctx, struct gl_program *vprog)
|
|||
* XXX we should check if these state vars are already declared.
|
||||
*/
|
||||
static const gl_state_index16 mvpState[4][STATE_LENGTH] = {
|
||||
{ STATE_MVP_MATRIX, 0, 0, 0, 0 }, /* state.matrix.mvp.row[0] */
|
||||
{ STATE_MVP_MATRIX, 0, 1, 1, 0 }, /* state.matrix.mvp.row[1] */
|
||||
{ STATE_MVP_MATRIX, 0, 2, 2, 0 }, /* state.matrix.mvp.row[2] */
|
||||
{ STATE_MVP_MATRIX, 0, 3, 3, 0 }, /* state.matrix.mvp.row[3] */
|
||||
{ STATE_MVP_MATRIX, 0, 0, 0 }, /* state.matrix.mvp.row[0] */
|
||||
{ STATE_MVP_MATRIX, 0, 1, 1 }, /* state.matrix.mvp.row[1] */
|
||||
{ STATE_MVP_MATRIX, 0, 2, 2 }, /* state.matrix.mvp.row[2] */
|
||||
{ STATE_MVP_MATRIX, 0, 3, 3 }, /* state.matrix.mvp.row[3] */
|
||||
};
|
||||
GLint mvpRef[4];
|
||||
|
||||
|
|
@ -126,10 +126,10 @@ insert_mvp_mad_code(struct gl_context *ctx, struct gl_program *vprog)
|
|||
* XXX we should check if these state vars are already declared.
|
||||
*/
|
||||
static const gl_state_index16 mvpState[4][STATE_LENGTH] = {
|
||||
{ STATE_MVP_MATRIX_TRANSPOSE, 0, 0, 0, 0 },
|
||||
{ STATE_MVP_MATRIX_TRANSPOSE, 0, 1, 1, 0 },
|
||||
{ STATE_MVP_MATRIX_TRANSPOSE, 0, 2, 2, 0 },
|
||||
{ STATE_MVP_MATRIX_TRANSPOSE, 0, 3, 3, 0 },
|
||||
{ STATE_MVP_MATRIX_TRANSPOSE, 0, 0, 0 },
|
||||
{ STATE_MVP_MATRIX_TRANSPOSE, 0, 1, 1 },
|
||||
{ STATE_MVP_MATRIX_TRANSPOSE, 0, 2, 2 },
|
||||
{ STATE_MVP_MATRIX_TRANSPOSE, 0, 3, 3 },
|
||||
};
|
||||
GLint mvpRef[4];
|
||||
|
||||
|
|
@ -248,9 +248,9 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
|
|||
GLenum fog_mode, GLboolean saturate)
|
||||
{
|
||||
static const gl_state_index16 fogPStateOpt[STATE_LENGTH]
|
||||
= { STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 };
|
||||
= { STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0 };
|
||||
static const gl_state_index16 fogColorState[STATE_LENGTH]
|
||||
= { STATE_FOG_COLOR, 0, 0, 0, 0};
|
||||
= { STATE_FOG_COLOR, 0, 0, 0 };
|
||||
struct prog_instruction *newInst, *inst;
|
||||
const GLuint origLen = fprog->arb.NumInstructions;
|
||||
const GLuint newLen = origLen + 5;
|
||||
|
|
|
|||
|
|
@ -547,9 +547,9 @@ st_init_atifs_prog(struct gl_context *ctx, struct gl_program *prog)
|
|||
unsigned pass, i, r, optype, arg;
|
||||
|
||||
static const gl_state_index16 fog_params_state[STATE_LENGTH] =
|
||||
{STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0};
|
||||
{STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0 };
|
||||
static const gl_state_index16 fog_color[STATE_LENGTH] =
|
||||
{STATE_FOG_COLOR, 0, 0, 0, 0};
|
||||
{STATE_FOG_COLOR, 0, 0, 0 };
|
||||
|
||||
prog->info.inputs_read = 0;
|
||||
prog->info.outputs_written = BITFIELD64_BIT(FRAG_RESULT_COLOR);
|
||||
|
|
|
|||
|
|
@ -635,7 +635,7 @@ emit_wpos_adjustment(struct gl_context *ctx,
|
|||
* where T = INPUT[WPOS] by y is inverted.
|
||||
*/
|
||||
static const gl_state_index16 wposTransformState[STATE_LENGTH]
|
||||
= { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM, 0, 0, 0 };
|
||||
= { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM, 0, 0 };
|
||||
|
||||
/* XXX: note we are modifying the incoming shader here! Need to
|
||||
* do this before emitting the constant decls below, or this
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue