translate_test: fix segfault on x86-64
authorLuca Barbieri <luca@luca-barbieri.com>
Wed, 11 Aug 2010 20:26:57 +0000 (22:26 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Wed, 11 Aug 2010 20:32:20 +0000 (22:32 +0200)
src/gallium/tests/unit/translate_test.c

index a934a6abf46677ac91bd3bb3b5153a7cb53e9ce5..097a5fd9371b209cbb03fafbb61f67df9178b3c4 100644 (file)
@@ -128,7 +128,7 @@ int main(int argc, char** argv)
    for (output_format = 1; output_format < PIPE_FORMAT_COUNT; ++output_format)
    {
       const struct util_format_description* output_format_desc = util_format_description(output_format);
-      unsigned output_format_size = util_format_get_stride(output_format, 1);
+      unsigned output_format_size;
       if (!output_format_desc
             || !output_format_desc->fetch_rgba_float
             || !output_format_desc->pack_rgba_float
@@ -137,10 +137,12 @@ int main(int argc, char** argv)
             || !translate_is_output_format_supported(output_format))
          continue;
 
+      output_format_size = util_format_get_stride(output_format, 1);
+
       for (input_format = 1; input_format < PIPE_FORMAT_COUNT; ++input_format)
       {
          const struct util_format_description* input_format_desc = util_format_description(input_format);
-         unsigned input_format_size = util_format_get_stride(input_format, 1);
+         unsigned input_format_size;
          struct translate* translate[2];
          unsigned fail = 0;
          unsigned used_generic = 0;
@@ -153,6 +155,8 @@ int main(int argc, char** argv)
                || !translate_is_output_format_supported(input_format))
             continue;
 
+         input_format_size = util_format_get_stride(input_format, 1);
+
          key.element[0].input_format = input_format;
          key.element[0].output_format = output_format;
          key.output_stride = output_format_size;