summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorLaura Ekstrand <[email protected]>2014-12-10 15:19:59 -0800
committerLaura Ekstrand <[email protected]>2015-01-08 11:37:29 -0800
commit86bb3be3193512c12c284bb2cc609fa78d27fc55 (patch)
treeab1f188fbf1cc6b7c786c371a5477bff9543f96a /src/mesa
parentbf5c588cdea616e0fb57f904c38bc0eb5eb2b962 (diff)
main: Added entry points for glGetTextureLevelParameteriv, fv.
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/tests/dispatch_sanity.cpp2
-rw-r--r--src/mesa/main/texparam.c138
-rw-r--r--src/mesa/main/texparam.h9
3 files changed, 117 insertions, 32 deletions
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index fdb1febf78d..c75b284100a 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -969,6 +969,8 @@ const struct function gl_core_functions_possible[] = {
{ "glTextureParameterIiv", 45, -1 },
{ "glTextureParameterIuiv", 45, -1 },
{ "glTextureParameteriv", 45, -1 },
+ { "glGetTextureLevelParameterfv", 45, -1 },
+ { "glGetTextureLevelParameteriv", 45, -1 },
{ NULL, 0, -1 }
};
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index bee37e4428f..6b8532f965b 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1278,11 +1278,13 @@ static void
get_tex_level_parameter_image(struct gl_context *ctx,
const struct gl_texture_object *texObj,
GLenum target, GLint level,
- GLenum pname, GLint *params)
+ GLenum pname, GLint *params,
+ bool dsa)
{
const struct gl_texture_image *img = NULL;
struct gl_texture_image dummy_image;
mesa_format texFormat;
+ const char *suffix = dsa ? "ture" : "";
img = _mesa_select_tex_image(texObj, target, level);
if (!img || img->TexFormat == MESA_FORMAT_NONE) {
@@ -1390,11 +1392,12 @@ get_tex_level_parameter_image(struct gl_context *ctx,
!_mesa_is_proxy_texture(target)) {
*params = _mesa_format_image_size(texFormat, img->Width,
img->Height, img->Depth);
- }
- else {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTexLevelParameter[if]v(pname)");
- }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
+ _mesa_lookup_enum_by_nr(pname));
+ }
break;
case GL_TEXTURE_COMPRESSED:
*params = (GLint) _mesa_is_format_compressed(texFormat);
@@ -1441,7 +1444,7 @@ get_tex_level_parameter_image(struct gl_context *ctx,
invalid_pname:
_mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname=%s)",
+ "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
_mesa_lookup_enum_by_nr(pname));
}
@@ -1449,12 +1452,13 @@ invalid_pname:
static void
get_tex_level_parameter_buffer(struct gl_context *ctx,
const struct gl_texture_object *texObj,
- GLenum pname, GLint *params)
+ GLenum pname, GLint *params, bool dsa)
{
const struct gl_buffer_object *bo = texObj->BufferObject;
mesa_format texFormat = texObj->_BufferObjectFormat;
GLenum internalFormat = texObj->BufferObjectFormat;
GLenum baseFormat = _mesa_get_format_base_format(texFormat);
+ const char *suffix = dsa ? "ture" : "";
if (!bo) {
/* undefined texture buffer object */
@@ -1524,7 +1528,8 @@ get_tex_level_parameter_buffer(struct gl_context *ctx,
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
/* Always illegal for GL_TEXTURE_BUFFER */
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTexLevelParameter[if]v(pname)");
+ "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
+ _mesa_lookup_enum_by_nr(pname));
break;
/* GL_ARB_texture_float */
@@ -1552,57 +1557,126 @@ get_tex_level_parameter_buffer(struct gl_context *ctx,
invalid_pname:
_mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname=%s)",
+ "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
_mesa_lookup_enum_by_nr(pname));
}
+/**
+ * This isn't exposed to the rest of the driver because it is a part of the
+ * OpenGL API that is rarely used.
+ */
+static void
+get_tex_level_parameteriv(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLenum target, GLint level,
+ GLenum pname, GLint *params,
+ bool dsa)
+{
+ GLint maxLevels;
+ const char *suffix = dsa ? "ture" : "";
+
+ /* Check for errors */
+ if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTex%sLevelParameter[if]v("
+ "current unit >= max combined texture units)", suffix);
+ return;
+ }
+
+ if (!legal_get_tex_level_parameter_target(ctx, target, dsa)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTex%sLevelParameter[if]v(target=%s)", suffix,
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ maxLevels = _mesa_max_texture_levels(ctx, target);
+ assert(maxLevels != 0);
+
+ if (level < 0 || level >= maxLevels) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetTex%sLevelParameter[if]v(level out of range)", suffix);
+ return;
+ }
+
+ /* Get the level parameter */
+ if (target == GL_TEXTURE_BUFFER) {
+ get_tex_level_parameter_buffer(ctx, texObj, pname, params, dsa);
+ }
+ else {
+ get_tex_level_parameter_image(ctx, texObj, target,
+ level, pname, params, dsa);
+ }
+}
+
void GLAPIENTRY
_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
GLenum pname, GLfloat *params )
{
+ struct gl_texture_object *texObj;
GLint iparam;
- _mesa_GetTexLevelParameteriv( target, level, pname, &iparam );
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ if (!texObj)
+ return;
+
+ get_tex_level_parameteriv(ctx, texObj, target, level,
+ pname, &iparam, false);
+
*params = (GLfloat) iparam;
}
-
void GLAPIENTRY
_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
GLenum pname, GLint *params )
{
struct gl_texture_object *texObj;
- GLint maxLevels;
GET_CURRENT_CONTEXT(ctx);
- if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTexLevelParameteriv(current unit)");
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ if (!texObj)
return;
- }
- if (!legal_get_tex_level_parameter_target(ctx, target, false)) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(target=0x%x)", target);
- return;
- }
+ get_tex_level_parameteriv(ctx, texObj, target, level,
+ pname, params, false);
+}
- maxLevels = _mesa_max_texture_levels(ctx, target);
- assert(maxLevels != 0);
+void GLAPIENTRY
+_mesa_GetTextureLevelParameterfv(GLuint texture, GLint level,
+ GLenum pname, GLfloat *params)
+{
+ struct gl_texture_object *texObj;
+ GLint iparam;
+ GET_CURRENT_CONTEXT(ctx);
- if (level < 0 || level >= maxLevels) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
+ texObj = _mesa_lookup_texture_err(ctx, texture,
+ "glGetTextureLevelParameterfv");
+ if (!texObj)
return;
- }
- texObj = _mesa_get_current_tex_object(ctx, target);
+ get_tex_level_parameteriv(ctx, texObj, texObj->Target, level,
+ pname, &iparam, true);
- if (target == GL_TEXTURE_BUFFER)
- get_tex_level_parameter_buffer(ctx, texObj, pname, params);
- else
- get_tex_level_parameter_image(ctx, texObj, target, level, pname, params);
+ *params = (GLfloat) iparam;
}
+void GLAPIENTRY
+_mesa_GetTextureLevelParameteriv(GLuint texture, GLint level,
+ GLenum pname, GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_lookup_texture_err(ctx, texture,
+ "glGetTextureLevelParameteriv");
+ if (!texObj)
+ return;
+
+ get_tex_level_parameteriv(ctx, texObj, texObj->Target, level,
+ pname, params, true);
+}
void GLAPIENTRY
_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
diff --git a/src/mesa/main/texparam.h b/src/mesa/main/texparam.h
index 8911219d1f1..961081def16 100644
--- a/src/mesa/main/texparam.h
+++ b/src/mesa/main/texparam.h
@@ -82,6 +82,15 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
GLenum pname, GLint *params );
extern void GLAPIENTRY
+_mesa_GetTextureLevelParameterfv(GLuint texture, GLint level,
+ GLenum pname, GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_GetTextureLevelParameteriv(GLuint texture, GLint level,
+ GLenum pname, GLint *params);
+
+
+extern void GLAPIENTRY
_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params );
extern void GLAPIENTRY