[Mesa-dev] [PATCH 2/3] st/glsl_to_tgsi: swizzle PROGRAM_OUTPUTs correctly in src_register translation
Nicolai Hähnle
nhaehnle at gmail.com
Tue Nov 29 11:01:46 UTC 2016
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
This is required for reading directly from fragment shader stencil and depth
outputs.
---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 978dc46..8a247ea 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5376,23 +5376,33 @@ src_register(struct st_translate *t, const st_src_reg *reg)
{
int index = reg->index;
int double_reg2 = reg->double_reg2 ? 1 : 0;
switch(reg->file) {
case PROGRAM_UNDEFINED:
return ureg_imm4f(t->ureg, 0, 0, 0, 0);
case PROGRAM_TEMPORARY:
case PROGRAM_ARRAY:
- case PROGRAM_OUTPUT:
return ureg_src(dst_register(t, reg->file, reg->index, reg->array_id));
+ case PROGRAM_OUTPUT: {
+ struct ureg_dst dst = dst_register(t, reg->file, reg->index, reg->array_id);
+ assert(dst.WriteMask != 0);
+ unsigned shift = ffs(dst.WriteMask) - 1;
+ return ureg_swizzle(ureg_src(dst),
+ shift,
+ MIN2(shift + 1, 3),
+ MIN2(shift + 2, 3),
+ MIN2(shift + 3, 3));
+ }
+
case PROGRAM_UNIFORM:
assert(reg->index >= 0);
return reg->index < t->num_constants ?
t->constants[reg->index] : ureg_imm4f(t->ureg, 0, 0, 0, 0);
case PROGRAM_STATE_VAR:
case PROGRAM_CONSTANT: /* ie, immediate */
if (reg->has_index2)
return ureg_src_register(TGSI_FILE_CONSTANT, reg->index);
else
return reg->index >= 0 && reg->index < t->num_constants ?
--
2.7.4
More information about the mesa-dev
mailing list