Brian Paul <[email protected]> writes:

> On 02/03/2015 01:08 PM, Francisco Jerez wrote:
>> Francisco Jerez <[email protected]> writes:
>>
>>> Francisco Jerez <[email protected]> writes:
>>>
>>>> Brian Paul <[email protected]> writes:
>>>>
>>>>> MSVC doesn't seem to like function calls inside struct initializers.
>>>>
>>>> That's awful.  But fine:
>>>> Reviewed-by: Francisco Jerez <[email protected]>
>>>>
>>> Actually it's surprising that you got it to build with so few changes.
>>> I'd expect you to find *many* more function calls inside struct
>>> initializers.  Does it actually work with this change or did you forget
>>> to include some files?
>>>
>>
>> Brian, if that's the case don't bother to fix all the function calls in
>> struct initalizers, just let me know, I'd like to try a less intrusive
>> solution.
>
> I'm just fixing the errors found via our automated build (which didn't 
> complete).  I don't have a MSVC piglit build on my local system ATM.
>
> -Brian

Hi Brian, if you still have trouble to get this to build with MSVC, can
you give the attached patch a try?

From 53f60bef756107fe155614ab42f72c4ac6d94e65 Mon Sep 17 00:00:00 2001
From: Francisco Jerez <[email protected]>
Date: Wed, 4 Feb 2015 12:25:25 +0200
Subject: [PATCH] arb_shader_image_load_store: Remove remaining function calls
 inside initializer lists.

Hopefully this will make MSVC happy.
---
 tests/spec/arb_shader_image_load_store/coherency.c |  5 +--
 tests/spec/arb_shader_image_load_store/common.c    | 10 ++---
 tests/spec/arb_shader_image_load_store/grid.h      | 34 +++++++++-------
 tests/spec/arb_shader_image_load_store/image.h     | 45 +++++++++++++++-------
 tests/spec/arb_shader_image_load_store/level.c     |  5 +--
 .../spec/arb_shader_image_load_store/max-images.c  |  8 ++--
 tests/spec/arb_shader_image_load_store/max-size.c  | 22 ++++-------
 tests/spec/arb_shader_image_load_store/semantics.c |  5 +--
 8 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/tests/spec/arb_shader_image_load_store/coherency.c b/tests/spec/arb_shader_image_load_store/coherency.c
index 5a5bbdd..7b23c69 100644
--- a/tests/spec/arb_shader_image_load_store/coherency.c
+++ b/tests/spec/arb_shader_image_load_store/coherency.c
@@ -127,11 +127,10 @@ run_test(const struct image_qualifier_info *qual,
          const struct image_stage_info *stage_r,
          unsigned l)
 {
-        const struct grid_info grid = {
+        const struct grid_info grid = _grid_info(
                 stage_w->bit | stage_r->bit,
                 get_image_format(GL_RGBA32UI),
-                { l, l, 1, 1 }
-        };
+                image_extent(l, l, 1, 1));
         const struct image_info img = image_info_for_grid(grid);
         GLuint prog = generate_program(
                 grid,
diff --git a/tests/spec/arb_shader_image_load_store/common.c b/tests/spec/arb_shader_image_load_store/common.c
index 88b0f75..4ed1056 100644
--- a/tests/spec/arb_shader_image_load_store/common.c
+++ b/tests/spec/arb_shader_image_load_store/common.c
@@ -277,11 +277,10 @@ upload_image_levels(const struct image_info img, unsigned num_levels,
                  * shader copying the contents of a larger
                  * single-sample 2D texture.
                  */
-                const struct grid_info grid = {
+                const struct grid_info grid = _grid_info(
                         get_image_stage(GL_FRAGMENT_SHADER)->bit,
                         img.format,
-                        image_optimal_extent(img.size)
-                };
+                        image_optimal_extent(img.size));
                 GLuint prog = generate_program(
                         grid, GL_FRAGMENT_SHADER,
                         concat(image_hunk(image_info_for_grid(grid), "SRC_"),
@@ -438,11 +437,10 @@ download_image_levels(const struct image_info img, unsigned num_levels,
                  * to copy its contents to a larger single-sample 2D
                  * texture from the fragment shader.
                  */
-                const struct grid_info grid = {
+                const struct grid_info grid = _grid_info(
                         get_image_stage(GL_FRAGMENT_SHADER)->bit,
                         img.format,
-                        image_optimal_extent(img.size)
-                };
+                        image_optimal_extent(img.size));
                 GLuint prog = generate_program(
                         grid, GL_FRAGMENT_SHADER,
                         concat(image_hunk(img, "SRC_"),
diff --git a/tests/spec/arb_shader_image_load_store/grid.h b/tests/spec/arb_shader_image_load_store/grid.h
index fca67ce..d9444a4 100644
--- a/tests/spec/arb_shader_image_load_store/grid.h
+++ b/tests/spec/arb_shader_image_load_store/grid.h
@@ -46,25 +46,34 @@ struct grid_info {
 };
 
 /**
+ * Full constructor for a grid_info object.
+ *
+ * Use instead of an initializer list because MSVC doesn't support
+ * function calls inside initializer lists.
+ */
+static inline struct grid_info
+_grid_info(unsigned stages, const struct image_format_info *format,
+           struct image_extent size)
+{
+        const struct grid_info grid = { stages, format, size };
+        return grid;
+}
+
+/**
  * Construct a grid_info object.
  */
 static inline struct grid_info
 grid_info(GLenum stage, GLenum format, unsigned w, unsigned h)
 {
-        const struct grid_info grid = {
-                get_image_stage(stage)->bit,
-                get_image_format(format),
-                { w, h, 1, 1 }
-        };
-
-        return grid;
+        return _grid_info(get_image_stage(stage)->bit,
+                          get_image_format(format),
+                          image_extent(w, h, 1, 1));
 }
 
 static inline struct grid_info
 set_grid_size(struct grid_info grid, unsigned x, unsigned y)
 {
-        const struct image_extent size = { x, y, 1, 1 };
-        grid.size = size;
+        grid.size = image_extent(x, y, 1, 1);
         return grid;
 }
 
@@ -75,13 +84,10 @@ set_grid_size(struct grid_info grid, unsigned x, unsigned y)
 static inline struct image_info
 image_info_for_grid(const struct grid_info grid)
 {
-        const struct image_info img = {
+        return _image_info(
                 get_image_target(GL_TEXTURE_2D),
                 grid.format, grid.size,
-                image_format_epsilon(grid.format)
-        };
-
-        return img;
+                image_format_epsilon(grid.format));
 }
 
 /**
diff --git a/tests/spec/arb_shader_image_load_store/image.h b/tests/spec/arb_shader_image_load_store/image.h
index ba4134a..b5730a0 100644
--- a/tests/spec/arb_shader_image_load_store/image.h
+++ b/tests/spec/arb_shader_image_load_store/image.h
@@ -61,6 +61,16 @@ struct image_extent {
         unsigned w;
 };
 
+/**
+ * Construct an image_extent object.
+ */
+static inline struct image_extent
+image_extent(unsigned x, unsigned y, unsigned z, unsigned w)
+{
+   const struct image_extent size = { x, y, z, w };
+   return size;
+}
+
 #define get_idx(v, i)                          \
         ((i) == 0 ? (v).x :                    \
          (i) == 1 ? (v).y :                    \
@@ -309,6 +319,22 @@ struct image_info {
 };
 
 /**
+ * Full constructor for an image_info object.
+ *
+ * Use instead of an initializer list because MSVC doesn't support
+ * function calls inside initializer lists.
+ */
+static inline struct image_info
+_image_info(const struct image_target_info *target,
+            const struct image_format_info *format,
+            struct image_extent size,
+            struct image_datum epsilon)
+{
+        const struct image_info img = { target, format, size, epsilon };
+        return img;
+}
+
+/**
  * Construct an image_info object.
  */
 static inline struct image_info
@@ -316,13 +342,8 @@ image_info(GLenum target, GLenum format, unsigned w, unsigned h)
 {
         const struct image_target_info *t = get_image_target(target);
         const struct image_format_info *f = get_image_format(format);
-        struct image_info img;
-        img.target = t;
-        img.format = f;
-        img.size = image_extent_for_target(t, w, h);
-        img.epsilon = image_format_epsilon(f);
-
-        return img;
+        return _image_info(t, f, image_extent_for_target(t, w, h),
+                           image_format_epsilon(f));
 }
 
 /**
@@ -374,13 +395,9 @@ image_level_offset(const struct image_info img, unsigned l)
 static inline struct image_info
 image_info_for_level(struct image_info img, unsigned l)
 {
-        struct image_info level_img;
-        level_img.target = img.target;
-        level_img.format = img.format;
-        level_img.size = image_level_size(img, l);
-        level_img.epsilon = img.epsilon;
-
-        return level_img;
+        return _image_info(img.target, img.format,
+                           image_level_size(img, l),
+                           img.epsilon);
 }
 
 #endif
diff --git a/tests/spec/arb_shader_image_load_store/level.c b/tests/spec/arb_shader_image_load_store/level.c
index 5fbdbaf..6c8a876 100644
--- a/tests/spec/arb_shader_image_load_store/level.c
+++ b/tests/spec/arb_shader_image_load_store/level.c
@@ -146,10 +146,9 @@ run_test(const struct image_target_info *target)
         const struct image_info img = image_info(
                 target->target, GL_RGBA32F, W, H);
         const struct image_info level_img = image_info_for_level(img, level);
-        const struct grid_info grid = {
+        const struct grid_info grid = _grid_info(
                 GL_FRAGMENT_SHADER_BIT, img.format,
-                image_optimal_extent(level_img.size)
-        };
+                image_optimal_extent(level_img.size));
         GLuint prog = generate_program(
                 grid, GL_FRAGMENT_SHADER,
                 concat(image_hunk(level_img, ""),
diff --git a/tests/spec/arb_shader_image_load_store/max-images.c b/tests/spec/arb_shader_image_load_store/max-images.c
index 1e1186c..49aa00f 100644
--- a/tests/spec/arb_shader_image_load_store/max-images.c
+++ b/tests/spec/arb_shader_image_load_store/max-images.c
@@ -207,11 +207,9 @@ check(const struct grid_info grid, const struct image_info img)
 static bool
 run_test(GLbitfield shaders)
 {
-        const struct grid_info grid = {
-                shaders,
-                get_image_format(GL_R32UI),
-                { W, H, 1, 1 }
-        };
+        const struct grid_info grid = _grid_info(
+                shaders, get_image_format(GL_R32UI),
+                image_extent(W, H, 1, 1));
         const struct image_info img = image_info_for_grid(grid);
         GLuint prog = generate_program(
                 grid,
diff --git a/tests/spec/arb_shader_image_load_store/max-size.c b/tests/spec/arb_shader_image_load_store/max-size.c
index dbab17c..f761500 100644
--- a/tests/spec/arb_shader_image_load_store/max-size.c
+++ b/tests/spec/arb_shader_image_load_store/max-size.c
@@ -80,20 +80,14 @@ static bool
 run_test(const struct image_target_info *target,
          const struct image_extent size)
 {
-        struct grid_info grid;
-        struct image_info img;
-        GLuint prog;
-
-        grid.stages = GL_FRAGMENT_SHADER_BIT;
-        grid.format = get_image_format(GL_RGBA32F);
-        grid.size = image_optimal_extent(size);
-
-        img.target = target;
-        img.format = grid.format;
-        img.size = size;
-        img.epsilon = image_format_epsilon(grid.format);
-
-        prog = generate_program(
+        const struct grid_info grid = _grid_info(
+                GL_FRAGMENT_SHADER_BIT,
+                get_image_format(GL_RGBA32F),
+                image_optimal_extent(size));
+        const struct image_info img = _image_info(
+                target, grid.format, size,
+                image_format_epsilon(grid.format));
+        GLuint prog = generate_program(
                 grid, GL_FRAGMENT_SHADER,
                 concat(image_hunk(img, ""),
                        hunk("readonly uniform IMAGE_T src_img;\n"
diff --git a/tests/spec/arb_shader_image_load_store/semantics.c b/tests/spec/arb_shader_image_load_store/semantics.c
index 122e490..a27cad3 100644
--- a/tests/spec/arb_shader_image_load_store/semantics.c
+++ b/tests/spec/arb_shader_image_load_store/semantics.c
@@ -271,10 +271,9 @@ check(const struct image_op_info *op,
       const struct grid_info grid,
       const struct image_info img)
 {
-        const struct image_info grid_img = {
+        const struct image_info grid_img = _image_info(
                 get_image_target(GL_TEXTURE_2D),
-                grid.format, grid.size, img.epsilon
-        };
+                grid.format, grid.size, img.epsilon);
         const unsigned m = image_num_components(img.format);
         uint32_t pixels_fb[4 * N], expect_fb[4 * N];
         uint32_t pixels_img[4 * N], expect_img[4 * N];
-- 
2.1.3

Attachment: pgpWIYZdSHvWg.pgp
Description: PGP signature

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to