Discussion:
[PATCH 2/3] nir: Add a new lowering option to lower all txd to txl.
Add Reply
Eric Anholt
2017-11-22 00:39:28 UTC
Reply
Permalink
Raw Message
VC5 requires that all txd are lowered in the shader.
---
src/compiler/nir/nir.h | 6 ++++++
src/compiler/nir/nir_lower_tex.c | 14 ++++++++------
2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f46f6147110a..dd969aeb81bd 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2584,6 +2584,12 @@ typedef struct nir_lower_tex_options {
* with lower_txd_cube_map.
*/
bool lower_txd_shadow;
+
+ /**
+ * If true, lower nir_texop_txd on all samplers to a nir_texop_txl.
+ * Implies lower_txd_cube_map and lower_txd_shadow.
+ */
+ bool lower_txd;
} nir_lower_tex_options;

bool nir_lower_tex(nir_shader *shader,
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index bd603cc22884..1062afd97f01 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -524,10 +524,9 @@ lower_gradient_cube_map(nir_builder *b, nir_tex_instr *tex)
}

static void
-lower_gradient_shadow(nir_builder *b, nir_tex_instr *tex)
+lower_gradient(nir_builder *b, nir_tex_instr *tex)
{
assert(tex->sampler_dim != GLSL_SAMPLER_DIM_CUBE);
- assert(tex->is_shadow);
assert(tex->op == nir_texop_txd);
assert(tex->dest.is_ssa);

@@ -809,16 +808,19 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,

if (tex->op == nir_texop_txd &&
tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE &&
- (options->lower_txd_cube_map ||
+ (options->lower_txd ||
+ options->lower_txd_cube_map ||
(tex->is_shadow && options->lower_txd_shadow))) {
lower_gradient_cube_map(b, tex);
progress = true;
continue;
}

- if (tex->op == nir_texop_txd && options->lower_txd_shadow &&
- tex->is_shadow && tex->sampler_dim != GLSL_SAMPLER_DIM_CUBE) {
- lower_gradient_shadow(b, tex);
+ if (tex->op == nir_texop_txd &&
+ (options->lower_txd ||
+ (options->lower_txd_shadow &&
+ tex->is_shadow && tex->sampler_dim != GLSL_SAMPLER_DIM_CUBE))) {
+ lower_gradient(b, tex);
progress = true;
continue;
}
--
2.15.0
Eric Anholt
2017-11-22 00:39:29 UTC
Reply
Permalink
Raw Message
Fixes almost all of piglit's arb_shader_texture_lod grad tests, except for
the base -texgrad/texgradcube ones which fail on what appear to be
precision problems.
---
src/broadcom/compiler/vir.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index e7c050923c7a..d95a150c720a 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -541,6 +541,7 @@ static void
v3d_lower_nir(struct v3d_compile *c)
{
struct nir_lower_tex_options tex_options = {
+ .lower_txd = true,
.lower_rect = false, /* XXX */
.lower_txp = ~0,
/* Apply swizzles to all samplers. */
--
2.15.0
Eric Anholt
2017-12-07 03:10:28 UTC
Reply
Permalink
Raw Message
We want the clamping of the coordinate to apply after the offset, so we
need to do math to lower the offset out of the instruction. Fixes texwrap
offset cases for GL_CLAMP with GL_NEAREST on vc5.
Still looking for a review on this series.
Ian Romanick
2017-12-11 19:09:58 UTC
Reply
Permalink
Raw Message
For some reason the patches didn't show up in my inbox, but I found it
on patchwork. Series is
Post by Eric Anholt
We want the clamping of the coordinate to apply after the offset, so we
need to do math to lower the offset out of the instruction. Fixes texwrap
offset cases for GL_CLAMP with GL_NEAREST on vc5.
Still looking for a review on this series.
_______________________________________________
mesa-dev mailing list
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Loading...