diff options
author | Marek Olšák <[email protected]> | 2017-11-15 23:53:04 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-11-25 17:18:22 +0100 |
commit | 78942e7dbfd234ce080b2773b9317a61deb77788 (patch) | |
tree | 71a93812dcc3229abee231c51ec40f39aa1aeb51 | |
parent | 43abaf2ad0c1c42e56e47732395cc98912a050e8 (diff) |
mesa: shrink VERT_ATTRIB bitfields to 32 bits
There are only 32 vertex attribs now.
Reviewed-by: Ian Romanick <[email protected]>
-rw-r--r-- | src/compiler/shader_enums.h | 46 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_draw_upload.c | 8 | ||||
-rw-r--r-- | src/mesa/main/arrayobj.c | 14 | ||||
-rw-r--r-- | src/mesa/main/enable.c | 2 | ||||
-rw-r--r-- | src/mesa/main/ff_fragment_shader.cpp | 2 | ||||
-rw-r--r-- | src/mesa/main/ffvertex_prog.c | 2 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 20 | ||||
-rw-r--r-- | src/mesa/main/state.c | 2 | ||||
-rw-r--r-- | src/mesa/main/state.h | 2 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 2 | ||||
-rw-r--r-- | src/mesa/program/program_parse.y | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_array.c | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_draw.c | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_save_draw.c | 2 |
14 files changed, 59 insertions, 49 deletions
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h index af4008c6179..ffe551ab20f 100644 --- a/src/compiler/shader_enums.h +++ b/src/compiler/shader_enums.h @@ -139,36 +139,36 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib); * These are used in bitfields in many places. */ /*@{*/ -#define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS) -#define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL) -#define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0) -#define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1) -#define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG) -#define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX) -#define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG) -#define VERT_BIT_TEX0 BITFIELD64_BIT(VERT_ATTRIB_TEX0) -#define VERT_BIT_TEX1 BITFIELD64_BIT(VERT_ATTRIB_TEX1) -#define VERT_BIT_TEX2 BITFIELD64_BIT(VERT_ATTRIB_TEX2) -#define VERT_BIT_TEX3 BITFIELD64_BIT(VERT_ATTRIB_TEX3) -#define VERT_BIT_TEX4 BITFIELD64_BIT(VERT_ATTRIB_TEX4) -#define VERT_BIT_TEX5 BITFIELD64_BIT(VERT_ATTRIB_TEX5) -#define VERT_BIT_TEX6 BITFIELD64_BIT(VERT_ATTRIB_TEX6) -#define VERT_BIT_TEX7 BITFIELD64_BIT(VERT_ATTRIB_TEX7) -#define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE) -#define VERT_BIT_GENERIC0 BITFIELD64_BIT(VERT_ATTRIB_GENERIC0) - -#define VERT_BIT(i) BITFIELD64_BIT(i) -#define VERT_BIT_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_MAX) +#define VERT_BIT_POS BITFIELD_BIT(VERT_ATTRIB_POS) +#define VERT_BIT_NORMAL BITFIELD_BIT(VERT_ATTRIB_NORMAL) +#define VERT_BIT_COLOR0 BITFIELD_BIT(VERT_ATTRIB_COLOR0) +#define VERT_BIT_COLOR1 BITFIELD_BIT(VERT_ATTRIB_COLOR1) +#define VERT_BIT_FOG BITFIELD_BIT(VERT_ATTRIB_FOG) +#define VERT_BIT_COLOR_INDEX BITFIELD_BIT(VERT_ATTRIB_COLOR_INDEX) +#define VERT_BIT_EDGEFLAG BITFIELD_BIT(VERT_ATTRIB_EDGEFLAG) +#define VERT_BIT_TEX0 BITFIELD_BIT(VERT_ATTRIB_TEX0) +#define VERT_BIT_TEX1 BITFIELD_BIT(VERT_ATTRIB_TEX1) +#define VERT_BIT_TEX2 BITFIELD_BIT(VERT_ATTRIB_TEX2) +#define VERT_BIT_TEX3 BITFIELD_BIT(VERT_ATTRIB_TEX3) +#define VERT_BIT_TEX4 BITFIELD_BIT(VERT_ATTRIB_TEX4) +#define VERT_BIT_TEX5 BITFIELD_BIT(VERT_ATTRIB_TEX5) +#define VERT_BIT_TEX6 BITFIELD_BIT(VERT_ATTRIB_TEX6) +#define VERT_BIT_TEX7 BITFIELD_BIT(VERT_ATTRIB_TEX7) +#define VERT_BIT_POINT_SIZE BITFIELD_BIT(VERT_ATTRIB_POINT_SIZE) +#define VERT_BIT_GENERIC0 BITFIELD_BIT(VERT_ATTRIB_GENERIC0) + +#define VERT_BIT(i) BITFIELD_BIT(i) +#define VERT_BIT_ALL BITFIELD_RANGE(0, VERT_ATTRIB_MAX) #define VERT_BIT_FF(i) VERT_BIT(i) -#define VERT_BIT_FF_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_FF_MAX) +#define VERT_BIT_FF_ALL BITFIELD_RANGE(0, VERT_ATTRIB_FF_MAX) #define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i)) #define VERT_BIT_TEX_ALL \ - BITFIELD64_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX) + BITFIELD_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX) #define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i)) #define VERT_BIT_GENERIC_ALL \ - BITFIELD64_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX) + BITFIELD_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX) /*@}*/ #define MAX_VARYING 32 /**< number of float[4] vectors */ diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 9b81999ea05..2204bf474bd 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -458,7 +458,7 @@ brw_prepare_vertices(struct brw_context *brw) /* BRW_NEW_VS_PROG_DATA */ const struct brw_vs_prog_data *vs_prog_data = brw_vs_prog_data(brw->vs.base.prog_data); - GLbitfield64 vs_inputs = vs_prog_data->inputs_read; + GLbitfield vs_inputs = vs_prog_data->inputs_read; const unsigned char *ptr = NULL; GLuint interleaved = 0; unsigned int min_index = brw->vb.min_index + brw->basevertex; @@ -487,16 +487,16 @@ brw_prepare_vertices(struct brw_context *brw) /* Accumulate the list of enabled arrays. */ brw->vb.nr_enabled = 0; while (vs_inputs) { - GLuint first = ffsll(vs_inputs) - 1; + GLuint first = ffs(vs_inputs) - 1; assert (first < 64); GLuint index = first - DIV_ROUND_UP(_mesa_bitcount_64(vs_prog_data->double_inputs_read & BITFIELD64_MASK(first)), 2); struct brw_vertex_element *input = &brw->vb.inputs[index]; input->is_dual_slot = (vs_prog_data->double_inputs_read & BITFIELD64_BIT(first)) != 0; - vs_inputs &= ~BITFIELD64_BIT(first); + vs_inputs &= ~BITFIELD_BIT(first); if (input->is_dual_slot) - vs_inputs &= ~BITFIELD64_BIT(first + 1); + vs_inputs &= ~BITFIELD_BIT(first + 1); brw->vb.enabled[brw->vb.nr_enabled++] = input; } diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 18d6d8008c1..d9a65ba4105 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -252,7 +252,7 @@ init_array(struct gl_context *ctx, binding->Offset = 0; binding->Stride = array->_ElementSize; binding->BufferObj = NULL; - binding->_BoundArrays = BITFIELD64_BIT(index); + binding->_BoundArrays = BITFIELD_BIT(index); /* Vertex array buffers */ _mesa_reference_buffer_object(ctx, &binding->BufferObj, @@ -314,10 +314,10 @@ void _mesa_update_vao_client_arrays(struct gl_context *ctx, struct gl_vertex_array_object *vao) { - GLbitfield64 arrays = vao->NewArrays; + GLbitfield arrays = vao->NewArrays; while (arrays) { - const int attrib = u_bit_scan64(&arrays); + const int attrib = u_bit_scan(&arrays); struct gl_vertex_array *client_array = &vao->_VertexAttrib[attrib]; const struct gl_array_attributes *attrib_array = &vao->VertexAttrib[attrib]; @@ -334,13 +334,13 @@ bool _mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao) { /* Walk those enabled arrays that have the default vbo attached */ - GLbitfield64 mask = vao->_Enabled & ~vao->VertexAttribBufferMask; + GLbitfield mask = vao->_Enabled & ~vao->VertexAttribBufferMask; while (mask) { /* Do not use u_bit_scan64 as we can walk multiple * attrib arrays at once */ - const int i = ffsll(mask) - 1; + const int i = ffs(mask) - 1; const struct gl_array_attributes *attrib_array = &vao->VertexAttrib[i]; const struct gl_vertex_buffer_binding *buffer_binding = @@ -368,10 +368,10 @@ bool _mesa_all_buffers_are_unmapped(const struct gl_vertex_array_object *vao) { /* Walk the enabled arrays that have a vbo attached */ - GLbitfield64 mask = vao->_Enabled & vao->VertexAttribBufferMask; + GLbitfield mask = vao->_Enabled & vao->VertexAttribBufferMask; while (mask) { - const int i = ffsll(mask) - 1; + const int i = ffs(mask) - 1; const struct gl_array_attributes *attrib_array = &vao->VertexAttrib[i]; const struct gl_vertex_buffer_binding *buffer_binding = diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 8e99f2504f1..c859a7ae1c7 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -64,7 +64,7 @@ static void client_state(struct gl_context *ctx, GLenum cap, GLboolean state) { struct gl_vertex_array_object *vao = ctx->Array.VAO; - GLbitfield64 flag; + GLbitfield flag; GLboolean *var; switch (cap) { diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index 2b924f6d101..83541a269ac 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -180,7 +180,7 @@ static GLbitfield filter_fp_input_mask( GLbitfield fp_inputs, GLbitfield possible_inputs = 0; /* _NEW_VARYING_VP_INPUTS */ - GLbitfield64 varying_inputs = ctx->varying_vp_inputs; + GLbitfield 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 85f8f24d830..44fbf4fb8a1 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; - GLbitfield64 varying_vp_inputs; + GLbitfield varying_vp_inputs; struct { unsigned light_enabled:1; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 4682e02fc85..9d704c1c158 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -56,6 +56,16 @@ extern "C" { #endif +/** Set a single bit */ +#define BITFIELD_BIT(b) ((GLbitfield)1 << (b)) +/** Set all bits up to excluding bit b */ +#define BITFIELD_MASK(b) \ + ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT(b) - 1) +/** Set count bits starting from bit b */ +#define BITFIELD_RANGE(b, count) \ + (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b)) + + /** * \name 64-bit extension of GLbitfield. */ @@ -1507,7 +1517,7 @@ struct gl_vertex_buffer_binding GLsizei Stride; /**< User-specified stride */ GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */ struct gl_buffer_object *BufferObj; /**< GL_ARB_vertex_buffer_object */ - GLbitfield64 _BoundArrays; /**< Arrays bound to this binding point */ + GLbitfield _BoundArrays; /**< Arrays bound to this binding point */ }; @@ -1544,13 +1554,13 @@ struct gl_vertex_array_object struct gl_vertex_buffer_binding BufferBinding[VERT_ATTRIB_MAX]; /** Mask indicating which vertex arrays have vertex buffer associated. */ - GLbitfield64 VertexAttribBufferMask; + GLbitfield VertexAttribBufferMask; /** Mask of VERT_BIT_* values indicating which arrays are enabled */ - GLbitfield64 _Enabled; + GLbitfield _Enabled; /** Mask of VERT_BIT_* values indicating changed/dirty arrays */ - GLbitfield64 NewArrays; + GLbitfield NewArrays; /** The index buffer (also known as the element array buffer in OpenGL). */ struct gl_buffer_object *IndexBufferObj; @@ -4948,7 +4958,7 @@ struct gl_context GLboolean ViewportInitialized; /**< has viewport size been initialized? */ - GLbitfield64 varying_vp_inputs; /**< mask of VERT_BIT_* flags */ + GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ /** \name Derived state */ GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 7aec98e5784..7a9732d37b2 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -414,7 +414,7 @@ _mesa_update_state( struct gl_context *ctx ) */ void _mesa_set_varying_vp_inputs( struct gl_context *ctx, - GLbitfield64 varying_inputs ) + GLbitfield varying_inputs ) { if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index b719f392965..9d4591790ae 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, GLbitfield64 varying_inputs); +_mesa_set_varying_vp_inputs(struct gl_context *ctx, GLbitfield varying_inputs); extern void diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 99347244891..31f1c8339df 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -138,7 +138,7 @@ vertex_attrib_binding(struct gl_context *ctx, struct gl_array_attributes *array = &vao->VertexAttrib[attribIndex]; if (array->BufferBindingIndex != bindingIndex) { - const GLbitfield64 array_bit = VERT_BIT(attribIndex); + const GLbitfield array_bit = VERT_BIT(attribIndex); if (_mesa_is_bufferobj(vao->BufferBinding[bindingIndex].BufferObj)) vao->VertexAttribBufferMask |= array_bit; diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y index 1bc5f515494..04ec18d840d 100644 --- a/src/mesa/program/program_parse.y +++ b/src/mesa/program/program_parse.y @@ -2212,7 +2212,7 @@ set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index, int validate_inputs(struct YYLTYPE *locp, struct asm_parser_state *state) { - const GLbitfield64 inputs = state->prog->info.inputs_read | state->InputsBound; + const GLbitfield inputs = state->prog->info.inputs_read | state->InputsBound; GLbitfield ff_inputs = 0; /* Since Mesa internal attribute indices are different from diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index e3421fa9b51..024d4d6c80e 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -299,7 +299,7 @@ recalculate_input_bindings(struct gl_context *ctx) const struct gl_array_attributes *array = ctx->Array.VAO->VertexAttrib; struct gl_vertex_array *vertexAttrib = ctx->Array.VAO->_VertexAttrib; const struct gl_vertex_array **inputs = &exec->array.inputs[0]; - GLbitfield64 const_inputs = 0x0; + GLbitfield const_inputs = 0x0; GLuint i; switch (get_program_mode(ctx)) { diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index df34f059b30..34cb4ff72e6 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -177,7 +177,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) struct gl_vertex_array *arrays = exec->vtx.arrays; const GLuint *map; GLuint attr; - GLbitfield64 varying_inputs = 0x0; + GLbitfield varying_inputs = 0x0; bool swap_pos = false; /* Install the default (ie Current) attributes first, then overlay diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 8a4b6599554..2a20bb8f05c 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -141,7 +141,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx, GLuint attr; GLubyte node_attrsz[VBO_ATTRIB_MAX]; /* copy of node->attrsz[] */ GLenum node_attrtype[VBO_ATTRIB_MAX]; /* copy of node->attrtype[] */ - GLbitfield64 varying_inputs = 0x0; + GLbitfield varying_inputs = 0x0; memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz)); memcpy(node_attrtype, node->attrtype, sizeof(node->attrtype)); |