summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/broadcom/compiler/v3d_nir_lower_image_load_store.c283
-rw-r--r--src/compiler/glsl/ast.h2
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp56
-rw-r--r--src/compiler/glsl/builtin_variables.cpp2
-rw-r--r--src/compiler/glsl/glsl_parser.yy91
-rw-r--r--src/compiler/glsl/ir.cpp2
-rw-r--r--src/compiler/glsl/ir.h8
-rw-r--r--src/compiler/glsl_types.h6
-rw-r--r--src/compiler/nir/nir.h7
-rw-r--r--src/compiler/nir/nir_print.c47
-rw-r--r--src/compiler/spirv/spirv_to_nir.c81
-rw-r--r--src/freedreno/ir3/ir3_a4xx.c2
-rw-r--r--src/freedreno/ir3/ir3_a6xx.c2
-rw-r--r--src/freedreno/ir3/ir3_image.c67
-rw-r--r--src/freedreno/ir3/ir3_image.h2
-rw-r--r--src/gallium/auxiliary/nir/tgsi_to_nir.c102
-rw-r--r--src/gallium/drivers/nouveau/codegen/nv50_ir.cpp62
-rw-r--r--src/gallium/drivers/nouveau/codegen/nv50_ir.h2
-rw-r--r--src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp68
-rw-r--r--src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp64
-rw-r--r--src/intel/compiler/brw_nir_lower_image_load_store.c60
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp7
22 files changed, 298 insertions, 725 deletions
diff --git a/src/broadcom/compiler/v3d_nir_lower_image_load_store.c b/src/broadcom/compiler/v3d_nir_lower_image_load_store.c
index 2aa3cbad495..e4db541f1b4 100644
--- a/src/broadcom/compiler/v3d_nir_lower_image_load_store.c
+++ b/src/broadcom/compiler/v3d_nir_lower_image_load_store.c
@@ -41,53 +41,13 @@
*/
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],
diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 67b258ce538..f6487643d42 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -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
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 7b7f6aff62a..cc1bb16bb64 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -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;
}
}
}
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index cf2a233d15f..6f960837321 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -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;
diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
index 048af1f0857..dc8a8b3db01 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -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++) {
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 3f4802013f2..f1e8a80db46 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -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;
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 93647f963f4..6d79d42af45 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -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:
/**
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index d5bb8dd6973..ae1a6e0fa7c 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -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,
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 8c0a0f03b7a..c9edcadaaef 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -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)
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index eaf902b4cd4..cdab71430a7 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -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),
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 411212c6b8f..22cbaf4145a 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -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);
diff --git a/src/freedreno/ir3/ir3_a4xx.c b/src/freedreno/ir3/ir3_a4xx.c
index 264b22fd430..91385344eff 100644
--- a/src/freedreno/ir3/ir3_a4xx.c
+++ b/src/freedreno/ir3/ir3_a4xx.c
@@ -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
diff --git a/src/freedreno/ir3/ir3_a6xx.c b/src/freedreno/ir3/ir3_a6xx.c
index 6fed98d7673..8f9e5734d59 100644
--- a/src/freedreno/ir3/ir3_a6xx.c
+++ b/src/freedreno/ir3/ir3_a6xx.c
@@ -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:
*/
diff --git a/src/freedreno/ir3/ir3_image.c b/src/freedreno/ir3/ir3_image.c
index 6dabf6c0376..4e96ba7e555 100644
--- a/src/freedreno/ir3/ir3_image.c
+++ b/src/freedreno/ir3/ir3_image.c
@@ -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);
}
diff --git a/src/freedreno/ir3/ir3_image.h b/src/freedreno/ir3/ir3_image.h
index b0e0959b157..ac9b1bab705 100644
--- a/src/freedreno/ir3/ir3_image.h
+++ b/src/freedreno/ir3/ir3_image.h
@@ -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_ */
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index bd59949da5c..8463e02d5e0 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -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;
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp
index ae07d967221..c65853578f6 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp
@@ -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)
{
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
index b19751ab372..296b79f5d49 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
@@ -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);
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
index 22dbbae4a92..c2b9f2043bf 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -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);
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
index 8c429026452..da9df42e232 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
@@ -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()) {
diff --git a/src/intel/compiler/brw_nir_lower_image_load_store.c b/src/intel/compiler/brw_nir_lower_image_load_store.c
index a0a7cd8b06a..3638ed52ec5 100644
--- a/src/intel/compiler/brw_nir_lower_image_load_store.c
+++ b/src/intel/compiler/brw_nir_lower_image_load_store.c
@@ -27,60 +27,6 @@
#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;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f23d27c09ad..7d63aac716b 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -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)