mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 22:38:05 +02:00
mesa: shrink VERT_ATTRIB bitfields to 32 bits
There are only 32 vertex attribs now. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
43abaf2ad0
commit
78942e7dbf
14 changed files with 58 additions and 48 deletions
|
|
@ -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_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) BITFIELD64_BIT(i)
|
||||
#define VERT_BIT_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_MAX)
|
||||
#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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue