{
fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type);
fs_reg wpos = *reg;
- bool flip = !ir->data.origin_upper_left ^ c->key.render_to_fbo;
+ bool flip = !ir->data.origin_upper_left ^ key->render_to_fbo;
/* gl_FragCoord.x */
if (ir->data.pixel_center_integer) {
if (flip) {
pixel_y.negate = true;
- offset += c->key.drawable_height - 1.0;
+ offset += key->drawable_height - 1.0;
}
emit(ADD(wpos, pixel_y, fs_reg(offset)));
}
glsl_interp_qualifier interpolation_mode =
- ir->determine_interpolation_mode(c->key.flat_shade);
+ ir->determine_interpolation_mode(key->flat_shade);
int location = ir->data.location;
for (unsigned int i = 0; i < array_elements; i++) {
for (unsigned int k = 0; k < type->vector_elements; k++) {
struct brw_reg interp = interp_reg(location, k);
emit_linterp(attr, fs_reg(interp), interpolation_mode,
- ir->data.centroid && !c->key.persample_shading,
- ir->data.sample || c->key.persample_shading);
+ ir->data.centroid && !key->persample_shading,
+ ir->data.sample || key->persample_shading);
if (brw->needs_unlit_centroid_workaround && ir->data.centroid) {
/* Get the pixel/sample mask into f0 so that we know
* which pixels are lit. Then, for each channel that is
{
assert(dst.type == BRW_REGISTER_TYPE_F);
- if (c->key.compute_pos_offset) {
+ if (key->compute_pos_offset) {
/* Convert int_sample_pos to floating point */
emit(MOV(dst, int_sample_pos));
/* Scale to the range [0, 1] */
this->current_annotation = "compute sample id";
fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type);
- if (c->key.compute_sample_id) {
+ if (key->compute_sample_id) {
fs_reg t1 = fs_reg(this, glsl_type::int_type);
fs_reg t2 = fs_reg(this, glsl_type::int_type);
t2.type = BRW_REGISTER_TYPE_UW;
*/
struct brw_vue_map prev_stage_vue_map;
brw_compute_vue_map(brw, &prev_stage_vue_map,
- c->key.input_slots_valid);
+ key->input_slots_valid);
int first_slot = 2 * BRW_SF_URB_ENTRY_READ_OFFSET;
assert(prev_stage_vue_map.num_slots <= first_slot + 32);
for (int slot = first_slot; slot < prev_stage_vue_map.num_slots;
if (i == VARYING_SLOT_PSIZ)
continue;
- if (c->key.input_slots_valid & BITFIELD64_BIT(i)) {
+ if (key->input_slots_valid & BITFIELD64_BIT(i)) {
/* The back color slot is skipped when the front color is
* also written to. In addition, some slots can be
* written in the vertex shader and not read in the
}
}
- prog_data->uses_pos_offset = c->key.compute_pos_offset;
+ prog_data->uses_pos_offset = key->compute_pos_offset;
/* R31: MSAA position offsets. */
if (prog_data->uses_pos_offset) {
payload.sample_pos_reg = payload.num_regs;
* renderbuffer, which we place at surface index 0.
*/
prog_data->binding_table.render_target_start = next_binding_table_offset;
- next_binding_table_offset += MAX2(c->key.nr_color_regions, 1);
+ next_binding_table_offset += MAX2(key->nr_color_regions, 1);
assign_common_binding_table_offsets(next_binding_table_offset);
}
/* We handle discards by keeping track of the still-live pixels in f0.1.
* Initialize it with the dispatched pixels.
*/
- if (fp->UsesKill || c->key.alpha_test_func) {
+ if (fp->UsesKill || key->alpha_test_func) {
fs_inst *discard_init = emit(FS_OPCODE_MOV_DISPATCH_TO_FLAGS);
discard_init->flag_subreg = 1;
}
emit(FS_OPCODE_PLACEHOLDER_HALT);
- if (c->key.alpha_test_func)
+ if (key->alpha_test_func)
emit_alpha_test();
emit_fb_writes();
this->do_dual_src = true;
} else if (ir->data.location == FRAG_RESULT_COLOR) {
/* Writing gl_FragColor outputs to all color regions. */
- for (unsigned int i = 0; i < MAX2(c->key.nr_color_regions, 1); i++) {
+ for (unsigned int i = 0; i < MAX2(key->nr_color_regions, 1); i++) {
this->outputs[i] = *reg;
this->output_components[i] = 4;
}
*/
if (is_rect &&
(brw->gen < 6 ||
- (brw->gen >= 6 && (c->key.tex.gl_clamp_mask[0] & (1 << sampler) ||
- c->key.tex.gl_clamp_mask[1] & (1 << sampler))))) {
+ (brw->gen >= 6 && (key->tex.gl_clamp_mask[0] & (1 << sampler) ||
+ key->tex.gl_clamp_mask[1] & (1 << sampler))))) {
struct gl_program_parameter_list *params = prog->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 << sampler)) {
+ if (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 << sampler)) {
+ if (key->tex.gl_clamp_mask[i] & (1 << sampler)) {
fs_reg chan = coordinate;
chan.reg_offset += i;
* emitting anything other than setting up the constant result.
*/
ir_constant *chan = ir->lod_info.component->as_constant();
- int swiz = GET_SWZ(c->key.tex.swizzles[sampler], chan->value.i[0]);
+ int swiz = GET_SWZ(key->tex.swizzles[sampler], chan->value.i[0]);
if (swiz == SWIZZLE_ZERO || swiz == SWIZZLE_ONE) {
fs_reg res = fs_reg(this, glsl_type::vec4_type);
ir->lod_info.sample_index->accept(this);
sample_index = this->result;
- if (brw->gen >= 7 && c->key.tex.compressed_multisample_layout_mask & (1<<sampler))
+ if (brw->gen >= 7 && key->tex.compressed_multisample_layout_mask & (1<<sampler))
mcs = emit_mcs_fetch(ir, coordinate, sampler);
else
mcs = fs_reg(0u);
}
if (brw->gen == 6 && ir->op == ir_tg4) {
- emit_gen6_gather_wa(c->key.tex.gen6_gather_wa[sampler], dst);
+ emit_gen6_gather_wa(key->tex.gen6_gather_wa[sampler], dst);
}
swizzle_result(ir, dst, sampler);
fs_visitor::gather_channel(ir_texture *ir, int sampler)
{
ir_constant *chan = ir->lod_info.component->as_constant();
- int swiz = GET_SWZ(c->key.tex.swizzles[sampler], chan->value.i[0]);
+ int swiz = GET_SWZ(key->tex.swizzles[sampler], chan->value.i[0]);
switch (swiz) {
case SWIZZLE_X: return 0;
case SWIZZLE_Y:
/* gather4 sampler is broken for green channel on RG32F --
* we must ask for blue instead.
*/
- if (c->key.tex.gather_channel_quirk_mask & (1<<sampler))
+ if (key->tex.gather_channel_quirk_mask & (1<<sampler))
return 2;
return 1;
case SWIZZLE_Z: return 2;
if (ir->type == glsl_type::float_type) {
/* Ignore DEPTH_TEXTURE_MODE swizzling. */
assert(ir->sampler->type->sampler_shadow);
- } else if (c->key.tex.swizzles[sampler] != SWIZZLE_NOOP) {
+ } else if (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[sampler], i);
+ int swiz = GET_SWZ(key->tex.swizzles[sampler], i);
fs_reg l = swizzled_result;
l.reg_offset += i;
emit(MOV(l, fs_reg(1.0f)));
} else {
fs_reg r = orig_val;
- r.reg_offset += GET_SWZ(c->key.tex.swizzles[sampler], i);
+ r.reg_offset += GET_SWZ(key->tex.swizzles[sampler], i);
emit(MOV(l, r));
}
}
inst = emit(MOV(fs_reg(MRF, first_color_mrf + index * reg_width,
color.type),
color));
- inst->saturate = c->key.clamp_fragment_color;
+ inst->saturate = key->clamp_fragment_color;
} else {
/* pre-gen6 SIMD16 single source DP write looks like:
* m + 0: r0
inst = emit(MOV(fs_reg(MRF, BRW_MRF_COMPR4 + first_color_mrf + index,
color.type),
color));
- inst->saturate = c->key.clamp_fragment_color;
+ inst->saturate = key->clamp_fragment_color;
} else {
push_force_uncompressed();
inst = emit(MOV(fs_reg(MRF, first_color_mrf + index, color.type),
color));
- inst->saturate = c->key.clamp_fragment_color;
+ inst->saturate = key->clamp_fragment_color;
pop_force_uncompressed();
inst = emit(MOV(fs_reg(MRF, first_color_mrf + index + 4, color.type),
half(color, 1)));
inst->force_sechalf = true;
- inst->saturate = c->key.clamp_fragment_color;
+ inst->saturate = key->clamp_fragment_color;
}
}
}
this->current_annotation = "Alpha test";
fs_inst *cmp;
- if (c->key.alpha_test_func == GL_ALWAYS)
+ if (key->alpha_test_func == GL_ALWAYS)
return;
- if (c->key.alpha_test_func == GL_NEVER) {
+ if (key->alpha_test_func == GL_NEVER) {
/* f0.1 = 0 */
fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
BRW_REGISTER_TYPE_UW));
color.reg_offset += 3;
/* f0.1 &= func(color, ref) */
- cmp = emit(CMP(reg_null_f, color, fs_reg(c->key.alpha_test_ref),
- cond_for_alpha_func(c->key.alpha_test_func)));
+ cmp = emit(CMP(reg_null_f, color, fs_reg(key->alpha_test_ref),
+ cond_for_alpha_func(key->alpha_test_func)));
}
cmp->predicate = BRW_PREDICATE_NORMAL;
cmp->flag_subreg = 1;
if (brw->gen >= 6 &&
(brw->is_haswell || brw->gen >= 8 || !this->fp->UsesKill) &&
!do_dual_src &&
- c->key.nr_color_regions == 1) {
+ key->nr_color_regions == 1) {
header_present = false;
}
if (header_present) {
src0_alpha_to_render_target = brw->gen >= 6 &&
!do_dual_src &&
- c->key.replicate_alpha;
+ key->replicate_alpha;
/* m2, m3 header */
nr += 2;
}
for (int i = 0; i < 4; i++) {
fs_inst *inst = emit(MOV(fs_reg(MRF, color_mrf + i, src0.type), src0));
src0.reg_offset++;
- inst->saturate = c->key.clamp_fragment_color;
+ inst->saturate = key->clamp_fragment_color;
}
this->current_annotation = ralloc_asprintf(this->mem_ctx,
fs_inst *inst = emit(MOV(fs_reg(MRF, color_mrf + 4 + i, src1.type),
src1));
src1.reg_offset++;
- inst->saturate = c->key.clamp_fragment_color;
+ inst->saturate = key->clamp_fragment_color;
}
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
return;
}
- for (int target = 0; target < c->key.nr_color_regions; target++) {
+ for (int target = 0; target < key->nr_color_regions; target++) {
this->current_annotation = ralloc_asprintf(this->mem_ctx,
"FB write target %d",
target);
inst = emit(MOV(fs_reg(MRF, write_color_mrf, color.type),
color));
- inst->saturate = c->key.clamp_fragment_color;
+ inst->saturate = key->clamp_fragment_color;
write_color_mrf = color_mrf + reg_width;
}
emit_color_write(target, i, write_color_mrf);
bool eot = false;
- if (target == c->key.nr_color_regions - 1) {
+ if (target == key->nr_color_regions - 1) {
eot = true;
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
}
}
- if (c->key.nr_color_regions == 0) {
+ if (key->nr_color_regions == 0) {
/* Even if there's no color buffers enabled, we still need to send
* alpha out the pipeline to our null renderbuffer to support
* alpha-testing, alpha-to-coverage, and so on.
unsigned dispatch_width)
: backend_visitor(brw, shader_prog, &fp->Base, &c->prog_data.base,
MESA_SHADER_FRAGMENT),
+ key(&c->key),
dispatch_width(dispatch_width)
{
this->c = c;