summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-01-31 23:36:52 -0800
committerKenneth Graunke <[email protected]>2015-03-25 16:17:19 -0700
commit649173b473ded2d7b1aded91cd4aab42eaeb5766 (patch)
tree60dad8120d0b0e6a8684880bcdc18224c9192761 /src/mesa
parent0a9bcf9e39409ea5acfdfbcf0c388e41e0f9ea45 (diff)
i965/fs: Implement texture projection support.
Our fragment program backend implements support for TXP directly, and there's no NIR lowering pass to remove the projection. When we switch fragment program support over to NIR, we need to support it somehow. It's easy enough to support directly. v2: Split out offset/tex_offset rename (requested by Jordan). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_nir.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 98ea70ca842..0b8ed1a8b83 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -1744,6 +1744,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
int lod_components = 0, offset_components = 0;
fs_reg coordinate, shadow_comparitor, lod, lod2, sample_index, mcs, tex_offset;
+ fs_reg projector;
for (unsigned i = 0; i < instr->num_srcs; i++) {
fs_reg src = get_nir_src(instr->src[i].src);
@@ -1796,7 +1797,8 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
offset_components = instr->coord_components;
break;
case nir_tex_src_projector:
- unreachable("should be lowered");
+ projector = retype(src, BRW_REGISTER_TYPE_F);
+ break;
case nir_tex_src_sampler_offset: {
/* Figure out the highest possible sampler index and mark it as used */
@@ -1820,6 +1822,13 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
}
}
+ if (projector.file != BAD_FILE) {
+ fs_reg invproj = vgrf(glsl_type::float_type);
+ emit_math(SHADER_OPCODE_RCP, invproj, projector);
+ for (int i = 0; i < 3; i++)
+ emit(MUL(offset(coordinate, i), offset(coordinate, i), invproj));
+ }
+
if (instr->op == nir_texop_txf_ms) {
if (brw->gen >= 7 &&
key_tex->compressed_multisample_layout_mask & (1 << sampler)) {