mesa: add missing queries for ARB_direct_state_access
This adds index queries (glGet*i_v) for GL_TEXTURE_BINDING_* and GL_SAMPLER_BINDING, as well as textue queries (glGetTex{,ture}Parameter*) for GL_TEXTURE_TARGET. CC: "10.6 11.0" <mesa-stable@lists.freedesktop.org> Reviewed-by: Fredrik Höglund <fredrik@kde.org> Signed-off-by: Fredrik Höglund <fredrik@kde.org>
This commit is contained in:
parent
2dbc6a0ad9
commit
5aaaaebf22
|
@ -35,6 +35,7 @@
|
||||||
#include "mtypes.h"
|
#include "mtypes.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "texcompress.h"
|
#include "texcompress.h"
|
||||||
|
#include "texstate.h"
|
||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
#include "samplerobj.h"
|
#include "samplerobj.h"
|
||||||
#include "stencil.h"
|
#include "stencil.h"
|
||||||
|
@ -1750,6 +1751,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:
|
||||||
|
return ctx->Extensions.ARB_texture_cube_map
|
||||||
|
? TEXTURE_CUBE_INDEX : -1;
|
||||||
|
case GL_TEXTURE_BINDING_RECTANGLE:
|
||||||
|
return _mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle
|
||||||
|
? TEXTURE_RECT_INDEX : -1;
|
||||||
|
case GL_TEXTURE_BINDING_1D_ARRAY:
|
||||||
|
return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array
|
||||||
|
? TEXTURE_1D_ARRAY_INDEX : -1;
|
||||||
|
case GL_TEXTURE_BINDING_2D_ARRAY:
|
||||||
|
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
|
static enum value_type
|
||||||
find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
|
find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
|
||||||
{
|
{
|
||||||
|
@ -2013,6 +2060,45 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
|
||||||
v->value_int = ctx->ImageUnits[index].Format;
|
v->value_int = ctx->ImageUnits[index].Format;
|
||||||
return TYPE_INT;
|
return TYPE_INT;
|
||||||
|
|
||||||
|
/* ARB_direct_state_access */
|
||||||
|
case GL_TEXTURE_BINDING_1D:
|
||||||
|
case GL_TEXTURE_BINDING_1D_ARRAY:
|
||||||
|
case GL_TEXTURE_BINDING_2D:
|
||||||
|
case GL_TEXTURE_BINDING_2D_ARRAY:
|
||||||
|
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:
|
||||||
|
case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
|
||||||
|
case GL_TEXTURE_BINDING_RECTANGLE: {
|
||||||
|
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 >= _mesa_max_tex_unit(ctx))
|
||||||
|
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 >= _mesa_max_tex_unit(ctx))
|
||||||
|
goto invalid_value;
|
||||||
|
|
||||||
|
samp = ctx->Texture.Unit[index].Sampler;
|
||||||
|
v->value_int = samp ? samp->Name : 0;
|
||||||
|
return TYPE_INT;
|
||||||
|
}
|
||||||
|
|
||||||
case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
|
case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
|
||||||
if (!_mesa_has_compute_shaders(ctx))
|
if (!_mesa_has_compute_shaders(ctx))
|
||||||
goto invalid_enum;
|
goto invalid_enum;
|
||||||
|
|
|
@ -1926,6 +1926,12 @@ get_tex_parameterfv(struct gl_context *ctx,
|
||||||
*params = (GLfloat) obj->ImageFormatCompatibilityType;
|
*params = (GLfloat) obj->ImageFormatCompatibilityType;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GL_TEXTURE_TARGET:
|
||||||
|
if (ctx->API != API_OPENGL_CORE)
|
||||||
|
goto invalid_pname;
|
||||||
|
*params = ENUM_TO_FLOAT(obj->Target);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
goto invalid_pname;
|
goto invalid_pname;
|
||||||
}
|
}
|
||||||
|
@ -2151,6 +2157,12 @@ get_tex_parameteriv(struct gl_context *ctx,
|
||||||
*params = obj->ImageFormatCompatibilityType;
|
*params = obj->ImageFormatCompatibilityType;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GL_TEXTURE_TARGET:
|
||||||
|
if (ctx->API != API_OPENGL_CORE)
|
||||||
|
goto invalid_pname;
|
||||||
|
*params = (GLint) obj->Target;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
goto invalid_pname;
|
goto invalid_pname;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue