[Mesa-dev] [PATCH v2] mesa: add missing queries for ARB_direct_state_access

Daniel Scharrer daniel at constexpr.org
Wed Aug 12 09:07:58 PDT 2015


On 2015-08-12 17:14, Brian Paul wrote:
> Another question below...
> 
> On 08/12/2015 08:31 AM, Daniel Scharrer wrote:
>> On 2015-08-06 15:46, Brian Paul wrote:
>>> On 08/06/2015 07:44 AM, Daniel Scharrer wrote:
>>>> CC: "10.6" <mesa-stable at lists.freedesktop.org>
>>>>
>>>> ---
>>>>
>>>> v2: added CC for 10.6
>>>>       renamed _mesa_tex_target_to_index to tex_target_to_index
>>>>       moved declaration of variable before code
>>>>       added missing spaces in ternary operators
>>>>
>>>>    src/mesa/main/get.c      | 93 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>>    src/mesa/main/texparam.c | 12 +++++++
>>>>    2 files changed, 105 insertions(+)
>>>>
>>>> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
>>>> index 307a5ff..3b8cbbc 100644
>>>> --- a/src/mesa/main/get.c
>>>> +++ b/src/mesa/main/get.c
>>>> @@ -1785,6 +1785,52 @@ _mesa_GetDoublev(GLenum pname, GLdouble *params)
>>>>       }
>>>>    }
>>>>
>>>> +/**
>>>> + * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
>>>> + * into the corresponding Mesa texture target index.
>>>> + * \return TEXTURE_x_INDEX or -1 if binding is invalid
>>>> + */
>>>> +static int
>>>> +tex_binding_to_index(const struct gl_context *ctx, GLenum binding)
>>>> +{
>>>> +   switch (binding) {
>>>> +   case GL_TEXTURE_BINDING_1D:
>>>> +      return _mesa_is_desktop_gl(ctx) ? TEXTURE_1D_INDEX : -1;
>>>> +   case GL_TEXTURE_BINDING_2D:
>>>> +      return TEXTURE_2D_INDEX;
>>>> +   case GL_TEXTURE_BINDING_3D:
>>>> +      return ctx->API != API_OPENGLES ? TEXTURE_3D_INDEX : -1;
>>>> +   case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
>>>> +      return ctx->Extensions.ARB_texture_cube_map
>>>> +         ? TEXTURE_CUBE_INDEX : -1;
>>>> +   case GL_TEXTURE_BINDING_RECTANGLE_NV:
>>>> +      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle
>>>> +         ? TEXTURE_RECT_INDEX : -1;
>>>> +   case GL_TEXTURE_BINDING_1D_ARRAY_EXT:
>>>> +      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array
>>>> +         ? TEXTURE_1D_ARRAY_INDEX : -1;
>>>> +   case GL_TEXTURE_BINDING_2D_ARRAY_EXT:
>>>> +      return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array)
>>>> +         || _mesa_is_gles3(ctx)
>>>> +         ? TEXTURE_2D_ARRAY_INDEX : -1;
>>>> +   case GL_TEXTURE_BINDING_BUFFER:
>>>> +      return ctx->API == API_OPENGL_CORE &&
>>>> +             ctx->Extensions.ARB_texture_buffer_object ?
>>>> +             TEXTURE_BUFFER_INDEX : -1;
>>>> +   case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
>>>> +      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_cube_map_array
>>>> +         ? TEXTURE_CUBE_ARRAY_INDEX : -1;
>>>> +   case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
>>>> +      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample
>>>> +         ? TEXTURE_2D_MULTISAMPLE_INDEX : -1;
>>>> +   case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
>>>> +      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample
>>>> +         ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : -1;
>>>> +   default:
>>>> +      return -1;
>>>> +   }
>>>> +}
>>>> +
>>>>    static enum value_type
>>>>    find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
>>>>    {
>>>> @@ -2048,6 +2094,53 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
>>>>          v->value_int = ctx->ImageUnits[index].Format;
>>>>          return TYPE_INT;
>>>>
>>>> +   /* ARB_direct_state_access */
>>>> +   case GL_TEXTURE_BINDING_1D:
>>>> +   case GL_TEXTURE_BINDING_1D_ARRAY_EXT:
>>>> +   case GL_TEXTURE_BINDING_2D:
>>>> +   case GL_TEXTURE_BINDING_2D_ARRAY_EXT:
>>>> +   case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
>>>> +   case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
>>>> +   case GL_TEXTURE_BINDING_3D:
>>>> +   case GL_TEXTURE_BINDING_BUFFER:
>>>> +   case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
>>>> +   case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
>>>> +   case GL_TEXTURE_BINDING_RECTANGLE_NV: {
>>>> +      int target;
>>>> +
>>>> +      if (ctx->API != API_OPENGL_CORE)
>>>> +         goto invalid_enum;
>>>> +      target = tex_binding_to_index(ctx, pname);
>>>> +      if (target < 0)
>>>> +         goto invalid_enum;
>>>> +      if (index >= ctx->Const.MaxTextureUnits)
> 
> Is ctx->Const.MaxTextureUnits the right limit here?  I think it might be ctx->Const.MaxCombinedTextureImageUnits

You're right, that limit is wrong.

However, I see now that glActiveTexture / glBindTextureUnit use _mesa_max_tex_unit(ctx) as the limit,
which equals MAX2(ctx->Const.MaxCombinedTextureImageUnits, ctx->Const.MaxTextureCoordUnits);
Shouldn't that also be used for the *_BINDING queries, or does it not matter for core contexts.

>>>> +         goto invalid_value;
>>>> +
>>>> +      v->value_int = ctx->Texture.Unit[index].CurrentTex[target]->Name;
>>>> +      return TYPE_INT;
>>>> +   }
>>>> +
>>>> +   case GL_SAMPLER_BINDING: {
>>>> +      struct gl_sampler_object *samp;
>>>> +
>>>> +      if (ctx->API != API_OPENGL_CORE)
>>>> +         goto invalid_enum;
>>>> +      if (index >= ctx->Const.MaxTextureUnits)
> 
> Same there.
> 
> 
>>>> +         goto invalid_value;
>>>> +
>>>> +      samp = ctx->Texture.Unit[index].Sampler;
>>>> +      /*
>>>> +       * The sampler object may have been deleted on another context,
>>>> +       * so we try to lookup the sampler object before returning its Name.
>>>> +       */
>>>> +      if (samp && _mesa_lookup_samplerobj(ctx, samp->Name)) {
>>>> +         v->value_int = samp->Name;
>>>> +      } else {
>>>> +         v->value_int = 0;
>>>> +      }
>>>> +      return TYPE_INT;
>>>> +   }
>>>> +
>>>>       case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
>>>>          if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_compute_shader)
>>>>             goto invalid_enum;
>>>> diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
>>>> index c0611c3..f68d49e 100644
>>>> --- a/src/mesa/main/texparam.c
>>>> +++ b/src/mesa/main/texparam.c
>>>> @@ -1890,6 +1890,12 @@ get_tex_parameterfv(struct gl_context *ctx,
>>>>             *params = (GLfloat) obj->Sampler.sRGBDecode;
>>>>             break;
>>>>
>>>> +      case GL_TEXTURE_TARGET:
>>>> +         if (ctx->API != API_OPENGL_CORE)
>>>> +            goto invalid_pname;
>>>> +         *params = ENUM_TO_FLOAT(obj->Target);
>>>> +         break;
>>>> +
>>>>          default:
>>>>             goto invalid_pname;
>>>>       }
>>>> @@ -2115,6 +2121,12 @@ get_tex_parameteriv(struct gl_context *ctx,
>>>>             *params = obj->ImageFormatCompatibilityType;
>>>>             break;
>>>>
>>>> +      case GL_TEXTURE_TARGET:
>>>> +         if (ctx->API != API_OPENGL_CORE)
>>>> +            goto invalid_pname;
>>>> +         *params = (GLint) obj->Target;
>>>> +         break;
>>>> +
>>>>          default:
>>>>             goto invalid_pname;
>>>>       }
>>>>
>>>
>>>
>>> Reviewed-by: Brian Paul <brianp at vmware.com>
>>>
>>
>> Hi,
>>
>> can you please push this - or is there something else I need to do here?
> 
> Will do after the question above is resolved.
> 
> -Brian
> 
> 

--
Daniel


More information about the mesa-dev mailing list