break;
case GL_CLAMP_TO_BORDER:
- supported = is_desktop_gl && e->ARB_texture_border_clamp
+ supported = ctx->API != API_OPENGLES && e->ARB_texture_border_clamp
&& (target != GL_TEXTURE_EXTERNAL_OES);
break;
* Only the glGetTexLevelParameter() functions accept proxy targets.
*/
static struct gl_texture_object *
-get_texobj_by_name(struct gl_context *ctx, GLuint texture, GLboolean get)
+get_texobj_by_name(struct gl_context *ctx, GLuint texture, const char *name)
{
struct gl_texture_object *texObj;
- texObj = _mesa_lookup_texture(ctx, texture);
- if (!texObj) {
- /*
- * User passed a non-generated name.
- * Throw the error in the caller.
- */
+ texObj = _mesa_lookup_texture_err(ctx, texture, name);
+ if (!texObj)
return NULL;
- }
switch (texObj->Target) {
case GL_TEXTURE_1D:
case GL_TEXTURE_RECTANGLE:
return texObj;
default:
- _mesa_error(ctx, GL_INVALID_ENUM,
- "gl%sTextureParameter(target)", get ? "Get" : "");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(target)", name);
return NULL;
}
static void
-set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz)
+set_swizzle_component(GLushort *swizzle, GLuint comp, GLuint swz)
{
assert(comp < 4);
assert(swz <= SWIZZLE_NIL);
static inline void
flush(struct gl_context *ctx)
{
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
}
/**
* This is called just prior to changing any texture object state which
* could affect texture completeness (texture base level, max level).
- * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
+ * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE_OBJECT
* state flag and then mark the texture object as 'incomplete' so that any
* per-texture derived state gets recomputed.
*/
static inline void
incomplete(struct gl_context *ctx, struct gl_texture_object *texObj)
{
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
_mesa_dirty_texobj(ctx, texObj);
}
-static GLboolean
-target_allows_setting_sampler_parameters(GLenum target)
+GLboolean
+_mesa_target_allows_setting_sampler_parameters(GLenum target)
{
switch (target) {
case GL_TEXTURE_2D_MULTISAMPLE:
{
const char *suffix = dsa ? "ture" : "";
+ if (texObj->HandleAllocated) {
+ /* The ARB_bindless_texture spec says:
+ *
+ * "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
+ * CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
+ * functions defined in terms of these, if the texture object to be
+ * modified is referenced by one or more texture or image handles."
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTex%sParameter(immutable texture)", suffix);
+ return GL_FALSE;
+ }
+
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.MinFilter == params[0])
return GL_FALSE;
case GL_TEXTURE_MAG_FILTER:
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.MagFilter == params[0])
return GL_FALSE;
case GL_TEXTURE_WRAP_S:
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.WrapS == params[0])
return GL_FALSE;
case GL_TEXTURE_WRAP_T:
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.WrapT == params[0])
return GL_FALSE;
case GL_TEXTURE_WRAP_R:
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.WrapR == params[0])
if (texObj->BaseLevel == params[0])
return GL_FALSE;
+ /* Section 8.10 (Texture Parameters) of the OpenGL 4.5 Core Profile spec
+ * says:
+ *
+ * An INVALID_OPERATION error is generated if the effective target is
+ * TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY, or
+ * TEXTURE_RECTANGLE, and pname TEXTURE_BASE_LEVEL is set to a value
+ * other than zero.
+ *
+ * Note that section 3.8.8 (Texture Parameters) of the OpenGL 3.3 Core
+ * Profile spec said:
+ *
+ * The error INVALID_VALUE is generated if TEXTURE_BASE_LEVEL is set
+ * to any value other than zero.
+ *
+ * We take the 4.5 language as a correction to 3.3, and we implement
+ * that on all GL versions.
+ */
if ((texObj->Target == GL_TEXTURE_2D_MULTISAMPLE ||
- texObj->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) && params[0] != 0)
+ texObj->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY ||
+ texObj->Target == GL_TEXTURE_RECTANGLE) && params[0] != 0)
goto invalid_operation;
if (params[0] < 0) {
"glTex%sParameter(param=%d)", suffix, params[0]);
return GL_FALSE;
}
- if (texObj->Target == GL_TEXTURE_RECTANGLE_ARB && params[0] != 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTex%sParameter(target=%s, param=%d)", suffix,
- _mesa_enum_to_string(texObj->Target), params[0]);
- return GL_FALSE;
- }
incomplete(ctx, texObj);
/** See note about ARB_texture_storage below */
if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_shadow)
|| _mesa_is_gles3(ctx)) {
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.CompareMode == params[0])
if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_shadow)
|| _mesa_is_gles3(ctx)) {
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.CompareFunc == params[0])
goto invalid_pname;
case GL_DEPTH_STENCIL_TEXTURE_MODE:
- if ((_mesa_is_desktop_gl(ctx) &&
- ctx->Extensions.ARB_stencil_texturing) ||
- _mesa_is_gles31(ctx)) {
+ if (_mesa_has_ARB_stencil_texturing(ctx) || _mesa_is_gles31(ctx)) {
bool stencil = params[0] == GL_STENCIL_INDEX;
if (!stencil && params[0] != GL_DEPTH_COMPONENT)
goto invalid_param;
goto invalid_pname;
case GL_TEXTURE_SRGB_DECODE_EXT:
- if (_mesa_is_desktop_gl(ctx)
- && ctx->Extensions.EXT_texture_sRGB_decode) {
+ if (ctx->Extensions.EXT_texture_sRGB_decode) {
GLenum decode = params[0];
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (decode == GL_DECODE_EXT || decode == GL_SKIP_DECODE_EXT) {
&& ctx->Extensions.AMD_seamless_cubemap_per_texture) {
GLenum param = params[0];
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (param != GL_TRUE && param != GL_FALSE) {
}
goto invalid_pname;
+ case GL_TEXTURE_TILING_EXT:
+ if (ctx->Extensions.EXT_memory_object) {
+ texObj->TextureTiling = params[0];
+
+ return GL_TRUE;
+ }
+ goto invalid_pname;
+
default:
goto invalid_pname;
}
{
const char *suffix = dsa ? "ture" : "";
+ if (texObj->HandleAllocated) {
+ /* The ARB_bindless_texture spec says:
+ *
+ * "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
+ * CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
+ * functions defined in terms of these, if the texture object to be
+ * modified is referenced by one or more texture or image handles."
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTex%sParameter(immutable texture)", suffix);
+ return GL_FALSE;
+ }
+
switch (pname) {
case GL_TEXTURE_MIN_LOD:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
goto invalid_pname;
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.MinLod == params[0])
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
goto invalid_pname;
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.MaxLod == params[0])
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (ctx->Extensions.EXT_texture_filter_anisotropic) {
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.MaxAnisotropy == params[0])
if (_mesa_is_gles(ctx))
goto invalid_pname;
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
if (texObj->Sampler.LodBias != params[0]) {
break;
case GL_TEXTURE_BORDER_COLOR:
- if (!_mesa_is_desktop_gl(ctx))
+ /* Border color exists in desktop OpenGL since 1.0 for GL_CLAMP. In
+ * OpenGL ES 2.0+, it only exists in when GL_OES_texture_border_clamp is
+ * enabled. It is never available in OpenGL ES 1.x.
+ *
+ * FIXME: Every driver that supports GLES2 has this extension. Elide
+ * the check?
+ */
+ if (ctx->API == API_OPENGLES ||
+ (ctx->API == API_OPENGLES2 &&
+ !ctx->Extensions.ARB_texture_border_clamp))
goto invalid_pname;
- if (!target_allows_setting_sampler_parameters(texObj->Target))
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
goto invalid_enum;
flush(ctx);
}
return GL_TRUE;
+ case GL_TEXTURE_TILING_EXT:
+ if (ctx->Extensions.EXT_memory_object) {
+ texObj->TextureTiling = params[0];
+ return GL_TRUE;
+ }
+ goto invalid_pname;
+
default:
goto invalid_pname;
}
}
if (ctx->Driver.TexParameter && need_update) {
- ctx->Driver.TexParameter(ctx, texObj, pname, ¶m);
+ ctx->Driver.TexParameter(ctx, texObj, pname);
}
}
}
if (ctx->Driver.TexParameter && need_update) {
- ctx->Driver.TexParameter(ctx, texObj, pname, params);
+ ctx->Driver.TexParameter(ctx, texObj, pname);
}
}
}
if (ctx->Driver.TexParameter && need_update) {
- GLfloat fparam = (GLfloat) param;
- ctx->Driver.TexParameter(ctx, texObj, pname, &fparam);
+ ctx->Driver.TexParameter(ctx, texObj, pname);
}
}
}
if (ctx->Driver.TexParameter && need_update) {
- GLfloat fparams[4];
- fparams[0] = INT_TO_FLOAT(params[0]);
- if (pname == GL_TEXTURE_BORDER_COLOR ||
- pname == GL_TEXTURE_CROP_RECT_OES) {
- fparams[1] = INT_TO_FLOAT(params[1]);
- fparams[2] = INT_TO_FLOAT(params[2]);
- fparams[3] = INT_TO_FLOAT(params[3]);
- }
- ctx->Driver.TexParameter(ctx, texObj, pname, fparams);
+ ctx->Driver.TexParameter(ctx, texObj, pname);
}
}
{
switch (pname) {
case GL_TEXTURE_BORDER_COLOR:
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ if (texObj->HandleAllocated) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterIiv(immutable texture)");
+ return;
+ }
+
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTextureParameterIiv(texture)");
+ return;
+ }
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
/* set the integer-valued border color */
COPY_4V(texObj->Sampler.BorderColor.i, params);
break;
{
switch (pname) {
case GL_TEXTURE_BORDER_COLOR:
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ if (texObj->HandleAllocated) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterIuiv(immutable texture)");
+ return;
+ }
+
+ if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTextureParameterIuiv(texture)");
+ return;
+ }
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
/* set the unsigned integer-valued border color */
COPY_4V(texObj->Sampler.BorderColor.ui, params);
break;
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
- if (!texObj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameterfv(texture)");
+ texObj = get_texobj_by_name(ctx, texture, "glTextureParameterfv");
+ if (!texObj)
return;
- }
_mesa_texture_parameterfv(ctx, texObj, pname, params, true);
}
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
- if (!texObj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameterf(texture)");
+ texObj = get_texobj_by_name(ctx, texture, "glTextureParameterf");
+ if (!texObj)
return;
- }
_mesa_texture_parameterf(ctx, texObj, pname, param, true);
}
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
- if (!texObj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameteri(texture)");
+ texObj = get_texobj_by_name(ctx, texture, "glTextureParameteri");
+ if (!texObj)
return;
- }
_mesa_texture_parameteri(ctx, texObj, pname, param, true);
}
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
- if (!texObj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameteriv(texture)");
+ texObj = get_texobj_by_name(ctx, texture, "glTextureParameteriv");
+ if (!texObj)
return;
- }
_mesa_texture_parameteriv(ctx, texObj, pname, params, true);
}
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
- if (!texObj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureParameterIiv(texture)");
+ texObj = get_texobj_by_name(ctx, texture, "glTextureParameterIiv");
+ if (!texObj)
return;
- }
_mesa_texture_parameterIiv(ctx, texObj, pname, params, true);
}
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
- if (!texObj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureParameterIuiv(texture)");
+ texObj = get_texobj_by_name(ctx, texture, "glTextureParameterIuiv");
+ if (!texObj)
return;
- }
_mesa_texture_parameterIuiv(ctx, texObj, pname, params, true);
}
-static GLboolean
-legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target,
- bool dsa)
+GLboolean
+_mesa_legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target,
+ bool dsa)
{
/* Common targets for desktop GL and GLES 3.1. */
switch (target) {
return GL_TRUE;
case GL_TEXTURE_2D_ARRAY_EXT:
return ctx->Extensions.EXT_texture_array;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
return ctx->Extensions.ARB_texture_cube_map;
case GL_TEXTURE_2D_MULTISAMPLE:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
return ctx->Extensions.ARB_texture_multisample;
+ case GL_TEXTURE_BUFFER:
+ /* GetTexLevelParameter accepts GL_TEXTURE_BUFFER in GL 3.1+ contexts,
+ * but not in earlier versions that expose ARB_texture_buffer_object.
+ *
+ * From the ARB_texture_buffer_object spec:
+ * "(7) Do buffer textures support texture parameters (TexParameter) or
+ * queries (GetTexParameter, GetTexLevelParameter, GetTexImage)?
+ *
+ * RESOLVED: No. [...] Note that the spec edits above don't add
+ * explicit error language for any of these cases. That is because
+ * each of the functions enumerate the set of valid <target>
+ * parameters. Not editing the spec to allow TEXTURE_BUFFER_ARB in
+ * these cases means that target is not legal, and an INVALID_ENUM
+ * error should be generated."
+ *
+ * From the OpenGL 3.1 spec:
+ * "target may also be TEXTURE_BUFFER, indicating the texture buffer."
+ */
+ return (_mesa_is_desktop_gl(ctx) && ctx->Version >= 31) ||
+ _mesa_has_OES_texture_buffer(ctx);
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ return _mesa_has_texture_cube_map_array(ctx);
}
if (!_mesa_is_desktop_gl(ctx))
case GL_PROXY_TEXTURE_2D:
case GL_PROXY_TEXTURE_3D:
return GL_TRUE;
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
return ctx->Extensions.ARB_texture_cube_map;
- case GL_TEXTURE_CUBE_MAP_ARRAY_ARB:
- case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY:
return ctx->Extensions.ARB_texture_cube_map_array;
case GL_TEXTURE_RECTANGLE_NV:
case GL_PROXY_TEXTURE_RECTANGLE_NV:
case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
return ctx->Extensions.EXT_texture_array;
- case GL_TEXTURE_BUFFER:
- /* GetTexLevelParameter accepts GL_TEXTURE_BUFFER in GL 3.1+ contexts,
- * but not in earlier versions that expose ARB_texture_buffer_object.
- *
- * From the ARB_texture_buffer_object spec:
- * "(7) Do buffer textures support texture parameters (TexParameter) or
- * queries (GetTexParameter, GetTexLevelParameter, GetTexImage)?
- *
- * RESOLVED: No. [...] Note that the spec edits above don't add
- * explicit error language for any of these cases. That is because
- * each of the functions enumerate the set of valid <target>
- * parameters. Not editing the spec to allow TEXTURE_BUFFER_ARB in
- * these cases means that target is not legal, and an INVALID_ENUM
- * error should be generated."
- *
- * From the OpenGL 3.1 spec:
- * "target may also be TEXTURE_BUFFER, indicating the texture buffer."
- */
- return ctx->API == API_OPENGL_CORE && ctx->Version >= 31;
case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
return ctx->Extensions.ARB_texture_multisample;
dummy_image.TexFormat = MESA_FORMAT_NONE;
dummy_image.InternalFormat = GL_RGBA;
dummy_image._BaseFormat = GL_NONE;
+ dummy_image.FixedSampleLocations = GL_TRUE;
img = &dummy_image;
}
/* GL_ARB_texture_compression */
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
- if (_mesa_is_format_compressed(texFormat) &&
+ if (_mesa_is_format_compressed(texFormat) &&
!_mesa_is_proxy_texture(target)) {
*params = _mesa_format_image_size(texFormat, img->Width,
img->Height, img->Depth);
- }
- else {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
- _mesa_enum_to_string(pname));
- }
+ } else {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
+ _mesa_enum_to_string(pname));
+ }
break;
case GL_TEXTURE_COMPRESSED:
*params = (GLint) _mesa_is_format_compressed(texFormat);
*params = img->FixedSampleLocations;
break;
+ /* There is never a buffer data store here, but these pnames still have
+ * to work.
+ */
+
+ /* GL_ARB_texture_buffer_object */
+ case GL_TEXTURE_BUFFER_DATA_STORE_BINDING:
+ if (!ctx->Extensions.ARB_texture_buffer_object)
+ goto invalid_pname;
+ *params = 0;
+ break;
+
+ /* GL_ARB_texture_buffer_range */
+ case GL_TEXTURE_BUFFER_OFFSET:
+ if (!ctx->Extensions.ARB_texture_buffer_range)
+ goto invalid_pname;
+ *params = 0;
+ break;
+ case GL_TEXTURE_BUFFER_SIZE:
+ if (!ctx->Extensions.ARB_texture_buffer_range)
+ goto invalid_pname;
+ *params = 0;
+ break;
+
default:
goto invalid_pname;
}
}
+/**
+ * Handle a glGetTexLevelParamteriv() call for a texture buffer.
+ */
static void
get_tex_level_parameter_buffer(struct gl_context *ctx,
const struct gl_texture_object *texObj,
{
const struct gl_buffer_object *bo = texObj->BufferObject;
mesa_format texFormat = texObj->_BufferObjectFormat;
+ int bytes = MAX2(1, _mesa_get_format_bytes(texFormat));
GLenum internalFormat = texObj->BufferObjectFormat;
GLenum baseFormat = _mesa_get_format_base_format(texFormat);
const char *suffix = dsa ? "ture" : "";
+ assert(texObj->Target == GL_TEXTURE_BUFFER);
+
if (!bo) {
/* undefined texture buffer object */
- *params = pname == GL_TEXTURE_COMPONENTS ? 1 : 0;
+ switch (pname) {
+ case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS:
+ *params = GL_TRUE;
+ break;
+ case GL_TEXTURE_INTERNAL_FORMAT:
+ *params = internalFormat;
+ break;
+ default:
+ *params = 0;
+ break;
+ }
return;
}
*params = bo->Name;
break;
case GL_TEXTURE_WIDTH:
- *params = bo->Size;
+ *params = ((texObj->BufferSize == -1) ? bo->Size : texObj->BufferSize)
+ / bytes;
break;
case GL_TEXTURE_HEIGHT:
case GL_TEXTURE_DEPTH:
+ *params = 1;
+ break;
case GL_TEXTURE_BORDER:
case GL_TEXTURE_SHARED_SIZE:
case GL_TEXTURE_COMPRESSED:
*params = (texObj->BufferSize == -1) ? bo->Size : texObj->BufferSize;
break;
+ /* GL_ARB_texture_multisample */
+ case GL_TEXTURE_SAMPLES:
+ if (!ctx->Extensions.ARB_texture_multisample)
+ goto invalid_pname;
+ *params = 0;
+ break;
+
+ case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS:
+ if (!ctx->Extensions.ARB_texture_multisample)
+ goto invalid_pname;
+ *params = GL_TRUE;
+ break;
+
/* GL_ARB_texture_compression */
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
/* Always illegal for GL_TEXTURE_BUFFER */
bool dsa)
{
const char *suffix = dsa ? "ture" : "";
- if (!legal_get_tex_level_parameter_target(ctx, target, dsa)) {
+ if (!_mesa_legal_get_tex_level_parameter_target(ctx, target, dsa)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetTex%sLevelParameter[if]v(target=%s)", suffix,
_mesa_enum_to_string(target));
*params = ENUM_TO_FLOAT(obj->Sampler.WrapR);
break;
case GL_TEXTURE_BORDER_COLOR:
- if (!_mesa_is_desktop_gl(ctx))
+ if (ctx->API == API_OPENGLES ||
+ !ctx->Extensions.ARB_texture_border_clamp)
goto invalid_pname;
if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
*params = (GLfloat) obj->DepthMode;
break;
case GL_DEPTH_STENCIL_TEXTURE_MODE:
- if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_stencil_texturing)
+ if (!_mesa_has_ARB_stencil_texturing(ctx) && !_mesa_is_gles31(ctx))
goto invalid_pname;
*params = (GLfloat)
(obj->StencilSampling ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT);
*params = (GLfloat) obj->ImageFormatCompatibilityType;
break;
+ case GL_TEXTURE_TARGET:
+ if (ctx->API != API_OPENGL_CORE)
+ goto invalid_pname;
+ *params = ENUM_TO_FLOAT(obj->Target);
+ break;
+
+ case GL_TEXTURE_TILING_EXT:
+ if (!ctx->Extensions.EXT_memory_object)
+ goto invalid_pname;
+ *params = ENUM_TO_FLOAT(obj->TextureTiling);
+ break;
+
default:
goto invalid_pname;
}
*params = (GLint) obj->Sampler.WrapR;
break;
case GL_TEXTURE_BORDER_COLOR:
- if (!_mesa_is_desktop_gl(ctx))
+ if (ctx->API == API_OPENGLES ||
+ !ctx->Extensions.ARB_texture_border_clamp)
goto invalid_pname;
{
*params = (GLint) obj->DepthMode;
break;
case GL_DEPTH_STENCIL_TEXTURE_MODE:
- if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_stencil_texturing)
+ if (!_mesa_has_ARB_stencil_texturing(ctx) && !_mesa_is_gles31(ctx))
goto invalid_pname;
*params = (GLint)
(obj->StencilSampling ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT);
*params = obj->ImageFormatCompatibilityType;
break;
+ case GL_TEXTURE_TARGET:
+ if (ctx->API != API_OPENGL_CORE)
+ goto invalid_pname;
+ *params = (GLint) obj->Target;
+ break;
+
+ case GL_TEXTURE_TILING_EXT:
+ if (!ctx->Extensions.EXT_memory_object)
+ goto invalid_pname;
+ *params = (GLint) obj->TextureTiling;
+ break;
+
default:
goto invalid_pname;
}
}
}
-static void
-get_tex_parameterIuiv(struct gl_context *ctx,
- struct gl_texture_object *obj,
- GLenum pname, GLuint *params, bool dsa)
-{
- switch (pname) {
- case GL_TEXTURE_BORDER_COLOR:
- COPY_4V(params, obj->Sampler.BorderColor.i);
- break;
- default:
- {
- GLint ip[4];
- get_tex_parameteriv(ctx, obj, pname, ip, dsa);
- params[0] = ip[0];
- if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT ||
- pname == GL_TEXTURE_CROP_RECT_OES) {
- params[1] = ip[1];
- params[2] = ip[2];
- params[3] = ip[3];
- }
- }
- }
-}
-
void GLAPIENTRY
_mesa_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
{
if (!texObj)
return;
- get_tex_parameterIuiv(ctx, texObj, pname, params, false);
+ get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, false);
}
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
- obj = get_texobj_by_name(ctx, texture, GL_TRUE);
- if (!obj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureParameterfv(texture)");
+ obj = get_texobj_by_name(ctx, texture, "glGetTextureParameterfv");
+ if (!obj)
return;
- }
get_tex_parameterfv(ctx, obj, pname, params, true);
}
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
- obj = get_texobj_by_name(ctx, texture, GL_TRUE);
- if (!obj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureParameteriv(texture)");
+ obj = get_texobj_by_name(ctx, texture, "glGetTextureParameteriv");
+ if (!obj)
return;
- }
get_tex_parameteriv(ctx, obj, pname, params, true);
}
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
- if (!texObj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureParameterIiv(texture)");
+ texObj = get_texobj_by_name(ctx, texture, "glGetTextureParameterIiv");
+ if (!texObj)
return;
- }
get_tex_parameterIiv(ctx, texObj, pname, params, true);
}
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
- if (!texObj) {
- /* User passed a non-generated name. */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTextureParameterIuiv(texture)");
+ texObj = get_texobj_by_name(ctx, texture, "glGetTextureParameterIuiv");
+ if (!texObj)
return;
- }
- get_tex_parameterIuiv(ctx, texObj, pname, params, true);
+ get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, true);
}