Re: [Mesa-dev] [PATCH v2 1/3] glsl: add glsl_external_mode() helper

2018-05-16 Thread Timothy Arceri

On 17/05/18 15:23, Timothy Arceri wrote:

On 17/05/18 14:59, Marek Olšák wrote:
On Thu, May 17, 2018 at 12:50 AM, Timothy Arceri 
mailto:tarc...@itsqueeze.com>> wrote:




    On 17/05/18 14:36, Marek Olšák wrote:

    On Wed, May 16, 2018 at 11:01 PM, Timothy Arceri
    mailto:tarc...@itsqueeze.com>
    >>
    wrote:



     On 17/05/18 10:59, Marek Olšák wrote:

         On Sat, May 12, 2018 at 12:49 AM, Timothy Arceri
         mailto:tarc...@itsqueeze.com>
    >
          

Re: [Mesa-dev] [PATCH v2 1/3] glsl: add glsl_external_mode() helper

2018-05-16 Thread Timothy Arceri



On 17/05/18 14:59, Marek Olšák wrote:
On Thu, May 17, 2018 at 12:50 AM, Timothy Arceri > wrote:




On 17/05/18 14:36, Marek Olšák wrote:

On Wed, May 16, 2018 at 11:01 PM, Timothy Arceri
mailto:tarc...@itsqueeze.com>
>>
wrote:



     On 17/05/18 10:59, Marek Olšák wrote:

         On Sat, May 12, 2018 at 12:49 AM, Timothy Arceri
         mailto:tarc...@itsqueeze.com>
>
          

Re: [Mesa-dev] [PATCH v2 1/3] glsl: add glsl_external_mode() helper

2018-05-16 Thread Marek Olšák
On Thu, May 17, 2018 at 12:50 AM, Timothy Arceri 
wrote:

>
>
> On 17/05/18 14:36, Marek Olšák wrote:
>
>> On Wed, May 16, 2018 at 11:01 PM, Timothy Arceri > > wrote:
>>
>>
>>
>> On 17/05/18 10:59, Marek Olšák wrote:
>>
>> On Sat, May 12, 2018 at 12:49 AM, Timothy Arceri
>> mailto:tarc...@itsqueeze.com>
>> >>
>>
>> wrote:
>>
>>  This allows us to get the variable mode as specified by the
>> GLSL
>>  spec. We will use this in the following patch.
>>  ---
>>src/compiler/glsl/ast_to_hir.cpp | 73
>> 
>>1 file changed, 73 insertions(+)
>>
>>  diff --git a/src/compiler/glsl/ast_to_hir.cpp
>>  b/src/compiler/glsl/ast_to_hir.cpp
>>  index 3bf581571e2..a7a9ac80769 100644
>>  --- a/src/compiler/glsl/ast_to_hir.cpp
>>  +++ b/src/compiler/glsl/ast_to_hir.cpp
>>  @@ -4175,6 +4175,79 @@
>> apply_type_qualifier_to_variable(const struct
>>  ast_type_qualifier *qual,
>>   apply_image_qualifier_to_variable(qual, var, state,
>> loc);
>>}
>>
>>  +/**
>>  + * Get the GLSL mode specified in for system values (if
>> any).
>>  + */
>>  +static enum ir_variable_mode
>>  +glsl_external_mode(enum ir_variable_mode internal_mode,
>>  gl_shader_stage stage,
>>  +   unsigned slot) {
>>  +   if (internal_mode == ir_var_system_value) {
>>  +  switch (slot) {
>>  +  case SYSTEM_VALUE_SUBGROUP_SIZE:
>>  + return ir_var_uniform;
>>  +  case SYSTEM_VALUE_PRIMITIVE_ID:
>>  + if (stage == MESA_SHADER_GEOMETRY) {
>>  +return ir_var_shader_out;
>>
>>
>> System values are always inputs. This one is gl_PrimitiveIDIn.
>>
>>  + } else {
>>  +return ir_var_shader_in;
>>  + }
>>  +  case SYSTEM_VALUE_TESS_LEVEL_OUTER:
>>  +  case SYSTEM_VALUE_TESS_LEVEL_INNER:
>>  + if (stage == MESA_SHADER_TESS_CTRL) {
>>  +return ir_var_shader_out;
>>
>>
>> System values are always inputs, i.e. TESS_CTRL isn't allowed
>> here.
>>
>>
>> Hmm yeah your right I seem to have confused myself here a bit.
>> However SYSTEM_VALUE_SUBGROUP_SIZE seems to be the odd one out in
>> that its a uniform.
>>
>>
>> Why is it uniform?
>>
>
> From ARB_shader_ballot:
>
>
> (Add to the list of built-in uniform variable declaration)
>
> uniform uint  gl_SubGroupSizeARB;
>

I think it means that gl_SubGroupSizeARB is a compile-time constant. It
probably shouldn't be a system value.

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


Re: [Mesa-dev] [PATCH v2 1/3] glsl: add glsl_external_mode() helper

2018-05-16 Thread Timothy Arceri



On 17/05/18 14:36, Marek Olšák wrote:
On Wed, May 16, 2018 at 11:01 PM, Timothy Arceri > wrote:




On 17/05/18 10:59, Marek Olšák wrote:

On Sat, May 12, 2018 at 12:49 AM, Timothy Arceri
mailto:tarc...@itsqueeze.com>
>>
wrote:

     This allows us to get the variable mode as specified by the
GLSL
     spec. We will use this in the following patch.
     ---
       src/compiler/glsl/ast_to_hir.cpp | 73

       1 file changed, 73 insertions(+)

     diff --git a/src/compiler/glsl/ast_to_hir.cpp
     b/src/compiler/glsl/ast_to_hir.cpp
     index 3bf581571e2..a7a9ac80769 100644
     --- a/src/compiler/glsl/ast_to_hir.cpp
     +++ b/src/compiler/glsl/ast_to_hir.cpp
     @@ -4175,6 +4175,79 @@
apply_type_qualifier_to_variable(const struct
     ast_type_qualifier *qual,
          apply_image_qualifier_to_variable(qual, var, state, loc);
       }

     +/**
     + * Get the GLSL mode specified in for system values (if any).
     + */
     +static enum ir_variable_mode
     +glsl_external_mode(enum ir_variable_mode internal_mode,
     gl_shader_stage stage,
     +                   unsigned slot) {
     +   if (internal_mode == ir_var_system_value) {
     +      switch (slot) {
     +      case SYSTEM_VALUE_SUBGROUP_SIZE:
     +         return ir_var_uniform;
     +      case SYSTEM_VALUE_PRIMITIVE_ID:
     +         if (stage == MESA_SHADER_GEOMETRY) {
     +            return ir_var_shader_out;


System values are always inputs. This one is gl_PrimitiveIDIn.

     +         } else {
     +            return ir_var_shader_in;
     +         }
     +      case SYSTEM_VALUE_TESS_LEVEL_OUTER:
     +      case SYSTEM_VALUE_TESS_LEVEL_INNER:
     +         if (stage == MESA_SHADER_TESS_CTRL) {
     +            return ir_var_shader_out;


System values are always inputs, i.e. TESS_CTRL isn't allowed here.


Hmm yeah your right I seem to have confused myself here a bit.
However SYSTEM_VALUE_SUBGROUP_SIZE seems to be the odd one out in
that its a uniform.


Why is it uniform?


From ARB_shader_ballot:


(Add to the list of built-in uniform variable declaration)

uniform uint  gl_SubGroupSizeARB;



Marek

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


Re: [Mesa-dev] [PATCH v2 1/3] glsl: add glsl_external_mode() helper

2018-05-16 Thread Marek Olšák
On Wed, May 16, 2018 at 11:01 PM, Timothy Arceri 
wrote:

>
>
> On 17/05/18 10:59, Marek Olšák wrote:
>
> On Sat, May 12, 2018 at 12:49 AM, Timothy Arceri > > wrote:
>>
>> This allows us to get the variable mode as specified by the GLSL
>> spec. We will use this in the following patch.
>> ---
>>   src/compiler/glsl/ast_to_hir.cpp | 73
>> 
>>   1 file changed, 73 insertions(+)
>>
>> diff --git a/src/compiler/glsl/ast_to_hir.cpp
>> b/src/compiler/glsl/ast_to_hir.cpp
>> index 3bf581571e2..a7a9ac80769 100644
>> --- a/src/compiler/glsl/ast_to_hir.cpp
>> +++ b/src/compiler/glsl/ast_to_hir.cpp
>> @@ -4175,6 +4175,79 @@ apply_type_qualifier_to_variable(const struct
>> ast_type_qualifier *qual,
>>  apply_image_qualifier_to_variable(qual, var, state, loc);
>>   }
>>
>> +/**
>> + * Get the GLSL mode specified in for system values (if any).
>> + */
>> +static enum ir_variable_mode
>> +glsl_external_mode(enum ir_variable_mode internal_mode,
>> gl_shader_stage stage,
>> +   unsigned slot) {
>> +   if (internal_mode == ir_var_system_value) {
>> +  switch (slot) {
>> +  case SYSTEM_VALUE_SUBGROUP_SIZE:
>> + return ir_var_uniform;
>> +  case SYSTEM_VALUE_PRIMITIVE_ID:
>> + if (stage == MESA_SHADER_GEOMETRY) {
>> +return ir_var_shader_out;
>>
>>
>> System values are always inputs. This one is gl_PrimitiveIDIn.
>>
>> + } else {
>> +return ir_var_shader_in;
>> + }
>> +  case SYSTEM_VALUE_TESS_LEVEL_OUTER:
>> +  case SYSTEM_VALUE_TESS_LEVEL_INNER:
>> + if (stage == MESA_SHADER_TESS_CTRL) {
>> +return ir_var_shader_out;
>>
>>
>> System values are always inputs, i.e. TESS_CTRL isn't allowed here.
>>
>
> Hmm yeah your right I seem to have confused myself here a bit. However
> SYSTEM_VALUE_SUBGROUP_SIZE seems to be the odd one out in that its a
> uniform.
>

Why is it uniform?

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


Re: [Mesa-dev] [PATCH v2 1/3] glsl: add glsl_external_mode() helper

2018-05-16 Thread Timothy Arceri



On 17/05/18 10:59, Marek Olšák wrote:
On Sat, May 12, 2018 at 12:49 AM, Timothy Arceri > wrote:


This allows us to get the variable mode as specified by the GLSL
spec. We will use this in the following patch.
---
  src/compiler/glsl/ast_to_hir.cpp | 73 
  1 file changed, 73 insertions(+)

diff --git a/src/compiler/glsl/ast_to_hir.cpp
b/src/compiler/glsl/ast_to_hir.cpp
index 3bf581571e2..a7a9ac80769 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -4175,6 +4175,79 @@ apply_type_qualifier_to_variable(const struct
ast_type_qualifier *qual,
     apply_image_qualifier_to_variable(qual, var, state, loc);
  }

+/**
+ * Get the GLSL mode specified in for system values (if any).
+ */
+static enum ir_variable_mode
+glsl_external_mode(enum ir_variable_mode internal_mode,
gl_shader_stage stage,
+                   unsigned slot) {
+   if (internal_mode == ir_var_system_value) {
+      switch (slot) {
+      case SYSTEM_VALUE_SUBGROUP_SIZE:
+         return ir_var_uniform;
+      case SYSTEM_VALUE_PRIMITIVE_ID:
+         if (stage == MESA_SHADER_GEOMETRY) {
+            return ir_var_shader_out;


System values are always inputs. This one is gl_PrimitiveIDIn.

+         } else {
+            return ir_var_shader_in;
+         }
+      case SYSTEM_VALUE_TESS_LEVEL_OUTER:
+      case SYSTEM_VALUE_TESS_LEVEL_INNER:
+         if (stage == MESA_SHADER_TESS_CTRL) {
+            return ir_var_shader_out;


System values are always inputs, i.e. TESS_CTRL isn't allowed here.


Hmm yeah your right I seem to have confused myself here a bit. However 
SYSTEM_VALUE_SUBGROUP_SIZE seems to be the odd one out in that its a 
uniform.




Marek


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


Re: [Mesa-dev] [PATCH v2 1/3] glsl: add glsl_external_mode() helper

2018-05-16 Thread Marek Olšák
On Sat, May 12, 2018 at 12:49 AM, Timothy Arceri 
wrote:

> This allows us to get the variable mode as specified by the GLSL
> spec. We will use this in the following patch.
> ---
>  src/compiler/glsl/ast_to_hir.cpp | 73 
>  1 file changed, 73 insertions(+)
>
> diff --git a/src/compiler/glsl/ast_to_hir.cpp
> b/src/compiler/glsl/ast_to_hir.cpp
> index 3bf581571e2..a7a9ac80769 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -4175,6 +4175,79 @@ apply_type_qualifier_to_variable(const struct
> ast_type_qualifier *qual,
> apply_image_qualifier_to_variable(qual, var, state, loc);
>  }
>
> +/**
> + * Get the GLSL mode specified in for system values (if any).
> + */
> +static enum ir_variable_mode
> +glsl_external_mode(enum ir_variable_mode internal_mode, gl_shader_stage
> stage,
> +   unsigned slot) {
> +   if (internal_mode == ir_var_system_value) {
> +  switch (slot) {
> +  case SYSTEM_VALUE_SUBGROUP_SIZE:
> + return ir_var_uniform;
> +  case SYSTEM_VALUE_PRIMITIVE_ID:
> + if (stage == MESA_SHADER_GEOMETRY) {
> +return ir_var_shader_out;
>

System values are always inputs. This one is gl_PrimitiveIDIn.


> + } else {
> +return ir_var_shader_in;
> + }
> +  case SYSTEM_VALUE_TESS_LEVEL_OUTER:
> +  case SYSTEM_VALUE_TESS_LEVEL_INNER:
> + if (stage == MESA_SHADER_TESS_CTRL) {
> +return ir_var_shader_out;
>

System values are always inputs, i.e. TESS_CTRL isn't allowed here.

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


[Mesa-dev] [PATCH v2 1/3] glsl: add glsl_external_mode() helper

2018-05-11 Thread Timothy Arceri
This allows us to get the variable mode as specified by the GLSL
spec. We will use this in the following patch.
---
 src/compiler/glsl/ast_to_hir.cpp | 73 
 1 file changed, 73 insertions(+)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 3bf581571e2..a7a9ac80769 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -4175,6 +4175,79 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
apply_image_qualifier_to_variable(qual, var, state, loc);
 }
 
+/**
+ * Get the GLSL mode specified in for system values (if any).
+ */
+static enum ir_variable_mode
+glsl_external_mode(enum ir_variable_mode internal_mode, gl_shader_stage stage,
+   unsigned slot) {
+   if (internal_mode == ir_var_system_value) {
+  switch (slot) {
+  case SYSTEM_VALUE_SUBGROUP_SIZE:
+ return ir_var_uniform;
+  case SYSTEM_VALUE_PRIMITIVE_ID:
+ if (stage == MESA_SHADER_GEOMETRY) {
+return ir_var_shader_out;
+ } else {
+return ir_var_shader_in;
+ }
+  case SYSTEM_VALUE_TESS_LEVEL_OUTER:
+  case SYSTEM_VALUE_TESS_LEVEL_INNER:
+ if (stage == MESA_SHADER_TESS_CTRL) {
+return ir_var_shader_out;
+ } else {
+assert(stage == MESA_SHADER_TESS_EVAL);
+return ir_var_shader_in;
+ }
+  case SYSTEM_VALUE_SUBGROUP_INVOCATION:
+  case SYSTEM_VALUE_SUBGROUP_EQ_MASK:
+  case SYSTEM_VALUE_SUBGROUP_GE_MASK:
+  case SYSTEM_VALUE_SUBGROUP_GT_MASK:
+  case SYSTEM_VALUE_SUBGROUP_LE_MASK:
+  case SYSTEM_VALUE_SUBGROUP_LT_MASK:
+  case SYSTEM_VALUE_INSTANCE_ID:
+  case SYSTEM_VALUE_VERTEX_ID:
+  case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE:
+  case SYSTEM_VALUE_BASE_VERTEX:
+  case SYSTEM_VALUE_BASE_INSTANCE:
+  case SYSTEM_VALUE_DRAW_ID:
+  case SYSTEM_VALUE_INVOCATION_ID:
+  case SYSTEM_VALUE_FRAG_COORD:
+  case SYSTEM_VALUE_FRONT_FACE:
+  case SYSTEM_VALUE_SAMPLE_ID:
+  case SYSTEM_VALUE_SAMPLE_POS:
+  case SYSTEM_VALUE_SAMPLE_MASK_IN:
+  case SYSTEM_VALUE_HELPER_INVOCATION:
+  case SYSTEM_VALUE_TESS_COORD:
+  case SYSTEM_VALUE_VERTICES_IN:
+  case SYSTEM_VALUE_LOCAL_INVOCATION_ID:
+  case SYSTEM_VALUE_LOCAL_INVOCATION_INDEX:
+  case SYSTEM_VALUE_GLOBAL_INVOCATION_ID:
+  case SYSTEM_VALUE_WORK_GROUP_ID:
+  case SYSTEM_VALUE_NUM_WORK_GROUPS:
+  case SYSTEM_VALUE_LOCAL_GROUP_SIZE:
+ return ir_var_shader_in;
+  case SYSTEM_VALUE_NUM_SUBGROUPS:
+  case SYSTEM_VALUE_SUBGROUP_ID:
+  case SYSTEM_VALUE_INSTANCE_INDEX:
+  case SYSTEM_VALUE_FIRST_VERTEX:
+  case SYSTEM_VALUE_IS_INDEXED_DRAW:
+  case SYSTEM_VALUE_DEVICE_INDEX:
+  case SYSTEM_VALUE_VIEW_INDEX:
+  case SYSTEM_VALUE_VERTEX_CNT:
+ /* These system values have no GLSL facing equal */
+ return internal_mode;
+  case SYSTEM_VALUE_MAX:
+ unreachable("Invalid system value slot SYSTEM_VALUE_MAX");
+ break;
+  default:
+ unreachable("Unhandled system value in glsl_external_mode()");
+  }
+   }
+
+   return internal_mode;
+}
+
 /**
  * Get the variable that is being redeclared by this declaration or if it
  * does not exist, the current declared variable.
-- 
2.17.0

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