key.clamp_fragment_color = true;
- for (int i = 0; i < BRW_MAX_TEX_UNIT; i++) {
+ for (int i = 0; i < MAX_SAMPLERS; i++) {
/* FINISHME: depth compares might use (0,0,0,W) for example */
key.tex.swizzles[i] = SWIZZLE_XYZW;
}
fs_reg *emit_general_interpolation(ir_variable *ir);
void emit_interpolation_setup_gen4();
void emit_interpolation_setup_gen6();
- fs_reg emit_texcoord(ir_texture *ir, int sampler);
+ fs_reg emit_texcoord(ir_texture *ir, int sampler, int texunit);
fs_inst *emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate,
fs_reg shadow_comp, fs_reg lod, fs_reg lod2);
fs_inst *emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
* setting this->result).
*/
fs_reg
-fs_visitor::emit_texcoord(ir_texture *ir, int texunit)
+fs_visitor::emit_texcoord(ir_texture *ir, int sampler, int texunit)
{
fs_inst *inst = NULL;
*/
if (ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_RECT &&
(intel->gen < 6 ||
- (intel->gen >= 6 && (c->key.tex.gl_clamp_mask[0] & (1 << texunit) ||
- c->key.tex.gl_clamp_mask[1] & (1 << texunit))))) {
+ (intel->gen >= 6 && (c->key.tex.gl_clamp_mask[0] & (1 << sampler) ||
+ c->key.tex.gl_clamp_mask[1] & (1 << sampler))))) {
struct gl_program_parameter_list *params = c->fp->program.Base.Parameters;
int tokens[STATE_LENGTH] = {
STATE_INTERNAL,
needs_gl_clamp = false;
for (int i = 0; i < 2; i++) {
- if (c->key.tex.gl_clamp_mask[i] & (1 << texunit)) {
+ if (c->key.tex.gl_clamp_mask[i] & (1 << sampler)) {
fs_reg chan = coordinate;
chan.reg_offset += i;
if (ir->coordinate && needs_gl_clamp) {
for (unsigned int i = 0;
i < MIN2(ir->coordinate->type->vector_elements, 3); i++) {
- if (c->key.tex.gl_clamp_mask[i] & (1 << texunit)) {
+ if (c->key.tex.gl_clamp_mask[i] & (1 << sampler)) {
fs_reg chan = coordinate;
chan.reg_offset += i;
* done before loading any values into MRFs for the sampler message since
* generating these values may involve SEND messages that need the MRFs.
*/
- fs_reg coordinate = emit_texcoord(ir, texunit);
+ fs_reg coordinate = emit_texcoord(ir, sampler, texunit);
fs_reg shadow_comparitor;
if (ir->shadow_comparitor) {
if (ir->shadow_comparitor)
inst->shadow_compare = true;
- swizzle_result(ir, dst, texunit);
+ swizzle_result(ir, dst, sampler);
}
/**
* EXT_texture_swizzle as well as DEPTH_TEXTURE_MODE for shadow comparisons.
*/
void
-fs_visitor::swizzle_result(ir_texture *ir, fs_reg orig_val, int texunit)
+fs_visitor::swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler)
{
this->result = orig_val;
if (ir->type == glsl_type::float_type) {
/* Ignore DEPTH_TEXTURE_MODE swizzling. */
assert(ir->sampler->type->sampler_shadow);
- } else if (c->key.tex.swizzles[texunit] != SWIZZLE_NOOP) {
+ } else if (c->key.tex.swizzles[sampler] != SWIZZLE_NOOP) {
fs_reg swizzled_result = fs_reg(this, glsl_type::vec4_type);
for (int i = 0; i < 4; i++) {
- int swiz = GET_SWZ(c->key.tex.swizzles[texunit], i);
+ int swiz = GET_SWZ(c->key.tex.swizzles[sampler], i);
fs_reg l = swizzled_result;
l.reg_offset += i;
emit(BRW_OPCODE_MOV, l, fs_reg(1.0f));
} else {
fs_reg r = orig_val;
- r.reg_offset += GET_SWZ(c->key.tex.swizzles[texunit], i);
+ r.reg_offset += GET_SWZ(c->key.tex.swizzles[sampler], i);
emit(BRW_OPCODE_MOV, l, r);
}
}
/**
* EXT_texture_swizzle and DEPTH_TEXTURE_MODE swizzles.
*/
- uint16_t swizzles[BRW_MAX_TEX_UNIT];
+ uint16_t swizzles[MAX_SAMPLERS];
uint16_t gl_clamp_mask[3];
vec4_visitor::visit(ir_texture *ir)
{
int sampler = _mesa_get_sampler_uniform_value(ir->sampler, prog, &vp->Base);
- int texunit = vp->Base.SamplerUnits[sampler];
/* Should be lowered by do_lower_texture_projection */
assert(!ir->projector);
emit(inst);
- swizzle_result(ir, src_reg(inst->dst), texunit);
+ swizzle_result(ir, src_reg(inst->dst), sampler);
}
void
-vec4_visitor::swizzle_result(ir_texture *ir, src_reg orig_val, int texunit)
+vec4_visitor::swizzle_result(ir_texture *ir, src_reg orig_val, int sampler)
{
this->result = orig_val;
- int s = c->key.tex.swizzles[texunit];
+ int s = c->key.tex.swizzles[sampler];
if (ir->op == ir_txs || ir->type == glsl_type::float_type
|| s == SWIZZLE_NOOP)
{
bool found = false;
- for (unsigned int i = 0; i < BRW_MAX_TEX_UNIT; i++) {
+ for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
found |= key_debug("EXT_texture_swizzle or DEPTH_TEXTURE_MODE",
old_key->swizzles[i], key->swizzles[i]);
}
const struct gl_program *prog,
struct brw_sampler_prog_key_data *key)
{
- for (int i = 0; i < BRW_MAX_TEX_UNIT; i++) {
- key->swizzles[i] = SWIZZLE_NOOP;
+ for (int s = 0; s < MAX_SAMPLERS; s++) {
+ key->swizzles[s] = SWIZZLE_NOOP;
- if (!prog->TexturesUsed[i])
+ if (!(prog->SamplersUsed & (1 << s)))
continue;
- const struct gl_texture_unit *unit = &ctx->Texture.Unit[i];
+ int unit_id = prog->SamplerUnits[s];
+ const struct gl_texture_unit *unit = &ctx->Texture.Unit[unit_id];
if (unit->_ReallyEnabled && unit->_Current->Target != GL_TEXTURE_BUFFER) {
const struct gl_texture_object *t = unit->_Current;
const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
- struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, i);
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit_id);
int swizzles[SWIZZLE_NIL + 1] = {
SWIZZLE_X,
SWIZZLE_Y,
}
if (img->InternalFormat == GL_YCBCR_MESA) {
- key->yuvtex_mask |= 1 << i;
+ key->yuvtex_mask |= 1 << s;
if (img->TexFormat == MESA_FORMAT_YCBCR)
- key->yuvtex_swap_mask |= 1 << i;
+ key->yuvtex_swap_mask |= 1 << s;
}
- key->swizzles[i] =
+ key->swizzles[s] =
MAKE_SWIZZLE4(swizzles[GET_SWZ(t->_Swizzle, 0)],
swizzles[GET_SWZ(t->_Swizzle, 1)],
swizzles[GET_SWZ(t->_Swizzle, 2)],
if (sampler->MinFilter != GL_NEAREST &&
sampler->MagFilter != GL_NEAREST) {
if (sampler->WrapS == GL_CLAMP)
- key->gl_clamp_mask[0] |= 1 << i;
+ key->gl_clamp_mask[0] |= 1 << s;
if (sampler->WrapT == GL_CLAMP)
- key->gl_clamp_mask[1] |= 1 << i;
+ key->gl_clamp_mask[1] |= 1 << s;
if (sampler->WrapR == GL_CLAMP)
- key->gl_clamp_mask[2] |= 1 << i;
+ key->gl_clamp_mask[2] |= 1 << s;
}
}
}