[Mesa-dev] [PATCH RFC 3/6] i965: add FS_OPCODE_OVERWRITE_DST
Chia-I Wu
olvaffe at gmail.com
Mon Sep 30 01:27:47 PDT 2013
From: Chia-I Wu <olv at lunarg.com>
FS_OPCODE_OVERWRITE_DST is used to indicate that the destination register is
(completely) overwritten. No code is emitted, but the liveness analysis can
use it as a hint to add the destination register to DEF bitset. This is
needed because it is hard to figure out if some partial writes combined
constitute a complete write during liveness analysis, while it is easier for
the FS visitor to know if that is the case.
Signed-off-by: Chia-I Wu <olv at lunarg.com>
---
src/mesa/drivers/dri/i965/brw_defines.h | 1 +
src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 4 ++++
src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp | 5 +++--
src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp | 3 ++-
src/mesa/drivers/dri/i965/brw_shader.cpp | 3 +++
5 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
index b14c346..2618180 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -789,6 +789,7 @@ enum opcode {
FS_OPCODE_UNPACK_HALF_2x16_SPLIT_X,
FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y,
FS_OPCODE_PLACEHOLDER_HALT,
+ FS_OPCODE_OVERWRITE_DST,
VS_OPCODE_URB_WRITE,
VS_OPCODE_SCRATCH_READ,
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 9406f7b..2b179b6 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1484,6 +1484,10 @@ fs_generator::generate_code(exec_list *instructions)
patch_discard_jumps_to_fb_writes();
break;
+ case FS_OPCODE_OVERWRITE_DST:
+ /* This is to help liveness analysis. */
+ break;
+
default:
if (inst->opcode < (int) ARRAY_SIZE(opcode_descs)) {
_mesa_problem(ctx, "Unsupported opcode `%s' in FS",
diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
index f5daab2..13891f8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
@@ -77,8 +77,9 @@ fs_live_variables::setup_def_use()
* variable, and thus qualify for being in def[].
*/
if (inst->dst.file == GRF &&
- inst->regs_written == v->virtual_grf_sizes[inst->dst.reg] &&
- !inst->is_partial_write()) {
+ (inst->opcode == FS_OPCODE_OVERWRITE_DST ||
+ (inst->regs_written == v->virtual_grf_sizes[inst->dst.reg] &&
+ !inst->is_partial_write()))) {
int reg = inst->dst.reg;
if (!BITSET_TEST(bd[b].use, reg))
BITSET_SET(bd[b].def, reg);
diff --git a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
index 5530683..4e59a10 100644
--- a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
+++ b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
@@ -562,7 +562,8 @@ fs_instruction_scheduler::calculate_deps()
schedule_node *n = (schedule_node *)node;
fs_inst *inst = (fs_inst *)n->inst;
- if (inst->opcode == FS_OPCODE_PLACEHOLDER_HALT)
+ if (inst->opcode == FS_OPCODE_PLACEHOLDER_HALT ||
+ inst->opcode == FS_OPCODE_OVERWRITE_DST)
add_barrier_deps(n);
/* read-after-write deps. */
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index a558d36..78029e2 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -485,6 +485,9 @@ brw_instruction_name(enum opcode op)
case FS_OPCODE_PLACEHOLDER_HALT:
return "placeholder_halt";
+ case FS_OPCODE_OVERWRITE_DST:
+ return "overwrite_dst";
+
case VS_OPCODE_URB_WRITE:
return "vs_urb_write";
case VS_OPCODE_SCRATCH_READ:
--
1.8.3.1
More information about the mesa-dev
mailing list