Re: [Mesa-dev] [PATCH 10/14] st: add st_glsl_type_size_scalar() helper

2018-03-19 Thread Marek Olšák
On Mon, Mar 19, 2018 at 7:37 PM, Timothy Arceri 
wrote:

>
>
> On 20/03/18 10:27, Marek Olšák wrote:
>
>> On Wed, Mar 14, 2018 at 2:01 AM, Timothy Arceri > > wrote:
>>
>> This will be used to support uniform packing.
>> ---
>>  src/mesa/state_tracker/st_glsl_types.cpp | 43
>> 
>>  src/mesa/state_tracker/st_glsl_types.h   |  1 +
>>  2 files changed, 44 insertions(+)
>>
>> diff --git a/src/mesa/state_tracker/st_glsl_types.cpp
>> b/src/mesa/state_tracker/st_glsl_types.cpp
>> index e57fbc8f31..5dbfab4dce 100644
>> --- a/src/mesa/state_tracker/st_glsl_types.cpp
>> +++ b/src/mesa/state_tracker/st_glsl_types.cpp
>> @@ -106,3 +106,46 @@ st_glsl_storage_type_size(const struct
>> glsl_type *type, bool is_bindless)
>> }
>> return 0;
>>  }
>> +
>> +int
>> +st_glsl_type_size_scalar(const struct glsl_type *type)
>>
>>
>> I don't know what "type_size_scalar" means, but the function seems to
>> return the type size in dwords. I'd like a clearer name.
>>
>
> This is the naming used in i965 for this type of function. Basically we
> are just returning the number of components as opposed to returning 1 for
> everything from float to vec4.
>
> Happy to rename if you have any suggestions?
>

st_glsl_type_dword_size

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


Re: [Mesa-dev] [PATCH 10/14] st: add st_glsl_type_size_scalar() helper

2018-03-19 Thread Timothy Arceri



On 20/03/18 10:27, Marek Olšák wrote:
On Wed, Mar 14, 2018 at 2:01 AM, Timothy Arceri > wrote:


This will be used to support uniform packing.
---
 src/mesa/state_tracker/st_glsl_types.cpp | 43

 src/mesa/state_tracker/st_glsl_types.h   |  1 +
 2 files changed, 44 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_types.cpp
b/src/mesa/state_tracker/st_glsl_types.cpp
index e57fbc8f31..5dbfab4dce 100644
--- a/src/mesa/state_tracker/st_glsl_types.cpp
+++ b/src/mesa/state_tracker/st_glsl_types.cpp
@@ -106,3 +106,46 @@ st_glsl_storage_type_size(const struct
glsl_type *type, bool is_bindless)
    }
    return 0;
 }
+
+int
+st_glsl_type_size_scalar(const struct glsl_type *type)


I don't know what "type_size_scalar" means, but the function seems to 
return the type size in dwords. I'd like a clearer name.


This is the naming used in i965 for this type of function. Basically we 
are just returning the number of components as opposed to returning 1 
for everything from float to vec4.


Happy to rename if you have any suggestions?



Marek



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


Re: [Mesa-dev] [PATCH 10/14] st: add st_glsl_type_size_scalar() helper

2018-03-19 Thread Marek Olšák
On Wed, Mar 14, 2018 at 2:01 AM, Timothy Arceri 
wrote:

> This will be used to support uniform packing.
> ---
>  src/mesa/state_tracker/st_glsl_types.cpp | 43
> 
>  src/mesa/state_tracker/st_glsl_types.h   |  1 +
>  2 files changed, 44 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_glsl_types.cpp
> b/src/mesa/state_tracker/st_glsl_types.cpp
> index e57fbc8f31..5dbfab4dce 100644
> --- a/src/mesa/state_tracker/st_glsl_types.cpp
> +++ b/src/mesa/state_tracker/st_glsl_types.cpp
> @@ -106,3 +106,46 @@ st_glsl_storage_type_size(const struct glsl_type
> *type, bool is_bindless)
> }
> return 0;
>  }
> +
> +int
> +st_glsl_type_size_scalar(const struct glsl_type *type)
>

I don't know what "type_size_scalar" means, but the function seems to
return the type size in dwords. I'd like a clearer name.

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


[Mesa-dev] [PATCH 10/14] st: add st_glsl_type_size_scalar() helper

2018-03-14 Thread Timothy Arceri
This will be used to support uniform packing.
---
 src/mesa/state_tracker/st_glsl_types.cpp | 43 
 src/mesa/state_tracker/st_glsl_types.h   |  1 +
 2 files changed, 44 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_types.cpp 
b/src/mesa/state_tracker/st_glsl_types.cpp
index e57fbc8f31..5dbfab4dce 100644
--- a/src/mesa/state_tracker/st_glsl_types.cpp
+++ b/src/mesa/state_tracker/st_glsl_types.cpp
@@ -106,3 +106,46 @@ st_glsl_storage_type_size(const struct glsl_type *type, 
bool is_bindless)
}
return 0;
 }
+
+int
+st_glsl_type_size_scalar(const struct glsl_type *type)
+{
+   unsigned int size, i;
+
+   switch (type->base_type) {
+   case GLSL_TYPE_UINT:
+   case GLSL_TYPE_INT:
+   case GLSL_TYPE_FLOAT:
+   case GLSL_TYPE_BOOL:
+  return type->components();
+   case GLSL_TYPE_UINT16:
+   case GLSL_TYPE_INT16:
+   case GLSL_TYPE_FLOAT16:
+  return DIV_ROUND_UP(type->components(), 2);
+   case GLSL_TYPE_DOUBLE:
+   case GLSL_TYPE_UINT64:
+   case GLSL_TYPE_INT64:
+  return type->components() * 2;
+   case GLSL_TYPE_ARRAY:
+  return st_glsl_type_size_scalar(type->fields.array) * type->length;
+   case GLSL_TYPE_STRUCT:
+  size = 0;
+  for (i = 0; i < type->length; i++) {
+ size += st_glsl_type_size_scalar(type->fields.structure[i].type);
+  }
+  return size;
+   case GLSL_TYPE_IMAGE:
+   case GLSL_TYPE_SAMPLER:
+   case GLSL_TYPE_ATOMIC_UINT:
+  return 0;
+   case GLSL_TYPE_SUBROUTINE:
+  return 1;
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
+   case GLSL_TYPE_INTERFACE:
+   case GLSL_TYPE_FUNCTION:
+  unreachable("not reached");
+   }
+
+   return 0;
+}
diff --git a/src/mesa/state_tracker/st_glsl_types.h 
b/src/mesa/state_tracker/st_glsl_types.h
index 915816d1fa..247cd2e1ed 100644
--- a/src/mesa/state_tracker/st_glsl_types.h
+++ b/src/mesa/state_tracker/st_glsl_types.h
@@ -36,6 +36,7 @@ extern "C" {
 int st_glsl_storage_type_size(const struct glsl_type *type,
   bool is_bindless);
 
+int st_glsl_type_size_scalar(const struct glsl_type *type);
 
 #ifdef __cplusplus
 }
-- 
2.14.3

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