[Mesa-dev] [PATCH 5/8] spirv: Use the new gl_image_format enum

Jason Ekstrand jason at jlekstrand.net
Thu Jul 13 07:32:15 UTC 2017


---
 src/compiler/spirv/spirv_to_nir.c | 82 +++++++++++++++++++--------------------
 src/compiler/spirv/vtn_private.h  |  2 +-
 2 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 1be0145..ceca3e7 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -651,50 +651,50 @@ type_decoration_cb(struct vtn_builder *b,
    }
 }
 
-static unsigned
+static enum gl_image_format
 translate_image_format(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 IMAGE_FORMAT_NONE;
+   case SpvImageFormatRgba32f:      return IMAGE_FORMAT_RGBA32F;
+   case SpvImageFormatRgba16f:      return IMAGE_FORMAT_RGBA16F;
+   case SpvImageFormatR32f:         return IMAGE_FORMAT_R32F;
+   case SpvImageFormatRgba8:        return IMAGE_FORMAT_RGBA8;
+   case SpvImageFormatRgba8Snorm:   return IMAGE_FORMAT_RGBA8_SNORM;
+   case SpvImageFormatRg32f:        return IMAGE_FORMAT_RG32F;
+   case SpvImageFormatRg16f:        return IMAGE_FORMAT_RG16F;
+   case SpvImageFormatR11fG11fB10f: return IMAGE_FORMAT_R11F_G11F_B10F;
+   case SpvImageFormatR16f:         return IMAGE_FORMAT_R16F;
+   case SpvImageFormatRgba16:       return IMAGE_FORMAT_RGBA16;
+   case SpvImageFormatRgb10A2:      return IMAGE_FORMAT_RGB10_A2;
+   case SpvImageFormatRg16:         return IMAGE_FORMAT_RG16;
+   case SpvImageFormatRg8:          return IMAGE_FORMAT_RG8;
+   case SpvImageFormatR16:          return IMAGE_FORMAT_R16;
+   case SpvImageFormatR8:           return IMAGE_FORMAT_R8;
+   case SpvImageFormatRgba16Snorm:  return IMAGE_FORMAT_RGBA16_SNORM;
+   case SpvImageFormatRg16Snorm:    return IMAGE_FORMAT_RG16_SNORM;
+   case SpvImageFormatRg8Snorm:     return IMAGE_FORMAT_RG8_SNORM;
+   case SpvImageFormatR16Snorm:     return IMAGE_FORMAT_R16_SNORM;
+   case SpvImageFormatR8Snorm:      return IMAGE_FORMAT_R8_SNORM;
+   case SpvImageFormatRgba32i:      return IMAGE_FORMAT_RGBA32I;
+   case SpvImageFormatRgba16i:      return IMAGE_FORMAT_RGBA16I;
+   case SpvImageFormatRgba8i:       return IMAGE_FORMAT_RGBA8I;
+   case SpvImageFormatR32i:         return IMAGE_FORMAT_R32I;
+   case SpvImageFormatRg32i:        return IMAGE_FORMAT_RG32I;
+   case SpvImageFormatRg16i:        return IMAGE_FORMAT_RG16I;
+   case SpvImageFormatRg8i:         return IMAGE_FORMAT_RG8I;
+   case SpvImageFormatR16i:         return IMAGE_FORMAT_R16I;
+   case SpvImageFormatR8i:          return IMAGE_FORMAT_R8I;
+   case SpvImageFormatRgba32ui:     return IMAGE_FORMAT_RGBA32UI;
+   case SpvImageFormatRgba16ui:     return IMAGE_FORMAT_RGBA16UI;
+   case SpvImageFormatRgba8ui:      return IMAGE_FORMAT_RGBA8UI;
+   case SpvImageFormatR32ui:        return IMAGE_FORMAT_R32UI;
+   case SpvImageFormatRgb10a2ui:    return IMAGE_FORMAT_RGB10_A2UI;
+   case SpvImageFormatRg32ui:       return IMAGE_FORMAT_RG32UI;
+   case SpvImageFormatRg16ui:       return IMAGE_FORMAT_RG16UI;
+   case SpvImageFormatRg8ui:        return IMAGE_FORMAT_RG8UI;
+   case SpvImageFormatR16ui:        return IMAGE_FORMAT_R16UI;
+   case SpvImageFormatR8ui:         return IMAGE_FORMAT_R8UI;
    default:
       assert(!"Invalid image format");
       return 0;
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index a377c90..c117907 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -220,7 +220,7 @@ struct vtn_type {
    bool builtin_block;
 
    /* Image format for image_load_store type images */
-   unsigned image_format;
+   enum gl_image_format image_format;
 
    /* Access qualifier for storage images */
    SpvAccessQualifier access_qualifier;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list