i965: Unify fs_generator:: and vec4_generator::mark_surface_used as a free function.
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 27 Nov 2013 03:56:07 +0000 (19:56 -0800)
committerFrancisco Jerez <currojerez@riseup.net>
Wed, 19 Feb 2014 15:27:25 +0000 (16:27 +0100)
This way it can be used anywhere.  I need it from the visitor.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_generator.cpp
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_program.h
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_vec4.h
src/mesa/drivers/dri/i965/brw_vec4_generator.cpp

index c6f4ffb4a1986738c91a600d22b7b268268e4a20..914ace67ce9b273a33eb7efb3711bafac8e08c17 100644 (file)
@@ -641,8 +641,6 @@ private:
                                       struct brw_reg dst,
                                       struct brw_reg surf_index);
 
-   void mark_surface_used(unsigned surf_index);
-
    void patch_discard_jumps_to_fb_writes();
 
    struct brw_context *brw;
index ee13ced9e57b67ebbb0ae341325dada8601641ad..82db1407e8110433ab36c42bf51dcb4bff137324 100644 (file)
@@ -56,15 +56,6 @@ fs_generator::~fs_generator()
 {
 }
 
-void
-fs_generator::mark_surface_used(unsigned surf_index)
-{
-   assert(surf_index < BRW_MAX_SURFACES);
-
-   c->prog_data.base.binding_table.size_bytes =
-      MAX2(c->prog_data.base.binding_table.size_bytes, (surf_index + 1) * 4);
-}
-
 void
 fs_generator::patch_discard_jumps_to_fb_writes()
 {
@@ -189,7 +180,7 @@ fs_generator::generate_fb_write(fs_inst *inst)
                eot,
                inst->header_present);
 
-   mark_surface_used(surf_index);
+   brw_mark_surface_used(&c->prog_data.base, surf_index);
 }
 
 void
@@ -619,7 +610,7 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src
              simd_mode,
              return_format);
 
-   mark_surface_used(surface_index);
+   brw_mark_surface_used(&c->prog_data.base, surface_index);
 }
 
 
@@ -831,7 +822,7 @@ fs_generator::generate_uniform_pull_constant_load(fs_inst *inst,
    brw_oword_block_read(p, dst, brw_message_reg(inst->base_mrf),
                        read_offset, surf_index);
 
-   mark_surface_used(surf_index);
+   brw_mark_surface_used(&c->prog_data.base, surf_index);
 }
 
 void
@@ -873,7 +864,7 @@ fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst,
                            BRW_SAMPLER_SIMD_MODE_SIMD4X2,
                            0);
 
-   mark_surface_used(surf_index);
+   brw_mark_surface_used(&c->prog_data.base, surf_index);
 }
 
 void
@@ -940,7 +931,7 @@ fs_generator::generate_varying_pull_constant_load(fs_inst *inst,
                            simd_mode,
                            return_format);
 
-   mark_surface_used(surf_index);
+   brw_mark_surface_used(&c->prog_data.base, surf_index);
 }
 
 void
@@ -984,7 +975,7 @@ fs_generator::generate_varying_pull_constant_load_gen7(fs_inst *inst,
                            simd_mode,
                            0);
 
-   mark_surface_used(surf_index);
+   brw_mark_surface_used(&c->prog_data.base, surf_index);
 }
 
 /**
@@ -1290,7 +1281,8 @@ fs_generator::generate_shader_time_add(fs_inst *inst,
                        c->prog_data.base.binding_table.shader_time_start);
    brw_pop_insn_state(p);
 
-   mark_surface_used(c->prog_data.base.binding_table.shader_time_start);
+   brw_mark_surface_used(&c->prog_data.base,
+                         c->prog_data.base.binding_table.shader_time_start);
 }
 
 void
@@ -1307,7 +1299,7 @@ fs_generator::generate_untyped_atomic(fs_inst *inst, struct brw_reg dst,
                       atomic_op.dw1.ud, surf_index.dw1.ud,
                       inst->mlen, dispatch_width / 8);
 
-   mark_surface_used(surf_index.dw1.ud);
+   brw_mark_surface_used(&c->prog_data.base, surf_index.dw1.ud);
 }
 
 void
@@ -1321,7 +1313,7 @@ fs_generator::generate_untyped_surface_read(fs_inst *inst, struct brw_reg dst,
                             surf_index.dw1.ud,
                             inst->mlen, dispatch_width / 8);
 
-   mark_surface_used(surf_index.dw1.ud);
+   brw_mark_surface_used(&c->prog_data.base, surf_index.dw1.ud);
 }
 
 void
index f69c3129c011e246c40472a74cba9039bab56e72..58a7e811e3a856e76bb5c2120a1b01b6245763ba 100644 (file)
@@ -545,6 +545,16 @@ brw_destroy_shader_time(struct brw_context *brw)
    brw->shader_time.bo = NULL;
 }
 
+void
+brw_mark_surface_used(struct brw_stage_prog_data *prog_data,
+                      unsigned surf_index)
+{
+   assert(surf_index < BRW_MAX_SURFACES);
+
+   prog_data->binding_table.size_bytes =
+      MAX2(prog_data->binding_table.size_bytes, (surf_index + 1) * 4);
+}
+
 bool
 brw_stage_prog_data_compare(const struct brw_stage_prog_data *a,
                             const struct brw_stage_prog_data *b)
index 36134de95daa3374ef0ba18363bd4ec01336245d..59f628be6ecaf19c9a656e25c494328ca0fd3800 100644 (file)
@@ -76,6 +76,10 @@ bool brw_debug_recompile_sampler_key(struct brw_context *brw,
                                      const struct brw_sampler_prog_key_data *key);
 void brw_add_texrect_params(struct gl_program *prog);
 
+void
+brw_mark_surface_used(struct brw_stage_prog_data *prog_data,
+                      unsigned surf_index);
+
 bool
 brw_stage_prog_data_compare(const struct brw_stage_prog_data *a,
                             const struct brw_stage_prog_data *b);
index d58c13d733cf906999a444b1cad751ec964f8e83..d3a756078467e0ed4bb80856a127907ba24fd803 100644 (file)
@@ -722,5 +722,5 @@ backend_visitor::assign_common_binding_table_offsets(uint32_t next_binding_table
 
    assert(next_binding_table_offset <= BRW_MAX_SURFACES);
 
-   /* prog_data->base.binding_table.size will be set by mark_surface_used. */
+   /* prog_data->base.binding_table.size will be set by brw_mark_surface_used. */
 }
index 9bbb6d823b8d13b8f21bcf0908341a3c0ceccf9e..ecb16497fdb43c56ee93d9049dfd1e8a2b6edd51 100644 (file)
@@ -644,8 +644,6 @@ private:
                                       struct brw_reg dst,
                                       struct brw_reg surf_index);
 
-   void mark_surface_used(unsigned surf_index);
-
    struct brw_context *brw;
 
    struct brw_compile *p;
index e5ed2c2930042547ae7fcc2d8900f4c123092f2b..058b639309b591ac6c58a998c69c18b3fdee173a 100644 (file)
@@ -150,15 +150,6 @@ vec4_generator::~vec4_generator()
 {
 }
 
-void
-vec4_generator::mark_surface_used(unsigned surf_index)
-{
-   assert(surf_index < BRW_MAX_SURFACES);
-
-   prog_data->base.binding_table.size_bytes =
-      MAX2(prog_data->base.binding_table.size_bytes, (surf_index + 1) * 4);
-}
-
 void
 vec4_generator::generate_math1_gen4(vec4_instruction *inst,
                                     struct brw_reg dst,
@@ -438,7 +429,7 @@ vec4_generator::generate_tex(vec4_instruction *inst,
              BRW_SAMPLER_SIMD_MODE_SIMD4X2,
              return_format);
 
-   mark_surface_used(surface_index);
+   brw_mark_surface_used(&prog_data->base, surface_index);
 }
 
 void
@@ -850,7 +841,7 @@ vec4_generator::generate_pull_constant_load(vec4_instruction *inst,
                            true, /* header_present */
                           1 /* rlen */);
 
-   mark_surface_used(surf_index);
+   brw_mark_surface_used(&prog_data->base, surf_index);
 }
 
 void
@@ -875,7 +866,7 @@ vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst,
                            BRW_SAMPLER_SIMD_MODE_SIMD4X2,
                            0);
 
-   mark_surface_used(surf_index.dw1.ud);
+   brw_mark_surface_used(&prog_data->base, surf_index.dw1.ud);
 }
 
 void
@@ -893,7 +884,7 @@ vec4_generator::generate_untyped_atomic(vec4_instruction *inst,
                       atomic_op.dw1.ud, surf_index.dw1.ud,
                       inst->mlen, 1);
 
-   mark_surface_used(surf_index.dw1.ud);
+   brw_mark_surface_used(&prog_data->base, surf_index.dw1.ud);
 }
 
 void
@@ -908,7 +899,7 @@ vec4_generator::generate_untyped_surface_read(vec4_instruction *inst,
                             surf_index.dw1.ud,
                             inst->mlen, 1);
 
-   mark_surface_used(surf_index.dw1.ud);
+   brw_mark_surface_used(&prog_data->base, surf_index.dw1.ud);
 }
 
 /**
@@ -1221,7 +1212,8 @@ vec4_generator::generate_vec4_instruction(vec4_instruction *instruction,
    case SHADER_OPCODE_SHADER_TIME_ADD:
       brw_shader_time_add(p, src[0],
                           prog_data->base.binding_table.shader_time_start);
-      mark_surface_used(prog_data->base.binding_table.shader_time_start);
+      brw_mark_surface_used(&prog_data->base,
+                            prog_data->base.binding_table.shader_time_start);
       break;
 
    case SHADER_OPCODE_UNTYPED_ATOMIC: