Re: [Mesa-dev] [PATCH] spirv: Add SpvCapabilityShaderViewportIndexLayerEXT

2018-03-06 Thread Samuel Iglesias Gonsálvez
On 05/03/18 22:58, Caio Marcelo de Oliveira Filho wrote:
> This capability allows gl_ViewportIndex and gl_Layer to also be used
> as outputs in Vertex and Tesselation shaders.
>
> v2: Make conditional to the capability, add gl_Layer, add tesselation
> shaders. (Iago)
>
> v3: Don't export to tesselation control shader.
>
> v4: Add Reviewd-by tag.
>
> Reviewed-by: Iago Toral Quiroga 
> ---
>
> Iago, I don't have write access to the repository. Could you apply
> this?

I pushed the patch for you :-)

Sam

>  src/compiler/shader_info.h | 1 +
>  src/compiler/spirv/spirv_to_nir.c  | 4 
>  src/compiler/spirv/vtn_variables.c | 8 
>  3 files changed, 13 insertions(+)
>
> diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
> index e7fd7dbe62..2fcbde74be 100644
> --- a/src/compiler/shader_info.h
> +++ b/src/compiler/shader_info.h
> @@ -43,6 +43,7 @@ struct spirv_supported_capabilities {
> bool multiview;
> bool variable_pointers;
> bool storage_16bit;
> +   bool shader_viewport_index_layer;
>  };
>  
>  typedef struct shader_info {
> diff --git a/src/compiler/spirv/spirv_to_nir.c 
> b/src/compiler/spirv/spirv_to_nir.c
> index c6df764682..fdb2993db5 100644
> --- a/src/compiler/spirv/spirv_to_nir.c
> +++ b/src/compiler/spirv/spirv_to_nir.c
> @@ -3203,6 +3203,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, 
> SpvOp opcode,
>   spv_check_supported(storage_16bit, cap);
>   break;
>  
> +  case SpvCapabilityShaderViewportIndexLayerEXT:
> + spv_check_supported(shader_viewport_index_layer, cap);
> + break;
> +
>default:
>   vtn_fail("Unhandled capability");
>}
> diff --git a/src/compiler/spirv/vtn_variables.c 
> b/src/compiler/spirv/vtn_variables.c
> index 7e8a090add..11d2aabac8 100644
> --- a/src/compiler/spirv/vtn_variables.c
> +++ b/src/compiler/spirv/vtn_variables.c
> @@ -1187,6 +1187,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
>   *mode = nir_var_shader_in;
>else if (b->shader->info.stage == MESA_SHADER_GEOMETRY)
>   *mode = nir_var_shader_out;
> +  else if (b->options && b->options->caps.shader_viewport_index_layer &&
> +   (b->shader->info.stage == MESA_SHADER_VERTEX ||
> +b->shader->info.stage == MESA_SHADER_TESS_EVAL))
> + *mode = nir_var_shader_out;
>else
>   vtn_fail("invalid stage for SpvBuiltInLayer");
>break;
> @@ -1194,6 +1198,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
>*location = VARYING_SLOT_VIEWPORT;
>if (b->shader->info.stage == MESA_SHADER_GEOMETRY)
>   *mode = nir_var_shader_out;
> +  else if (b->options && b->options->caps.shader_viewport_index_layer &&
> +   (b->shader->info.stage == MESA_SHADER_VERTEX ||
> +b->shader->info.stage == MESA_SHADER_TESS_EVAL))
> + *mode = nir_var_shader_out;
>else if (b->shader->info.stage == MESA_SHADER_FRAGMENT)
>   *mode = nir_var_shader_in;
>else




signature.asc
Description: OpenPGP digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] spirv: Add SpvCapabilityShaderViewportIndexLayerEXT

2018-03-05 Thread Caio Marcelo de Oliveira Filho
This capability allows gl_ViewportIndex and gl_Layer to also be used
as outputs in Vertex and Tesselation shaders.

v2: Make conditional to the capability, add gl_Layer, add tesselation
shaders. (Iago)

v3: Don't export to tesselation control shader.

v4: Add Reviewd-by tag.

Reviewed-by: Iago Toral Quiroga 
---

Iago, I don't have write access to the repository. Could you apply
this?

 src/compiler/shader_info.h | 1 +
 src/compiler/spirv/spirv_to_nir.c  | 4 
 src/compiler/spirv/vtn_variables.c | 8 
 3 files changed, 13 insertions(+)

diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index e7fd7dbe62..2fcbde74be 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -43,6 +43,7 @@ struct spirv_supported_capabilities {
bool multiview;
bool variable_pointers;
bool storage_16bit;
+   bool shader_viewport_index_layer;
 };
 
 typedef struct shader_info {
diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index c6df764682..fdb2993db5 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3203,6 +3203,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, 
SpvOp opcode,
  spv_check_supported(storage_16bit, cap);
  break;
 
+  case SpvCapabilityShaderViewportIndexLayerEXT:
+ spv_check_supported(shader_viewport_index_layer, cap);
+ break;
+
   default:
  vtn_fail("Unhandled capability");
   }
diff --git a/src/compiler/spirv/vtn_variables.c 
b/src/compiler/spirv/vtn_variables.c
index 7e8a090add..11d2aabac8 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1187,6 +1187,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
  *mode = nir_var_shader_in;
   else if (b->shader->info.stage == MESA_SHADER_GEOMETRY)
  *mode = nir_var_shader_out;
+  else if (b->options && b->options->caps.shader_viewport_index_layer &&
+   (b->shader->info.stage == MESA_SHADER_VERTEX ||
+b->shader->info.stage == MESA_SHADER_TESS_EVAL))
+ *mode = nir_var_shader_out;
   else
  vtn_fail("invalid stage for SpvBuiltInLayer");
   break;
@@ -1194,6 +1198,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
   *location = VARYING_SLOT_VIEWPORT;
   if (b->shader->info.stage == MESA_SHADER_GEOMETRY)
  *mode = nir_var_shader_out;
+  else if (b->options && b->options->caps.shader_viewport_index_layer &&
+   (b->shader->info.stage == MESA_SHADER_VERTEX ||
+b->shader->info.stage == MESA_SHADER_TESS_EVAL))
+ *mode = nir_var_shader_out;
   else if (b->shader->info.stage == MESA_SHADER_FRAGMENT)
  *mode = nir_var_shader_in;
   else
-- 
2.16.2

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