[Piglit] [PATCH 3/4] arb_shader_image_load_store/image: Expose array of known shader shader stages.

Francisco Jerez currojerez at riseup.net
Tue May 12 05:39:13 PDT 2015


---
 tests/spec/arb_shader_image_load_store/image.c | 24 +++++++++++++++++-------
 tests/spec/arb_shader_image_load_store/image.h |  7 +++++++
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/tests/spec/arb_shader_image_load_store/image.c b/tests/spec/arb_shader_image_load_store/image.c
index 58cda9b..7a1867f 100644
--- a/tests/spec/arb_shader_image_load_store/image.c
+++ b/tests/spec/arb_shader_image_load_store/image.c
@@ -599,9 +599,9 @@ image_target_mipmapping_dimensions(const struct image_target_info *target)
 }
 
 const struct image_stage_info *
-image_stages(void)
+known_image_stages(void)
 {
-        const struct image_stage_info known[] = {
+        static const struct image_stage_info known[] = {
                 { "Vertex", GL_VERTEX_SHADER, GL_VERTEX_SHADER_BIT },
                 { "Tessellation control", GL_TESS_CONTROL_SHADER,
                   GL_TESS_CONTROL_SHADER_BIT },
@@ -610,15 +610,25 @@ image_stages(void)
                 { "Geometry", GL_GEOMETRY_SHADER, GL_GEOMETRY_SHADER_BIT },
                 { "Fragment", GL_FRAGMENT_SHADER, GL_FRAGMENT_SHADER_BIT },
                 { "Compute", GL_COMPUTE_SHADER, GL_COMPUTE_SHADER_BIT },
+                { 0 }
         };
-        static struct image_stage_info supported[ARRAY_SIZE(known) + 1];
+        return known;
+}
+
+const struct image_stage_info *
+image_stages(void)
+{
+        static struct image_stage_info supported[7];
 
         if (!supported[0].name) {
-                int i, n = 0;
+                const struct image_stage_info *stage;
+                int n = 0;
 
-                for (i = 0; i < ARRAY_SIZE(known); ++i) {
-                        if (image_stage_max_images(&known[i]))
-                                supported[n++] = known[i];
+                for (stage = known_image_stages(); stage->stage; ++stage) {
+                        if (image_stage_max_images(stage)) {
+                                assert(n < ARRAY_SIZE(supported) - 1);
+                                supported[n++] = *stage;
+                        }
                 }
         }
 
diff --git a/tests/spec/arb_shader_image_load_store/image.h b/tests/spec/arb_shader_image_load_store/image.h
index f35c89f..fc43f22 100644
--- a/tests/spec/arb_shader_image_load_store/image.h
+++ b/tests/spec/arb_shader_image_load_store/image.h
@@ -264,6 +264,13 @@ struct image_stage_info {
 };
 
 /**
+ * Get all shader stages in pipeline order regardless of whether they
+ * support image access.
+ */
+const struct image_stage_info *
+known_image_stages(void);
+
+/**
  * Get all shader stages that support image access in pipeline order.
  */
 const struct image_stage_info *
-- 
2.3.5



More information about the Piglit mailing list