Make gl_program::InputsRead a 64 bits bitfield.
Adapt the intel and radeon driver to handle a 64 bits
InputsRead value.
Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
static void
check_wpos(struct i915_fragment_program *p)
{
- GLuint inputs = p->FragProg.Base.InputsRead;
+ GLbitfield64 inputs = p->FragProg.Base.InputsRead;
GLint i;
p->wpos_tex = -1;
struct i915_fragment_program *p =
(struct i915_fragment_program *) ctx->FragmentProgram._Current;
- const GLuint inputsRead = p->FragProg.Base.InputsRead;
+ const GLbitfield64 inputsRead = p->FragProg.Base.InputsRead;
GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK;
GLuint s2 = S2_TEXCOORD_NONE;
int i, offset = 0;
GLuint nr_pull_params; /**< number of dwords referenced by pull_param[] */
GLuint total_scratch;
- GLuint inputs_read;
+ GLbitfield64 inputs_read;
/* Used for calculating urb partitions:
*/
struct gl_context *ctx = &brw->intel.ctx;
struct intel_context *intel = intel_context(ctx);
/* CACHE_NEW_VS_PROG */
- GLbitfield vs_inputs = brw->vs.prog_data->inputs_read;
+ GLbitfield64 vs_inputs = brw->vs.prog_data->inputs_read;
const unsigned char *ptr = NULL;
GLuint interleaved = 0, total_size = 0;
unsigned int min_index = brw->vb.min_index;
/* Accumulate the list of enabled arrays. */
brw->vb.nr_enabled = 0;
while (vs_inputs) {
- GLuint i = ffs(vs_inputs) - 1;
+ GLuint i = ffsll(vs_inputs) - 1;
struct brw_vertex_element *input = &brw->vb.inputs[i];
- vs_inputs &= ~(1 << i);
+ vs_inputs &= ~BITFIELD64_BIT(i);
if (input->glarray->Size && get_size(input->glarray->Type))
brw->vb.enabled[brw->vb.nr_enabled++] = input;
}
if (c.key.copy_edgeflag) {
c.prog_data.outputs_written |= BITFIELD64_BIT(VERT_RESULT_EDGE);
- c.prog_data.inputs_read |= 1<<VERT_ATTRIB_EDGEFLAG;
+ c.prog_data.inputs_read |= VERT_BIT_EDGEFLAG;
}
/* Put dummy slots into the VUE for the SF to put the replaced
/* BRW_NEW_VERTICES */
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- if (vp->program.Base.InputsRead & (1 << i) &&
+ if (vp->program.Base.InputsRead & BITFIELD64_BIT(i) &&
brw->vb.inputs[i].glarray->Type == GL_FIXED) {
key.gl_fixed_input_size[i] = brw->vb.inputs[i].glarray->Size;
}
t.twoside = 1;
for (i = 0; i < VERT_ATTRIB_MAX; i++)
- if (vp->program.Base.InputsRead & (1<<i))
+ if (vp->program.Base.InputsRead & BITFIELD64_BIT(i))
set_active_component(&t, PROGRAM_INPUT, i,
szflag[get_input_size(brw, i)]);
*/
c->nr_inputs = 0;
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- if (c->prog_data.inputs_read & (1 << i)) {
+ if (c->prog_data.inputs_read & BITFIELD64_BIT(i)) {
c->nr_inputs++;
c->regs[PROGRAM_INPUT][i] = brw_vec8_grf(reg, 0);
reg++;
int i;
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- if (!(c->prog_data.inputs_read & (1 << i)))
+ if (!(c->prog_data.inputs_read & BITFIELD64_BIT(i)))
continue;
if (c->key.gl_fixed_input_size[i] != 0) {
dw5 |= GEN6_WM_POLYGON_STIPPLE_ENABLE;
/* BRW_NEW_FRAGMENT_PROGRAM */
- if (fp->program.Base.InputsRead & (1 << FRAG_ATTRIB_WPOS))
+ if (fp->program.Base.InputsRead & FRAG_BIT_WPOS)
dw5 |= GEN6_WM_USES_SOURCE_DEPTH | GEN6_WM_USES_SOURCE_W;
if (fp->program.Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH))
dw5 |= GEN6_WM_COMPUTED_DEPTH;
dw1 |= GEN7_WM_POLYGON_STIPPLE_ENABLE;
/* BRW_NEW_FRAGMENT_PROGRAM */
- if (fp->program.Base.InputsRead & (1 << FRAG_ATTRIB_WPOS))
+ if (fp->program.Base.InputsRead & FRAG_BIT_WPOS)
dw1 |= GEN7_WM_USES_SOURCE_DEPTH | GEN7_WM_USES_SOURCE_W;
if (fp->program.Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) {
writes_depth = true;
vp->inputmap_rev[3] = VERT_ATTRIB_FOG;
array_count++;
}
- for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX5; i++) {
- if (mesa_vp->Base.InputsRead & (1 << i)) {
- vp->inputs[i] = i - VERT_ATTRIB_TEX0 + 6;
- vp->inputmap_rev[8 + i - VERT_ATTRIB_TEX0] = i;
- free_inputs &= ~(1 << (i - VERT_ATTRIB_TEX0 + 6));
+ /* VERT_ATTRIB_TEX0-5 */
+ for (i = 0; i <= 5; i++) {
+ if (mesa_vp->Base.InputsRead & VERT_BIT_TEX(i)) {
+ vp->inputs[VERT_ATTRIB_TEX(i)] = i + 6;
+ vp->inputmap_rev[8 + i] = VERT_ATTRIB_TEX(i);
+ free_inputs &= ~(1 << (i + 6));
array_count++;
}
}
/* using VERT_ATTRIB_TEX6/7 would be illegal */
+ for (; i < VERT_ATTRIB_TEX_MAX; i++) {
+ if (mesa_vp->Base.InputsRead & VERT_BIT_TEX(i)) {
+ if (R200_DEBUG & RADEON_FALLBACKS) {
+ fprintf(stderr, "texture attribute %d in vert prog\n", i);
+ }
+ return GL_FALSE;
+ }
+ }
/* completely ignore aliasing? */
- for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) {
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
int j;
/* completely ignore aliasing? */
- if (mesa_vp->Base.InputsRead & (1 << i)) {
+ if (mesa_vp->Base.InputsRead & VERT_BIT_GENERIC(i)) {
array_count++;
if (array_count > 12) {
if (R200_DEBUG & RADEON_FALLBACKS) {
/* will always find one due to limited array_count */
if (free_inputs & (1 << j)) {
free_inputs &= ~(1 << j);
- vp->inputs[i] = j;
- if (j == 0) vp->inputmap_rev[j] = i; /* mapped to pos */
- else if (j < 12) vp->inputmap_rev[j + 2] = i; /* mapped to col/tex */
- else vp->inputmap_rev[j + 1] = i; /* mapped to pos1 */
+ vp->inputs[VERT_ATTRIB_GENERIC(i)] = j;
+ if (j == 0) {
+ /* mapped to pos */
+ vp->inputmap_rev[j] = VERT_ATTRIB_GENERIC(i);
+ } else if (j < 12) {
+ /* mapped to col/tex */
+ vp->inputmap_rev[j + 2] = VERT_ATTRIB_GENERIC(i);
+ } else {
+ /* mapped to pos1 */
+ vp->inputmap_rev[j + 1] = VERT_ATTRIB_GENERIC(i);
+ }
break;
}
}
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;
}
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:
unsigned texture_enabled_global:1;
unsigned fragprog_inputs_read:12;
- unsigned varying_vp_inputs;
+ GLbitfield64 varying_vp_inputs;
struct {
unsigned light_enabled:1;
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;
*/
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 {
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);
}
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 */
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 */
/*@{*/
*/
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;
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
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;
| 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;
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
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);
}
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);
/*
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 */
inst->sampler = 0;
inst->tex_target = TEXTURE_2D_INDEX;
- prog->InputsRead |= (1 << FRAG_ATTRIB_TEX0);
+ prog->InputsRead |= FRAG_BIT_TEX0;
prog->SamplersUsed |= (1 << 0); /* mark sampler 0 as used */
v->samplers_used |= (1 << 0);
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]);
inst->sampler = samplerIndex;
inst->tex_target = TEXTURE_2D_INDEX;
- prog->InputsRead |= (1 << FRAG_ATTRIB_TEX0);
+ prog->InputsRead |= FRAG_BIT_TEX0;
prog->SamplersUsed |= (1 << samplerIndex); /* mark sampler as used */
v->samplers_used |= (1 << samplerIndex);
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]);
* 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++;
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;
* 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;
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;
* 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++;
/* 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;
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)) {
break;
}
- _mesa_set_varying_vp_inputs( ctx, ~const_inputs );
+ _mesa_set_varying_vp_inputs( ctx, VERT_BIT_ALL & (~const_inputs) );
}
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.
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));