From 12e1f0c69676c256279f29309c36ece584f02c17 Mon Sep 17 00:00:00 2001 From: Timothy Arceri <tarceri@itsqueeze.com> Date: Mon, 24 Jul 2017 10:11:04 +1000 Subject: glsl: add get_internal_ifc_packing() type helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is used to avoid code duplication when selecting the packing type for shared and packed layouts. Reviewed-by: Marek Olšák <marek.olsak@amd.com> --- src/compiler/glsl_types.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/compiler') diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index f67465e6c87..3c18f6cce5b 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -816,6 +816,27 @@ struct glsl_type { 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 */ -- cgit v1.2.3