summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texobj.c
diff options
context:
space:
mode:
authorKalyan Kondapally <[email protected]>2015-01-07 20:30:25 -0800
committerTapani Pälli <[email protected]>2015-01-29 08:16:47 +0200
commita63c8a524b01e802cf2505099f930c0cb97df0b2 (patch)
tree16622ee46c65fe21ce4200234ce08c314b9f8b8d /src/mesa/main/texobj.c
parentdd4d9a4e62ecf44011cfa2e020d08029299dd7e0 (diff)
Mesa: Add support for GL_OES_texture_*float* extensions.
This patch series adds support for following GLES2 Texture Float extensions: 1)GL_OES_texture_float, 2)GL_OES_texture_half_float, 3)GL_OES_texture_float_linear, 4)GL_OES_texture_half_float_linear. This patch adds basic infrastructure and needed boolean flags to advertise support for these extensions, by default the support is disabled. Next patch in the series introduces support for HALF_FLOAT_OES token. v4: take assert away and make valid_filter_for_float conditional (Tapani), fix the alphabetical order (Emil) Signed-off-by: Kevin Rogovin <[email protected]> Signed-off-by: Kalyan Kondapally <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/mesa/main/texobj.c')
-rw-r--r--src/mesa/main/texobj.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index a99dd7ad7c7..59090db4ecf 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -49,6 +49,54 @@
/** \name Internal functions */
/*@{*/
+/**
+ * This function checks for all valid combinations of Min and Mag filters for
+ * Float types, when extensions like OES_texture_float and
+ * OES_texture_float_linear are supported. OES_texture_float mentions support
+ * for NEAREST, NEAREST_MIPMAP_NEAREST magnification and minification filters.
+ * Mag filters like LINEAR and min filters like NEAREST_MIPMAP_LINEAR,
+ * LINEAR_MIPMAP_NEAREST and LINEAR_MIPMAP_LINEAR are only valid in case
+ * OES_texture_float_linear is supported.
+ *
+ * Returns true in case the filter is valid for given Float type else false.
+ */
+static bool
+valid_filter_for_float(const struct gl_context *ctx,
+ const struct gl_texture_object *obj)
+{
+ switch (obj->Sampler.MagFilter) {
+ case GL_LINEAR:
+ if (obj->_IsHalfFloat && !ctx->Extensions.OES_texture_half_float_linear) {
+ return false;
+ } else if (obj->_IsFloat && !ctx->Extensions.OES_texture_float_linear) {
+ return false;
+ }
+ case GL_NEAREST:
+ case GL_NEAREST_MIPMAP_NEAREST:
+ break;
+ default:
+ unreachable("Invalid mag filter");
+ }
+
+ switch (obj->Sampler.MinFilter) {
+ case GL_LINEAR:
+ case GL_NEAREST_MIPMAP_LINEAR:
+ case GL_LINEAR_MIPMAP_NEAREST:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ if (obj->_IsHalfFloat && !ctx->Extensions.OES_texture_half_float_linear) {
+ return false;
+ } else if (obj->_IsFloat && !ctx->Extensions.OES_texture_float_linear) {
+ return false;
+ }
+ case GL_NEAREST:
+ case GL_NEAREST_MIPMAP_NEAREST:
+ break;
+ default:
+ unreachable("Invalid min filter");
+ }
+
+ return true;
+}
/**
* Return the gl_texture_object for a given ID.
@@ -408,6 +456,8 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
dest->_MipmapComplete = src->_MipmapComplete;
COPY_4V(dest->Swizzle, src->Swizzle);
dest->_Swizzle = src->_Swizzle;
+ dest->_IsHalfFloat = src->_IsHalfFloat;
+ dest->_IsFloat = src->_IsFloat;
dest->RequiredTextureImageUnits = src->RequiredTextureImageUnits;
}
@@ -641,6 +691,14 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx,
t->_IsIntegerFormat = datatype == GL_INT || datatype == GL_UNSIGNED_INT;
}
+ /* Check if the texture type is Float or HalfFloatOES and ensure Min and Mag
+ * filters are supported in this case.
+ */
+ if (_mesa_is_gles(ctx) && !valid_filter_for_float(ctx, t)) {
+ incomplete(t, BASE, "Filter is not supported with Float types.");
+ return;
+ }
+
/* Compute _MaxLevel (the maximum mipmap level we'll sample from given the
* mipmap image sizes and GL_TEXTURE_MAX_LEVEL state).
*/