mesa,glsl,nir: reduce gl_state_index size to 2 bytes
Let's use the new gl_state_index16 type everywhere and remove the typecasts. This helps reduce the size of gl_program_parameter. Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
a7882013d3
commit
e149a0253c
|
@ -397,7 +397,7 @@ depth_layout_string(ir_depth_layout layout);
|
||||||
* \sa ir_variable::state_slots
|
* \sa ir_variable::state_slots
|
||||||
*/
|
*/
|
||||||
struct ir_state_slot {
|
struct ir_state_slot {
|
||||||
int tokens[5];
|
gl_state_index16 tokens[5];
|
||||||
int swizzle;
|
int swizzle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -975,7 +975,7 @@ static void
|
||||||
read_shader_parameters(struct blob_reader *metadata,
|
read_shader_parameters(struct blob_reader *metadata,
|
||||||
struct gl_program_parameter_list *params)
|
struct gl_program_parameter_list *params)
|
||||||
{
|
{
|
||||||
gl_state_index state_indexes[STATE_LENGTH];
|
gl_state_index16 state_indexes[STATE_LENGTH];
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint32_t num_parameters = blob_read_uint32(metadata);
|
uint32_t num_parameters = blob_read_uint32(metadata);
|
||||||
|
|
||||||
|
|
|
@ -100,13 +100,13 @@ _mesa_new_shader(GLuint name, gl_shader_stage stage)
|
||||||
}
|
}
|
||||||
|
|
||||||
GLbitfield
|
GLbitfield
|
||||||
_mesa_program_state_flags(UNUSED const gl_state_index state[STATE_LENGTH])
|
_mesa_program_state_flags(UNUSED const gl_state_index16 state[STATE_LENGTH])
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
_mesa_program_state_string(UNUSED const gl_state_index state[STATE_LENGTH])
|
_mesa_program_state_string(UNUSED const gl_state_index16 state[STATE_LENGTH])
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,11 +69,11 @@ _mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id,
|
||||||
const char *msg);
|
const char *msg);
|
||||||
|
|
||||||
extern "C" GLbitfield
|
extern "C" GLbitfield
|
||||||
_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]);
|
_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]);
|
||||||
|
|
||||||
|
|
||||||
extern "C" char *
|
extern "C" char *
|
||||||
_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]);
|
_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]);
|
||||||
|
|
||||||
static inline gl_shader_stage
|
static inline gl_shader_stage
|
||||||
_mesa_shader_enum_to_shader_stage(GLenum v)
|
_mesa_shader_enum_to_shader_stage(GLenum v)
|
||||||
|
|
|
@ -89,7 +89,7 @@ struct nir_instr;
|
||||||
* \sa nir_variable::state_slots
|
* \sa nir_variable::state_slots
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int tokens[5];
|
gl_state_index16 tokens[5];
|
||||||
int swizzle;
|
int swizzle;
|
||||||
} nir_state_slot;
|
} nir_state_slot;
|
||||||
|
|
||||||
|
@ -2653,7 +2653,7 @@ void nir_lower_passthrough_edgeflags(nir_shader *shader);
|
||||||
void nir_lower_tes_patch_vertices(nir_shader *tes, unsigned patch_vertices);
|
void nir_lower_tes_patch_vertices(nir_shader *tes, unsigned patch_vertices);
|
||||||
|
|
||||||
typedef struct nir_lower_wpos_ytransform_options {
|
typedef struct nir_lower_wpos_ytransform_options {
|
||||||
int state_tokens[5];
|
gl_state_index16 state_tokens[5];
|
||||||
bool fs_coord_origin_upper_left :1;
|
bool fs_coord_origin_upper_left :1;
|
||||||
bool fs_coord_origin_lower_left :1;
|
bool fs_coord_origin_lower_left :1;
|
||||||
bool fs_coord_pixel_center_integer :1;
|
bool fs_coord_pixel_center_integer :1;
|
||||||
|
@ -2665,9 +2665,9 @@ bool nir_lower_wpos_ytransform(nir_shader *shader,
|
||||||
bool nir_lower_wpos_center(nir_shader *shader, const bool for_sample_shading);
|
bool nir_lower_wpos_center(nir_shader *shader, const bool for_sample_shading);
|
||||||
|
|
||||||
typedef struct nir_lower_drawpixels_options {
|
typedef struct nir_lower_drawpixels_options {
|
||||||
int texcoord_state_tokens[5];
|
gl_state_index16 texcoord_state_tokens[5];
|
||||||
int scale_state_tokens[5];
|
gl_state_index16 scale_state_tokens[5];
|
||||||
int bias_state_tokens[5];
|
gl_state_index16 bias_state_tokens[5];
|
||||||
unsigned drawpix_sampler;
|
unsigned drawpix_sampler;
|
||||||
unsigned pixelmap_sampler;
|
unsigned pixelmap_sampler;
|
||||||
bool pixel_maps :1;
|
bool pixel_maps :1;
|
||||||
|
|
|
@ -67,7 +67,8 @@ get_texcoord(lower_drawpixels_state *state)
|
||||||
}
|
}
|
||||||
|
|
||||||
static nir_variable *
|
static nir_variable *
|
||||||
create_uniform(nir_shader *shader, const char *name, const int state_tokens[5])
|
create_uniform(nir_shader *shader, const char *name,
|
||||||
|
const gl_state_index16 state_tokens[5])
|
||||||
{
|
{
|
||||||
nir_variable *var = nir_variable_create(shader,
|
nir_variable *var = nir_variable_create(shader,
|
||||||
nir_var_uniform,
|
nir_var_uniform,
|
||||||
|
|
|
@ -48,6 +48,8 @@ typedef enum
|
||||||
MESA_SHADER_COMPUTE = 5,
|
MESA_SHADER_COMPUTE = 5,
|
||||||
} gl_shader_stage;
|
} gl_shader_stage;
|
||||||
|
|
||||||
|
typedef short gl_state_index16; /* see enum gl_state_index */
|
||||||
|
|
||||||
const char *gl_shader_stage_name(gl_shader_stage stage);
|
const char *gl_shader_stage_name(gl_shader_stage stage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -319,8 +319,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
|
||||||
assert(var->state_slots != NULL);
|
assert(var->state_slots != NULL);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < var->num_state_slots; i++) {
|
for (unsigned int i = 0; i < var->num_state_slots; i++) {
|
||||||
_mesa_add_state_reference(prog->Parameters,
|
_mesa_add_state_reference(prog->Parameters, slots[i].tokens);
|
||||||
(gl_state_index *)slots[i].tokens);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ brw_nir_setup_glsl_builtin_uniform(nir_variable *var,
|
||||||
* get the same index back here.
|
* get the same index back here.
|
||||||
*/
|
*/
|
||||||
int index = _mesa_add_state_reference(prog->Parameters,
|
int index = _mesa_add_state_reference(prog->Parameters,
|
||||||
(gl_state_index *)slots[i].tokens);
|
slots[i].tokens);
|
||||||
|
|
||||||
/* Add each of the unique swizzles of the element as a parameter.
|
/* Add each of the unique swizzles of the element as a parameter.
|
||||||
* This'll end up matching the expected layout of the
|
* This'll end up matching the expected layout of the
|
||||||
|
|
|
@ -127,7 +127,7 @@ brw_create_nir(struct brw_context *brw,
|
||||||
NIR_PASS(progress, nir, nir_lower_wpos_ytransform, &wpos_options);
|
NIR_PASS(progress, nir, nir_lower_wpos_ytransform, &wpos_options);
|
||||||
if (progress) {
|
if (progress) {
|
||||||
_mesa_add_state_reference(prog->Parameters,
|
_mesa_add_state_reference(prog->Parameters,
|
||||||
(gl_state_index *) wpos_options.state_tokens);
|
wpos_options.state_tokens);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -456,7 +456,7 @@ static GLboolean r200_translate_vertex_program(struct gl_context *ctx, struct r2
|
||||||
if ((mesa_vp->info.outputs_written & (1 << VARYING_SLOT_FOGC)) &&
|
if ((mesa_vp->info.outputs_written & (1 << VARYING_SLOT_FOGC)) &&
|
||||||
!vp->fogpidx) {
|
!vp->fogpidx) {
|
||||||
struct gl_program_parameter_list *paramList;
|
struct gl_program_parameter_list *paramList;
|
||||||
gl_state_index tokens[STATE_LENGTH] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
|
gl_state_index16 tokens[STATE_LENGTH] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
|
||||||
paramList = mesa_vp->Parameters;
|
paramList = mesa_vp->Parameters;
|
||||||
vp->fogpidx = _mesa_add_state_reference(paramList, tokens);
|
vp->fogpidx = _mesa_add_state_reference(paramList, tokens);
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,7 +413,7 @@ static struct ureg register_param5(struct tnl_program *p,
|
||||||
GLint s3,
|
GLint s3,
|
||||||
GLint s4)
|
GLint s4)
|
||||||
{
|
{
|
||||||
gl_state_index tokens[STATE_LENGTH];
|
gl_state_index16 tokens[STATE_LENGTH];
|
||||||
GLint idx;
|
GLint idx;
|
||||||
tokens[0] = s0;
|
tokens[0] = s0;
|
||||||
tokens[1] = s1;
|
tokens[1] = s1;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
TEST(program_state_string, depth_range)
|
TEST(program_state_string, depth_range)
|
||||||
{
|
{
|
||||||
const gl_state_index state[STATE_LENGTH] = {
|
const gl_state_index16 state[STATE_LENGTH] = {
|
||||||
STATE_DEPTH_RANGE
|
STATE_DEPTH_RANGE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -505,7 +505,7 @@ _mesa_flush_vertices_for_uniforms(struct gl_context *ctx,
|
||||||
|
|
||||||
struct gl_builtin_uniform_element {
|
struct gl_builtin_uniform_element {
|
||||||
const char *field;
|
const char *field;
|
||||||
int tokens[STATE_LENGTH];
|
gl_state_index16 tokens[STATE_LENGTH];
|
||||||
int swizzle;
|
int swizzle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -663,7 +663,7 @@ ir_to_mesa_visitor::visit(ir_variable *ir)
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) {
|
for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) {
|
||||||
int index = _mesa_add_state_reference(this->prog->Parameters,
|
int index = _mesa_add_state_reference(this->prog->Parameters,
|
||||||
(gl_state_index *)slots[i].tokens);
|
slots[i].tokens);
|
||||||
|
|
||||||
if (storage->file == PROGRAM_STATE_VAR) {
|
if (storage->file == PROGRAM_STATE_VAR) {
|
||||||
if (storage->index == -1) {
|
if (storage->index == -1) {
|
||||||
|
|
|
@ -232,7 +232,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
|
||||||
gl_register_file type, const char *name,
|
gl_register_file type, const char *name,
|
||||||
GLuint size, GLenum datatype,
|
GLuint size, GLenum datatype,
|
||||||
const gl_constant_value *values,
|
const gl_constant_value *values,
|
||||||
const gl_state_index state[STATE_LENGTH])
|
const gl_state_index16 state[STATE_LENGTH])
|
||||||
{
|
{
|
||||||
assert(0 < size && size <=4);
|
assert(0 < size && size <=4);
|
||||||
const GLuint oldNum = paramList->NumParameters;
|
const GLuint oldNum = paramList->NumParameters;
|
||||||
|
@ -352,7 +352,7 @@ _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
|
||||||
*/
|
*/
|
||||||
GLint
|
GLint
|
||||||
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
|
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
|
||||||
const gl_state_index stateTokens[STATE_LENGTH])
|
const gl_state_index16 stateTokens[STATE_LENGTH])
|
||||||
{
|
{
|
||||||
const GLuint size = 4; /* XXX fix */
|
const GLuint size = 4; /* XXX fix */
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -361,15 +361,15 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
|
||||||
/* Check if the state reference is already in the list */
|
/* Check if the state reference is already in the list */
|
||||||
for (index = 0; index < (GLint) paramList->NumParameters; index++) {
|
for (index = 0; index < (GLint) paramList->NumParameters; index++) {
|
||||||
if (!memcmp(paramList->Parameters[index].StateIndexes,
|
if (!memcmp(paramList->Parameters[index].StateIndexes,
|
||||||
stateTokens, STATE_LENGTH * sizeof(gl_state_index))) {
|
stateTokens,
|
||||||
|
sizeof(paramList->Parameters[index].StateIndexes))) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
name = _mesa_program_state_string(stateTokens);
|
name = _mesa_program_state_string(stateTokens);
|
||||||
index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
|
index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
|
||||||
size, GL_NONE,
|
size, GL_NONE, NULL, stateTokens);
|
||||||
NULL, (gl_state_index *) stateTokens);
|
|
||||||
paramList->StateFlags |= _mesa_program_state_flags(stateTokens);
|
paramList->StateFlags |= _mesa_program_state_flags(stateTokens);
|
||||||
|
|
||||||
/* free name string here since we duplicated it in add_parameter() */
|
/* free name string here since we duplicated it in add_parameter() */
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct gl_program_parameter
|
||||||
/**
|
/**
|
||||||
* A sequence of STATE_* tokens and integers to identify GL state.
|
* A sequence of STATE_* tokens and integers to identify GL state.
|
||||||
*/
|
*/
|
||||||
gl_state_index StateIndexes[STATE_LENGTH];
|
gl_state_index16 StateIndexes[STATE_LENGTH];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
|
||||||
gl_register_file type, const char *name,
|
gl_register_file type, const char *name,
|
||||||
GLuint size, GLenum datatype,
|
GLuint size, GLenum datatype,
|
||||||
const gl_constant_value *values,
|
const gl_constant_value *values,
|
||||||
const gl_state_index state[STATE_LENGTH]);
|
const gl_state_index16 state[STATE_LENGTH]);
|
||||||
|
|
||||||
extern GLint
|
extern GLint
|
||||||
_mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
|
_mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
|
||||||
|
@ -126,7 +126,7 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
|
||||||
|
|
||||||
extern GLint
|
extern GLint
|
||||||
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
|
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
|
||||||
const gl_state_index stateTokens[STATE_LENGTH]);
|
const gl_state_index16 stateTokens[]);
|
||||||
|
|
||||||
|
|
||||||
static inline GLint
|
static inline GLint
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
* The program parser will produce the state[] values.
|
* The program parser will produce the state[] values.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
_mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
|
_mesa_fetch_state(struct gl_context *ctx, const gl_state_index16 state[],
|
||||||
gl_constant_value *val)
|
gl_constant_value *val)
|
||||||
{
|
{
|
||||||
GLfloat *value = &val->f;
|
GLfloat *value = &val->f;
|
||||||
|
@ -628,7 +628,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
|
||||||
* some GL state has changed.
|
* some GL state has changed.
|
||||||
*/
|
*/
|
||||||
GLbitfield
|
GLbitfield
|
||||||
_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
|
_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH])
|
||||||
{
|
{
|
||||||
switch (state[0]) {
|
switch (state[0]) {
|
||||||
case STATE_MATERIAL:
|
case STATE_MATERIAL:
|
||||||
|
@ -948,7 +948,7 @@ append_index(char *dst, GLint index)
|
||||||
* Use free() to deallocate the string.
|
* Use free() to deallocate the string.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
_mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
|
_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH])
|
||||||
{
|
{
|
||||||
char str[1000] = "";
|
char str[1000] = "";
|
||||||
char tmp[30];
|
char tmp[30];
|
||||||
|
|
|
@ -138,18 +138,17 @@ typedef enum gl_state_index_ {
|
||||||
} gl_state_index;
|
} gl_state_index;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_load_state_parameters(struct gl_context *ctx,
|
_mesa_load_state_parameters(struct gl_context *ctx,
|
||||||
struct gl_program_parameter_list *paramList);
|
struct gl_program_parameter_list *paramList);
|
||||||
|
|
||||||
|
|
||||||
extern GLbitfield
|
extern GLbitfield
|
||||||
_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]);
|
_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]);
|
||||||
|
|
||||||
|
|
||||||
extern char *
|
extern char *
|
||||||
_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]);
|
_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,13 +45,13 @@ static struct asm_symbol *declare_variable(struct asm_parser_state *state,
|
||||||
char *name, enum asm_type t, struct YYLTYPE *locp);
|
char *name, enum asm_type t, struct YYLTYPE *locp);
|
||||||
|
|
||||||
static int add_state_reference(struct gl_program_parameter_list *param_list,
|
static int add_state_reference(struct gl_program_parameter_list *param_list,
|
||||||
const gl_state_index tokens[STATE_LENGTH]);
|
const gl_state_index16 tokens[STATE_LENGTH]);
|
||||||
|
|
||||||
static int initialize_symbol_from_state(struct gl_program *prog,
|
static int initialize_symbol_from_state(struct gl_program *prog,
|
||||||
struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]);
|
struct asm_symbol *param_var, const gl_state_index16 tokens[STATE_LENGTH]);
|
||||||
|
|
||||||
static int initialize_symbol_from_param(struct gl_program *prog,
|
static int initialize_symbol_from_param(struct gl_program *prog,
|
||||||
struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]);
|
struct asm_symbol *param_var, const gl_state_index16 tokens[STATE_LENGTH]);
|
||||||
|
|
||||||
static int initialize_symbol_from_const(struct gl_program *prog,
|
static int initialize_symbol_from_const(struct gl_program *prog,
|
||||||
struct asm_symbol *param_var, const struct asm_vector *vec,
|
struct asm_symbol *param_var, const struct asm_vector *vec,
|
||||||
|
@ -136,7 +136,7 @@ static struct asm_instruction *asm_instruction_copy_ctor(
|
||||||
unsigned attrib;
|
unsigned attrib;
|
||||||
int integer;
|
int integer;
|
||||||
float real;
|
float real;
|
||||||
gl_state_index state[STATE_LENGTH];
|
gl_state_index16 state[STATE_LENGTH];
|
||||||
int negate;
|
int negate;
|
||||||
struct asm_vector vector;
|
struct asm_vector vector;
|
||||||
enum prog_opcode opcode;
|
enum prog_opcode opcode;
|
||||||
|
@ -2299,7 +2299,7 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
|
||||||
|
|
||||||
|
|
||||||
int add_state_reference(struct gl_program_parameter_list *param_list,
|
int add_state_reference(struct gl_program_parameter_list *param_list,
|
||||||
const gl_state_index tokens[STATE_LENGTH])
|
const gl_state_index16 tokens[STATE_LENGTH])
|
||||||
{
|
{
|
||||||
const GLuint size = 4; /* XXX fix */
|
const GLuint size = 4; /* XXX fix */
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -2320,10 +2320,10 @@ int add_state_reference(struct gl_program_parameter_list *param_list,
|
||||||
int
|
int
|
||||||
initialize_symbol_from_state(struct gl_program *prog,
|
initialize_symbol_from_state(struct gl_program *prog,
|
||||||
struct asm_symbol *param_var,
|
struct asm_symbol *param_var,
|
||||||
const gl_state_index tokens[STATE_LENGTH])
|
const gl_state_index16 tokens[STATE_LENGTH])
|
||||||
{
|
{
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
gl_state_index state_tokens[STATE_LENGTH];
|
gl_state_index16 state_tokens[STATE_LENGTH];
|
||||||
|
|
||||||
|
|
||||||
memcpy(state_tokens, tokens, sizeof(state_tokens));
|
memcpy(state_tokens, tokens, sizeof(state_tokens));
|
||||||
|
@ -2372,10 +2372,10 @@ initialize_symbol_from_state(struct gl_program *prog,
|
||||||
int
|
int
|
||||||
initialize_symbol_from_param(struct gl_program *prog,
|
initialize_symbol_from_param(struct gl_program *prog,
|
||||||
struct asm_symbol *param_var,
|
struct asm_symbol *param_var,
|
||||||
const gl_state_index tokens[STATE_LENGTH])
|
const gl_state_index16 tokens[STATE_LENGTH])
|
||||||
{
|
{
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
gl_state_index state_tokens[STATE_LENGTH];
|
gl_state_index16 state_tokens[STATE_LENGTH];
|
||||||
|
|
||||||
|
|
||||||
memcpy(state_tokens, tokens, sizeof(state_tokens));
|
memcpy(state_tokens, tokens, sizeof(state_tokens));
|
||||||
|
|
|
@ -57,7 +57,7 @@ insert_mvp_dp4_code(struct gl_context *ctx, struct gl_program *vprog)
|
||||||
* Setup state references for the modelview/projection matrix.
|
* Setup state references for the modelview/projection matrix.
|
||||||
* XXX we should check if these state vars are already declared.
|
* XXX we should check if these state vars are already declared.
|
||||||
*/
|
*/
|
||||||
static const gl_state_index mvpState[4][STATE_LENGTH] = {
|
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, 0, 0, 0 }, /* state.matrix.mvp.row[0] */
|
||||||
{ STATE_MVP_MATRIX, 0, 1, 1, 0 }, /* state.matrix.mvp.row[1] */
|
{ 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, 2, 2, 0 }, /* state.matrix.mvp.row[2] */
|
||||||
|
@ -125,7 +125,7 @@ insert_mvp_mad_code(struct gl_context *ctx, struct gl_program *vprog)
|
||||||
* Setup state references for the modelview/projection matrix.
|
* Setup state references for the modelview/projection matrix.
|
||||||
* XXX we should check if these state vars are already declared.
|
* XXX we should check if these state vars are already declared.
|
||||||
*/
|
*/
|
||||||
static const gl_state_index mvpState[4][STATE_LENGTH] = {
|
static const gl_state_index16 mvpState[4][STATE_LENGTH] = {
|
||||||
{ STATE_MVP_MATRIX, 0, 0, 0, STATE_MATRIX_TRANSPOSE },
|
{ STATE_MVP_MATRIX, 0, 0, 0, STATE_MATRIX_TRANSPOSE },
|
||||||
{ STATE_MVP_MATRIX, 0, 1, 1, STATE_MATRIX_TRANSPOSE },
|
{ STATE_MVP_MATRIX, 0, 1, 1, STATE_MATRIX_TRANSPOSE },
|
||||||
{ STATE_MVP_MATRIX, 0, 2, 2, STATE_MATRIX_TRANSPOSE },
|
{ STATE_MVP_MATRIX, 0, 2, 2, STATE_MATRIX_TRANSPOSE },
|
||||||
|
@ -247,9 +247,9 @@ void
|
||||||
_mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
|
_mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
|
||||||
GLenum fog_mode, GLboolean saturate)
|
GLenum fog_mode, GLboolean saturate)
|
||||||
{
|
{
|
||||||
static const gl_state_index fogPStateOpt[STATE_LENGTH]
|
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, 0 };
|
||||||
static const gl_state_index fogColorState[STATE_LENGTH]
|
static const gl_state_index16 fogColorState[STATE_LENGTH]
|
||||||
= { STATE_FOG_COLOR, 0, 0, 0, 0};
|
= { STATE_FOG_COLOR, 0, 0, 0, 0};
|
||||||
struct prog_instruction *newInst, *inst;
|
struct prog_instruction *newInst, *inst;
|
||||||
const GLuint origLen = fprog->arb.NumInstructions;
|
const GLuint origLen = fprog->arb.NumInstructions;
|
||||||
|
|
|
@ -544,9 +544,9 @@ st_init_atifs_prog(struct gl_context *ctx, struct gl_program *prog)
|
||||||
|
|
||||||
unsigned pass, i, r, optype, arg;
|
unsigned pass, i, r, optype, arg;
|
||||||
|
|
||||||
static const gl_state_index fog_params_state[STATE_LENGTH] =
|
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, 0};
|
||||||
static const gl_state_index fog_color[STATE_LENGTH] =
|
static const gl_state_index16 fog_color[STATE_LENGTH] =
|
||||||
{STATE_FOG_COLOR, 0, 0, 0, 0};
|
{STATE_FOG_COLOR, 0, 0, 0, 0};
|
||||||
|
|
||||||
prog->info.inputs_read = 0;
|
prog->info.inputs_read = 0;
|
||||||
|
|
|
@ -247,7 +247,7 @@ st_nir_assign_uniform_locations(struct gl_program *prog,
|
||||||
else
|
else
|
||||||
loc = imageidx++;
|
loc = imageidx++;
|
||||||
} else if (strncmp(uniform->name, "gl_", 3) == 0) {
|
} else if (strncmp(uniform->name, "gl_", 3) == 0) {
|
||||||
const gl_state_index *const stateTokens = (gl_state_index *)uniform->state_slots[0].tokens;
|
const gl_state_index16 *const stateTokens = uniform->state_slots[0].tokens;
|
||||||
/* This state reference has already been setup by ir_to_mesa, but we'll
|
/* This state reference has already been setup by ir_to_mesa, but we'll
|
||||||
* get the same index back here.
|
* get the same index back here.
|
||||||
*/
|
*/
|
||||||
|
@ -365,7 +365,7 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
|
||||||
|
|
||||||
for (unsigned int i = 0; i < var->num_state_slots; i++) {
|
for (unsigned int i = 0; i < var->num_state_slots; i++) {
|
||||||
_mesa_add_state_reference(prog->Parameters,
|
_mesa_add_state_reference(prog->Parameters,
|
||||||
(gl_state_index *)slots[i].tokens);
|
slots[i].tokens);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ st_link_nir(struct gl_context *ctx,
|
||||||
|
|
||||||
/* fragment shaders may need : */
|
/* fragment shaders may need : */
|
||||||
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
|
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
|
||||||
static const gl_state_index wposTransformState[STATE_LENGTH] = {
|
static const gl_state_index16 wposTransformState[STATE_LENGTH] = {
|
||||||
STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
|
STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
|
||||||
};
|
};
|
||||||
nir_lower_wpos_ytransform_options wpos_options = { { 0 } };
|
nir_lower_wpos_ytransform_options wpos_options = { { 0 } };
|
||||||
|
|
|
@ -1135,7 +1135,6 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) {
|
for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) {
|
||||||
int index = _mesa_add_state_reference(this->prog->Parameters,
|
int index = _mesa_add_state_reference(this->prog->Parameters,
|
||||||
(gl_state_index *)
|
|
||||||
slots[i].tokens);
|
slots[i].tokens);
|
||||||
|
|
||||||
if (storage->file == PROGRAM_STATE_VAR) {
|
if (storage->file == PROGRAM_STATE_VAR) {
|
||||||
|
@ -1497,7 +1496,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
|
||||||
* is a FBO or the window system buffer, respectively.
|
* is a FBO or the window system buffer, respectively.
|
||||||
* It is then multiplied with the source operand of DDY.
|
* It is then multiplied with the source operand of DDY.
|
||||||
*/
|
*/
|
||||||
static const gl_state_index transform_y_state[STATE_LENGTH]
|
static const gl_state_index16 transform_y_state[STATE_LENGTH]
|
||||||
= { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM };
|
= { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM };
|
||||||
|
|
||||||
unsigned transform_y_index =
|
unsigned transform_y_index =
|
||||||
|
@ -2115,7 +2114,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
|
||||||
break;
|
break;
|
||||||
case ir_binop_interpolate_at_offset: {
|
case ir_binop_interpolate_at_offset: {
|
||||||
/* The y coordinate needs to be flipped for the default fb */
|
/* The y coordinate needs to be flipped for the default fb */
|
||||||
static const gl_state_index transform_y_state[STATE_LENGTH]
|
static const gl_state_index16 transform_y_state[STATE_LENGTH]
|
||||||
= { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM };
|
= { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM };
|
||||||
|
|
||||||
unsigned transform_y_index =
|
unsigned transform_y_index =
|
||||||
|
@ -6866,7 +6865,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
|
||||||
if (shader->Stage == MESA_SHADER_FRAGMENT &&
|
if (shader->Stage == MESA_SHADER_FRAGMENT &&
|
||||||
(prog->info.inputs_read & VARYING_BIT_POS ||
|
(prog->info.inputs_read & VARYING_BIT_POS ||
|
||||||
prog->info.system_values_read & (1 << SYSTEM_VALUE_FRAG_COORD))) {
|
prog->info.system_values_read & (1 << SYSTEM_VALUE_FRAG_COORD))) {
|
||||||
static const gl_state_index wposTransformState[STATE_LENGTH] = {
|
static const gl_state_index16 wposTransformState[STATE_LENGTH] = {
|
||||||
STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
|
STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -622,7 +622,7 @@ emit_wpos_adjustment(struct gl_context *ctx,
|
||||||
* Need to replace instances of INPUT[WPOS] with temp T
|
* Need to replace instances of INPUT[WPOS] with temp T
|
||||||
* where T = INPUT[WPOS] by y is inverted.
|
* where T = INPUT[WPOS] by y is inverted.
|
||||||
*/
|
*/
|
||||||
static const gl_state_index wposTransformState[STATE_LENGTH]
|
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, 0 };
|
||||||
|
|
||||||
/* XXX: note we are modifying the incoming shader here! Need to
|
/* XXX: note we are modifying the incoming shader here! Need to
|
||||||
|
|
|
@ -100,7 +100,7 @@ get_variable(lower_builtin_state *state, nir_deref_var *deref,
|
||||||
const struct gl_builtin_uniform_element *element)
|
const struct gl_builtin_uniform_element *element)
|
||||||
{
|
{
|
||||||
nir_shader *shader = state->shader;
|
nir_shader *shader = state->shader;
|
||||||
int tokens[STATE_LENGTH];
|
gl_state_index16 tokens[STATE_LENGTH];
|
||||||
|
|
||||||
memcpy(tokens, element->tokens, sizeof(tokens));
|
memcpy(tokens, element->tokens, sizeof(tokens));
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ get_variable(lower_builtin_state *state, nir_deref_var *deref,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *name = _mesa_program_state_string((gl_state_index *)tokens);
|
char *name = _mesa_program_state_string(tokens);
|
||||||
|
|
||||||
nir_foreach_variable(var, &shader->uniforms) {
|
nir_foreach_variable(var, &shader->uniforms) {
|
||||||
if (strcmp(var->name, name) == 0) {
|
if (strcmp(var->name, name) == 0) {
|
||||||
|
|
|
@ -1013,11 +1013,11 @@ st_create_fp_variant(struct st_context *st,
|
||||||
struct st_fp_variant *variant = CALLOC_STRUCT(st_fp_variant);
|
struct st_fp_variant *variant = CALLOC_STRUCT(st_fp_variant);
|
||||||
struct pipe_shader_state tgsi = {0};
|
struct pipe_shader_state tgsi = {0};
|
||||||
struct gl_program_parameter_list *params = stfp->Base.Parameters;
|
struct gl_program_parameter_list *params = stfp->Base.Parameters;
|
||||||
static const gl_state_index texcoord_state[STATE_LENGTH] =
|
static const gl_state_index16 texcoord_state[STATE_LENGTH] =
|
||||||
{ STATE_INTERNAL, STATE_CURRENT_ATTRIB, VERT_ATTRIB_TEX0 };
|
{ STATE_INTERNAL, STATE_CURRENT_ATTRIB, VERT_ATTRIB_TEX0 };
|
||||||
static const gl_state_index scale_state[STATE_LENGTH] =
|
static const gl_state_index16 scale_state[STATE_LENGTH] =
|
||||||
{ STATE_INTERNAL, STATE_PT_SCALE };
|
{ STATE_INTERNAL, STATE_PT_SCALE };
|
||||||
static const gl_state_index bias_state[STATE_LENGTH] =
|
static const gl_state_index16 bias_state[STATE_LENGTH] =
|
||||||
{ STATE_INTERNAL, STATE_PT_BIAS };
|
{ STATE_INTERNAL, STATE_PT_BIAS };
|
||||||
|
|
||||||
if (!variant)
|
if (!variant)
|
||||||
|
|
Loading…
Reference in New Issue