glsl: add get_internal_ifc_packing() type helper
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 24 Jul 2017 00:11:04 +0000 (10:11 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 22 Aug 2017 01:29:27 +0000 (11:29 +1000)
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

index f67465e6c873e76c1524fb1c284b094d9d7bc7cd..3c18f6cce5b3decfaa03caf18a5c1dd5d89916c3 100644 (file)
@@ -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
     */