summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/formatquery.c
diff options
context:
space:
mode:
authorAntia Puentes <apuentes@igalia.com>2015-12-16 20:46:49 +0100
committerEduardo Lima Mitev <elima@igalia.com>2016-03-03 15:14:05 +0100
commit806bc2bf223c03c488de5549582141824dcbbc40 (patch)
tree351d2138729ef7cc2f2c418263b494e5c308fff5 /src/mesa/main/formatquery.c
parent4af3e5e9f1f80e18b5f9b198f9bd652936170908 (diff)
downloadexternal_mesa3d-806bc2bf223c03c488de5549582141824dcbbc40.zip
external_mesa3d-806bc2bf223c03c488de5549582141824dcbbc40.tar.gz
external_mesa3d-806bc2bf223c03c488de5549582141824dcbbc40.tar.bz2
mesa/formatquery: Added a func to check if the <target> is supported
From the ARB_internalformat_query2 spec: "If the particular <target> and <internalformat> combination do not make sense, or if a particular type of <target> is not supported by the implementation the "unsupported" answer should be given. This is not an error." This function checks if the <target> is supported by the implementation. v2: Allow RENDERBUFFER targets also on GLES 3 profiles. Reviewed-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/mesa/main/formatquery.c')
-rw-r--r--src/mesa/main/formatquery.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 1a9d86c..17de33e 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -28,6 +28,7 @@
#include "enums.h"
#include "fbobject.h"
#include "formatquery.h"
+#include "teximage.h"
/* Handles the cases where either ARB_internalformat_query or
* ARB_internalformat_query2 have to return an error.
@@ -362,6 +363,75 @@ _set_default_response(GLenum pname, GLint buffer[16])
}
}
+static bool
+_is_target_supported(struct gl_context *ctx, GLenum target)
+{
+ /* The ARB_internalformat_query2 spec says:
+ *
+ * "if a particular type of <target> is not supported by the
+ * implementation the "unsupported" answer should be given.
+ * This is not an error."
+ */
+ switch(target){
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ break;
+
+ case GL_TEXTURE_1D:
+ if (!_mesa_is_desktop_gl(ctx))
+ return false;
+ break;
+
+ case GL_TEXTURE_1D_ARRAY:
+ if (!_mesa_has_EXT_texture_array(ctx))
+ return false;
+ break;
+
+ case GL_TEXTURE_2D_ARRAY:
+ if (!(_mesa_has_EXT_texture_array(ctx) || _mesa_is_gles3(ctx)))
+ return false;
+ break;
+
+ case GL_TEXTURE_CUBE_MAP:
+ if (!_mesa_has_ARB_texture_cube_map(ctx))
+ return false;
+ break;
+
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ if (!_mesa_has_ARB_texture_cube_map_array(ctx))
+ return false;
+ break;
+
+ case GL_TEXTURE_RECTANGLE:
+ if (!_mesa_has_NV_texture_rectangle(ctx))
+ return false;
+ break;
+
+ case GL_TEXTURE_BUFFER:
+ if (!_mesa_has_ARB_texture_buffer_object(ctx))
+ return false;
+ break;
+
+ case GL_RENDERBUFFER:
+ if (!(_mesa_has_ARB_framebuffer_object(ctx) ||
+ _mesa_is_gles3(ctx)))
+ return false;
+ break;
+
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ if (!(_mesa_has_ARB_texture_multisample(ctx) ||
+ _mesa_is_gles31(ctx)))
+ return false;
+ break;
+
+ default:
+ unreachable("invalid target");
+ }
+
+ return true;
+}
+
/* default implementation of QueryInternalFormat driverfunc, for
* drivers not implementing ARB_internalformat_query2.
*/