[Mesa-dev] [PATCH 03/10] i965/fs: Do not mark used direct surfaces in the generator for texture opcodes
Iago Toral Quiroga
itoral at igalia.com
Fri Oct 30 04:11:55 PDT 2015
Right now the generator marks direct surfaces as used but leaves marking of
indirect surfaces to the caller. Just make the callers handle marking in both
cases for consistency.
---
src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 6 ------
src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 24 ++++++++++++++++--------
2 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 740003c..96d34b7 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -914,8 +914,6 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src
inst->header_size != 0,
simd_mode,
return_format);
-
- brw_mark_surface_used(prog_data, sampler + base_binding_table_index);
} else {
/* Non-const sampler index */
@@ -946,10 +944,6 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src
inst->header_size != 0 /* header */,
simd_mode,
return_format);
-
- /* visitor knows more than we do about the surface limit required,
- * so has already done marking.
- */
}
if (is_combined_send) {
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 349b428..1298148 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -1980,6 +1980,11 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
unsigned sampler = instr->sampler_index;
fs_reg sampler_reg(sampler);
+ unsigned binding_table_texture_start =
+ instr->op == nir_texop_tg4 && devinfo->gen < 8 ?
+ stage_prog_data->binding_table.gather_texture_start :
+ stage_prog_data->binding_table.texture_start;
+
int gather_component = instr->component;
bool is_rect = instr->sampler_dim == GLSL_SAMPLER_DIM_RECT;
@@ -1992,6 +1997,7 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
fs_reg coordinate, shadow_comparitor, lod, lod2, sample_index, mcs, tex_offset;
+ bool is_indirect_sampler = false;
for (unsigned i = 0; i < instr->num_srcs; i++) {
fs_reg src = get_nir_src(instr->src[i].src);
switch (instr->src[i].src_type) {
@@ -2046,14 +2052,7 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
unreachable("should be lowered");
case nir_tex_src_sampler_offset: {
- /* Figure out the highest possible sampler index and mark it as used */
- uint32_t max_used = sampler + instr->sampler_array_size - 1;
- if (instr->op == nir_texop_tg4 && devinfo->gen < 8) {
- max_used += stage_prog_data->binding_table.gather_texture_start;
- } else {
- max_used += stage_prog_data->binding_table.texture_start;
- }
- brw_mark_surface_used(prog_data, max_used);
+ is_indirect_sampler = true;
/* Emit code to evaluate the actual indexing expression */
sampler_reg = vgrf(glsl_type::uint_type);
@@ -2067,6 +2066,15 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
}
}
+ if (!is_indirect_sampler) {
+ brw_mark_surface_used(prog_data, binding_table_texture_start + sampler);
+ } else {
+ /* Figure out the highest possible sampler index and mark it as used */
+ uint32_t max_used = binding_table_texture_start + sampler +
+ instr->sampler_array_size - 1;
+ brw_mark_surface_used(prog_data, max_used);
+ }
+
if (instr->op == nir_texop_txf_ms) {
if (devinfo->gen >= 7 &&
key_tex->compressed_multisample_layout_mask & (1 << sampler)) {
--
1.9.1
More information about the mesa-dev
mailing list