[Mesa-dev] [PATCH 3/8] compiler/glsl: Use the new gl_image_format enum
Jason Ekstrand
jason at jlekstrand.net
Thu Jul 13 07:32:13 UTC 2017
---
src/compiler/glsl/ast.h | 2 +-
src/compiler/glsl/ast_to_hir.cpp | 4 +-
src/compiler/glsl/builtin_variables.cpp | 2 +-
src/compiler/glsl/glsl_parser.yy | 80 ++++++++++++++++-----------------
src/compiler/glsl/ir.h | 2 +-
src/compiler/glsl_types.h | 8 ++--
6 files changed, 50 insertions(+), 48 deletions(-)
diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 3bf4b08..b4d444c 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -740,7 +740,7 @@ struct ast_type_qualifier {
* \note
* This field is only valid if \c explicit_image_format is set.
*/
- GLenum image_format;
+ gl_image_format image_format;
/**
* Base type of the data read from or written to this image. Only
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index b1e490e..68a432c 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -3456,7 +3456,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 = IMAGE_FORMAT_NONE;
}
/* From page 70 of the GLSL ES 3.1 specification:
@@ -7456,7 +7456,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
"qualifier");
}
- fields[i].image_format = GL_NONE;
+ fields[i].image_format = IMAGE_FORMAT_NONE;
}
}
}
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index 19d427e..e0339f6 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -341,7 +341,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 = IMAGE_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 7b93d34..e69aec8 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -1326,7 +1326,7 @@ layout_qualifier_id:
if (!$$.flags.i) {
static const struct {
const char *name;
- GLenum format;
+ enum gl_image_format format;
glsl_base_type base_type;
/** Minimum desktop GLSL version required for the image
* format. Use 130 if already present in the original
@@ -1338,45 +1338,45 @@ layout_qualifier_id:
/* NV_image_formats */
bool nv_image_formats;
} map[] = {
- { "rgba32f", GL_RGBA32F, GLSL_TYPE_FLOAT, 130, 310, false },
- { "rgba16f", GL_RGBA16F, GLSL_TYPE_FLOAT, 130, 310, false },
- { "rg32f", GL_RG32F, GLSL_TYPE_FLOAT, 130, 0, true },
- { "rg16f", GL_RG16F, GLSL_TYPE_FLOAT, 130, 0, true },
- { "r11f_g11f_b10f", GL_R11F_G11F_B10F, GLSL_TYPE_FLOAT, 130, 0, true },
- { "r32f", GL_R32F, GLSL_TYPE_FLOAT, 130, 310, false },
- { "r16f", GL_R16F, GLSL_TYPE_FLOAT, 130, 0, true },
- { "rgba32ui", GL_RGBA32UI, GLSL_TYPE_UINT, 130, 310, false },
- { "rgba16ui", GL_RGBA16UI, GLSL_TYPE_UINT, 130, 310, false },
- { "rgb10_a2ui", GL_RGB10_A2UI, GLSL_TYPE_UINT, 130, 0, true },
- { "rgba8ui", GL_RGBA8UI, GLSL_TYPE_UINT, 130, 310, false },
- { "rg32ui", GL_RG32UI, GLSL_TYPE_UINT, 130, 0, true },
- { "rg16ui", GL_RG16UI, GLSL_TYPE_UINT, 130, 0, true },
- { "rg8ui", GL_RG8UI, GLSL_TYPE_UINT, 130, 0, true },
- { "r32ui", GL_R32UI, GLSL_TYPE_UINT, 130, 310, false },
- { "r16ui", GL_R16UI, GLSL_TYPE_UINT, 130, 0, true },
- { "r8ui", GL_R8UI, GLSL_TYPE_UINT, 130, 0, true },
- { "rgba32i", GL_RGBA32I, GLSL_TYPE_INT, 130, 310, false },
- { "rgba16i", GL_RGBA16I, GLSL_TYPE_INT, 130, 310, false },
- { "rgba8i", GL_RGBA8I, GLSL_TYPE_INT, 130, 310, false },
- { "rg32i", GL_RG32I, GLSL_TYPE_INT, 130, 0, true },
- { "rg16i", GL_RG16I, GLSL_TYPE_INT, 130, 0, true },
- { "rg8i", GL_RG8I, GLSL_TYPE_INT, 130, 0, true },
- { "r32i", GL_R32I, GLSL_TYPE_INT, 130, 310, false },
- { "r16i", GL_R16I, GLSL_TYPE_INT, 130, 0, true },
- { "r8i", GL_R8I, GLSL_TYPE_INT, 130, 0, true },
- { "rgba16", GL_RGBA16, GLSL_TYPE_FLOAT, 130, 0, false },
- { "rgb10_a2", GL_RGB10_A2, GLSL_TYPE_FLOAT, 130, 0, true },
- { "rgba8", GL_RGBA8, GLSL_TYPE_FLOAT, 130, 310, false },
- { "rg16", GL_RG16, GLSL_TYPE_FLOAT, 130, 0, false },
- { "rg8", GL_RG8, GLSL_TYPE_FLOAT, 130, 0, true },
- { "r16", GL_R16, GLSL_TYPE_FLOAT, 130, 0, false },
- { "r8", GL_R8, GLSL_TYPE_FLOAT, 130, 0, true },
- { "rgba16_snorm", GL_RGBA16_SNORM, GLSL_TYPE_FLOAT, 130, 0, false },
- { "rgba8_snorm", GL_RGBA8_SNORM, GLSL_TYPE_FLOAT, 130, 310, false },
- { "rg16_snorm", GL_RG16_SNORM, GLSL_TYPE_FLOAT, 130, 0, false },
- { "rg8_snorm", GL_RG8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true },
- { "r16_snorm", GL_R16_SNORM, GLSL_TYPE_FLOAT, 130, 0, false },
- { "r8_snorm", GL_R8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true }
+ { "rgba32f", IMAGE_FORMAT_RGBA32F, GLSL_TYPE_FLOAT, 130, 310, false },
+ { "rgba16f", IMAGE_FORMAT_RGBA16F, GLSL_TYPE_FLOAT, 130, 310, false },
+ { "rg32f", IMAGE_FORMAT_RG32F, GLSL_TYPE_FLOAT, 130, 0, true },
+ { "rg16f", IMAGE_FORMAT_RG16F, GLSL_TYPE_FLOAT, 130, 0, true },
+ { "r11f_g11f_b10f", IMAGE_FORMAT_R11F_G11F_B10F, GLSL_TYPE_FLOAT, 130, 0, true },
+ { "r32f", IMAGE_FORMAT_R32F, GLSL_TYPE_FLOAT, 130, 310, false },
+ { "r16f", IMAGE_FORMAT_R16F, GLSL_TYPE_FLOAT, 130, 0, true },
+ { "rgba32ui", IMAGE_FORMAT_RGBA32UI, GLSL_TYPE_UINT, 130, 310, false },
+ { "rgba16ui", IMAGE_FORMAT_RGBA16UI, GLSL_TYPE_UINT, 130, 310, false },
+ { "rgb10_a2ui", IMAGE_FORMAT_RGB10_A2UI, GLSL_TYPE_UINT, 130, 0, true },
+ { "rgba8ui", IMAGE_FORMAT_RGBA8UI, GLSL_TYPE_UINT, 130, 310, false },
+ { "rg32ui", IMAGE_FORMAT_RG32UI, GLSL_TYPE_UINT, 130, 0, true },
+ { "rg16ui", IMAGE_FORMAT_RG16UI, GLSL_TYPE_UINT, 130, 0, true },
+ { "rg8ui", IMAGE_FORMAT_RG8UI, GLSL_TYPE_UINT, 130, 0, true },
+ { "r32ui", IMAGE_FORMAT_R32UI, GLSL_TYPE_UINT, 130, 310, false },
+ { "r16ui", IMAGE_FORMAT_R16UI, GLSL_TYPE_UINT, 130, 0, true },
+ { "r8ui", IMAGE_FORMAT_R8UI, GLSL_TYPE_UINT, 130, 0, true },
+ { "rgba32i", IMAGE_FORMAT_RGBA32I, GLSL_TYPE_INT, 130, 310, false },
+ { "rgba16i", IMAGE_FORMAT_RGBA16I, GLSL_TYPE_INT, 130, 310, false },
+ { "rgba8i", IMAGE_FORMAT_RGBA8I, GLSL_TYPE_INT, 130, 310, false },
+ { "rg32i", IMAGE_FORMAT_RG32I, GLSL_TYPE_INT, 130, 0, true },
+ { "rg16i", IMAGE_FORMAT_RG16I, GLSL_TYPE_INT, 130, 0, true },
+ { "rg8i", IMAGE_FORMAT_RG8I, GLSL_TYPE_INT, 130, 0, true },
+ { "r32i", IMAGE_FORMAT_R32I, GLSL_TYPE_INT, 130, 310, false },
+ { "r16i", IMAGE_FORMAT_R16I, GLSL_TYPE_INT, 130, 0, true },
+ { "r8i", IMAGE_FORMAT_R8I, GLSL_TYPE_INT, 130, 0, true },
+ { "rgba16", IMAGE_FORMAT_RGBA16, GLSL_TYPE_FLOAT, 130, 0, false },
+ { "rgb10_a2", IMAGE_FORMAT_RGB10_A2, GLSL_TYPE_FLOAT, 130, 0, true },
+ { "rgba8", IMAGE_FORMAT_RGBA8, GLSL_TYPE_FLOAT, 130, 310, false },
+ { "rg16", IMAGE_FORMAT_RG16, GLSL_TYPE_FLOAT, 130, 0, false },
+ { "rg8", IMAGE_FORMAT_RG8, GLSL_TYPE_FLOAT, 130, 0, true },
+ { "r16", IMAGE_FORMAT_R16, GLSL_TYPE_FLOAT, 130, 0, false },
+ { "r8", IMAGE_FORMAT_R8, GLSL_TYPE_FLOAT, 130, 0, true },
+ { "rgba16_snorm", IMAGE_FORMAT_RGBA16_SNORM, GLSL_TYPE_FLOAT, 130, 0, false },
+ { "rgba8_snorm", IMAGE_FORMAT_RGBA8_SNORM, GLSL_TYPE_FLOAT, 130, 310, false },
+ { "rg16_snorm", IMAGE_FORMAT_RG16_SNORM, GLSL_TYPE_FLOAT, 130, 0, false },
+ { "rg8_snorm", IMAGE_FORMAT_RG8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true },
+ { "r16_snorm", IMAGE_FORMAT_R16_SNORM, GLSL_TYPE_FLOAT, 130, 0, false },
+ { "r8_snorm", IMAGE_FORMAT_R8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true }
};
for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 840c06e..45f1a25 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -880,7 +880,7 @@ public:
public:
/** Image internal format if specified explicitly, otherwise GL_NONE. */
- uint16_t image_format;
+ gl_image_format image_format;
private:
/**
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 55faac2..047afee 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -28,6 +28,8 @@
#include <string.h>
#include <assert.h>
+#include "shader_enums.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -987,7 +989,7 @@ struct glsl_struct_field {
/**
* Layout format, applicable to image variables only.
*/
- unsigned image_format:16;
+ enum gl_image_format image_format;
/**
* Any of the xfb_* qualifiers trigger the shader to be in transform
@@ -1004,8 +1006,8 @@ struct glsl_struct_field {
sample(0), matrix_layout(GLSL_MATRIX_LAYOUT_INHERITED), patch(0),
precision(GLSL_PRECISION_NONE), memory_read_only(0),
memory_write_only(0), memory_coherent(0), memory_volatile(0),
- memory_restrict(0), image_format(0), explicit_xfb_buffer(0),
- implicit_sized_array(0)
+ memory_restrict(0), image_format(IMAGE_FORMAT_NONE),
+ explicit_xfb_buffer(0), implicit_sized_array(0)
{
/* empty */
}
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list