{ "GL_OES_texture_3D", o(EXT_texture3D), ES2, 2005 },
{ "GL_OES_texture_cube_map", o(ARB_texture_cube_map), ES1, 2007 },
{ "GL_OES_texture_env_crossbar", o(ARB_texture_env_crossbar), ES1, 2005 },
+ { "GL_OES_texture_float", o(OES_texture_float), ES2, 2005 },
+ { "GL_OES_texture_float_linear", o(OES_texture_float_linear), ES2, 2005 },
+ { "GL_OES_texture_half_float", o(OES_texture_half_float), ES2, 2005 },
+ { "GL_OES_texture_half_float_linear", o(OES_texture_half_float_linear), ES2, 2005 },
{ "GL_OES_texture_mirrored_repeat", o(dummy_true), ES1, 2005 },
{ "GL_OES_texture_npot", o(ARB_texture_non_power_of_two), ES1 | ES2, 2005 },
{ "GL_OES_vertex_array_object", o(dummy_true), ES1 | ES2, 2010 },
GLboolean Purgeable; /**< Is the buffer purgeable under memory
pressure? */
GLboolean Immutable; /**< GL_ARB_texture_storage */
+ GLboolean _IsFloat; /**< GL_OES_float_texture */
+ GLboolean _IsHalfFloat; /**< GL_OES_half_float_texture */
GLuint MinLevel; /**< GL_ARB_texture_view */
GLuint MinLayer; /**< GL_ARB_texture_view */
GLboolean OES_draw_texture;
GLboolean OES_depth_texture_cube_map;
GLboolean OES_EGL_image_external;
+ GLboolean OES_texture_float;
+ GLboolean OES_texture_float_linear;
+ GLboolean OES_texture_half_float;
+ GLboolean OES_texture_half_float_linear;
GLboolean OES_compressed_ETC1_RGB8_texture;
GLboolean extension_sentinel;
/** The extension string */
*/
#define NEW_COPY_TEX_STATE (_NEW_BUFFERS | _NEW_PIXEL)
+/**
+ * Returns a corresponding internal floating point format for a given base
+ * format as specifed by OES_texture_float. In case of GL_FLOAT, the internal
+ * format needs to be a 32 bit component and in case of GL_HALF_FLOAT_OES it
+ * needs to be a 16 bit component.
+ *
+ * For example, given base format GL_RGBA, type GL_Float return GL_RGBA32F_ARB.
+ */
+static GLenum
+adjust_for_oes_float_texture(GLenum format, GLenum type)
+{
+ switch (type) {
+ case GL_FLOAT:
+ switch (format) {
+ case GL_RGBA:
+ return GL_RGBA32F;
+ case GL_RGB:
+ return GL_RGB32F;
+ case GL_ALPHA:
+ return GL_ALPHA32F_ARB;
+ case GL_LUMINANCE:
+ return GL_LUMINANCE32F_ARB;
+ case GL_LUMINANCE_ALPHA:
+ return GL_LUMINANCE_ALPHA32F_ARB;
+ default:
+ break;
+ }
+ break;
+ case GL_HALF_FLOAT_OES:
+ switch (format) {
+ case GL_RGBA:
+ return GL_RGBA16F;
+ case GL_RGB:
+ return GL_RGB16F;
+ case GL_ALPHA:
+ return GL_ALPHA16F_ARB;
+ case GL_LUMINANCE:
+ return GL_LUMINANCE16F_ARB;
+ case GL_LUMINANCE_ALPHA:
+ return GL_LUMINANCE_ALPHA16F_ARB;
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return format;
+}
/**
* Return the simple base format for a given internal texture format.
texFormat = _mesa_glenum_to_compressed_format(internalFormat);
}
else {
+ /* In case of HALF_FLOAT_OES or FLOAT_OES, find corresponding sized
+ * internal floating point format for the given base format.
+ */
+ if (_mesa_is_gles(ctx) && format == internalFormat) {
+ if (type == GL_FLOAT) {
+ texObj->_IsFloat = GL_TRUE;
+ } else if (type == GL_HALF_FLOAT_OES || type == GL_HALF_FLOAT) {
+ texObj->_IsHalfFloat = GL_TRUE;
+ }
+
+ internalFormat = adjust_for_oes_float_texture(format, type);
+ }
+
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
internalFormat, format, type);
}
/** \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.
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;
}
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).
*/