[Mesa-dev] [PATCH 02/11] glsl: add get_internal_ifc_packing() type helper
Timothy Arceri
tarceri at itsqueeze.com
Thu Aug 17 11:02:59 UTC 2017
This is used to avoid code duplication when selecting the
packing type for shared and packed layouts.
---
src/compiler/glsl_types.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index f67465e6c8..3c18f6cce5 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -810,20 +810,41 @@ struct glsl_type {
/**
* Get the type interface packing.
*/
enum glsl_interface_packing get_interface_packing() const
{
return (enum glsl_interface_packing)interface_packing;
}
/**
+ * Get the type interface packing used internally. For shared and packing
+ * layouts this is implementation defined.
+ */
+ enum glsl_interface_packing get_internal_ifc_packing(bool std430_supported) const
+ {
+ enum glsl_interface_packing packing = this->get_interface_packing();
+ if (packing == GLSL_INTERFACE_PACKING_STD140 ||
+ (!std430_supported &&
+ (packing == GLSL_INTERFACE_PACKING_SHARED ||
+ packing == GLSL_INTERFACE_PACKING_PACKED))) {
+ return GLSL_INTERFACE_PACKING_STD140;
+ } else {
+ assert(packing == GLSL_INTERFACE_PACKING_STD430 ||
+ (std430_supported &&
+ (packing == GLSL_INTERFACE_PACKING_SHARED ||
+ packing == GLSL_INTERFACE_PACKING_PACKED)));
+ return GLSL_INTERFACE_PACKING_STD430;
+ }
+ }
+
+ /**
* Check if the type interface is row major
*/
bool get_interface_row_major() const
{
return (bool) interface_row_major;
}
private:
static mtx_t mem_mutex;
--
2.13.4
More information about the mesa-dev
mailing list