[Mesa-dev] [PATCH 05/23] i965: Unify fs_generator:: and vec4_generator::mark_surface_used as a free function.
Francisco Jerez
currojerez at riseup.net
Mon Dec 2 11:31:10 PST 2013
This way it can be used anywhere. I need it from the visitor.
---
src/mesa/drivers/dri/i965/brw_fs.h | 2 --
src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 28 +++++++++---------------
src/mesa/drivers/dri/i965/brw_program.c | 10 +++++++++
src/mesa/drivers/dri/i965/brw_program.h | 4 ++++
src/mesa/drivers/dri/i965/brw_shader.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_vec4.h | 2 --
src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 22 ++++++-------------
7 files changed, 32 insertions(+), 38 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index ad165f0..f8fb1c5 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -596,8 +596,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;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 6626a8c..b5882a8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -59,15 +59,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()
{
if (brw->gen < 6 || this->discard_halt_patches.is_empty())
@@ -187,7 +178,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);
}
/* Computes the integer pixel x,y values from the origin.
@@ -582,7 +573,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);
}
@@ -794,7 +785,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
@@ -836,7 +827,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
@@ -903,7 +894,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
@@ -947,7 +938,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);
}
/**
@@ -1255,7 +1246,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
@@ -1272,7 +1264,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
@@ -1286,7 +1278,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
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index a494bc2..908782b 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -526,6 +526,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 void *in_a, const void *in_b)
{
diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
index 0bf8aef..d107c48 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -60,6 +60,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 void *in_a, const void *in_b);
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index ddb4524..6ce7653 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -675,5 +675,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. */
}
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 666a0fb4..3b3f35b 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -634,8 +634,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;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index 30c2ca2..9ce2cf7 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -153,15 +153,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,
struct brw_reg src)
@@ -414,7 +405,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
@@ -826,7 +817,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
@@ -851,7 +842,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
@@ -869,7 +860,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
@@ -884,7 +875,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);
}
/**
@@ -1196,7 +1187,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:
--
1.8.3.4
More information about the mesa-dev
mailing list