compiler/types: Add glsl_get_std430_array_stride() and use it in C++
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
This commit is contained in:
@@ -2414,10 +2414,10 @@ glsl_get_std430_base_alignment(const struct glsl_type *t, bool row_major)
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned
|
||||
glsl_type::std430_array_stride(bool row_major) const
|
||||
extern "C" unsigned
|
||||
glsl_get_std430_array_stride(const struct glsl_type *t, bool row_major)
|
||||
{
|
||||
unsigned N = is_64bit() ? 8 : 4;
|
||||
unsigned N = t->is_64bit() ? 8 : 4;
|
||||
|
||||
/* Notice that the array stride of a vec3 is not 3 * N but 4 * N.
|
||||
* See OpenGL 4.30 spec, section 7.6.2.2 "Standard Uniform Block Layout"
|
||||
@@ -2425,12 +2425,12 @@ glsl_type::std430_array_stride(bool row_major) const
|
||||
* (3) If the member is a three-component vector with components consuming
|
||||
* <N> basic machine units, the base alignment is 4<N>.
|
||||
*/
|
||||
if (this->is_vector() && this->vector_elements == 3)
|
||||
if (t->is_vector() && t->vector_elements == 3)
|
||||
return 4 * N;
|
||||
|
||||
/* By default use std430_size(row_major) */
|
||||
unsigned stride = this->std430_size(row_major);
|
||||
assert(this->explicit_stride == 0 || this->explicit_stride == stride);
|
||||
unsigned stride = t->std430_size(row_major);
|
||||
assert(t->explicit_stride == 0 || t->explicit_stride == stride);
|
||||
return stride;
|
||||
}
|
||||
|
||||
|
||||
@@ -1587,6 +1587,7 @@ glsl_get_ifc_packing(const struct glsl_type *t)
|
||||
|
||||
unsigned glsl_get_std140_base_alignment(const struct glsl_type *t, bool row_major);
|
||||
unsigned glsl_get_std140_size(const struct glsl_type *t, bool row_major);
|
||||
unsigned glsl_get_std430_array_stride(const struct glsl_type *t, bool row_major);
|
||||
unsigned glsl_get_std430_base_alignment(const struct glsl_type *t, bool row_major);
|
||||
unsigned glsl_get_std430_size(const struct glsl_type *t, bool row_major);
|
||||
unsigned glsl_get_explicit_size(const struct glsl_type *t, bool align_to_stride);
|
||||
|
||||
@@ -77,6 +77,7 @@ inline unsigned glsl_type::cl_alignment() const { return glsl_get_cl_alignment(t
|
||||
inline unsigned glsl_type::std140_base_alignment(bool row_major) const { return glsl_get_std140_base_alignment(this, row_major); }
|
||||
inline unsigned glsl_type::std140_size(bool row_major) const { return glsl_get_std140_size(this, row_major); }
|
||||
inline unsigned glsl_type::std430_base_alignment(bool row_major) const { return glsl_get_std430_base_alignment(this, row_major); }
|
||||
inline unsigned glsl_type::std430_array_stride(bool row_major) const { return glsl_get_std430_array_stride(this, row_major); }
|
||||
inline unsigned glsl_type::std430_size(bool row_major) const { return glsl_get_std430_size(this, row_major); }
|
||||
inline unsigned glsl_type::explicit_size(bool align_to_stride) const { return glsl_get_explicit_size(this, align_to_stride); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user