Discussion:
[Mesa-dev] [PATCH 1/2] tgsi: improve comment on tgsi_util_get_shadow_ref_src_index()
Brian Paul
2017-12-24 22:40:27 UTC
Permalink
---
src/gallium/auxiliary/tgsi/tgsi_util.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.c b/src/gallium/auxiliary/tgsi/tgsi_util.c
index 78a5413..a78172a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_util.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_util.c
@@ -506,8 +506,12 @@ tgsi_util_get_texture_coord_dim(enum tgsi_texture_type tgsi_tex)


/**
- * Given a TGSI_TEXTURE_x target, return the src register index for the
- * shadow reference coordinate.
+ * Given a TGSI_TEXTURE_x target, return register component where the
+ * shadow reference/distance coordinate is found. Typically, components
+ * 0 and 1 are the (s,t) texcoords and component 2 or 3 hold the shadow
+ * reference value. But if we return 4, it means the reference value is
+ * found in the 0th component of the second coordinate argument to the
+ * TEX2 instruction.
*/
int
tgsi_util_get_shadow_ref_src_index(enum tgsi_texture_type tgsi_tex)
--
1.9.1
Brian Paul
2017-12-24 22:40:28 UTC
Permalink
No piglit changes.
---
src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index 31149dd..3e4a6ed 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -4782,16 +4782,12 @@ emit_tex_compare_refcoord(struct svga_shader_emitter_v10 *emit,
const struct tgsi_full_src_register *coord)
{
struct tgsi_full_src_register coord_src_ref;
- unsigned component;
+ int component;

assert(tgsi_is_shadow_target(target));

- assert(target != TGSI_TEXTURE_SHADOWCUBE_ARRAY); /* XXX not implemented */
- if (target == TGSI_TEXTURE_SHADOW2D_ARRAY ||
- target == TGSI_TEXTURE_SHADOWCUBE)
- component = TGSI_SWIZZLE_W;
- else
- component = TGSI_SWIZZLE_Z;
+ component = tgsi_util_get_shadow_ref_src_index(target) % 4;
+ assert(component >= 0);

coord_src_ref = scalar_src(coord, component);

@@ -4895,21 +4891,10 @@ end_tex_swizzle(struct svga_shader_emitter_v10 *emit,

assert(emit->unit == PIPE_SHADER_FRAGMENT);

- switch (swz->texture_target) {
- case TGSI_TEXTURE_SHADOW2D:
- case TGSI_TEXTURE_SHADOWRECT:
- case TGSI_TEXTURE_SHADOW1D:
- case TGSI_TEXTURE_SHADOW1D_ARRAY:
- coord_src = scalar_src(swz->coord_src, TGSI_SWIZZLE_Z);
- break;
- case TGSI_TEXTURE_SHADOWCUBE:
- case TGSI_TEXTURE_SHADOW2D_ARRAY:
- coord_src = scalar_src(swz->coord_src, TGSI_SWIZZLE_W);
- break;
- default:
- assert(!"Unexpected texture target in end_tex_swizzle()");
- coord_src = scalar_src(swz->coord_src, TGSI_SWIZZLE_Z);
- }
+ int component =
+ tgsi_util_get_shadow_ref_src_index(swz->texture_target) % 4;
+ assert(component >= 0);
+ coord_src = scalar_src(swz->coord_src, component);

/* COMPARE tmp, coord, texel */
emit_comparison(emit, compare_func,
--
1.9.1
Charmaine Lee
2017-12-26 19:31:41 UTC
Permalink
For this series, Reviewed-by: Charmaine Lee <***@vmware.com>

________________________________________
From: Brian Paul <***@vmware.com>
Sent: Sunday, December 24, 2017 2:40:28 PM
To: mesa-***@lists.freedesktop.org
Cc: Charmaine Lee; Neha Bhende
Subject: [PATCH 2/2] svga: use tgsi_util_get_shadow_ref_src_index() in a couple place

No piglit changes.
---
src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index 31149dd..3e4a6ed 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -4782,16 +4782,12 @@ emit_tex_compare_refcoord(struct svga_shader_emitter_v10 *emit,
const struct tgsi_full_src_register *coord)
{
struct tgsi_full_src_register coord_src_ref;
- unsigned component;
+ int component;

assert(tgsi_is_shadow_target(target));

- assert(target != TGSI_TEXTURE_SHADOWCUBE_ARRAY); /* XXX not implemented */
- if (target == TGSI_TEXTURE_SHADOW2D_ARRAY ||
- target == TGSI_TEXTURE_SHADOWCUBE)
- component = TGSI_SWIZZLE_W;
- else
- component = TGSI_SWIZZLE_Z;
+ component = tgsi_util_get_shadow_ref_src_index(target) % 4;
+ assert(component >= 0);

coord_src_ref = scalar_src(coord, component);

@@ -4895,21 +4891,10 @@ end_tex_swizzle(struct svga_shader_emitter_v10 *emit,

assert(emit->unit == PIPE_SHADER_FRAGMENT);

- switch (swz->texture_target) {
- case TGSI_TEXTURE_SHADOW2D:
- case TGSI_TEXTURE_SHADOWRECT:
- case TGSI_TEXTURE_SHADOW1D:
- case TGSI_TEXTURE_SHADOW1D_ARRAY:
- coord_src = scalar_src(swz->coord_src, TGSI_SWIZZLE_Z);
- break;
- case TGSI_TEXTURE_SHADOWCUBE:
- case TGSI_TEXTURE_SHADOW2D_ARRAY:
- coord_src = scalar_src(swz->coord_src, TGSI_SWIZZLE_W);
- break;
- default:
- assert(!"Unexpected texture target in end_tex_swizzle()");
- coord_src = scalar_src(swz->coord_src, TGSI_SWIZZLE_Z);
- }
+ int component =
+ tgsi_util_get_shadow_ref_src_index(swz->texture_target) % 4;
+ assert(component >= 0);
+ coord_src = scalar_src(swz->coord_src, component);

/* COMPARE tmp, coord, texel */
emit_comparison(emit, compare_func,
--
1.9.1
Neha Bhende
2017-12-26 20:09:14 UTC
Permalink
For the series,


Reviewed-by: Neha Bhende<***@vmware.com>



Regards,

Neha

________________________________
From: Brian Paul <***@vmware.com>
Sent: Sunday, December 24, 2017 2:40:28 PM
To: mesa-***@lists.freedesktop.org
Cc: Charmaine Lee; Neha Bhende
Subject: [PATCH 2/2] svga: use tgsi_util_get_shadow_ref_src_index() in a couple place

No piglit changes.
---
src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index 31149dd..3e4a6ed 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -4782,16 +4782,12 @@ emit_tex_compare_refcoord(struct svga_shader_emitter_v10 *emit,
const struct tgsi_full_src_register *coord)
{
struct tgsi_full_src_register coord_src_ref;
- unsigned component;
+ int component;

assert(tgsi_is_shadow_target(target));

- assert(target != TGSI_TEXTURE_SHADOWCUBE_ARRAY); /* XXX not implemented */
- if (target == TGSI_TEXTURE_SHADOW2D_ARRAY ||
- target == TGSI_TEXTURE_SHADOWCUBE)
- component = TGSI_SWIZZLE_W;
- else
- component = TGSI_SWIZZLE_Z;
+ component = tgsi_util_get_shadow_ref_src_index(target) % 4;
+ assert(component >= 0);

coord_src_ref = scalar_src(coord, component);

@@ -4895,21 +4891,10 @@ end_tex_swizzle(struct svga_shader_emitter_v10 *emit,

assert(emit->unit == PIPE_SHADER_FRAGMENT);

- switch (swz->texture_target) {
- case TGSI_TEXTURE_SHADOW2D:
- case TGSI_TEXTURE_SHADOWRECT:
- case TGSI_TEXTURE_SHADOW1D:
- case TGSI_TEXTURE_SHADOW1D_ARRAY:
- coord_src = scalar_src(swz->coord_src, TGSI_SWIZZLE_Z);
- break;
- case TGSI_TEXTURE_SHADOWCUBE:
- case TGSI_TEXTURE_SHADOW2D_ARRAY:
- coord_src = scalar_src(swz->coord_src, TGSI_SWIZZLE_W);
- break;
- default:
- assert(!"Unexpected texture target in end_tex_swizzle()");
- coord_src = scalar_src(swz->coord_src, TGSI_SWIZZLE_Z);
- }
+ int component =
+ tgsi_util_get_shadow_ref_src_index(swz->texture_target) % 4;
+ assert(component >= 0);
+ coord_src = scalar_src(swz->coord_src, component);

/* COMPARE tmp, coord, texel */
emit_comparison(emit, compare_func,
--
1.9.1
Marek Olšák
2017-12-26 17:13:26 UTC
Permalink
Reviewed-by: Marek Olšák <***@amd.com>

Marek

On Sun, Dec 24, 2017 at 11:40 PM, Brian Paul <***@vmware.com> wrote:
> ---
> src/gallium/auxiliary/tgsi/tgsi_util.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.c b/src/gallium/auxiliary/tgsi/tgsi_util.c
> index 78a5413..a78172a 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_util.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_util.c
> @@ -506,8 +506,12 @@ tgsi_util_get_texture_coord_dim(enum tgsi_texture_type tgsi_tex)
>
>
> /**
> - * Given a TGSI_TEXTURE_x target, return the src register index for the
> - * shadow reference coordinate.
> + * Given a TGSI_TEXTURE_x target, return register component where the
> + * shadow reference/distance coordinate is found. Typically, components
> + * 0 and 1 are the (s,t) texcoords and component 2 or 3 hold the shadow
> + * reference value. But if we return 4, it means the reference value is
> + * found in the 0th component of the second coordinate argument to the
> + * TEX2 instruction.
> */
> int
> tgsi_util_get_shadow_ref_src_index(enum tgsi_texture_type tgsi_tex)
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-***@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Loading...