[Mesa-dev] [PATCH 05/11] mesa: Add image parameter queries for ARB_shader_image_load_store.

Francisco Jerez currojerez at riseup.net
Sun Nov 24 21:00:42 PST 2013


---
 src/mesa/main/get.c              | 70 ++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/get_hash_params.py |  9 ++++++
 src/mesa/main/texparam.c         |  6 ++++
 3 files changed, 85 insertions(+)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index eee8550..db77a65 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -145,6 +145,7 @@ enum value_extra {
    EXTRA_GLSL_130,
    EXTRA_EXT_UBO_GS4,
    EXTRA_EXT_ATOMICS_GS4,
+   EXTRA_EXT_SHADER_IMAGE_GS4,
 };
 
 #define NO_EXTRA NULL
@@ -338,6 +339,11 @@ static const int extra_ARB_shader_atomic_counters_and_geometry_shader[] = {
    EXTRA_END
 };
 
+static const int extra_ARB_shader_image_load_store_and_geometry_shader[] = {
+   EXTRA_EXT_SHADER_IMAGE_GS4,
+   EXTRA_END
+};
+
 EXTRA_EXT(ARB_texture_cube_map);
 EXTRA_EXT(MESA_texture_array);
 EXTRA_EXT(NV_fog_distance);
@@ -375,6 +381,7 @@ EXTRA_EXT(ARB_texture_buffer_range);
 EXTRA_EXT(ARB_texture_multisample);
 EXTRA_EXT(ARB_texture_gather);
 EXTRA_EXT(ARB_shader_atomic_counters);
+EXTRA_EXT(ARB_shader_image_load_store);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
@@ -1023,6 +1030,11 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
          api_found = (ctx->Extensions.ARB_shader_atomic_counters &&
                       _mesa_has_geometry_shaders(ctx));
          break;
+      case EXTRA_EXT_SHADER_IMAGE_GS4:
+         api_check = GL_TRUE;
+         api_found = (ctx->Extensions.ARB_shader_image_load_store &&
+                      _mesa_has_geometry_shaders(ctx));
+         break;
       case EXTRA_END:
 	 break;
       default: /* *e is a offset into the extension struct */
@@ -1763,6 +1775,64 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
       if (index >= ctx->Const.VertexProgram.MaxAttribs)
           goto invalid_value;
       v->value_int = ctx->Array.ArrayObj->VertexBinding[VERT_ATTRIB_GENERIC(index)].Stride;
+
+   /* ARB_shader_image_load_store */
+   case GL_IMAGE_BINDING_NAME: {
+      struct gl_texture_object *t;
+
+      if (!ctx->Extensions.ARB_shader_image_load_store)
+         goto invalid_enum;
+      if (index > ctx->Const.MaxImageUnits)
+         goto invalid_value;
+
+      t = ctx->ImageUnits[index].TexObj;
+      v->value_int = (t ? t->Name : 0);
+      return TYPE_INT;
+   }
+
+   case GL_IMAGE_BINDING_LEVEL:
+      if (!ctx->Extensions.ARB_shader_image_load_store)
+         goto invalid_enum;
+      if (index > ctx->Const.MaxImageUnits)
+         goto invalid_value;
+
+      v->value_int = ctx->ImageUnits[index].Level;
+      return TYPE_INT;
+
+   case GL_IMAGE_BINDING_LAYERED:
+      if (!ctx->Extensions.ARB_shader_image_load_store)
+         goto invalid_enum;
+      if (index > ctx->Const.MaxImageUnits)
+         goto invalid_value;
+
+      v->value_int = ctx->ImageUnits[index].Layered;
+      return TYPE_INT;
+
+   case GL_IMAGE_BINDING_LAYER:
+      if (!ctx->Extensions.ARB_shader_image_load_store)
+         goto invalid_enum;
+      if (index > ctx->Const.MaxImageUnits)
+         goto invalid_value;
+
+      v->value_int = ctx->ImageUnits[index].Layer;
+      return TYPE_INT;
+
+   case GL_IMAGE_BINDING_ACCESS:
+      if (!ctx->Extensions.ARB_shader_image_load_store)
+         goto invalid_enum;
+      if (index > ctx->Const.MaxImageUnits)
+         goto invalid_value;
+
+      v->value_int = ctx->ImageUnits[index].Access;
+      return TYPE_INT;
+
+   case GL_IMAGE_BINDING_FORMAT:
+      if (!ctx->Extensions.ARB_shader_image_load_store)
+         goto invalid_enum;
+      if (index > ctx->Const.MaxImageUnits)
+         goto invalid_value;
+
+      v->value_int = ctx->ImageUnits[index].Format;
       return TYPE_INT;
    }
 
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index c961fee..ab7a900 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -741,6 +741,15 @@ descriptor=[
 # GL_ARB_vertex_attrib_binding
   [ "MAX_VERTEX_ATTRIB_RELATIVE_OFFSET", "CONTEXT_ENUM(Const.MaxVertexAttribRelativeOffset), NO_EXTRA" ],
   [ "MAX_VERTEX_ATTRIB_BINDINGS", "CONTEXT_ENUM(Const.MaxVertexAttribBindings), NO_EXTRA" ],
+
+# GL_ARB_shader_image_load_store
+  [ "MAX_IMAGE_UNITS", "CONTEXT_INT(Const.MaxImageUnits), extra_ARB_shader_image_load_store"],
+  [ "MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS", "CONTEXT_INT(Const.MaxCombinedImageUnitsAndFragmentOutputs), extra_ARB_shader_image_load_store"],
+  [ "MAX_IMAGE_SAMPLES", "CONTEXT_INT(Const.MaxImageSamples), extra_ARB_shader_image_load_store"],
+  [ "MAX_VERTEX_IMAGE_UNIFORMS", "CONTEXT_INT(Const.VertexProgram.MaxImageUniforms), extra_ARB_shader_image_load_store"],
+  [ "MAX_GEOMETRY_IMAGE_UNIFORMS", "CONTEXT_INT(Const.GeometryProgram.MaxImageUniforms), extra_ARB_shader_image_load_store_and_geometry_shader"],
+  [ "MAX_FRAGMENT_IMAGE_UNIFORMS", "CONTEXT_INT(Const.FragmentProgram.MaxImageUniforms), extra_ARB_shader_image_load_store"],
+  [ "MAX_COMBINED_IMAGE_UNIFORMS", "CONTEXT_INT(Const.MaxCombinedImageUniforms), extra_ARB_shader_image_load_store"],
 ]},
 
 # Enums restricted to OpenGL Core profile
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 7092c63..8268f26 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1763,6 +1763,12 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
          *params = obj->Sampler.sRGBDecode;
          break;
 
+      case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE:
+         if (!ctx->Extensions.ARB_shader_image_load_store)
+            goto invalid_pname;
+         *params = obj->ImageFormatCompatibility;
+         break;
+
       default:
          goto invalid_pname;
    }
-- 
1.8.3.4



More information about the mesa-dev mailing list