glsl,nir: Switch the enum representing shader image formats to PIPE_FORMAT.
authorEric Anholt <eric@anholt.net>
Fri, 10 Jan 2020 22:09:43 +0000 (14:09 -0800)
committerEric Anholt <eric@anholt.net>
Wed, 5 Feb 2020 18:31:14 +0000 (10:31 -0800)
This means you can directly use format utils on it without having to have
your own GL enum to number-of-components switch statement (or whatever) in
your vulkan backend.

Thanks to imirkin for fixing up the nouveau driver (and a couple of core
details).

This fixes the computed qualifiers for EXT_shader_image_load_store's
non-integer sizeNxM qualifiers, which we don't have tests for.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> (v3d)
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3355>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3355>

22 files changed:
src/broadcom/compiler/v3d_nir_lower_image_load_store.c
src/compiler/glsl/ast.h
src/compiler/glsl/ast_to_hir.cpp
src/compiler/glsl/builtin_variables.cpp
src/compiler/glsl/glsl_parser.yy
src/compiler/glsl/ir.cpp
src/compiler/glsl/ir.h
src/compiler/glsl_types.h
src/compiler/nir/nir.h
src/compiler/nir/nir_print.c
src/compiler/spirv/spirv_to_nir.c
src/freedreno/ir3/ir3_a4xx.c
src/freedreno/ir3/ir3_a6xx.c
src/freedreno/ir3/ir3_image.c
src/freedreno/ir3/ir3_image.h
src/gallium/auxiliary/nir/tgsi_to_nir.c
src/gallium/drivers/nouveau/codegen/nv50_ir.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir.h
src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
src/intel/compiler/brw_nir_lower_image_load_store.c
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 2aa3cbad4956ada5a0b620c9cbddd27c2683dcae..e4db541f1b426f052355672da73be020929c70b2 100644 (file)
  */
 
 bool
-v3d_gl_format_is_return_32(GLenum format)
+v3d_gl_format_is_return_32(enum pipe_format format)
 {
-        switch (format) {
-        case GL_R8:
-        case GL_R8_SNORM:
-        case GL_R8UI:
-        case GL_R8I:
-        case GL_RG8:
-        case GL_RG8_SNORM:
-        case GL_RG8UI:
-        case GL_RG8I:
-        case GL_RGBA8:
-        case GL_RGBA8_SNORM:
-        case GL_RGBA8UI:
-        case GL_RGBA8I:
-        case GL_R11F_G11F_B10F:
-        case GL_RGB10_A2:
-        case GL_RGB10_A2UI:
-        case GL_R16F:
-        case GL_R16UI:
-        case GL_R16I:
-        case GL_RG16F:
-        case GL_RG16UI:
-        case GL_RG16I:
-        case GL_RGBA16F:
-        case GL_RGBA16UI:
-        case GL_RGBA16I:
-                return false;
-        case GL_R16:
-        case GL_R16_SNORM:
-        case GL_RG16:
-        case GL_RG16_SNORM:
-        case GL_RGBA16:
-        case GL_RGBA16_SNORM:
-        case GL_R32F:
-        case GL_R32UI:
-        case GL_R32I:
-        case GL_RG32F:
-        case GL_RG32UI:
-        case GL_RG32I:
-        case GL_RGBA32F:
-        case GL_RGBA32UI:
-        case GL_RGBA32I:
-                return true;
-        default:
-                unreachable("Invalid image format");
-        }
+        const struct util_format_description *desc =
+                util_format_description(format);
+        const struct util_format_channel_description *chan = &desc->channel[0];
+
+        return chan->size > 16 || (chan->size == 16 && chan->normalized);
 }
 
 /* Packs a 32-bit vector of colors in the range [0, (1 << bits[i]) - 1] to a
@@ -124,192 +84,75 @@ pack_bits(nir_builder *b, nir_ssa_def *color, const unsigned *bits,
         return nir_vec(b, results, DIV_ROUND_UP(offset, 32));
 }
 
-static nir_ssa_def *
-pack_unorm(nir_builder *b, nir_ssa_def *color, const unsigned *bits,
-           int num_components)
-{
-        color = nir_channels(b, color, (1 << num_components) - 1);
-        color = nir_format_float_to_unorm(b, color, bits);
-        return pack_bits(b, color, bits, color->num_components, false);
-}
-
-static nir_ssa_def *
-pack_snorm(nir_builder *b, nir_ssa_def *color, const unsigned *bits,
-           int num_components)
-{
-        color = nir_channels(b, color, (1 << num_components) - 1);
-        color = nir_format_float_to_snorm(b, color, bits);
-        return pack_bits(b, color, bits, color->num_components, true);
-}
-
-static nir_ssa_def *
-pack_uint(nir_builder *b, nir_ssa_def *color, const unsigned *bits,
-          int num_components)
-{
-        color = nir_channels(b, color, (1 << num_components) - 1);
-        color = nir_format_clamp_uint(b, color, bits);
-        return pack_bits(b, color, bits, num_components, false);
-}
-
-static nir_ssa_def *
-pack_sint(nir_builder *b, nir_ssa_def *color, const unsigned *bits,
-          int num_components)
-{
-        color = nir_channels(b, color, (1 << num_components) - 1);
-        color = nir_format_clamp_sint(b, color, bits);
-        return pack_bits(b, color, bits, num_components, true);
-}
-
-static nir_ssa_def *
-pack_half(nir_builder *b, nir_ssa_def *color, const unsigned *bits,
-          int num_components)
-{
-        color = nir_channels(b, color, (1 << num_components) - 1);
-        color = nir_format_float_to_half(b, color);
-        return pack_bits(b, color, bits, color->num_components, false);
-}
-
 static void
 v3d_nir_lower_image_store(nir_builder *b, nir_intrinsic_instr *instr)
 {
         nir_variable *var = nir_intrinsic_get_var(instr, 0);
-        GLenum format = var->data.image.format;
-        static const unsigned bits_8[4] = {8, 8, 8, 8};
-        static const unsigned bits_16[4] = {16, 16, 16, 16};
-        static const unsigned bits_1010102[4] = {10, 10, 10, 2};
+        enum pipe_format format = var->data.image.format;
+        const struct util_format_description *desc =
+                util_format_description(format);
+        const struct util_format_channel_description *r_chan = &desc->channel[0];
+        unsigned num_components = util_format_get_nr_components(format);
 
         b->cursor = nir_before_instr(&instr->instr);
 
-        nir_ssa_def *unformatted = nir_ssa_for_src(b, instr->src[3], 4);
+        nir_ssa_def *color = nir_channels(b,
+                                          nir_ssa_for_src(b, instr->src[3], 4),
+                                          (1 << num_components) - 1);
         nir_ssa_def *formatted = NULL;
-        switch (format) {
-        case GL_RGBA32F:
-        case GL_RGBA32UI:
-        case GL_RGBA32I:
-                /* For 4-component 32-bit components, there's no packing to be
-                 * done.
-                 */
-                return;
 
-        case GL_R32F:
-        case GL_R32UI:
-        case GL_R32I:
-                /* For other 32-bit components, just reduce the size of
-                 * the input vector.
+        if (format == PIPE_FORMAT_R11G11B10_FLOAT) {
+                formatted = nir_format_pack_11f11f10f(b, color);
+        } else if (format == PIPE_FORMAT_R9G9B9E5_FLOAT) {
+                formatted = nir_format_pack_r9g9b9e5(b, color);
+        } else if (r_chan->size == 32) {
+                /* For 32-bit formats, we just have to move the vector
+                 * across (possibly reducing the number of channels).
                  */
-                formatted = nir_channels(b, unformatted, 1);
-                break;
-        case GL_RG32F:
-        case GL_RG32UI:
-        case GL_RG32I:
-                formatted = nir_channels(b, unformatted, 2);
-                break;
-
-        case GL_R8:
-                formatted = pack_unorm(b, unformatted, bits_8, 1);
-                break;
-        case GL_RG8:
-                formatted = pack_unorm(b, unformatted, bits_8, 2);
-                break;
-        case GL_RGBA8:
-                formatted = pack_unorm(b, unformatted, bits_8, 4);
-                break;
-
-        case GL_R8_SNORM:
-                formatted = pack_snorm(b, unformatted, bits_8, 1);
-                break;
-        case GL_RG8_SNORM:
-                formatted = pack_snorm(b, unformatted, bits_8, 2);
-                break;
-        case GL_RGBA8_SNORM:
-                formatted = pack_snorm(b, unformatted, bits_8, 4);
-                break;
-
-        case GL_R16:
-                formatted = pack_unorm(b, unformatted, bits_16, 1);
-                break;
-        case GL_RG16:
-                formatted = pack_unorm(b, unformatted, bits_16, 2);
-                break;
-        case GL_RGBA16:
-                formatted = pack_unorm(b, unformatted, bits_16, 4);
-                break;
-
-        case GL_R16_SNORM:
-                formatted = pack_snorm(b, unformatted, bits_16, 1);
-                break;
-        case GL_RG16_SNORM:
-                formatted = pack_snorm(b, unformatted, bits_16, 2);
-                break;
-        case GL_RGBA16_SNORM:
-                formatted = pack_snorm(b, unformatted, bits_16, 4);
-                break;
-
-        case GL_R16F:
-                formatted = pack_half(b, unformatted, bits_16, 1);
-                break;
-        case GL_RG16F:
-                formatted = pack_half(b, unformatted, bits_16, 2);
-                break;
-        case GL_RGBA16F:
-                formatted = pack_half(b, unformatted, bits_16, 4);
-                break;
-
-        case GL_R8UI:
-                formatted = pack_uint(b, unformatted, bits_8, 1);
-                break;
-        case GL_R8I:
-                formatted = pack_sint(b, unformatted, bits_8, 1);
-                break;
-        case GL_RG8UI:
-                formatted = pack_uint(b, unformatted, bits_8, 2);
-                break;
-        case GL_RG8I:
-                formatted = pack_sint(b, unformatted, bits_8, 2);
-                break;
-        case GL_RGBA8UI:
-                formatted = pack_uint(b, unformatted, bits_8, 4);
-                break;
-        case GL_RGBA8I:
-                formatted = pack_sint(b, unformatted, bits_8, 4);
-                break;
-
-        case GL_R16UI:
-                formatted = pack_uint(b, unformatted, bits_16, 1);
-                break;
-        case GL_R16I:
-                formatted = pack_sint(b, unformatted, bits_16, 1);
-                break;
-        case GL_RG16UI:
-                formatted = pack_uint(b, unformatted, bits_16, 2);
-                break;
-        case GL_RG16I:
-                formatted = pack_sint(b, unformatted, bits_16, 2);
-                break;
-        case GL_RGBA16UI:
-                formatted = pack_uint(b, unformatted, bits_16, 4);
-                break;
-        case GL_RGBA16I:
-                formatted = pack_sint(b, unformatted, bits_16, 4);
-                break;
-
-        case GL_R11F_G11F_B10F:
-                formatted = nir_format_pack_11f11f10f(b, unformatted);
-                break;
-        case GL_RGB9_E5:
-                formatted = nir_format_pack_r9g9b9e5(b, unformatted);
-                break;
-
-        case GL_RGB10_A2:
-                formatted = pack_unorm(b, unformatted, bits_1010102, 4);
-                break;
+                formatted = color;
+        } else {
+                static const unsigned bits_8[4] = {8, 8, 8, 8};
+                static const unsigned bits_16[4] = {16, 16, 16, 16};
+                static const unsigned bits_1010102[4] = {10, 10, 10, 2};
+                const unsigned *bits;
+
+                switch (r_chan->size) {
+                case 8:
+                        bits = bits_8;
+                        break;
+                case 10:
+                        bits = bits_1010102;
+                        break;
+                case 16:
+                        bits = bits_16;
+                        break;
+                default:
+                        unreachable("unrecognized bits");
+                }
 
-        case GL_RGB10_A2UI:
-                formatted = pack_uint(b, unformatted, bits_1010102, 4);
-                break;
+                bool pack_mask = false;
+                if (r_chan->pure_integer &&
+                    r_chan->type == UTIL_FORMAT_TYPE_SIGNED) {
+                        formatted = nir_format_clamp_sint(b, color, bits);
+                        pack_mask = true;
+                } else if (r_chan->pure_integer &&
+                           r_chan->type == UTIL_FORMAT_TYPE_UNSIGNED) {
+                        formatted = nir_format_clamp_uint(b, color, bits);
+                } else if (r_chan->normalized &&
+                           r_chan->type == UTIL_FORMAT_TYPE_SIGNED) {
+                        formatted = nir_format_float_to_snorm(b, color, bits);
+                        pack_mask = true;
+                } else if (r_chan->normalized &&
+                           r_chan->type == UTIL_FORMAT_TYPE_UNSIGNED) {
+                        formatted = nir_format_float_to_unorm(b, color, bits);
+                } else {
+                        assert(r_chan->size == 16);
+                        assert(r_chan->type == UTIL_FORMAT_TYPE_FLOAT);
+                        formatted = nir_format_float_to_half(b, color);
+                }
 
-        default:
-                unreachable("bad format");
+                formatted = pack_bits(b, formatted, bits, num_components,
+                                      pack_mask);
         }
 
         nir_instr_rewrite_src(&instr->instr, &instr->src[3],
index 67b258ce5386249199c8c80180551d72441b09f2..f6487643d42ced7dc379a2af3f15dc9d6289bad6 100644 (file)
@@ -773,7 +773,7 @@ struct ast_type_qualifier {
     * \note
     * This field is only valid if \c explicit_image_format is set.
     */
-   GLenum image_format;
+   enum pipe_format image_format;
 
    /**
     * Arrangement of invocations used to calculate derivatives in a compute
index 7b7f6aff62aced4a3045d0c6b444f959fed8fee3..cc1bb16bb64583d622298af846b869286afa9e82 100644 (file)
@@ -3497,7 +3497,7 @@ apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
                              "`writeonly' must have a format layout qualifier");
          }
       }
-      var->data.image_format = GL_NONE;
+      var->data.image_format = PIPE_FORMAT_NONE;
    }
 
    /* From page 70 of the GLSL ES 3.1 specification:
@@ -3507,9 +3507,9 @@ apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
     *  readonly or the memory qualifier writeonly."
     */
    if (state->es_shader &&
-       var->data.image_format != GL_R32F &&
-       var->data.image_format != GL_R32I &&
-       var->data.image_format != GL_R32UI &&
+       var->data.image_format != PIPE_FORMAT_R32_FLOAT &&
+       var->data.image_format != PIPE_FORMAT_R32_SINT &&
+       var->data.image_format != PIPE_FORMAT_R32_UINT &&
        !var->data.memory_read_only &&
        !var->data.memory_write_only) {
       _mesa_glsl_error(loc, state, "image variables of format other than r32f, "
@@ -4947,12 +4947,50 @@ ast_declarator_list::hir(exec_list *instructions,
        *       size4x32      rgba32f   rgba32i   rgba32ui"
        */
       if (strncmp(this->type->specifier->type_name, "image", strlen("image")) == 0) {
-         this->type->qualifier.image_format = GL_R8 +
-                                         this->type->qualifier.image_format - GL_R8I;
+         switch (this->type->qualifier.image_format) {
+         case PIPE_FORMAT_R8_SINT:
+            /* No valid qualifier in this case, driver will need to look at
+             * the underlying image's format (just like no qualifier being
+             * present).
+             */
+            this->type->qualifier.image_format = PIPE_FORMAT_NONE;
+            break;
+         case PIPE_FORMAT_R16_SINT:
+            this->type->qualifier.image_format = PIPE_FORMAT_R16_FLOAT;
+            break;
+         case PIPE_FORMAT_R32_SINT:
+            this->type->qualifier.image_format = PIPE_FORMAT_R32_FLOAT;
+            break;
+         case PIPE_FORMAT_R32G32_SINT:
+            this->type->qualifier.image_format = PIPE_FORMAT_R32G32_FLOAT;
+            break;
+         case PIPE_FORMAT_R32G32B32A32_SINT:
+            this->type->qualifier.image_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+            break;
+         default:
+            unreachable("Unknown image format");
+         }
          this->type->qualifier.image_base_type = GLSL_TYPE_FLOAT;
       } else if (strncmp(this->type->specifier->type_name, "uimage", strlen("uimage")) == 0) {
-         this->type->qualifier.image_format = GL_R8UI +
-                                         this->type->qualifier.image_format - GL_R8I;
+         switch (this->type->qualifier.image_format) {
+         case PIPE_FORMAT_R8_SINT:
+            this->type->qualifier.image_format = PIPE_FORMAT_R8_UINT;
+            break;
+         case PIPE_FORMAT_R16_SINT:
+            this->type->qualifier.image_format = PIPE_FORMAT_R16_UINT;
+            break;
+         case PIPE_FORMAT_R32_SINT:
+            this->type->qualifier.image_format = PIPE_FORMAT_R32_UINT;
+            break;
+         case PIPE_FORMAT_R32G32_SINT:
+            this->type->qualifier.image_format = PIPE_FORMAT_R32G32_UINT;
+            break;
+         case PIPE_FORMAT_R32G32B32A32_SINT:
+            this->type->qualifier.image_format = PIPE_FORMAT_R32G32B32A32_UINT;
+            break;
+         default:
+            unreachable("Unknown image format");
+         }
          this->type->qualifier.image_base_type = GLSL_TYPE_UINT;
       } else if (strncmp(this->type->specifier->type_name, "iimage", strlen("iimage")) == 0) {
          this->type->qualifier.image_base_type = GLSL_TYPE_INT;
@@ -7630,7 +7668,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
                                       "qualifier");
                   }
 
-                  fields[i].image_format = GL_NONE;
+                  fields[i].image_format = PIPE_FORMAT_NONE;
                }
             }
          }
index cf2a233d15f96d6e8b41798355699baf46eacb2a..6f96083732100cf41afb029bfffb822e750ffec3 100644 (file)
@@ -351,7 +351,7 @@ per_vertex_accumulator::add_field(int slot, const glsl_type *type,
    this->fields[this->num_fields].memory_coherent = 0;
    this->fields[this->num_fields].memory_volatile = 0;
    this->fields[this->num_fields].memory_restrict = 0;
-   this->fields[this->num_fields].image_format = 0;
+   this->fields[this->num_fields].image_format = PIPE_FORMAT_NONE;
    this->fields[this->num_fields].explicit_xfb_buffer = 0;
    this->fields[this->num_fields].xfb_buffer = -1;
    this->fields[this->num_fields].xfb_stride = -1;
index 048af1f085747b5e4a42dcc5f1290b188f66ec00..dc8a8b3db0147134b5192a552e8c48bf255e510f 100644 (file)
@@ -34,6 +34,7 @@
 #include "compiler/glsl_types.h"
 #include "main/context.h"
 #include "util/u_string.h"
+#include "util/format/u_format.h"
 
 #ifdef _MSC_VER
 #pragma warning( disable : 4065 ) // switch statement contains 'default' but no 'case' labels
@@ -1336,7 +1337,7 @@ layout_qualifier_id:
          if (!$$.flags.i) {
             static const struct {
                const char *name;
-               GLenum format;
+               enum pipe_format format;
                glsl_base_type base_type;
                /** Minimum desktop GLSL version required for the image
                 * format.  Use 130 if already present in the original
@@ -1349,54 +1350,54 @@ layout_qualifier_id:
                bool nv_image_formats;
                bool ext_qualifiers;
             } map[] = {
-               { "rgba32f", GL_RGBA32F, GLSL_TYPE_FLOAT, 130, 310, false, false },
-               { "rgba16f", GL_RGBA16F, GLSL_TYPE_FLOAT, 130, 310, false, false },
-               { "rg32f", GL_RG32F, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "rg16f", GL_RG16F, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "r11f_g11f_b10f", GL_R11F_G11F_B10F, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "r32f", GL_R32F, GLSL_TYPE_FLOAT, 130, 310, false, false },
-               { "r16f", GL_R16F, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "rgba32ui", GL_RGBA32UI, GLSL_TYPE_UINT, 130, 310, false, false },
-               { "rgba16ui", GL_RGBA16UI, GLSL_TYPE_UINT, 130, 310, false, false },
-               { "rgb10_a2ui", GL_RGB10_A2UI, GLSL_TYPE_UINT, 130, 0, true, false },
-               { "rgba8ui", GL_RGBA8UI, GLSL_TYPE_UINT, 130, 310, false, false },
-               { "rg32ui", GL_RG32UI, GLSL_TYPE_UINT, 130, 0, true, false },
-               { "rg16ui", GL_RG16UI, GLSL_TYPE_UINT, 130, 0, true, false },
-               { "rg8ui", GL_RG8UI, GLSL_TYPE_UINT, 130, 0, true, false },
-               { "r32ui", GL_R32UI, GLSL_TYPE_UINT, 130, 310, false, false },
-               { "r16ui", GL_R16UI, GLSL_TYPE_UINT, 130, 0, true, false },
-               { "r8ui", GL_R8UI, GLSL_TYPE_UINT, 130, 0, true, false },
-               { "rgba32i", GL_RGBA32I, GLSL_TYPE_INT, 130, 310, false, false },
-               { "rgba16i", GL_RGBA16I, GLSL_TYPE_INT, 130, 310, false, false },
-               { "rgba8i", GL_RGBA8I, GLSL_TYPE_INT, 130, 310, false, false },
-               { "rg32i", GL_RG32I, GLSL_TYPE_INT, 130, 0, true, false },
-               { "rg16i", GL_RG16I, GLSL_TYPE_INT, 130, 0, true, false },
-               { "rg8i", GL_RG8I, GLSL_TYPE_INT, 130, 0, true, false },
-               { "r32i", GL_R32I, GLSL_TYPE_INT, 130, 310, false, false },
-               { "r16i", GL_R16I, GLSL_TYPE_INT, 130, 0, true, false },
-               { "r8i", GL_R8I, GLSL_TYPE_INT, 130, 0, true, false },
-               { "rgba16", GL_RGBA16, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "rgb10_a2", GL_RGB10_A2, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "rgba8", GL_RGBA8, GLSL_TYPE_FLOAT, 130, 310, false, false },
-               { "rg16", GL_RG16, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "rg8", GL_RG8, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "r16", GL_R16, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "r8", GL_R8, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "rgba16_snorm", GL_RGBA16_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "rgba8_snorm", GL_RGBA8_SNORM, GLSL_TYPE_FLOAT, 130, 310, false, false },
-               { "rg16_snorm", GL_RG16_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "rg8_snorm", GL_RG8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "r16_snorm", GL_R16_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
-               { "r8_snorm", GL_R8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "rgba32f", PIPE_FORMAT_R32G32B32A32_FLOAT, GLSL_TYPE_FLOAT, 130, 310, false, false },
+               { "rgba16f", PIPE_FORMAT_R16G16B16A16_FLOAT, GLSL_TYPE_FLOAT, 130, 310, false, false },
+               { "rg32f", PIPE_FORMAT_R32G32_FLOAT, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "rg16f", PIPE_FORMAT_R16G16_FLOAT, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "r11f_g11f_b10f", PIPE_FORMAT_R11G11B10_FLOAT, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "r32f", PIPE_FORMAT_R32_FLOAT, GLSL_TYPE_FLOAT, 130, 310, false, false },
+               { "r16f", PIPE_FORMAT_R16_FLOAT, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "rgba32ui", PIPE_FORMAT_R32G32B32A32_UINT, GLSL_TYPE_UINT, 130, 310, false, false },
+               { "rgba16ui", PIPE_FORMAT_R16G16B16A16_UINT, GLSL_TYPE_UINT, 130, 310, false, false },
+               { "rgb10_a2ui", PIPE_FORMAT_R10G10B10A2_UINT, GLSL_TYPE_UINT, 130, 0, true, false },
+               { "rgba8ui", PIPE_FORMAT_R8G8B8A8_UINT, GLSL_TYPE_UINT, 130, 310, false, false },
+               { "rg32ui", PIPE_FORMAT_R32G32_UINT, GLSL_TYPE_UINT, 130, 0, true, false },
+               { "rg16ui", PIPE_FORMAT_R16G16_UINT, GLSL_TYPE_UINT, 130, 0, true, false },
+               { "rg8ui", PIPE_FORMAT_R8G8_UINT, GLSL_TYPE_UINT, 130, 0, true, false },
+               { "r32ui", PIPE_FORMAT_R32_UINT, GLSL_TYPE_UINT, 130, 310, false, false },
+               { "r16ui", PIPE_FORMAT_R16_UINT, GLSL_TYPE_UINT, 130, 0, true, false },
+               { "r8ui", PIPE_FORMAT_R8_UINT, GLSL_TYPE_UINT, 130, 0, true, false },
+               { "rgba32i", PIPE_FORMAT_R32G32B32A32_SINT, GLSL_TYPE_INT, 130, 310, false, false },
+               { "rgba16i", PIPE_FORMAT_R16G16B16A16_SINT, GLSL_TYPE_INT, 130, 310, false, false },
+               { "rgba8i", PIPE_FORMAT_R8G8B8A8_SINT, GLSL_TYPE_INT, 130, 310, false, false },
+               { "rg32i", PIPE_FORMAT_R32G32_SINT, GLSL_TYPE_INT, 130, 0, true, false },
+               { "rg16i", PIPE_FORMAT_R16G16_SINT, GLSL_TYPE_INT, 130, 0, true, false },
+               { "rg8i", PIPE_FORMAT_R8G8_SINT, GLSL_TYPE_INT, 130, 0, true, false },
+               { "r32i", PIPE_FORMAT_R32_SINT, GLSL_TYPE_INT, 130, 310, false, false },
+               { "r16i", PIPE_FORMAT_R16_SINT, GLSL_TYPE_INT, 130, 0, true, false },
+               { "r8i", PIPE_FORMAT_R8_SINT, GLSL_TYPE_INT, 130, 0, true, false },
+               { "rgba16", PIPE_FORMAT_R16G16B16A16_UNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "rgb10_a2", PIPE_FORMAT_R10G10B10A2_UNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "rgba8", PIPE_FORMAT_R8G8B8A8_UNORM, GLSL_TYPE_FLOAT, 130, 310, false, false },
+               { "rg16", PIPE_FORMAT_R16G16_UNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "rg8", PIPE_FORMAT_R8G8_UNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "r16", PIPE_FORMAT_R16_UNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "r8", PIPE_FORMAT_R8_UNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "rgba16_snorm", PIPE_FORMAT_R16G16B16A16_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "rgba8_snorm", PIPE_FORMAT_R8G8B8A8_SNORM, GLSL_TYPE_FLOAT, 130, 310, false, false },
+               { "rg16_snorm", PIPE_FORMAT_R16G16_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "rg8_snorm", PIPE_FORMAT_R8G8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "r16_snorm", PIPE_FORMAT_R16_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
+               { "r8_snorm", PIPE_FORMAT_R8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true, false },
 
                /* From GL_EXT_shader_image_load_store: */
                /* base_type is incorrect but it'll be patched later when we know
                 * the variable type. See ast_to_hir.cpp */
-               { "size1x8", GL_R8I, GLSL_TYPE_VOID, 130, 0, false, true },
-               { "size1x16", GL_R16I, GLSL_TYPE_VOID, 130, 0, false, true },
-               { "size1x32", GL_R32I, GLSL_TYPE_VOID, 130, 0, false, true },
-               { "size2x32", GL_RG32I, GLSL_TYPE_VOID, 130, 0, false, true },
-               { "size4x32", GL_RGBA32I, GLSL_TYPE_VOID, 130, 0, false, true },
+               { "size1x8", PIPE_FORMAT_R8_SINT, GLSL_TYPE_VOID, 130, 0, false, true },
+               { "size1x16", PIPE_FORMAT_R16_SINT, GLSL_TYPE_VOID, 130, 0, false, true },
+               { "size1x32", PIPE_FORMAT_R32_SINT, GLSL_TYPE_VOID, 130, 0, false, true },
+               { "size2x32", PIPE_FORMAT_R32G32_SINT, GLSL_TYPE_VOID, 130, 0, false, true },
+               { "size4x32", PIPE_FORMAT_R32G32B32A32_SINT, GLSL_TYPE_VOID, 130, 0, false, true },
             };
 
             for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
index 3f4802013f2ff54588d3140678aa45ac58cc8a22..f1e8a80db46729548c5137e314a8ed9aca3addd3 100644 (file)
@@ -1806,7 +1806,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
    this->data.fb_fetch_output = false;
    this->data.bindless = false;
    this->data.bound = false;
-   this->data.image_format = GL_NONE;
+   this->data.image_format = PIPE_FORMAT_NONE;
    this->data._num_state_slots = 0;
    this->data.param_index = 0;
    this->data.stream = 0;
index 93647f963f405121182aad17d13e80cb4cd265ad..6d79d42af45d974b8a6e0c8f73bac11070752e28 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 
 #include "util/ralloc.h"
+#include "util/format/u_format.h"
 #include "compiler/glsl_types.h"
 #include "list.h"
 #include "ir_visitor.h"
@@ -885,8 +886,11 @@ public:
       uint8_t warn_extension_index;
 
    public:
-      /** Image internal format if specified explicitly, otherwise GL_NONE. */
-      uint16_t image_format;
+      /**
+       * Image internal format if specified explicitly, otherwise
+       * PIPE_FORMAT_NONE.
+       */
+      enum pipe_format image_format;
 
    private:
       /**
index d5bb8dd6973e4751b03b37dbf45c24ce3fc9f20c..ae1a6e0fa7c71434b79ffb4f00c1f7a8272d1be9 100644 (file)
@@ -31,6 +31,7 @@
 #include "shader_enums.h"
 #include "c11/threads.h"
 #include "util/blob.h"
+#include "util/format/u_format.h"
 #include "util/macros.h"
 
 #ifdef __cplusplus
@@ -1297,7 +1298,7 @@ struct glsl_struct_field {
    /**
     * Layout format, applicable to image variables only.
     */
-   unsigned image_format:16;
+   enum pipe_format image_format;
 
    /**
     * Any of the xfb_* qualifiers trigger the shader to be in transform
@@ -1314,7 +1315,8 @@ struct glsl_struct_field {
    sample(0), matrix_layout(GLSL_MATRIX_LAYOUT_INHERITED), patch(0),    \
    precision(_precision), memory_read_only(0),                          \
    memory_write_only(0), memory_coherent(0), memory_volatile(0),        \
-   memory_restrict(0), image_format(0), explicit_xfb_buffer(0),         \
+   memory_restrict(0), image_format(PIPE_FORMAT_NONE),                  \
+   explicit_xfb_buffer(0),                                              \
    implicit_sized_array(0)
 
    glsl_struct_field(const struct glsl_type *_type,
index 8c0a0f03b7a480f1e991e22597e6e28f936d0d8d..c9edcadaaef278290009b037648a0d88483b470d 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/bitscan.h"
 #include "util/bitset.h"
 #include "util/macros.h"
+#include "util/format/u_format.h"
 #include "compiler/nir_types.h"
 #include "compiler/shader_enums.h"
 #include "compiler/shader_info.h"
@@ -525,8 +526,8 @@ typedef struct nir_variable {
 
       union {
          struct {
-            /** Image internal format if specified explicitly, otherwise GL_NONE. */
-            uint16_t format; /* GLenum */
+            /** Image internal format if specified explicitly, otherwise PIPE_FORMAT_NONE. */
+            enum pipe_format format;
          } image;
 
          struct {
@@ -1719,7 +1720,7 @@ INTRINSIC_IDX_ACCESSORS(image_array, IMAGE_ARRAY, bool)
 INTRINSIC_IDX_ACCESSORS(access, ACCESS, enum gl_access_qualifier)
 INTRINSIC_IDX_ACCESSORS(src_access, SRC_ACCESS, enum gl_access_qualifier)
 INTRINSIC_IDX_ACCESSORS(dst_access, DST_ACCESS, enum gl_access_qualifier)
-INTRINSIC_IDX_ACCESSORS(format, FORMAT, unsigned)
+INTRINSIC_IDX_ACCESSORS(format, FORMAT, enum pipe_format)
 INTRINSIC_IDX_ACCESSORS(align_mul, ALIGN_MUL, unsigned)
 INTRINSIC_IDX_ACCESSORS(align_offset, ALIGN_OFFSET, unsigned)
 INTRINSIC_IDX_ACCESSORS(desc_type, DESC_TYPE, unsigned)
index eaf902b4cd46078c4e5a58017bf0c3f70a5a18a6..cdab71430a71f4621584b5b2a6e6e721d2774ca3 100644 (file)
@@ -475,52 +475,7 @@ print_var_decl(nir_variable *var, print_state *state)
    fprintf(fp, "%s%s%s%s%s%s", coher, volat, restr, ronly, wonly, reorder);
 
    if (glsl_get_base_type(glsl_without_array(var->type)) == GLSL_TYPE_IMAGE) {
-#define FORMAT_CASE(x) case x: fprintf(fp, #x " "); break
-      switch (var->data.image.format) {
-      FORMAT_CASE(GL_RGBA32F);
-      FORMAT_CASE(GL_RGBA32UI);
-      FORMAT_CASE(GL_RGBA32I);
-      FORMAT_CASE(GL_R32F);
-      FORMAT_CASE(GL_R32UI);
-      FORMAT_CASE(GL_R32I);
-      FORMAT_CASE(GL_RG32F);
-      FORMAT_CASE(GL_RG32UI);
-      FORMAT_CASE(GL_RG32I);
-      FORMAT_CASE(GL_R8);
-      FORMAT_CASE(GL_RG8);
-      FORMAT_CASE(GL_RGBA8);
-      FORMAT_CASE(GL_R8_SNORM);
-      FORMAT_CASE(GL_RG8_SNORM);
-      FORMAT_CASE(GL_RGBA8_SNORM);
-      FORMAT_CASE(GL_R16);
-      FORMAT_CASE(GL_RG16);
-      FORMAT_CASE(GL_RGBA16);
-      FORMAT_CASE(GL_R16_SNORM);
-      FORMAT_CASE(GL_RG16_SNORM);
-      FORMAT_CASE(GL_RGBA16_SNORM);
-      FORMAT_CASE(GL_R16F);
-      FORMAT_CASE(GL_RG16F);
-      FORMAT_CASE(GL_RGBA16F);
-      FORMAT_CASE(GL_R8UI);
-      FORMAT_CASE(GL_R8I);
-      FORMAT_CASE(GL_RG8UI);
-      FORMAT_CASE(GL_RG8I);
-      FORMAT_CASE(GL_RGBA8UI);
-      FORMAT_CASE(GL_RGBA8I);
-      FORMAT_CASE(GL_R16UI);
-      FORMAT_CASE(GL_R16I);
-      FORMAT_CASE(GL_RG16UI);
-      FORMAT_CASE(GL_RG16I);
-      FORMAT_CASE(GL_RGBA16UI);
-      FORMAT_CASE(GL_RGBA16I);
-      FORMAT_CASE(GL_R11F_G11F_B10F);
-      FORMAT_CASE(GL_RGB9_E5);
-      FORMAT_CASE(GL_RGB10_A2);
-      FORMAT_CASE(GL_RGB10_A2UI);
-      default: /* Including the normal GL_NONE */
-         break;
-      }
-#undef FORMAT_CASE
+      fprintf(fp, "%s ", util_format_short_name(var->data.image.format));
    }
 
    fprintf(fp, "%s %s", glsl_get_type_name(var->type),
index 411212c6b8f1437c34eabe87218d8050bcbff04e..22cbaf4145a7eb7d1dd905173240e34a2668eead 100644 (file)
@@ -32,6 +32,7 @@
 #include "nir/nir_deref.h"
 #include "spirv_info.h"
 
+#include "util/format/u_format.h"
 #include "util/u_math.h"
 
 #include <stdio.h>
@@ -1057,46 +1058,46 @@ static unsigned
 translate_image_format(struct vtn_builder *b, SpvImageFormat format)
 {
    switch (format) {
-   case SpvImageFormatUnknown:      return 0;      /* GL_NONE */
-   case SpvImageFormatRgba32f:      return 0x8814; /* GL_RGBA32F */
-   case SpvImageFormatRgba16f:      return 0x881A; /* GL_RGBA16F */
-   case SpvImageFormatR32f:         return 0x822E; /* GL_R32F */
-   case SpvImageFormatRgba8:        return 0x8058; /* GL_RGBA8 */
-   case SpvImageFormatRgba8Snorm:   return 0x8F97; /* GL_RGBA8_SNORM */
-   case SpvImageFormatRg32f:        return 0x8230; /* GL_RG32F */
-   case SpvImageFormatRg16f:        return 0x822F; /* GL_RG16F */
-   case SpvImageFormatR11fG11fB10f: return 0x8C3A; /* GL_R11F_G11F_B10F */
-   case SpvImageFormatR16f:         return 0x822D; /* GL_R16F */
-   case SpvImageFormatRgba16:       return 0x805B; /* GL_RGBA16 */
-   case SpvImageFormatRgb10A2:      return 0x8059; /* GL_RGB10_A2 */
-   case SpvImageFormatRg16:         return 0x822C; /* GL_RG16 */
-   case SpvImageFormatRg8:          return 0x822B; /* GL_RG8 */
-   case SpvImageFormatR16:          return 0x822A; /* GL_R16 */
-   case SpvImageFormatR8:           return 0x8229; /* GL_R8 */
-   case SpvImageFormatRgba16Snorm:  return 0x8F9B; /* GL_RGBA16_SNORM */
-   case SpvImageFormatRg16Snorm:    return 0x8F99; /* GL_RG16_SNORM */
-   case SpvImageFormatRg8Snorm:     return 0x8F95; /* GL_RG8_SNORM */
-   case SpvImageFormatR16Snorm:     return 0x8F98; /* GL_R16_SNORM */
-   case SpvImageFormatR8Snorm:      return 0x8F94; /* GL_R8_SNORM */
-   case SpvImageFormatRgba32i:      return 0x8D82; /* GL_RGBA32I */
-   case SpvImageFormatRgba16i:      return 0x8D88; /* GL_RGBA16I */
-   case SpvImageFormatRgba8i:       return 0x8D8E; /* GL_RGBA8I */
-   case SpvImageFormatR32i:         return 0x8235; /* GL_R32I */
-   case SpvImageFormatRg32i:        return 0x823B; /* GL_RG32I */
-   case SpvImageFormatRg16i:        return 0x8239; /* GL_RG16I */
-   case SpvImageFormatRg8i:         return 0x8237; /* GL_RG8I */
-   case SpvImageFormatR16i:         return 0x8233; /* GL_R16I */
-   case SpvImageFormatR8i:          return 0x8231; /* GL_R8I */
-   case SpvImageFormatRgba32ui:     return 0x8D70; /* GL_RGBA32UI */
-   case SpvImageFormatRgba16ui:     return 0x8D76; /* GL_RGBA16UI */
-   case SpvImageFormatRgba8ui:      return 0x8D7C; /* GL_RGBA8UI */
-   case SpvImageFormatR32ui:        return 0x8236; /* GL_R32UI */
-   case SpvImageFormatRgb10a2ui:    return 0x906F; /* GL_RGB10_A2UI */
-   case SpvImageFormatRg32ui:       return 0x823C; /* GL_RG32UI */
-   case SpvImageFormatRg16ui:       return 0x823A; /* GL_RG16UI */
-   case SpvImageFormatRg8ui:        return 0x8238; /* GL_RG8UI */
-   case SpvImageFormatR16ui:        return 0x8234; /* GL_R16UI */
-   case SpvImageFormatR8ui:         return 0x8232; /* GL_R8UI */
+   case SpvImageFormatUnknown:      return PIPE_FORMAT_NONE;
+   case SpvImageFormatRgba32f:      return PIPE_FORMAT_R32G32B32A32_FLOAT;
+   case SpvImageFormatRgba16f:      return PIPE_FORMAT_R16G16B16A16_FLOAT;
+   case SpvImageFormatR32f:         return PIPE_FORMAT_R32_FLOAT;
+   case SpvImageFormatRgba8:        return PIPE_FORMAT_R8G8B8A8_UNORM;
+   case SpvImageFormatRgba8Snorm:   return PIPE_FORMAT_R8G8B8A8_SNORM;
+   case SpvImageFormatRg32f:        return PIPE_FORMAT_R32G32_FLOAT;
+   case SpvImageFormatRg16f:        return PIPE_FORMAT_R16G16_FLOAT;
+   case SpvImageFormatR11fG11fB10f: return PIPE_FORMAT_R11G11B10_FLOAT;
+   case SpvImageFormatR16f:         return PIPE_FORMAT_R16_FLOAT;
+   case SpvImageFormatRgba16:       return PIPE_FORMAT_R16G16B16A16_UNORM;
+   case SpvImageFormatRgb10A2:      return PIPE_FORMAT_R10G10B10A2_UNORM;
+   case SpvImageFormatRg16:         return PIPE_FORMAT_R16G16_UNORM;
+   case SpvImageFormatRg8:          return PIPE_FORMAT_R8G8_UNORM;
+   case SpvImageFormatR16:          return PIPE_FORMAT_R16_UNORM;
+   case SpvImageFormatR8:           return PIPE_FORMAT_R8_UNORM;
+   case SpvImageFormatRgba16Snorm:  return PIPE_FORMAT_R16G16B16A16_SNORM;
+   case SpvImageFormatRg16Snorm:    return PIPE_FORMAT_R16G16_SNORM;
+   case SpvImageFormatRg8Snorm:     return PIPE_FORMAT_R8G8_SNORM;
+   case SpvImageFormatR16Snorm:     return PIPE_FORMAT_R16_SNORM;
+   case SpvImageFormatR8Snorm:      return PIPE_FORMAT_R8_SNORM;
+   case SpvImageFormatRgba32i:      return PIPE_FORMAT_R32G32B32A32_SINT;
+   case SpvImageFormatRgba16i:      return PIPE_FORMAT_R16G16B16A16_SINT;
+   case SpvImageFormatRgba8i:       return PIPE_FORMAT_R8G8B8A8_SINT;
+   case SpvImageFormatR32i:         return PIPE_FORMAT_R32_SINT;
+   case SpvImageFormatRg32i:        return PIPE_FORMAT_R32G32_SINT;
+   case SpvImageFormatRg16i:        return PIPE_FORMAT_R16G16_SINT;
+   case SpvImageFormatRg8i:         return PIPE_FORMAT_R8G8_SINT;
+   case SpvImageFormatR16i:         return PIPE_FORMAT_R16_SINT;
+   case SpvImageFormatR8i:          return PIPE_FORMAT_R8_SINT;
+   case SpvImageFormatRgba32ui:     return PIPE_FORMAT_R32G32B32A32_UINT;
+   case SpvImageFormatRgba16ui:     return PIPE_FORMAT_R16G16B16A16_UINT;
+   case SpvImageFormatRgba8ui:      return PIPE_FORMAT_R8G8B8A8_UINT;
+   case SpvImageFormatR32ui:        return PIPE_FORMAT_R32_UINT;
+   case SpvImageFormatRgb10a2ui:    return PIPE_FORMAT_R10G10B10A2_UINT;
+   case SpvImageFormatRg32ui:       return PIPE_FORMAT_R32G32_UINT;
+   case SpvImageFormatRg16ui:       return PIPE_FORMAT_R16G16_UINT;
+   case SpvImageFormatRg8ui:        return PIPE_FORMAT_R8G8_UINT;
+   case SpvImageFormatR16ui:        return PIPE_FORMAT_R16_UINT;
+   case SpvImageFormatR8ui:         return PIPE_FORMAT_R8_UINT;
    default:
       vtn_fail("Invalid image format: %s (%u)",
                spirv_imageformat_to_string(format), format);
index 264b22fd4309113bc63c5a73bdff73c8ad8121d7..91385344eff0887622618c30b1631cbc5cbdae0b 100644 (file)
@@ -263,7 +263,7 @@ emit_intrinsic_store_image(struct ir3_context *ctx, nir_intrinsic_instr *intr)
        unsigned ncoords = ir3_get_image_coords(var, NULL);
        unsigned slot = ir3_get_image_slot(nir_src_as_deref(intr->src[0]));
        unsigned ibo_idx = ir3_image_to_ibo(ctx->so->shader, slot);
-       unsigned ncomp = ir3_get_num_components_for_glformat(var->data.image.format);
+       unsigned ncomp = ir3_get_num_components_for_image_format(var->data.image.format);
 
        /* src0 is value
         * src1 is coords
index 6fed98d7673f933a3d188067bca93312b1f76b02..8f9e5734d5929ce178dd1cb75cdaa1bc0286f3d9 100644 (file)
@@ -215,7 +215,7 @@ emit_intrinsic_store_image(struct ir3_context *ctx, nir_intrinsic_instr *intr)
        unsigned ncoords = ir3_get_image_coords(var, NULL);
        unsigned slot = ir3_get_image_slot(nir_src_as_deref(intr->src[0]));
        unsigned ibo_idx = ir3_image_to_ibo(ctx->so->shader, slot);
-       unsigned ncomp = ir3_get_num_components_for_glformat(var->data.image.format);
+       unsigned ncomp = ir3_get_num_components_for_image_format(var->data.image.format);
 
        /* src0 is offset, src1 is value:
         */
index 6dabf6c037645d7c6739190750b023dedd09e69d..4e96ba7e5554a2b919dc6d511951759c9fb36cc6 100644 (file)
@@ -151,69 +151,10 @@ ir3_get_image_type(const nir_variable *var)
  * GL_NV_image_formats extension.
  */
 unsigned
-ir3_get_num_components_for_glformat(GLuint format)
+ir3_get_num_components_for_image_format(GLuint format)
 {
-       switch (format) {
-       case GL_R32F:
-       case GL_R32I:
-       case GL_R32UI:
-       case GL_R16F:
-       case GL_R16I:
-       case GL_R16UI:
-       case GL_R16:
-       case GL_R16_SNORM:
-       case GL_R8I:
-       case GL_R8UI:
-       case GL_R8:
-       case GL_R8_SNORM:
-               return 1;
-
-       case GL_RG32F:
-       case GL_RG32I:
-       case GL_RG32UI:
-       case GL_RG16F:
-       case GL_RG16I:
-       case GL_RG16UI:
-       case GL_RG16:
-       case GL_RG16_SNORM:
-       case GL_RG8I:
-       case GL_RG8UI:
-       case GL_RG8:
-       case GL_RG8_SNORM:
-               return 2;
-
-       case GL_R11F_G11F_B10F:
-               return 3;
-
-       case GL_RGBA32F:
-       case GL_RGBA32I:
-       case GL_RGBA32UI:
-       case GL_RGBA16F:
-       case GL_RGBA16I:
-       case GL_RGBA16UI:
-       case GL_RGBA16:
-       case GL_RGBA16_SNORM:
-       case GL_RGBA8I:
-       case GL_RGBA8UI:
-       case GL_RGBA8:
-       case GL_RGBA8_SNORM:
-       case GL_RGB10_A2UI:
-       case GL_RGB10_A2:
+       if (format == PIPE_FORMAT_NONE)
                return 4;
-
-       case GL_NONE:
-               /* Omitting the image format qualifier is allowed on desktop GL
-                * profiles. Assuming 4 components is always safe.
-                */
-               return 4;
-
-       default:
-               /* Return 4 components also for all other formats we don't know
-                * about. The format should have been validated already by
-                * the higher level API, but drop a debug message just in case.
-                */
-               debug_printf("Unhandled GL format %u while emitting imageStore()\n",
-                                        format);
-               return 4;
-       }
+       else
+               return util_format_get_nr_components(format);
 }
index b0e0959b157802e7edf1cabd57069e48990116f0..ac9b1bab705fb8763bb686a4cd487a2de9678043 100644 (file)
@@ -39,6 +39,6 @@ unsigned ir3_image_to_tex(struct ir3_ibo_mapping *mapping, unsigned image);
 unsigned ir3_get_image_slot(nir_deref_instr *deref);
 unsigned ir3_get_image_coords(const nir_variable *var, unsigned *flagsp);
 type_t ir3_get_image_type(const nir_variable *var);
-unsigned ir3_get_num_components_for_glformat(GLuint format);
+unsigned ir3_get_num_components_for_image_format(GLuint format);
 
 #endif /* IR3_IMAGE_H_ */
index bd59949da5c85e7fbe929c6574c6e8b43f787181..8463e02d5e038ae32865a97952a4ece2a569a451 100644 (file)
@@ -1345,7 +1345,7 @@ get_image_var(struct ttn_compile *c, int binding,
               bool is_array,
               enum glsl_base_type base_type,
               enum gl_access_qualifier access,
-              GLenum format)
+              enum pipe_format format)
 {
    nir_variable *var = c->images[binding];
 
@@ -1741,102 +1741,6 @@ get_mem_qualifier(struct tgsi_full_instruction *tgsi_inst)
    return access;
 }
 
-static GLenum
-get_image_format(struct tgsi_full_instruction *tgsi_inst)
-{
-   switch (tgsi_inst->Memory.Format) {
-   case PIPE_FORMAT_NONE:
-      return GL_NONE;
-
-   case PIPE_FORMAT_R8_UNORM:
-      return GL_R8;
-   case PIPE_FORMAT_R8G8_UNORM:
-      return GL_RG8;
-   case PIPE_FORMAT_R8G8B8A8_UNORM:
-      return GL_RGBA8;
-   case PIPE_FORMAT_R16_UNORM:
-      return GL_R16;
-   case PIPE_FORMAT_R16G16_UNORM:
-      return GL_RG16;
-   case PIPE_FORMAT_R16G16B16A16_UNORM:
-      return GL_RGBA16;
-
-   case PIPE_FORMAT_R8_SNORM:
-      return GL_R8_SNORM;
-   case PIPE_FORMAT_R8G8_SNORM:
-      return GL_RG8_SNORM;
-   case PIPE_FORMAT_R8G8B8A8_SNORM:
-      return GL_RGBA8_SNORM;
-   case PIPE_FORMAT_R16_SNORM:
-      return GL_R16_SNORM;
-   case PIPE_FORMAT_R16G16_SNORM:
-      return GL_RG16_SNORM;
-   case PIPE_FORMAT_R16G16B16A16_SNORM:
-      return GL_RGBA16_SNORM;
-
-   case PIPE_FORMAT_R8_UINT:
-      return GL_R8UI;
-   case PIPE_FORMAT_R8G8_UINT:
-      return GL_RG8UI;
-   case PIPE_FORMAT_R8G8B8A8_UINT:
-      return GL_RGBA8UI;
-   case PIPE_FORMAT_R16_UINT:
-      return GL_R16UI;
-   case PIPE_FORMAT_R16G16_UINT:
-      return GL_RG16UI;
-   case PIPE_FORMAT_R16G16B16A16_UINT:
-      return GL_RGBA16UI;
-   case PIPE_FORMAT_R32_UINT:
-      return GL_R32UI;
-   case PIPE_FORMAT_R32G32_UINT:
-      return GL_RG32UI;
-   case PIPE_FORMAT_R32G32B32A32_UINT:
-      return GL_RGBA32UI;
-
-   case PIPE_FORMAT_R8_SINT:
-      return GL_R8I;
-   case PIPE_FORMAT_R8G8_SINT:
-      return GL_RG8I;
-   case PIPE_FORMAT_R8G8B8A8_SINT:
-      return GL_RGBA8I;
-   case PIPE_FORMAT_R16_SINT:
-      return GL_R16I;
-   case PIPE_FORMAT_R16G16_SINT:
-      return GL_RG16I;
-   case PIPE_FORMAT_R16G16B16A16_SINT:
-      return GL_RGBA16I;
-   case PIPE_FORMAT_R32_SINT:
-      return GL_R32I;
-   case PIPE_FORMAT_R32G32_SINT:
-      return GL_RG32I;
-   case PIPE_FORMAT_R32G32B32A32_SINT:
-      return GL_RGBA32I;
-
-   case PIPE_FORMAT_R16_FLOAT:
-      return GL_R16F;
-   case PIPE_FORMAT_R16G16_FLOAT:
-      return GL_RG16F;
-   case PIPE_FORMAT_R16G16B16A16_FLOAT:
-      return GL_RGBA16F;
-   case PIPE_FORMAT_R32_FLOAT:
-      return GL_R32F;
-   case PIPE_FORMAT_R32G32_FLOAT:
-      return GL_RG32F;
-   case PIPE_FORMAT_R32G32B32A32_FLOAT:
-      return GL_RGBA32F;
-
-   case PIPE_FORMAT_R11G11B10_FLOAT:
-      return GL_R11F_G11F_B10F;
-   case PIPE_FORMAT_R10G10B10A2_UINT:
-      return GL_RGB10_A2UI;
-   case PIPE_FORMAT_R10G10B10A2_UNORM:
-      return GL_RGB10_A2;
-
-   default:
-      unreachable("unhandled image format");
-   }
-}
-
 static void
 ttn_mem(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
 {
@@ -1912,11 +1816,11 @@ ttn_mem(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
 
       enum glsl_base_type base_type = get_image_base_type(tgsi_inst);
       enum gl_access_qualifier access = get_mem_qualifier(tgsi_inst);
-      GLenum format = get_image_format(tgsi_inst);
 
       nir_variable *image =
          get_image_var(c, resource_index,
-                       dim, is_array, base_type, access, format);
+                       dim, is_array, base_type, access,
+                       tgsi_inst->Memory.Format);
       nir_deref_instr *image_deref = nir_build_deref_var(b, image);
       const struct glsl_type *type = image_deref->type;
 
index ae07d9672217b7600f0d01678717fbcd537c5f87..c65853578f662c832e13c4ab2a202198b0eb265d 100644 (file)
@@ -1024,6 +1024,68 @@ const struct TexInstruction::ImgFormatDesc TexInstruction::formatTable[] =
    { "BGRA8",        4, {  8,  8,  8,  8 }, UNORM, true },
 };
 
+const struct TexInstruction::ImgFormatDesc *
+TexInstruction::translateImgFormat(enum pipe_format format)
+{
+
+#define FMT_CASE(a, b) \
+  case PIPE_FORMAT_ ## a: return &formatTable[nv50_ir::FMT_ ## b]
+
+   switch (format) {
+   FMT_CASE(NONE, NONE);
+
+   FMT_CASE(R32G32B32A32_FLOAT, RGBA32F);
+   FMT_CASE(R16G16B16A16_FLOAT, RGBA16F);
+   FMT_CASE(R32G32_FLOAT, RG32F);
+   FMT_CASE(R16G16_FLOAT, RG16F);
+   FMT_CASE(R11G11B10_FLOAT, R11G11B10F);
+   FMT_CASE(R32_FLOAT, R32F);
+   FMT_CASE(R16_FLOAT, R16F);
+
+   FMT_CASE(R32G32B32A32_UINT, RGBA32UI);
+   FMT_CASE(R16G16B16A16_UINT, RGBA16UI);
+   FMT_CASE(R10G10B10A2_UINT, RGB10A2UI);
+   FMT_CASE(R8G8B8A8_UINT, RGBA8UI);
+   FMT_CASE(R32G32_UINT, RG32UI);
+   FMT_CASE(R16G16_UINT, RG16UI);
+   FMT_CASE(R8G8_UINT, RG8UI);
+   FMT_CASE(R32_UINT, R32UI);
+   FMT_CASE(R16_UINT, R16UI);
+   FMT_CASE(R8_UINT, R8UI);
+
+   FMT_CASE(R32G32B32A32_SINT, RGBA32I);
+   FMT_CASE(R16G16B16A16_SINT, RGBA16I);
+   FMT_CASE(R8G8B8A8_SINT, RGBA8I);
+   FMT_CASE(R32G32_SINT, RG32I);
+   FMT_CASE(R16G16_SINT, RG16I);
+   FMT_CASE(R8G8_SINT, RG8I);
+   FMT_CASE(R32_SINT, R32I);
+   FMT_CASE(R16_SINT, R16I);
+   FMT_CASE(R8_SINT, R8I);
+
+   FMT_CASE(R16G16B16A16_UNORM, RGBA16);
+   FMT_CASE(R10G10B10A2_UNORM, RGB10A2);
+   FMT_CASE(R8G8B8A8_UNORM, RGBA8);
+   FMT_CASE(R16G16_UNORM, RG16);
+   FMT_CASE(R8G8_UNORM, RG8);
+   FMT_CASE(R16_UNORM, R16);
+   FMT_CASE(R8_UNORM, R8);
+
+   FMT_CASE(R16G16B16A16_SNORM, RGBA16_SNORM);
+   FMT_CASE(R8G8B8A8_SNORM, RGBA8_SNORM);
+   FMT_CASE(R16G16_SNORM, RG16_SNORM);
+   FMT_CASE(R8G8_SNORM, RG8_SNORM);
+   FMT_CASE(R16_SNORM, R16_SNORM);
+   FMT_CASE(R8_SNORM, R8_SNORM);
+
+   FMT_CASE(B8G8R8A8_UNORM, BGRA8);
+
+   default:
+      assert(!"Unexpected format");
+      return &formatTable[nv50_ir::FMT_NONE];
+   }
+}
+
 void
 TexInstruction::setIndirectR(Value *v)
 {
index b19751ab372ee5608d89f85967fc3790e86838dd..296b79f5d4941d0de29c728f4b7baf43e84ccc69 100644 (file)
@@ -1016,6 +1016,8 @@ public:
    };
 
    static const struct ImgFormatDesc formatTable[IMG_FORMAT_COUNT];
+   static const struct ImgFormatDesc *translateImgFormat(
+         enum pipe_format format);
 
 public:
    TexInstruction(Function *, operation);
index 22dbbae4a923b770c24f623f56ec6d79994d6dc0..c2b9f2043bf03359c67d69f5acc4fee33ee7628d 100644 (file)
@@ -81,8 +81,6 @@ private:
    LValues& convert(nir_register *);
    LValues& convert(nir_ssa_def *);
 
-   ImgFormat convertGLImgFormat(GLuint);
-
    Value* getSrc(nir_alu_src *, uint8_t component = 0);
    Value* getSrc(nir_register *, uint8_t);
    Value* getSrc(nir_src *, uint8_t, bool indirect = false);
@@ -1860,68 +1858,6 @@ Converter::convert(nir_intrinsic_op intr)
    }
 }
 
-ImgFormat
-Converter::convertGLImgFormat(GLuint format)
-{
-#define FMT_CASE(a, b) \
-  case GL_ ## a: return nv50_ir::FMT_ ## b
-
-   switch (format) {
-   FMT_CASE(NONE, NONE);
-
-   FMT_CASE(RGBA32F, RGBA32F);
-   FMT_CASE(RGBA16F, RGBA16F);
-   FMT_CASE(RG32F, RG32F);
-   FMT_CASE(RG16F, RG16F);
-   FMT_CASE(R11F_G11F_B10F, R11G11B10F);
-   FMT_CASE(R32F, R32F);
-   FMT_CASE(R16F, R16F);
-
-   FMT_CASE(RGBA32UI, RGBA32UI);
-   FMT_CASE(RGBA16UI, RGBA16UI);
-   FMT_CASE(RGB10_A2UI, RGB10A2UI);
-   FMT_CASE(RGBA8UI, RGBA8UI);
-   FMT_CASE(RG32UI, RG32UI);
-   FMT_CASE(RG16UI, RG16UI);
-   FMT_CASE(RG8UI, RG8UI);
-   FMT_CASE(R32UI, R32UI);
-   FMT_CASE(R16UI, R16UI);
-   FMT_CASE(R8UI, R8UI);
-
-   FMT_CASE(RGBA32I, RGBA32I);
-   FMT_CASE(RGBA16I, RGBA16I);
-   FMT_CASE(RGBA8I, RGBA8I);
-   FMT_CASE(RG32I, RG32I);
-   FMT_CASE(RG16I, RG16I);
-   FMT_CASE(RG8I, RG8I);
-   FMT_CASE(R32I, R32I);
-   FMT_CASE(R16I, R16I);
-   FMT_CASE(R8I, R8I);
-
-   FMT_CASE(RGBA16, RGBA16);
-   FMT_CASE(RGB10_A2, RGB10A2);
-   FMT_CASE(RGBA8, RGBA8);
-   FMT_CASE(RG16, RG16);
-   FMT_CASE(RG8, RG8);
-   FMT_CASE(R16, R16);
-   FMT_CASE(R8, R8);
-
-   FMT_CASE(RGBA16_SNORM, RGBA16_SNORM);
-   FMT_CASE(RGBA8_SNORM, RGBA8_SNORM);
-   FMT_CASE(RG16_SNORM, RG16_SNORM);
-   FMT_CASE(RG8_SNORM, RG8_SNORM);
-   FMT_CASE(R16_SNORM, R16_SNORM);
-   FMT_CASE(R8_SNORM, R8_SNORM);
-
-   FMT_CASE(BGRA_INTEGER, BGRA8);
-   default:
-      ERROR("unknown format %x\n", format);
-      assert(false);
-      return nv50_ir::FMT_NONE;
-   }
-#undef FMT_CASE
-}
-
 bool
 Converter::visit(nir_intrinsic_instr *insn)
 {
@@ -2502,7 +2438,7 @@ Converter::visit(nir_intrinsic_instr *insn)
 
       TexInstruction *texi = mkTex(getOperation(op), target.getEnum(), location, 0, defs, srcs);
       texi->tex.bindless = false;
-      texi->tex.format = &nv50_ir::TexInstruction::formatTable[convertGLImgFormat(nir_intrinsic_format(insn))];
+      texi->tex.format = nv50_ir::TexInstruction::translateImgFormat(nir_intrinsic_format(insn));
       texi->tex.mask = mask;
       texi->tex.bindless = true;
       texi->cache = convert(nir_intrinsic_access(insn));
@@ -2608,7 +2544,7 @@ Converter::visit(nir_intrinsic_instr *insn)
 
       TexInstruction *texi = mkTex(getOperation(op), target.getEnum(), location, 0, defs, srcs);
       texi->tex.bindless = false;
-      texi->tex.format = &nv50_ir::TexInstruction::formatTable[convertGLImgFormat(tex->data.image.format)];
+      texi->tex.format = nv50_ir::TexInstruction::translateImgFormat(tex->data.image.format);
       texi->tex.mask = mask;
       texi->cache = getCacheModeFromVar(tex);
       texi->setType(ty);
index 8c42902645252bb9697c1c66fe005cb8778d75f0..da9df42e23256631c9b68549914965a660a166bc 100644 (file)
@@ -40,7 +40,6 @@ static nv50_ir::DataFile translateFile(uint file);
 static nv50_ir::TexTarget translateTexture(uint texTarg);
 static nv50_ir::SVSemantic translateSysVal(uint sysval);
 static nv50_ir::CacheMode translateCacheMode(uint qualifier);
-static nv50_ir::ImgFormat translateImgFormat(uint format);
 
 class Instruction
 {
@@ -224,8 +223,7 @@ public:
    nv50_ir::TexInstruction::Target getTexture(const Source *, int s) const;
 
    const nv50_ir::TexInstruction::ImgFormatDesc *getImageFormat() const {
-      return &nv50_ir::TexInstruction::formatTable[
-            translateImgFormat(insn->Memory.Format)];
+      return nv50_ir::TexInstruction::translateImgFormat((enum pipe_format)insn->Memory.Format);
    }
 
    nv50_ir::TexTarget getImageTarget() const {
@@ -513,66 +511,6 @@ static nv50_ir::CacheMode translateCacheMode(uint qualifier)
    return nv50_ir::CACHE_CA;
 }
 
-static nv50_ir::ImgFormat translateImgFormat(uint format)
-{
-
-#define FMT_CASE(a, b) \
-  case PIPE_FORMAT_ ## a: return nv50_ir::FMT_ ## b
-
-   switch (format) {
-   FMT_CASE(NONE, NONE);
-
-   FMT_CASE(R32G32B32A32_FLOAT, RGBA32F);
-   FMT_CASE(R16G16B16A16_FLOAT, RGBA16F);
-   FMT_CASE(R32G32_FLOAT, RG32F);
-   FMT_CASE(R16G16_FLOAT, RG16F);
-   FMT_CASE(R11G11B10_FLOAT, R11G11B10F);
-   FMT_CASE(R32_FLOAT, R32F);
-   FMT_CASE(R16_FLOAT, R16F);
-
-   FMT_CASE(R32G32B32A32_UINT, RGBA32UI);
-   FMT_CASE(R16G16B16A16_UINT, RGBA16UI);
-   FMT_CASE(R10G10B10A2_UINT, RGB10A2UI);
-   FMT_CASE(R8G8B8A8_UINT, RGBA8UI);
-   FMT_CASE(R32G32_UINT, RG32UI);
-   FMT_CASE(R16G16_UINT, RG16UI);
-   FMT_CASE(R8G8_UINT, RG8UI);
-   FMT_CASE(R32_UINT, R32UI);
-   FMT_CASE(R16_UINT, R16UI);
-   FMT_CASE(R8_UINT, R8UI);
-
-   FMT_CASE(R32G32B32A32_SINT, RGBA32I);
-   FMT_CASE(R16G16B16A16_SINT, RGBA16I);
-   FMT_CASE(R8G8B8A8_SINT, RGBA8I);
-   FMT_CASE(R32G32_SINT, RG32I);
-   FMT_CASE(R16G16_SINT, RG16I);
-   FMT_CASE(R8G8_SINT, RG8I);
-   FMT_CASE(R32_SINT, R32I);
-   FMT_CASE(R16_SINT, R16I);
-   FMT_CASE(R8_SINT, R8I);
-
-   FMT_CASE(R16G16B16A16_UNORM, RGBA16);
-   FMT_CASE(R10G10B10A2_UNORM, RGB10A2);
-   FMT_CASE(R8G8B8A8_UNORM, RGBA8);
-   FMT_CASE(R16G16_UNORM, RG16);
-   FMT_CASE(R8G8_UNORM, RG8);
-   FMT_CASE(R16_UNORM, R16);
-   FMT_CASE(R8_UNORM, R8);
-
-   FMT_CASE(R16G16B16A16_SNORM, RGBA16_SNORM);
-   FMT_CASE(R8G8B8A8_SNORM, RGBA8_SNORM);
-   FMT_CASE(R16G16_SNORM, RG16_SNORM);
-   FMT_CASE(R8G8_SNORM, RG8_SNORM);
-   FMT_CASE(R16_SNORM, R16_SNORM);
-   FMT_CASE(R8_SNORM, R8_SNORM);
-
-   FMT_CASE(B8G8R8A8_UNORM, BGRA8);
-   }
-
-   assert(!"Unexpected format");
-   return nv50_ir::FMT_NONE;
-}
-
 nv50_ir::DataType Instruction::inferSrcType() const
 {
    switch (getOpcode()) {
index a0a7cd8b06acf9702ee45a800eecab0767e97ad8..3638ed52ec51bc62ef594da2d4d13d00fabfbd4f 100644 (file)
 #include "compiler/nir/nir_builder.h"
 #include "compiler/nir/nir_format_convert.h"
 
-/* The higher compiler layers use the GL enums for image formats even if
- * they come in from SPIR-V or Vulkan.  We need to turn them into an ISL
- * enum before we can use them.
- */
-static enum isl_format
-isl_format_for_gl_format(uint32_t gl_format)
-{
-   switch (gl_format) {
-   case GL_R8:             return ISL_FORMAT_R8_UNORM;
-   case GL_R8_SNORM:       return ISL_FORMAT_R8_SNORM;
-   case GL_R8UI:           return ISL_FORMAT_R8_UINT;
-   case GL_R8I:            return ISL_FORMAT_R8_SINT;
-   case GL_RG8:            return ISL_FORMAT_R8G8_UNORM;
-   case GL_RG8_SNORM:      return ISL_FORMAT_R8G8_SNORM;
-   case GL_RG8UI:          return ISL_FORMAT_R8G8_UINT;
-   case GL_RG8I:           return ISL_FORMAT_R8G8_SINT;
-   case GL_RGBA8:          return ISL_FORMAT_R8G8B8A8_UNORM;
-   case GL_RGBA8_SNORM:    return ISL_FORMAT_R8G8B8A8_SNORM;
-   case GL_RGBA8UI:        return ISL_FORMAT_R8G8B8A8_UINT;
-   case GL_RGBA8I:         return ISL_FORMAT_R8G8B8A8_SINT;
-   case GL_R11F_G11F_B10F: return ISL_FORMAT_R11G11B10_FLOAT;
-   case GL_RGB10_A2:       return ISL_FORMAT_R10G10B10A2_UNORM;
-   case GL_RGB10_A2UI:     return ISL_FORMAT_R10G10B10A2_UINT;
-   case GL_R16:            return ISL_FORMAT_R16_UNORM;
-   case GL_R16_SNORM:      return ISL_FORMAT_R16_SNORM;
-   case GL_R16F:           return ISL_FORMAT_R16_FLOAT;
-   case GL_R16UI:          return ISL_FORMAT_R16_UINT;
-   case GL_R16I:           return ISL_FORMAT_R16_SINT;
-   case GL_RG16:           return ISL_FORMAT_R16G16_UNORM;
-   case GL_RG16_SNORM:     return ISL_FORMAT_R16G16_SNORM;
-   case GL_RG16F:          return ISL_FORMAT_R16G16_FLOAT;
-   case GL_RG16UI:         return ISL_FORMAT_R16G16_UINT;
-   case GL_RG16I:          return ISL_FORMAT_R16G16_SINT;
-   case GL_RGBA16:         return ISL_FORMAT_R16G16B16A16_UNORM;
-   case GL_RGBA16_SNORM:   return ISL_FORMAT_R16G16B16A16_SNORM;
-   case GL_RGBA16F:        return ISL_FORMAT_R16G16B16A16_FLOAT;
-   case GL_RGBA16UI:       return ISL_FORMAT_R16G16B16A16_UINT;
-   case GL_RGBA16I:        return ISL_FORMAT_R16G16B16A16_SINT;
-   case GL_R32F:           return ISL_FORMAT_R32_FLOAT;
-   case GL_R32UI:          return ISL_FORMAT_R32_UINT;
-   case GL_R32I:           return ISL_FORMAT_R32_SINT;
-   case GL_RG32F:          return ISL_FORMAT_R32G32_FLOAT;
-   case GL_RG32UI:         return ISL_FORMAT_R32G32_UINT;
-   case GL_RG32I:          return ISL_FORMAT_R32G32_SINT;
-   case GL_RGBA32F:        return ISL_FORMAT_R32G32B32A32_FLOAT;
-   case GL_RGBA32UI:       return ISL_FORMAT_R32G32B32A32_UINT;
-   case GL_RGBA32I:        return ISL_FORMAT_R32G32B32A32_SINT;
-   case GL_NONE:           return ISL_FORMAT_UNSUPPORTED;
-   default:
-      assert(!"Invalid image format");
-      return ISL_FORMAT_UNSUPPORTED;
-   }
-}
-
 static nir_ssa_def *
 _load_image_param(nir_builder *b, nir_deref_instr *deref, unsigned offset)
 {
@@ -422,7 +368,7 @@ lower_image_load_instr(nir_builder *b,
    nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
    nir_variable *var = nir_deref_instr_get_variable(deref);
    const enum isl_format image_fmt =
-      isl_format_for_gl_format(var->data.image.format);
+      isl_format_for_pipe_format(var->data.image.format);
 
    if (isl_has_matching_typed_storage_image_format(devinfo, image_fmt)) {
       const enum isl_format lower_fmt =
@@ -587,7 +533,7 @@ lower_image_store_instr(nir_builder *b,
       return false;
 
    const enum isl_format image_fmt =
-      isl_format_for_gl_format(var->data.image.format);
+      isl_format_for_pipe_format(var->data.image.format);
 
    if (isl_has_matching_typed_storage_image_format(devinfo, image_fmt)) {
       const enum isl_format lower_fmt =
@@ -703,7 +649,7 @@ lower_image_size_instr(nir_builder *b,
     * so we fall back and let the back-end emit a TXS for this.
     */
    const enum isl_format image_fmt =
-      isl_format_for_gl_format(var->data.image.format);
+      isl_format_for_pipe_format(var->data.image.format);
    if (isl_has_matching_typed_storage_image_format(devinfo, image_fmt))
       return false;
 
index f23d27c09adefba0e3210e8a3d96fa666637c081..7d63aac716b617833fcb814ad60e6be5c6283537 100644 (file)
@@ -3768,7 +3768,7 @@ static void
 get_image_qualifiers(ir_dereference *ir, const glsl_type **type,
                      bool *memory_coherent, bool *memory_volatile,
                      bool *memory_restrict, bool *memory_read_only,
-                     unsigned *image_format)
+                     enum pipe_format *image_format)
 {
 
    switch (ir->ir_type) {
@@ -3826,7 +3826,7 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
    unsigned sampler_array_size = 1, sampler_base = 0;
    bool memory_coherent = false, memory_volatile = false,
         memory_restrict = false, memory_read_only = false;
-   unsigned image_format = 0;
+   enum pipe_format image_format = PIPE_FORMAT_NONE;
    const glsl_type *type = NULL;
 
    get_image_qualifiers(img, &type, &memory_coherent, &memory_volatile,
@@ -3982,8 +3982,7 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
    }
 
    inst->tex_target = type->sampler_index();
-   inst->image_format = st_mesa_format_to_pipe_format(st_context(ctx),
-         _mesa_get_shader_image_format(image_format));
+   inst->image_format = image_format;
    inst->read_only = memory_read_only;
 
    if (memory_coherent)