nir/drawpixels: handle load_color0, load_input, load_interpolated_input
[mesa.git] / src / compiler / glsl / builtin_types.cpp
index ee24bd5e411351c051514cb820201acfd88bb95c..d3a28acf27bc55592678e986c9e615517d9be5b4 100644 (file)
@@ -37,6 +37,7 @@
 #include "compiler/glsl_types.h"
 #include "glsl_parser_extras.h"
 #include "util/macros.h"
+#include "main/mtypes.h"
 
 /**
  * Declarations of type flyweights (glsl_type::_foo_type) and
@@ -52,9 +53,9 @@
       &glsl_type::_struct_##NAME##_type;
 
 static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
-   glsl_struct_field(glsl_type::float_type, "near"),
-   glsl_struct_field(glsl_type::float_type, "far"),
-   glsl_struct_field(glsl_type::float_type, "diff"),
+   glsl_struct_field(glsl_type::float_type, GLSL_PRECISION_HIGH, "near"),
+   glsl_struct_field(glsl_type::float_type, GLSL_PRECISION_HIGH, "far"),
+   glsl_struct_field(glsl_type::float_type, GLSL_PRECISION_HIGH, "diff"),
 };
 
 static const struct glsl_struct_field gl_PointParameters_fields[] = {
@@ -177,11 +178,11 @@ static const struct builtin_type_versions {
    T(samplerCube,                     110, 100)
    T(sampler1DArray,                  130, 999)
    T(sampler2DArray,                  130, 300)
-   T(samplerCubeArray,                400, 999)
+   T(samplerCubeArray,                400, 320)
    T(sampler2DRect,                   140, 999)
-   T(samplerBuffer,                   140, 999)
+   T(samplerBuffer,                   140, 320)
    T(sampler2DMS,                     150, 310)
-   T(sampler2DMSArray,                150, 999)
+   T(sampler2DMSArray,                150, 320)
 
    T(isampler1D,                      130, 999)
    T(isampler2D,                      130, 300)
@@ -189,11 +190,11 @@ static const struct builtin_type_versions {
    T(isamplerCube,                    130, 300)
    T(isampler1DArray,                 130, 999)
    T(isampler2DArray,                 130, 300)
-   T(isamplerCubeArray,               400, 999)
+   T(isamplerCubeArray,               400, 320)
    T(isampler2DRect,                  140, 999)
-   T(isamplerBuffer,                  140, 999)
+   T(isamplerBuffer,                  140, 320)
    T(isampler2DMS,                    150, 310)
-   T(isampler2DMSArray,               150, 999)
+   T(isampler2DMSArray,               150, 320)
 
    T(usampler1D,                      130, 999)
    T(usampler2D,                      130, 300)
@@ -201,18 +202,18 @@ static const struct builtin_type_versions {
    T(usamplerCube,                    130, 300)
    T(usampler1DArray,                 130, 999)
    T(usampler2DArray,                 130, 300)
-   T(usamplerCubeArray,               400, 999)
+   T(usamplerCubeArray,               400, 320)
    T(usampler2DRect,                  140, 999)
-   T(usamplerBuffer,                  140, 999)
+   T(usamplerBuffer,                  140, 320)
    T(usampler2DMS,                    150, 310)
-   T(usampler2DMSArray,               150, 999)
+   T(usampler2DMSArray,               150, 320)
 
    T(sampler1DShadow,                 110, 999)
    T(sampler2DShadow,                 110, 300)
    T(samplerCubeShadow,               130, 300)
    T(sampler1DArrayShadow,            130, 999)
    T(sampler2DArrayShadow,            130, 300)
-   T(samplerCubeArrayShadow,          400, 999)
+   T(samplerCubeArrayShadow,          400, 320)
    T(sampler2DRectShadow,             140, 999)
 
    T(struct_gl_DepthRangeParameters,  110, 100)
@@ -222,10 +223,10 @@ static const struct builtin_type_versions {
    T(image3D,                         420, 310)
    T(image2DRect,                     420, 999)
    T(imageCube,                       420, 310)
-   T(imageBuffer,                     420, 999)
+   T(imageBuffer,                     420, 320)
    T(image1DArray,                    420, 999)
    T(image2DArray,                    420, 310)
-   T(imageCubeArray,                  420, 999)
+   T(imageCubeArray,                  420, 320)
    T(image2DMS,                       420, 999)
    T(image2DMSArray,                  420, 999)
    T(iimage1D,                        420, 999)
@@ -233,10 +234,10 @@ static const struct builtin_type_versions {
    T(iimage3D,                        420, 310)
    T(iimage2DRect,                    420, 999)
    T(iimageCube,                      420, 310)
-   T(iimageBuffer,                    420, 999)
+   T(iimageBuffer,                    420, 320)
    T(iimage1DArray,                   420, 999)
    T(iimage2DArray,                   420, 310)
-   T(iimageCubeArray,                 420, 999)
+   T(iimageCubeArray,                 420, 320)
    T(iimage2DMS,                      420, 999)
    T(iimage2DMSArray,                 420, 999)
    T(uimage1D,                        420, 999)
@@ -244,10 +245,10 @@ static const struct builtin_type_versions {
    T(uimage3D,                        420, 310)
    T(uimage2DRect,                    420, 999)
    T(uimageCube,                      420, 310)
-   T(uimageBuffer,                    420, 999)
+   T(uimageBuffer,                    420, 320)
    T(uimage1DArray,                   420, 999)
    T(uimage2DArray,                   420, 310)
-   T(uimageCubeArray,                 420, 999)
+   T(uimageCubeArray,                 420, 320)
    T(uimage2DMS,                      420, 999)
    T(uimage2DMSArray,                 420, 999)
 
@@ -288,7 +289,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
    /* Add deprecated structure types.  While these were deprecated in 1.30,
     * they're still present.  We've removed them in 1.40+ (OpenGL 3.1+).
     */
-   if (!state->es_shader && state->language_version < 140) {
+   if (state->compat_shader || state->ARB_compatibility_enable) {
       for (unsigned i = 0; i < ARRAY_SIZE(deprecated_types); i++) {
          add_type(symbols, deprecated_types[i]);
       }
@@ -298,18 +299,22 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
     * by the version-based loop, but attempting to add them a second time
     * is harmless.
     */
-   if (state->ARB_texture_cube_map_array_enable) {
+   if (state->ARB_texture_cube_map_array_enable ||
+       state->EXT_texture_cube_map_array_enable ||
+       state->OES_texture_cube_map_array_enable) {
       add_type(symbols, glsl_type::samplerCubeArray_type);
       add_type(symbols, glsl_type::samplerCubeArrayShadow_type);
       add_type(symbols, glsl_type::isamplerCubeArray_type);
       add_type(symbols, glsl_type::usamplerCubeArray_type);
    }
 
-   if (state->ARB_texture_multisample_enable ||
-       state->OES_texture_storage_multisample_2d_array_enable) {
+   if (state->ARB_texture_multisample_enable) {
       add_type(symbols, glsl_type::sampler2DMS_type);
       add_type(symbols, glsl_type::isampler2DMS_type);
       add_type(symbols, glsl_type::usampler2DMS_type);
+   }
+   if (state->ARB_texture_multisample_enable ||
+       state->OES_texture_storage_multisample_2d_array_enable) {
       add_type(symbols, glsl_type::sampler2DMSArray_type);
       add_type(symbols, glsl_type::isampler2DMSArray_type);
       add_type(symbols, glsl_type::usampler2DMSArray_type);
@@ -320,6 +325,52 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
       add_type(symbols, glsl_type::sampler2DRectShadow_type);
    }
 
+   if (state->EXT_gpu_shader4_enable) {
+      add_type(symbols, glsl_type::uint_type);
+      add_type(symbols, glsl_type::uvec2_type);
+      add_type(symbols, glsl_type::uvec3_type);
+      add_type(symbols, glsl_type::uvec4_type);
+
+      add_type(symbols, glsl_type::samplerCubeShadow_type);
+
+      if (state->ctx->Extensions.EXT_texture_array) {
+         add_type(symbols, glsl_type::sampler1DArray_type);
+         add_type(symbols, glsl_type::sampler2DArray_type);
+         add_type(symbols, glsl_type::sampler1DArrayShadow_type);
+         add_type(symbols, glsl_type::sampler2DArrayShadow_type);
+      }
+      if (state->ctx->Extensions.EXT_texture_buffer_object) {
+         add_type(symbols, glsl_type::samplerBuffer_type);
+      }
+
+      if (state->ctx->Extensions.EXT_texture_integer) {
+         add_type(symbols, glsl_type::isampler1D_type);
+         add_type(symbols, glsl_type::isampler2D_type);
+         add_type(symbols, glsl_type::isampler3D_type);
+         add_type(symbols, glsl_type::isamplerCube_type);
+
+         add_type(symbols, glsl_type::usampler1D_type);
+         add_type(symbols, glsl_type::usampler2D_type);
+         add_type(symbols, glsl_type::usampler3D_type);
+         add_type(symbols, glsl_type::usamplerCube_type);
+
+         if (state->ctx->Extensions.NV_texture_rectangle) {
+            add_type(symbols, glsl_type::isampler2DRect_type);
+            add_type(symbols, glsl_type::usampler2DRect_type);
+         }
+         if (state->ctx->Extensions.EXT_texture_array) {
+            add_type(symbols, glsl_type::isampler1DArray_type);
+            add_type(symbols, glsl_type::isampler2DArray_type);
+            add_type(symbols, glsl_type::usampler1DArray_type);
+            add_type(symbols, glsl_type::usampler2DArray_type);
+         }
+         if (state->ctx->Extensions.EXT_texture_buffer_object) {
+            add_type(symbols, glsl_type::isamplerBuffer_type);
+            add_type(symbols, glsl_type::usamplerBuffer_type);
+         }
+      }
+   }
+
    if (state->EXT_texture_array_enable) {
       add_type(symbols, glsl_type::sampler1DArray_type);
       add_type(symbols, glsl_type::sampler2DArray_type);
@@ -327,7 +378,8 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
       add_type(symbols, glsl_type::sampler2DArrayShadow_type);
    }
 
-   if (state->OES_EGL_image_external_enable) {
+   if (state->OES_EGL_image_external_enable ||
+       state->OES_EGL_image_external_essl3_enable) {
       add_type(symbols, glsl_type::samplerExternalOES_type);
    }
 
@@ -335,6 +387,14 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
       add_type(symbols, glsl_type::sampler3D_type);
    }
 
+   if (state->ARB_shader_image_load_store_enable ||
+       state->EXT_texture_cube_map_array_enable ||
+       state->OES_texture_cube_map_array_enable) {
+      add_type(symbols, glsl_type::imageCubeArray_type);
+      add_type(symbols, glsl_type::iimageCubeArray_type);
+      add_type(symbols, glsl_type::uimageCubeArray_type);
+   }
+
    if (state->ARB_shader_image_load_store_enable) {
       add_type(symbols, glsl_type::image1D_type);
       add_type(symbols, glsl_type::image2D_type);
@@ -344,7 +404,6 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
       add_type(symbols, glsl_type::imageBuffer_type);
       add_type(symbols, glsl_type::image1DArray_type);
       add_type(symbols, glsl_type::image2DArray_type);
-      add_type(symbols, glsl_type::imageCubeArray_type);
       add_type(symbols, glsl_type::image2DMS_type);
       add_type(symbols, glsl_type::image2DMSArray_type);
       add_type(symbols, glsl_type::iimage1D_type);
@@ -355,7 +414,6 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
       add_type(symbols, glsl_type::iimageBuffer_type);
       add_type(symbols, glsl_type::iimage1DArray_type);
       add_type(symbols, glsl_type::iimage2DArray_type);
-      add_type(symbols, glsl_type::iimageCubeArray_type);
       add_type(symbols, glsl_type::iimage2DMS_type);
       add_type(symbols, glsl_type::iimage2DMSArray_type);
       add_type(symbols, glsl_type::uimage1D_type);
@@ -366,11 +424,20 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
       add_type(symbols, glsl_type::uimageBuffer_type);
       add_type(symbols, glsl_type::uimage1DArray_type);
       add_type(symbols, glsl_type::uimage2DArray_type);
-      add_type(symbols, glsl_type::uimageCubeArray_type);
       add_type(symbols, glsl_type::uimage2DMS_type);
       add_type(symbols, glsl_type::uimage2DMSArray_type);
    }
 
+   if (state->EXT_texture_buffer_enable || state->OES_texture_buffer_enable) {
+      add_type(symbols, glsl_type::samplerBuffer_type);
+      add_type(symbols, glsl_type::isamplerBuffer_type);
+      add_type(symbols, glsl_type::usamplerBuffer_type);
+
+      add_type(symbols, glsl_type::imageBuffer_type);
+      add_type(symbols, glsl_type::iimageBuffer_type);
+      add_type(symbols, glsl_type::uimageBuffer_type);
+   }
+
    if (state->has_atomic_counters()) {
       add_type(symbols, glsl_type::atomic_uint_type);
    }
@@ -390,5 +457,18 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
       add_type(symbols, glsl_type::dmat4x2_type);
       add_type(symbols, glsl_type::dmat4x3_type);
    }
+
+   if (state->ARB_gpu_shader_int64_enable ||
+       state->AMD_gpu_shader_int64_enable) {
+      add_type(symbols, glsl_type::int64_t_type);
+      add_type(symbols, glsl_type::i64vec2_type);
+      add_type(symbols, glsl_type::i64vec3_type);
+      add_type(symbols, glsl_type::i64vec4_type);
+
+      add_type(symbols, glsl_type::uint64_t_type);
+      add_type(symbols, glsl_type::u64vec2_type);
+      add_type(symbols, glsl_type::u64vec3_type);
+      add_type(symbols, glsl_type::u64vec4_type);
+   }
 }
 /** @} */