* \sa ir_variable::state_slots
*/
struct ir_state_slot {
- int tokens[5];
+ gl_state_index16 tokens[5];
int swizzle;
};
read_shader_parameters(struct blob_reader *metadata,
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 num_parameters = blob_read_uint32(metadata);
}
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;
}
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;
}
const char *msg);
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 *
-_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
_mesa_shader_enum_to_shader_stage(GLenum v)
* \sa nir_variable::state_slots
*/
typedef struct {
- int tokens[5];
+ gl_state_index16 tokens[5];
int swizzle;
} nir_state_slot;
void nir_lower_tes_patch_vertices(nir_shader *tes, unsigned patch_vertices);
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_lower_left :1;
bool fs_coord_pixel_center_integer :1;
bool nir_lower_wpos_center(nir_shader *shader, const bool for_sample_shading);
typedef struct nir_lower_drawpixels_options {
- int texcoord_state_tokens[5];
- int scale_state_tokens[5];
- int bias_state_tokens[5];
+ gl_state_index16 texcoord_state_tokens[5];
+ gl_state_index16 scale_state_tokens[5];
+ gl_state_index16 bias_state_tokens[5];
unsigned drawpix_sampler;
unsigned pixelmap_sampler;
bool pixel_maps :1;
}
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_var_uniform,
MESA_SHADER_COMPUTE = 5,
} gl_shader_stage;
+typedef short gl_state_index16; /* see enum gl_state_index */
+
const char *gl_shader_stage_name(gl_shader_stage stage);
/**
assert(var->state_slots != NULL);
for (unsigned int i = 0; i < var->num_state_slots; i++) {
- _mesa_add_state_reference(prog->Parameters,
- (gl_state_index *)slots[i].tokens);
+ _mesa_add_state_reference(prog->Parameters, slots[i].tokens);
}
}
}
* get the same index back here.
*/
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.
* This'll end up matching the expected layout of the
NIR_PASS(progress, nir, nir_lower_wpos_ytransform, &wpos_options);
if (progress) {
_mesa_add_state_reference(prog->Parameters,
- (gl_state_index *) wpos_options.state_tokens);
+ wpos_options.state_tokens);
}
}
if ((mesa_vp->info.outputs_written & (1 << VARYING_SLOT_FOGC)) &&
!vp->fogpidx) {
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;
vp->fogpidx = _mesa_add_state_reference(paramList, tokens);
}
GLint s3,
GLint s4)
{
- gl_state_index tokens[STATE_LENGTH];
+ gl_state_index16 tokens[STATE_LENGTH];
GLint idx;
tokens[0] = s0;
tokens[1] = s1;
TEST(program_state_string, depth_range)
{
- const gl_state_index state[STATE_LENGTH] = {
+ const gl_state_index16 state[STATE_LENGTH] = {
STATE_DEPTH_RANGE
};
struct gl_builtin_uniform_element {
const char *field;
- int tokens[STATE_LENGTH];
+ gl_state_index16 tokens[STATE_LENGTH];
int swizzle;
};
for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) {
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->index == -1) {
gl_register_file type, const char *name,
GLuint size, GLenum datatype,
const gl_constant_value *values,
- const gl_state_index state[STATE_LENGTH])
+ const gl_state_index16 state[STATE_LENGTH])
{
assert(0 < size && size <=4);
const GLuint oldNum = paramList->NumParameters;
*/
GLint
_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 */
char *name;
/* Check if the state reference is already in the list */
for (index = 0; index < (GLint) paramList->NumParameters; index++) {
if (!memcmp(paramList->Parameters[index].StateIndexes,
- stateTokens, STATE_LENGTH * sizeof(gl_state_index))) {
+ stateTokens,
+ sizeof(paramList->Parameters[index].StateIndexes))) {
return index;
}
}
name = _mesa_program_state_string(stateTokens);
index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
- size, GL_NONE,
- NULL, (gl_state_index *) stateTokens);
+ size, GL_NONE, NULL, stateTokens);
paramList->StateFlags |= _mesa_program_state_flags(stateTokens);
/* free name string here since we duplicated it in add_parameter() */
/**
* A sequence of STATE_* tokens and integers to identify GL state.
*/
- gl_state_index StateIndexes[STATE_LENGTH];
+ gl_state_index16 StateIndexes[STATE_LENGTH];
};
gl_register_file type, const char *name,
GLuint size, GLenum datatype,
const gl_constant_value *values,
- const gl_state_index state[STATE_LENGTH]);
+ const gl_state_index16 state[STATE_LENGTH]);
extern GLint
_mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
extern GLint
_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
* The program parser will produce the state[] values.
*/
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)
{
GLfloat *value = &val->f;
* some GL state has changed.
*/
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]) {
case STATE_MATERIAL:
* Use free() to deallocate the string.
*/
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 tmp[30];
} gl_state_index;
-
extern void
_mesa_load_state_parameters(struct gl_context *ctx,
struct gl_program_parameter_list *paramList);
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 *
-_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]);
+_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]);
char *name, enum asm_type t, struct YYLTYPE *locp);
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,
- 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,
- 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,
struct asm_symbol *param_var, const struct asm_vector *vec,
unsigned attrib;
int integer;
float real;
- gl_state_index state[STATE_LENGTH];
+ gl_state_index16 state[STATE_LENGTH];
int negate;
struct asm_vector vector;
enum prog_opcode opcode;
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 */
char *name;
int
initialize_symbol_from_state(struct gl_program *prog,
struct asm_symbol *param_var,
- const gl_state_index tokens[STATE_LENGTH])
+ const gl_state_index16 tokens[STATE_LENGTH])
{
int idx = -1;
- gl_state_index state_tokens[STATE_LENGTH];
+ gl_state_index16 state_tokens[STATE_LENGTH];
memcpy(state_tokens, tokens, sizeof(state_tokens));
int
initialize_symbol_from_param(struct gl_program *prog,
struct asm_symbol *param_var,
- const gl_state_index tokens[STATE_LENGTH])
+ const gl_state_index16 tokens[STATE_LENGTH])
{
int idx = -1;
- gl_state_index state_tokens[STATE_LENGTH];
+ gl_state_index16 state_tokens[STATE_LENGTH];
memcpy(state_tokens, tokens, sizeof(state_tokens));
* Setup state references for the modelview/projection matrix.
* 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, 1, 1, 0 }, /* state.matrix.mvp.row[1] */
{ STATE_MVP_MATRIX, 0, 2, 2, 0 }, /* state.matrix.mvp.row[2] */
* Setup state references for the modelview/projection matrix.
* 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, 1, 1, STATE_MATRIX_TRANSPOSE },
{ STATE_MVP_MATRIX, 0, 2, 2, STATE_MATRIX_TRANSPOSE },
_mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
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 };
- static const gl_state_index fogColorState[STATE_LENGTH]
+ static const gl_state_index16 fogColorState[STATE_LENGTH]
= { STATE_FOG_COLOR, 0, 0, 0, 0};
struct prog_instruction *newInst, *inst;
const GLuint origLen = fprog->arb.NumInstructions;
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};
- 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};
prog->info.inputs_read = 0;
else
loc = imageidx++;
} 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
* get the same index back here.
*/
for (unsigned int i = 0; i < var->num_state_slots; i++) {
_mesa_add_state_reference(prog->Parameters,
- (gl_state_index *)slots[i].tokens);
+ slots[i].tokens);
}
}
}
/* fragment shaders may need : */
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
};
nir_lower_wpos_ytransform_options wpos_options = { { 0 } };
for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) {
int index = _mesa_add_state_reference(this->prog->Parameters,
- (gl_state_index *)
slots[i].tokens);
if (storage->file == PROGRAM_STATE_VAR) {
* is a FBO or the window system buffer, respectively.
* 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 };
unsigned transform_y_index =
break;
case ir_binop_interpolate_at_offset: {
/* 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 };
unsigned transform_y_index =
if (shader->Stage == MESA_SHADER_FRAGMENT &&
(prog->info.inputs_read & VARYING_BIT_POS ||
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
};
* Need to replace instances of INPUT[WPOS] with temp T
* 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 };
/* XXX: note we are modifying the incoming shader here! Need to
const struct gl_builtin_uniform_element *element)
{
nir_shader *shader = state->shader;
- int tokens[STATE_LENGTH];
+ gl_state_index16 tokens[STATE_LENGTH];
memcpy(tokens, element->tokens, sizeof(tokens));
}
}
- char *name = _mesa_program_state_string((gl_state_index *)tokens);
+ char *name = _mesa_program_state_string(tokens);
nir_foreach_variable(var, &shader->uniforms) {
if (strcmp(var->name, name) == 0) {
struct st_fp_variant *variant = CALLOC_STRUCT(st_fp_variant);
struct pipe_shader_state tgsi = {0};
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 };
- static const gl_state_index scale_state[STATE_LENGTH] =
+ static const gl_state_index16 scale_state[STATE_LENGTH] =
{ 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 };
if (!variant)