Re: [Mesa-dev] [PATCH 1/2] nvc0/ir: Export viewport index in fragment shaders

2017-04-19 Thread Ilia Mirkin
On Wed, Apr 19, 2017 at 5:10 PM, Lyude  wrote:
> Since ABR_vertex_shader_layer/viewport_index enables the ability to
> interact with gl_ViewportIndex from the fragment shader, we don't want
> to skip emitting the viewport index for fragment shaders.
>
> As well, only save the viewport index into a scratch register for
> Geometry shaders, since EMIT is not a thing elsewhere.
>
> Signed-off-by: Lyude 
> ---
>  .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp  | 22 
> ++
>  1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> index 92cc13d..5af0ac5 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> @@ -2150,18 +2150,16 @@ Converter::storeDst(const 
> tgsi::Instruction::DstRegister dst, int c,
>assert(!ptr);
>mkOp2(OP_WRSV, TYPE_U32, NULL, dstToSym(dst, c), val);
> } else
> -   if (f == TGSI_FILE_OUTPUT && prog->getType() != Program::TYPE_FRAGMENT) {
> -
> -  if (ptr || (info->out[idx].mask & (1 << c))) {
> - /* Save the viewport index into a scratch register so that it can be
> -exported at EMIT time */
> - if (info->out[idx].sn == TGSI_SEMANTIC_VIEWPORT_INDEX &&
> - viewport != NULL)
> -mkOp1(OP_MOV, TYPE_U32, viewport, val);
> - else
> -mkStore(OP_EXPORT, TYPE_U32, dstToSym(dst, c), ptr, 
> val)->perPatch =
> -   info->out[idx].patch;
> -  }
> +   if (f == TGSI_FILE_OUTPUT && (ptr || (info->out[idx].mask & (1 << c {

This actually still needs to prog->getType() !=
Program::TYPE_FRAGMENT. Sorry. The original condition was correct.

> +  /* Save the viewport index into a scratch register so that it can be
> + exported at EMIT time */
> +  if (prog->getType() == Program::TYPE_GEOMETRY &&

And that's what was missing before. So I think just adding that to the
existing code would solve the issue quite nicely.

> +  info->out[idx].sn == TGSI_SEMANTIC_VIEWPORT_INDEX &&
> +  viewport != NULL)
> + mkOp1(OP_MOV, TYPE_U32, viewport, val);
> +  else
> + mkStore(OP_EXPORT, TYPE_U32, dstToSym(dst, c), ptr, val)->perPatch =
> +info->out[idx].patch;
> } else
> if (f == TGSI_FILE_TEMPORARY ||
> f == TGSI_FILE_ADDRESS ||
> --
> 2.9.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] nvc0/ir: Export viewport index in fragment shaders

2017-04-19 Thread Lyude
Since ABR_vertex_shader_layer/viewport_index enables the ability to
interact with gl_ViewportIndex from the fragment shader, we don't want
to skip emitting the viewport index for fragment shaders.

As well, only save the viewport index into a scratch register for
Geometry shaders, since EMIT is not a thing elsewhere.

Signed-off-by: Lyude 
---
 .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp  | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
index 92cc13d..5af0ac5 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
@@ -2150,18 +2150,16 @@ Converter::storeDst(const 
tgsi::Instruction::DstRegister dst, int c,
   assert(!ptr);
   mkOp2(OP_WRSV, TYPE_U32, NULL, dstToSym(dst, c), val);
} else
-   if (f == TGSI_FILE_OUTPUT && prog->getType() != Program::TYPE_FRAGMENT) {
-
-  if (ptr || (info->out[idx].mask & (1 << c))) {
- /* Save the viewport index into a scratch register so that it can be
-exported at EMIT time */
- if (info->out[idx].sn == TGSI_SEMANTIC_VIEWPORT_INDEX &&
- viewport != NULL)
-mkOp1(OP_MOV, TYPE_U32, viewport, val);
- else
-mkStore(OP_EXPORT, TYPE_U32, dstToSym(dst, c), ptr, val)->perPatch 
=
-   info->out[idx].patch;
-  }
+   if (f == TGSI_FILE_OUTPUT && (ptr || (info->out[idx].mask & (1 << c {
+  /* Save the viewport index into a scratch register so that it can be
+ exported at EMIT time */
+  if (prog->getType() == Program::TYPE_GEOMETRY &&
+  info->out[idx].sn == TGSI_SEMANTIC_VIEWPORT_INDEX &&
+  viewport != NULL)
+ mkOp1(OP_MOV, TYPE_U32, viewport, val);
+  else
+ mkStore(OP_EXPORT, TYPE_U32, dstToSym(dst, c), ptr, val)->perPatch =
+info->out[idx].patch;
} else
if (f == TGSI_FILE_TEMPORARY ||
f == TGSI_FILE_ADDRESS ||
-- 
2.9.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev