On Wed, Feb 28, 2018 at 10:59 PM, Rob Clark <robdcl...@gmail.com> wrote: > hmm, I haven't tried passing a struct (rather than a pointer to a > struct) as a parameter, but if there were 8/16 bit fields in the > struct it would calculate the size incorrectly. > > (otoh the more important question is whether this agrees with how > clover lays out the input buffer, as far as where the n+1'th parameter > starts, which I'm not sure about) >
you can also pack structs in OpenCL C. I just used those functions in my backend code, because it worked for the more simple examples. > BR, > -R > > On Wed, Feb 28, 2018 at 4:47 PM, Jason Ekstrand <ja...@jlekstrand.net> wrote: >> I thought OpenCL used a different set of alignment rules for structs, >> unions, etc. In particular, I thought it was very close to standard C. If >> that's true, then std430 is not what you want. >> >> On Wed, Feb 28, 2018 at 1:44 PM, Karol Herbst <kher...@redhat.com> wrote: >>> >>> it isn't yet. But you would use it in your driver when calculating >>> your memory offsets for kernel arguments. In OpenCL things are aligned >>> in memory by the size of the type and we would use those functions to >>> calculate those. >>> >>> On Wed, Feb 28, 2018 at 10:39 PM, Jason Ekstrand <ja...@jlekstrand.net> >>> wrote: >>> > Looking through commit titles, I don't see any obvious place where this >>> > would get used. >>> > >>> > On Wed, Feb 28, 2018 at 11:51 AM, Rob Clark <robdcl...@gmail.com> wrote: >>> >> >>> >> Signed-off-by: Rob Clark <robdcl...@gmail.com> >>> >> --- >>> >> src/compiler/nir_types.cpp | 12 ++++++++++++ >>> >> src/compiler/nir_types.h | 4 ++++ >>> >> 2 files changed, 16 insertions(+) >>> >> >>> >> diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp >>> >> index cbdd452dc81..0085a19248a 100644 >>> >> --- a/src/compiler/nir_types.cpp >>> >> +++ b/src/compiler/nir_types.cpp >>> >> @@ -117,6 +117,18 @@ glsl_get_aoa_size(const struct glsl_type *type) >>> >> return type->arrays_of_arrays_size(); >>> >> } >>> >> >>> >> +unsigned >>> >> +glsl_std430_size(const struct glsl_type *type, bool row_major) >>> >> +{ >>> >> + return type->std430_size(row_major); >>> >> +} >>> >> + >>> >> +unsigned >>> >> +glsl_std430_base_alignment(const struct glsl_type *type, bool >>> >> row_major) >>> >> +{ >>> >> + return type->std430_base_alignment(row_major); >>> >> +} >>> >> + >>> >> unsigned >>> >> glsl_count_attribute_slots(const struct glsl_type *type, >>> >> bool is_vertex_input) >>> >> diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h >>> >> index e2dfd1ef5b7..5b5e09d137f 100644 >>> >> --- a/src/compiler/nir_types.h >>> >> +++ b/src/compiler/nir_types.h >>> >> @@ -71,6 +71,10 @@ unsigned glsl_get_length(const struct glsl_type >>> >> *type); >>> >> >>> >> unsigned glsl_get_aoa_size(const struct glsl_type *type); >>> >> >>> >> +unsigned glsl_std430_size(const struct glsl_type *type, bool >>> >> row_major); >>> >> + >>> >> +unsigned glsl_std430_base_alignment(const struct glsl_type *type, bool >>> >> row_major); >>> >> + >>> >> unsigned glsl_count_attribute_slots(const struct glsl_type *type, >>> >> bool is_vertex_input); >>> >> >>> >> -- >>> >> 2.14.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