i965/fs: Replace c->key with a direct reference in the generators.

'c' is going away.  This is also a bit shorter.

Marking the key pointer as const will also deter people from changing
it in these classes, as that's absolutely not OK.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
This commit is contained in:
Kenneth Graunke
2014-05-14 00:24:50 -07:00
parent 65b2df3ec8
commit c96fdeb723
3 changed files with 18 additions and 15 deletions

View File

@@ -700,6 +700,7 @@ private:
struct brw_compile *p; struct brw_compile *p;
struct brw_wm_compile *c; struct brw_wm_compile *c;
const struct brw_wm_prog_key *const key;
struct brw_wm_prog_data *prog_data; struct brw_wm_prog_data *prog_data;
struct gl_shader_program *prog; struct gl_shader_program *prog;
@@ -785,6 +786,7 @@ private:
void patch_discard_jumps_to_fb_writes(); void patch_discard_jumps_to_fb_writes();
struct brw_wm_compile *c; struct brw_wm_compile *c;
const struct brw_wm_prog_key *const key;
struct brw_wm_prog_data *prog_data; struct brw_wm_prog_data *prog_data;
const struct gl_fragment_program *fp; const struct gl_fragment_program *fp;

View File

@@ -42,7 +42,7 @@ fs_generator::fs_generator(struct brw_context *brw,
struct gl_fragment_program *fp, struct gl_fragment_program *fp,
bool dual_source_output) bool dual_source_output)
: brw(brw), c(c), prog(prog), fp(fp), dual_source_output(dual_source_output) : brw(brw), c(c), key(&c->key), prog(prog), fp(fp), dual_source_output(dual_source_output)
{ {
ctx = &brw->ctx; ctx = &brw->ctx;
prog_data = &c->prog_data; prog_data = &c->prog_data;
@@ -111,7 +111,7 @@ fs_generator::generate_fb_write(fs_inst *inst)
/* On HSW, the GPU will use the predicate on SENDC, unless the header is /* On HSW, the GPU will use the predicate on SENDC, unless the header is
* present. * present.
*/ */
if ((fp && fp->UsesKill) || c->key.alpha_test_func) { if ((fp && fp->UsesKill) || key->alpha_test_func) {
struct brw_reg pixel_mask; struct brw_reg pixel_mask;
if (brw->gen >= 6) if (brw->gen >= 6)
@@ -129,7 +129,7 @@ fs_generator::generate_fb_write(fs_inst *inst)
retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD)); retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD));
brw_set_compression_control(p, BRW_COMPRESSION_NONE); brw_set_compression_control(p, BRW_COMPRESSION_NONE);
if (inst->target > 0 && c->key.replicate_alpha) { if (inst->target > 0 && key->replicate_alpha) {
/* Set "Source0 Alpha Present to RenderTarget" bit in message /* Set "Source0 Alpha Present to RenderTarget" bit in message
* header. * header.
*/ */
@@ -648,7 +648,7 @@ fs_generator::generate_ddx(fs_inst *inst, struct brw_reg dst, struct brw_reg src
{ {
unsigned vstride, width; unsigned vstride, width;
if (c->key.high_quality_derivatives) { if (key->high_quality_derivatives) {
/* produce accurate derivatives */ /* produce accurate derivatives */
vstride = BRW_VERTICAL_STRIDE_2; vstride = BRW_VERTICAL_STRIDE_2;
width = BRW_WIDTH_2; width = BRW_WIDTH_2;
@@ -682,7 +682,7 @@ void
fs_generator::generate_ddy(fs_inst *inst, struct brw_reg dst, struct brw_reg src, fs_generator::generate_ddy(fs_inst *inst, struct brw_reg dst, struct brw_reg src,
bool negate_value) bool negate_value)
{ {
if (c->key.high_quality_derivatives) { if (key->high_quality_derivatives) {
/* From the Ivy Bridge PRM, volume 4 part 3, section 3.3.9 (Register /* From the Ivy Bridge PRM, volume 4 part 3, section 3.3.9 (Register
* Region Restrictions): * Region Restrictions):
* *
@@ -1702,10 +1702,10 @@ fs_generator::generate_code(exec_list *instructions, FILE *dump_file)
break; break;
case FS_OPCODE_DDY: case FS_OPCODE_DDY:
/* Make sure fp->UsesDFdy flag got set (otherwise there's no /* Make sure fp->UsesDFdy flag got set (otherwise there's no
* guarantee that c->key.render_to_fbo is set). * guarantee that key->render_to_fbo is set).
*/ */
assert(fp->UsesDFdy); assert(fp->UsesDFdy);
generate_ddy(inst, dst, src[0], c->key.render_to_fbo); generate_ddy(inst, dst, src[0], key->render_to_fbo);
break; break;
case SHADER_OPCODE_GEN4_SCRATCH_WRITE: case SHADER_OPCODE_GEN4_SCRATCH_WRITE:

View File

@@ -40,8 +40,9 @@ gen8_fs_generator::gen8_fs_generator(struct brw_context *brw,
struct gl_shader_program *shader_prog, struct gl_shader_program *shader_prog,
struct gl_fragment_program *fp, struct gl_fragment_program *fp,
bool dual_source_output) bool dual_source_output)
: gen8_generator(brw, shader_prog, fp ? &fp->Base : NULL, c), c(c), fp(fp), : gen8_generator(brw, shader_prog, fp ? &fp->Base : NULL, c),
dual_source_output(dual_source_output) c(c), key(&c->key),
fp(fp), dual_source_output(dual_source_output)
{ {
prog_data = &c->prog_data; prog_data = &c->prog_data;
} }
@@ -72,7 +73,7 @@ gen8_fs_generator::generate_fb_write(fs_inst *ir)
MOV_RAW(brw_message_reg(ir->base_mrf), brw_vec8_grf(0, 0)); MOV_RAW(brw_message_reg(ir->base_mrf), brw_vec8_grf(0, 0));
gen8_set_exec_size(mov, BRW_EXECUTE_16); gen8_set_exec_size(mov, BRW_EXECUTE_16);
if (ir->target > 0 && c->key.replicate_alpha) { if (ir->target > 0 && key->replicate_alpha) {
/* Set "Source0 Alpha Present to RenderTarget" bit in the header. */ /* Set "Source0 Alpha Present to RenderTarget" bit in the header. */
OR(vec1(retype(brw_message_reg(ir->base_mrf), BRW_REGISTER_TYPE_UD)), OR(vec1(retype(brw_message_reg(ir->base_mrf), BRW_REGISTER_TYPE_UD)),
vec1(retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD)), vec1(retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD)),
@@ -116,7 +117,7 @@ gen8_fs_generator::generate_fb_write(fs_inst *ir)
/* "Last Render Target Select" must be set on all writes to the last of /* "Last Render Target Select" must be set on all writes to the last of
* the render targets (if using MRT), or always for a single RT scenario. * the render targets (if using MRT), or always for a single RT scenario.
*/ */
if ((ir->target == c->key.nr_color_regions - 1) || !c->key.nr_color_regions) if ((ir->target == key->nr_color_regions - 1) || !key->nr_color_regions)
msg_control |= (1 << 4); /* Last Render Target Select */ msg_control |= (1 << 4); /* Last Render Target Select */
uint32_t surf_index = uint32_t surf_index =
@@ -330,7 +331,7 @@ gen8_fs_generator::generate_ddx(fs_inst *inst,
{ {
unsigned vstride, width; unsigned vstride, width;
if (c->key.high_quality_derivatives) { if (key->high_quality_derivatives) {
/* Produce accurate derivatives. */ /* Produce accurate derivatives. */
vstride = BRW_VERTICAL_STRIDE_2; vstride = BRW_VERTICAL_STRIDE_2;
width = BRW_WIDTH_2; width = BRW_WIDTH_2;
@@ -370,7 +371,7 @@ gen8_fs_generator::generate_ddy(fs_inst *inst,
unsigned src1_swizzle; unsigned src1_swizzle;
unsigned src1_subnr; unsigned src1_subnr;
if (c->key.high_quality_derivatives) { if (key->high_quality_derivatives) {
/* Produce accurate derivatives. */ /* Produce accurate derivatives. */
hstride = BRW_HORIZONTAL_STRIDE_1; hstride = BRW_HORIZONTAL_STRIDE_1;
src0_swizzle = BRW_SWIZZLE_XYXY; src0_swizzle = BRW_SWIZZLE_XYXY;
@@ -1205,10 +1206,10 @@ gen8_fs_generator::generate_code(exec_list *instructions)
break; break;
case FS_OPCODE_DDY: case FS_OPCODE_DDY:
/* Make sure fp->UsesDFdy flag got set (otherwise there's no /* Make sure fp->UsesDFdy flag got set (otherwise there's no
* guarantee that c->key.render_to_fbo is set). * guarantee that key->render_to_fbo is set).
*/ */
assert(fp->UsesDFdy); assert(fp->UsesDFdy);
generate_ddy(ir, dst, src[0], c->key.render_to_fbo); generate_ddy(ir, dst, src[0], key->render_to_fbo);
break; break;
case SHADER_OPCODE_GEN4_SCRATCH_WRITE: case SHADER_OPCODE_GEN4_SCRATCH_WRITE: