[Mesa-dev] [PATCH 05/10] mesa: Make gl_program::InputsRead 64 bits.

Mathias Fröhlich Mathias.Froehlich at gmx.net
Fri Nov 11 09:09:36 PST 2011


---
 src/mesa/main/context.c                        |    2 +-
 src/mesa/main/ff_fragment_shader.cpp           |    2 +-
 src/mesa/main/ffvertex_prog.c                  |   18 +++++++++---------
 src/mesa/main/mtypes.h                         |    4 ++--
 src/mesa/main/state.c                          |    2 +-
 src/mesa/main/state.h                          |    2 +-
 src/mesa/program/program_parse.y               |    6 +++---
 src/mesa/program/programopt.c                  |    4 ++--
 src/mesa/state_tracker/st_atom_pixeltransfer.c |    2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp     |    8 ++++----
 src/mesa/state_tracker/st_program.c            |   10 +++++-----
 src/mesa/tnl/t_vb_program.c                    |    2 +-
 src/mesa/vbo/vbo_exec_array.c                  |    4 ++--
 src/mesa/vbo/vbo_exec_draw.c                   |    2 +-
 src/mesa/vbo/vbo_save_draw.c                   |    2 +-
 15 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 19e43d1..6a0376d 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -827,7 +827,7 @@ init_attrib_groups(struct gl_context *ctx)
    ctx->NewState = _NEW_ALL;
    ctx->ErrorValue = (GLenum) GL_NO_ERROR;
    ctx->ResetStatus = (GLenum) GL_NO_ERROR;
-   ctx->varying_vp_inputs = ~0;
+   ctx->varying_vp_inputs = VERT_BIT_ALL;
 
    return GL_TRUE;
 }
diff --git a/src/mesa/main/ff_fragment_shader.cpp 
b/src/mesa/main/ff_fragment_shader.cpp
index 2ce81fe..7d698c3 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -334,7 +334,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx 
)
    else if (!(vertexProgram || vertexShader)) {
       /* Fixed function vertex logic */
       /* _NEW_ARRAY */
-      GLbitfield varying_inputs = ctx->varying_vp_inputs;
+      GLbitfield64 varying_inputs = ctx->varying_vp_inputs;
 
       /* These get generated in the setup routine regardless of the
        * vertex program:
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 8469078..c0003c5 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -68,7 +68,7 @@ struct state_key {
    unsigned texture_enabled_global:1;
    unsigned fragprog_inputs_read:12;
 
-   unsigned varying_vp_inputs;
+   GLbitfield64 varying_vp_inputs;
 
    struct {
       unsigned light_enabled:1;
@@ -130,16 +130,16 @@ static GLboolean check_active_shininess( struct 
gl_context *ctx,
                                          const struct state_key *key,
                                          GLuint side )
 {
-   GLuint bit = 1 << (MAT_ATTRIB_FRONT_SHININESS + side);
+   GLuint attr = MAT_ATTRIB_FRONT_SHININESS + side;
 
    if ((key->varying_vp_inputs & VERT_BIT_COLOR0) &&
-       (key->light_color_material_mask & bit))
+       (key->light_color_material_mask & (1 << attr)))
       return GL_TRUE;
 
-   if (key->varying_vp_inputs & (bit << 16))
+   if (key->varying_vp_inputs & VERT_ATTRIB_GENERIC(attr))
       return GL_TRUE;
 
-   if (ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS + side][0] != 
0.0F)
+   if (ctx->Light.Material.Attrib[attr][0] != 0.0F)
       return GL_TRUE;
 
    return GL_FALSE;
@@ -445,10 +445,10 @@ static struct ureg register_param5(struct tnl_program 
*p,
  */
 static struct ureg register_input( struct tnl_program *p, GLuint input )
 {
-   assert(input < 32);
+   assert(input < VERT_ATTRIB_MAX);
 
-   if (p->state->varying_vp_inputs & (1<<input)) {
-      p->program->Base.InputsRead |= (1<<input);
+   if (p->state->varying_vp_inputs & VERT_BIT(input)) {
+      p->program->Base.InputsRead |= VERT_BIT(input);
       return make_ureg(PROGRAM_INPUT, input);
    }
    else {
@@ -871,7 +871,7 @@ static void set_material_flags( struct tnl_program *p )
 	 p->color_materials = p->state->light_color_material_mask;
    }
 
-   p->materials |= (p->state->varying_vp_inputs >> 16);
+   p->materials |= (p->state->varying_vp_inputs >> VERT_ATTRIB_GENERIC0);
 }
 
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3859344..84e09d8 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1873,7 +1873,7 @@ struct gl_program
 
    struct prog_instruction *Instructions;
 
-   GLbitfield InputsRead;     /**< Bitmask of which input regs are read */
+   GLbitfield64 InputsRead;     /**< Bitmask of which input regs are read */
    GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written 
*/
    GLbitfield SystemValuesRead;   /**< Bitmask of SYSTEM_VALUE_x inputs used 
*/
    GLbitfield InputFlags[MAX_PROGRAM_INPUTS];   /**< PROG_PARAM_BIT_x flags */
@@ -3367,7 +3367,7 @@ struct gl_context
 
    GLboolean ViewportInitialized;  /**< has viewport size been initialized? 
*/
 
-   GLbitfield varying_vp_inputs;  /**< mask of VERT_BIT_* flags */
+   GLbitfield64 varying_vp_inputs;  /**< mask of VERT_BIT_* flags */
 
    /** \name Derived state */
    /*@{*/
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 80fd03b..f57579c 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -737,7 +737,7 @@ _mesa_update_state( struct gl_context *ctx )
  */
 void
 _mesa_set_varying_vp_inputs( struct gl_context *ctx,
-                             GLbitfield varying_inputs )
+                             GLbitfield64 varying_inputs )
 {
    if (ctx->varying_vp_inputs != varying_inputs) {
       ctx->varying_vp_inputs = varying_inputs;
diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h
index 2b5b3d5..29a2540 100644
--- a/src/mesa/main/state.h
+++ b/src/mesa/main/state.h
@@ -39,7 +39,7 @@ _mesa_update_state_locked(struct gl_context *ctx);
 
 
 extern void
-_mesa_set_varying_vp_inputs(struct gl_context *ctx, GLbitfield 
varying_inputs);
+_mesa_set_varying_vp_inputs(struct gl_context *ctx, GLbitfield64 
varying_inputs);
 
 
 extern void
diff --git a/src/mesa/program/program_parse.y 
b/src/mesa/program/program_parse.y
index dec3503..9fdb99d 100644
--- a/src/mesa/program/program_parse.y
+++ b/src/mesa/program/program_parse.y
@@ -802,7 +802,7 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle 
*/
 	      break;
 	   case at_attrib:
 	      set_src_reg(& $$, PROGRAM_INPUT, s->attrib_binding);
-	      state->prog->InputsRead |= (1U << $$.Base.Index);
+	      state->prog->InputsRead |= BITFIELD64_BIT($$.Base.Index);
 
 	      if (!validate_inputs(& @1, state)) {
 		 YYERROR;
@@ -817,7 +817,7 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle 
*/
 	| attribBinding
 	{
 	   set_src_reg(& $$, PROGRAM_INPUT, $1);
-	   state->prog->InputsRead |= (1U << $$.Base.Index);
+	   state->prog->InputsRead |= BITFIELD64_BIT($$.Base.Index);
 
 	   if (!validate_inputs(& @1, state)) {
 	      YYERROR;
@@ -2768,7 +2768,7 @@ _mesa_parse_arb_program(struct gl_context *ctx, GLenum 
target, const GLubyte *st
    state->prog->NumInstructions++;
 
    state->prog->NumParameters = state->prog->Parameters->NumParameters;
-   state->prog->NumAttributes = _mesa_bitcount(state->prog->InputsRead);
+   state->prog->NumAttributes = _mesa_bitcount_64(state->prog->InputsRead);
 
    /*
     * Initialize native counts to logical counts.  The device driver may
diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c
index c72dfb2..389ea21 100644
--- a/src/mesa/program/programopt.c
+++ b/src/mesa/program/programopt.c
@@ -631,7 +631,7 @@ _mesa_nop_fragment_program(struct gl_context *ctx, struct 
gl_fragment_program *p
 
    prog->Base.Instructions = inst;
    prog->Base.NumInstructions = 2;
-   prog->Base.InputsRead = 1 << inputAttr;
+   prog->Base.InputsRead = BITFIELD64_BIT(inputAttr);
    prog->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR);
 }
 
@@ -675,7 +675,7 @@ _mesa_nop_vertex_program(struct gl_context *ctx, struct 
gl_vertex_program *prog)
 
    prog->Base.Instructions = inst;
    prog->Base.NumInstructions = 2;
-   prog->Base.InputsRead = 1 << inputAttr;
+   prog->Base.InputsRead = BITFIELD64_BIT(inputAttr);
    prog->Base.OutputsWritten = BITFIELD64_BIT(VERT_RESULT_COL0);
 
    /*
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c 
b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index 12b5bc5..afca609 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -166,7 +166,7 @@ get_pixel_transfer_program(struct gl_context *ctx, const 
struct state_key *key)
    inst[ic].TexSrcUnit = 0;
    inst[ic].TexSrcTarget = TEXTURE_2D_INDEX;
    ic++;
-   fp->Base.InputsRead = (1 << FRAG_ATTRIB_TEX0);
+   fp->Base.InputsRead = BITFIELD64_BIT(FRAG_ATTRIB_TEX0);
    fp->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR);
    fp->Base.SamplersUsed = 0x1;  /* sampler 0 (bit 0) is used */
 
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index b133164..4f6743a 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3803,7 +3803,7 @@ get_pixel_transfer_visitor(struct st_fragment_program 
*fp,
    inst->sampler = 0;
    inst->tex_target = TEXTURE_2D_INDEX;
 
-   prog->InputsRead |= (1 << FRAG_ATTRIB_TEX0);
+   prog->InputsRead |= BITFIELD64_BIT(FRAG_ATTRIB_TEX0);
    prog->SamplersUsed |= (1 << 0); /* mark sampler 0 as used */
    v->samplers_used |= (1 << 0);
 
@@ -3874,7 +3874,7 @@ get_pixel_transfer_visitor(struct st_fragment_program 
*fp,
             src_regs[i].index = src0.index;
          }
          else if (src_regs[i].file == PROGRAM_INPUT)
-            prog->InputsRead |= (1 << src_regs[i].index);
+            prog->InputsRead |= BITFIELD64_BIT(src_regs[i].index);
       }
 
       v->emit(NULL, inst->op, inst->dst, src_regs[0], src_regs[1], 
src_regs[2]);
@@ -3927,7 +3927,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
    inst->sampler = samplerIndex;
    inst->tex_target = TEXTURE_2D_INDEX;
 
-   prog->InputsRead |= (1 << FRAG_ATTRIB_TEX0);
+   prog->InputsRead |= BITFIELD64_BIT(FRAG_ATTRIB_TEX0);
    prog->SamplersUsed |= (1 << samplerIndex); /* mark sampler as used */
    v->samplers_used |= (1 << samplerIndex);
 
@@ -3949,7 +3949,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
       for (int i=0; i<3; i++) {
          src_regs[i] = inst->src[i];
          if (src_regs[i].file == PROGRAM_INPUT)
-            prog->InputsRead |= (1 << src_regs[i].index);
+            prog->InputsRead |= BITFIELD64_BIT(src_regs[i].index);
       }
 
       v->emit(NULL, inst->op, inst->dst, src_regs[0], src_regs[1], 
src_regs[2]);
diff --git a/src/mesa/state_tracker/st_program.c 
b/src/mesa/state_tracker/st_program.c
index e031579..768da51 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -194,7 +194,7 @@ st_prepare_vertex_program(struct gl_context *ctx,
     * and TGSI generic input indexes, plus input attrib semantic info.
     */
    for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
-      if (stvp->Base.Base.InputsRead & (1 << attr)) {
+      if ((stvp->Base.Base.InputsRead & BITFIELD64_BIT(attr)) != 0) {
          stvp->input_to_index[attr] = stvp->num_inputs;
          stvp->index_to_input[stvp->num_inputs] = attr;
          stvp->num_inputs++;
@@ -490,7 +490,7 @@ st_translate_fragment_program(struct st_context *st,
       GLuint inputMapping[FRAG_ATTRIB_MAX];
       GLuint interpMode[PIPE_MAX_SHADER_INPUTS];  /* XXX size? */
       GLuint attr;
-      const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
+      const GLbitfield64 inputsRead = stfp->Base.Base.InputsRead;
       struct ureg_program *ureg;
 
       GLboolean write_all = GL_FALSE;
@@ -510,7 +510,7 @@ st_translate_fragment_program(struct st_context *st,
        * Convert Mesa program inputs to TGSI input register semantics.
        */
       for (attr = 0; attr < FRAG_ATTRIB_MAX; attr++) {
-         if (inputsRead & (1 << attr)) {
+         if ((inputsRead & BITFIELD64_BIT(attr)) != 0) {
             const GLuint slot = fs_num_inputs++;
 
             inputMapping[attr] = slot;
@@ -749,7 +749,7 @@ st_translate_geometry_program(struct st_context *st,
    GLuint outputMapping[GEOM_RESULT_MAX];
    struct pipe_context *pipe = st->pipe;
    GLuint attr;
-   const GLbitfield inputsRead = stgp->Base.Base.InputsRead;
+   const GLbitfield64 inputsRead = stgp->Base.Base.InputsRead;
    GLuint vslot = 0;
    GLuint num_generic = 0;
 
@@ -790,7 +790,7 @@ st_translate_geometry_program(struct st_context *st,
     * Convert Mesa program inputs to TGSI input register semantics.
     */
    for (attr = 0; attr < GEOM_ATTRIB_MAX; attr++) {
-      if (inputsRead & (1 << attr)) {
+      if ((inputsRead & BITFIELD64_BIT(attr)) != 0) {
          const GLuint slot = gs_num_inputs;
 
          gs_num_inputs++;
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 836e8e8..8b060ff 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -379,7 +379,7 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage 
*stage )
 
       /* the vertex array case */
       for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
-	 if (program->Base.InputsRead & (1 << attr)) {
+	 if (program->Base.InputsRead & BITFIELD64_BIT(attr)) {
 	    const GLubyte *ptr = (const GLubyte*) VB->AttribPtr[attr]->data;
 	    const GLuint size = VB->AttribPtr[attr]->size;
 	    const GLuint stride = VB->AttribPtr[attr]->stride;
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 79e72e4..e1ce345 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -439,7 +439,7 @@ recalculate_input_bindings(struct gl_context *ctx)
    struct vbo_context *vbo = vbo_context(ctx);
    struct vbo_exec_context *exec = &vbo->exec;
    const struct gl_client_array **inputs = &exec->array.inputs[0];
-   GLbitfield const_inputs = 0x0;
+   GLbitfield64 const_inputs = 0x0;
    GLuint i;
 
    switch (get_program_mode(ctx)) {
@@ -548,7 +548,7 @@ recalculate_input_bindings(struct gl_context *ctx)
       break;
    }
 
-   _mesa_set_varying_vp_inputs( ctx, ~const_inputs );
+   _mesa_set_varying_vp_inputs( ctx, VERT_BIT_ALL & (~const_inputs) );
 }
 
 
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 2df408e..4962b54 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -166,7 +166,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
    const GLuint count = exec->vtx.vert_count;
    const GLuint *map;
    GLuint attr;
-   GLbitfield varying_inputs = 0x0;
+   GLbitfield64 varying_inputs = 0x0;
 
    /* Install the default (ie Current) attributes first, then overlay
     * all active ones.
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 08d2e4a..0773786 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -137,7 +137,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
    const GLuint *map;
    GLuint attr;
    GLubyte node_attrsz[VBO_ATTRIB_MAX];  /* copy of node->attrsz[] */
-   GLbitfield varying_inputs = 0x0;
+   GLbitfield64 varying_inputs = 0x0;
 
    memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz));
 
-- 
1.7.4.4



More information about the mesa-dev mailing list