On 05/19/2014 06:39 AM, Marek Olšák wrote: > You are complicating it. If we followed the specification to the > letter, the driver would have to advertise OpenGL 1.1 instead of 2.1. > > The fact r300 cannot filter floating-point textures is documented by > the vendor and game developers (especially those who targeted D3D9) > knew about it. > > For OpenGL ES, I propose a simpler solution: > - don't touch ARB_texture_float at all > - add OES_texture_float to gl_extensions > - add OES_texture_float_linear to gl_extensions > - define OES_texture_half_float as o(OES_texture_float) > - define OES_texture_half_float_linear as o(OES_texture_float_linear) > > Then, drivers can enable the extensions as they see fit.
That sounds like a happy medium. It seems like we could use ARB_texture_float as the enable for OES_texture_float, but I'm not crying over one extra flag. It will mean that a bunch of extension checks in the code will need to be expanded. We'll probably also want a negative test that verifies an error is generated for glTexParameteri(..., GL_LINEAR_MIPMAP_LINEAR) when OES_texture_float_linear (or OES_texture_half_float_linear) is not supported. > Marek > > On Mon, May 19, 2014 at 8:34 AM, Rogovin, Kevin <[email protected]> > wrote: >> Hi, >> >> Each of the four extensions are right now set to be advertised if and only >> if a GL context would advertise GL_ARB_texture_float: >> >> { "GL_OES_texture_float", o(ARB_texture_float), >> ES2, 2005 }, >> { "GL_OES_texture_half_float", o(ARB_texture_float), >> ES2, 2005 }, >> { "GL_OES_texture_float_linear", o(ARB_texture_float), >> ES2, 2005 }, >> { "GL_OES_texture_half_float_linear", o(ARB_texture_float), >> ES2, 2005 }, >> >> From my interpretation of ARB_texture_float, that extension requires both >> 16-bit and 32-bit textures and ability to filter linearly such textures. Did >> I misunderstand the specification? If I got the specification correct, then >> the r300 should not be advertising any of the extensions for otherwise it >> would be advertising GL_ARB_texture_float. >> >> However, the r300 does give an example of ability to support some of the OES >> extensions but not all. Previously Matt asked if there an example or need >> and I thought not. It turns out I was wrong and there is a need atleast for >> the r300. Supporting that granularity is going to be a bigger patch since it >> would require changing the data structure struct gl_extensions to have four >> entries and in turn additional logic to combine them to >> GL_ARB_texture_float. The correct and more work way to do it would be to >> remove ARB_texture_float from gl_extension, add a GLboolean for each of the >> 4 OES extensions, change each driver to correctly fill them and then >> additional logic in creating extension string(s) to check if each of the 4 >> OES extensions are TRUE then to advertise GL_ARB_texture_float; we could >> also instead just add the 4 OES booleans and have additional logic in >> mesa/main to set them each to TRUE if ARB_texture_float is true. The latter >> solution though easier is less clean a! nd begging for trouble later. Regardless, lets first get this patch as-is into Mesa, then do the "right" thing to allow a backend to support a subset of the OES extensions without needing to support the ARB extension. >> >> -Kevin >> >> >> >> ________________________________________ >> From: Marek Olšák [[email protected]] >> Sent: Friday, May 16, 2014 4:33 PM >> To: Rogovin, Kevin >> Cc: [email protected] >> Subject: Re: [Mesa-dev] [PATCH] mesa: Expose GL_OES_texture_float and >> GL_OES_texture_half_float. >> >> Sorry, I meant the linear filtering extensions. >> >> Marek >> >> On Fri, May 16, 2014 at 3:31 PM, Marek Olšák <[email protected]> wrote: >>> Hi Kevin, >>> >>> r300g doesn't support filtering of floating-point textures, so the >>> extension shouldn't be advertised there. >>> >>> Marek >>> >>> On Wed, May 7, 2014 at 1:18 PM, Kevin Rogovin <[email protected]> >>> wrote: >>>> Add support for GLES2 extensions for floating point and half >>>> floating point textures (GL_OES_texture_float, GL_OES_texture_half_float, >>>> GL_OES_texture_float_linear and GL_OES_texture_half_float_linear). >>>> >>>> --- >>>> src/mesa/main/extensions.c | 12 +++++++++- >>>> src/mesa/main/glformats.c | 25 ++++++++++++++++++++ >>>> src/mesa/main/pack.c | 17 +++++++++++++ >>>> src/mesa/main/teximage.c | 59 >>>> ++++++++++++++++++++++++++++++++++++++++++++++ >>>> 4 files changed, 112 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c >>>> index c2ff7e3..e39f65e 100644 >>>> --- a/src/mesa/main/extensions.c >>>> +++ b/src/mesa/main/extensions.c >>>> @@ -301,7 +301,17 @@ static const struct extension extension_table[] = { >>>> { "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 }, >>>> - >>>> + /* >>>> + * TODO: >>>> + * - rather than have an all or nothing approach for floating point >>>> textures, >>>> + * allow for driver to specify what parts of floating point texture >>>> functionality >>>> + * is supported: float/half-float and filtering for each. >>>> + */ >>>> + { "GL_OES_texture_float", o(ARB_texture_float), >>>> ES2, 2005 }, >>>> + { "GL_OES_texture_half_float", o(ARB_texture_float), >>>> ES2, 2005 }, >>>> + { "GL_OES_texture_float_linear", o(ARB_texture_float), >>>> ES2, 2005 }, >>>> + { "GL_OES_texture_half_float_linear", o(ARB_texture_float), >>>> ES2, 2005 }, >>>> + >>>> /* KHR extensions */ >>>> { "GL_KHR_debug", o(dummy_true), >>>> GL, 2012 }, >>>> >>>> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c >>>> index 9bb341c..093fd59 100644 >>>> --- a/src/mesa/main/glformats.c >>>> +++ b/src/mesa/main/glformats.c >>>> @@ -93,6 +93,7 @@ _mesa_sizeof_type(GLenum type) >>>> case GL_DOUBLE: >>>> return sizeof(GLdouble); >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> return sizeof(GLhalfARB); >>>> case GL_FIXED: >>>> return sizeof(GLfixed); >>>> @@ -125,6 +126,7 @@ _mesa_sizeof_packed_type(GLenum type) >>>> case GL_INT: >>>> return sizeof(GLint); >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> return sizeof(GLhalfARB); >>>> case GL_FLOAT: >>>> return sizeof(GLfloat); >>>> @@ -243,6 +245,7 @@ _mesa_bytes_per_pixel(GLenum format, GLenum type) >>>> case GL_FLOAT: >>>> return comps * sizeof(GLfloat); >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> return comps * sizeof(GLhalfARB); >>>> case GL_UNSIGNED_BYTE_3_3_2: >>>> case GL_UNSIGNED_BYTE_2_3_3_REV: >>>> @@ -1365,6 +1368,11 @@ _mesa_error_check_format_and_type(const struct >>>> gl_context *ctx, >>>> case GL_FLOAT: >>>> case GL_HALF_FLOAT: >>>> return GL_NO_ERROR; >>>> + case GL_HALF_FLOAT_OES: >>>> + return (format == GL_LUMINANCE || >>>> + format == GL_LUMINANCE_ALPHA || >>>> + format == GL_ALPHA) >>>> + ? GL_NO_ERROR: GL_INVALID_ENUM; >>>> default: >>>> return GL_INVALID_ENUM; >>>> } >>>> @@ -1401,6 +1409,9 @@ _mesa_error_check_format_and_type(const struct >>>> gl_context *ctx, >>>> case GL_UNSIGNED_SHORT_5_6_5_REV: >>>> case GL_HALF_FLOAT: >>>> return GL_NO_ERROR; >>>> + case GL_HALF_FLOAT_OES: >>>> + return (format == GL_RGB) >>>> + ? GL_NO_ERROR: GL_INVALID_ENUM; >>>> case GL_UNSIGNED_INT_2_10_10_10_REV: >>>> /* OK by GL_EXT_texture_type_2_10_10_10_REV */ >>>> return (ctx->API == API_OPENGLES2) >>>> @@ -1454,6 +1465,9 @@ _mesa_error_check_format_and_type(const struct >>>> gl_context *ctx, >>>> case GL_UNSIGNED_INT_2_10_10_10_REV: >>>> case GL_HALF_FLOAT: >>>> return GL_NO_ERROR; >>>> + case GL_HALF_FLOAT_OES: >>>> + return (format == GL_RGBA) >>>> + ? GL_NO_ERROR: GL_INVALID_ENUM; >>>> default: >>>> return GL_INVALID_ENUM; >>>> } >>>> @@ -1676,6 +1690,17 @@ GLenum >>>> _mesa_es3_error_check_format_and_type(GLenum format, GLenum type, >>>> GLenum internalFormat) >>>> { >>>> + /* special case checking for support the GLES2 extension >>>> + * GL_OES_texture_float and GL_OES_texture_half_float >>>> + */ >>>> + if(format == internalFormat && >>>> + (type == GL_HALF_FLOAT_OES || type == GL_FLOAT) && >>>> + (format == GL_RGBA || format == GL_RGB || >>>> + format == GL_LUMINANCE || format == GL_ALPHA || >>>> + format == GL_LUMINANCE_ALPHA) ) { >>>> + return GL_NO_ERROR; >>>> + } >>>> + >>>> switch (format) { >>>> case GL_RGBA: >>>> switch (type) { >>>> diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c >>>> index 1df6568..4b298ea 100644 >>>> --- a/src/mesa/main/pack.c >>>> +++ b/src/mesa/main/pack.c >>>> @@ -2355,6 +2355,7 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, >>>> GLuint n, GLfloat rgba[][4], >>>> } >>>> break; >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> { >>>> GLhalfARB *dst = (GLhalfARB *) dstAddr; >>>> switch (dstFormat) { >>>> @@ -2785,6 +2786,7 @@ extract_uint_indexes(GLuint n, GLuint indexes[], >>>> srcType == GL_INT || >>>> srcType == GL_UNSIGNED_INT_24_8_EXT || >>>> srcType == GL_HALF_FLOAT_ARB || >>>> + srcType == GL_HALF_FLOAT_OES || >>>> srcType == GL_FLOAT || >>>> srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); >>>> >>>> @@ -2924,6 +2926,7 @@ extract_u meh.int_indexes(GLuint n, GLuint >>>> indexes[], >>>> } >>>> break; >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> { >>>> GLuint i; >>>> const GLhalfARB *s = (const GLhalfARB *) src; >>>> @@ -3172,6 +3175,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], >>>> srcType == GL_UNSIGNED_INT || >>>> srcType == GL_INT || >>>> srcType == GL_HALF_FLOAT_ARB || >>>> + srcType == GL_HALF_FLOAT_OES || >>>> srcType == GL_FLOAT || >>>> srcType == GL_UNSIGNED_BYTE_3_3_2 || >>>> srcType == GL_UNSIGNED_BYTE_2_3_3_REV || >>>> @@ -3289,6 +3293,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], >>>> PROCESS(aSrc, ACOMP, 1.0F, 1.0F, GLfloat, (GLfloat)); >>>> break; >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> PROCESS(rSrc, RCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); >>>> PROCESS(gSrc, GCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); >>>> PROCESS(bSrc, BCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); >>>> @@ -3789,6 +3794,7 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4], >>>> srcType == GL_UNSIGNED_INT || >>>> srcType == GL_INT || >>>> srcType == GL_HALF_FLOAT_ARB || >>>> + srcType == GL_HALF_FLOAT_OES || >>>> srcType == GL_FLOAT || >>>> srcType == GL_UNSIGNED_BYTE_3_3_2 || >>>> srcType == GL_UNSIGNED_BYTE_2_3_3_REV || >>>> @@ -3886,6 +3892,7 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4], >>>> PROCESS(aSrc, ACOMP, 1, GLfloat, clamp_float_to_uint); >>>> break; >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> PROCESS(rSrc, RCOMP, 0, GLhalfARB, clamp_half_to_uint); >>>> PROCESS(gSrc, GCOMP, 0, GLhalfARB, clamp_half_to_uint); >>>> PROCESS(bSrc, BCOMP, 0, GLhalfARB, clamp_half_to_uint); >>>> @@ -4290,6 +4297,7 @@ _mesa_unpack_color_span_ubyte(struct gl_context *ctx, >>>> srcType == GL_UNSIGNED_INT || >>>> srcType == GL_INT || >>>> srcType == GL_HALF_FLOAT_ARB || >>>> + srcType == GL_HALF_FLOAT_OES || >>>> srcType == GL_FLOAT || >>>> srcType == GL_UNSIGNED_BYTE_3_3_2 || >>>> srcType == GL_UNSIGNED_BYTE_2_3_3_REV || >>>> @@ -4543,6 +4551,7 @@ _mesa_unpack_color_span_float( struct gl_context >>>> *ctx, >>>> srcType == GL_UNSIGNED_INT || >>>> srcType == GL_INT || >>>> srcType == GL_HALF_FLOAT_ARB || >>>> + srcType == GL_HALF_FLOAT_OES || >>>> srcType == GL_FLOAT || >>>> srcType == GL_UNSIGNED_BYTE_3_3_2 || >>>> srcType == GL_UNSIGNED_BYTE_2_3_3_REV || >>>> @@ -4747,6 +4756,7 @@ _mesa_unpack_color_span_uint(struct gl_context *ctx, >>>> srcType == GL_UNSIGNED_INT || >>>> srcType == GL_INT || >>>> srcType == GL_HALF_FLOAT_ARB || >>>> + srcType == GL_HALF_FLOAT_OES || >>>> srcType == GL_FLOAT || >>>> srcType == GL_UNSIGNED_BYTE_3_3_2 || >>>> srcType == GL_UNSIGNED_BYTE_2_3_3_REV || >>>> @@ -4870,6 +4880,7 @@ _mesa_unpack_dudv_span_byte( struct gl_context *ctx, >>>> srcType == GL_UNSIGNED_INT || >>>> srcType == GL_INT || >>>> srcType == GL_HALF_FLOAT_ARB || >>>> + srcType == GL_HALF_FLOAT_OES || >>>> srcType == GL_FLOAT); >>>> >>>> /* general solution */ >>>> @@ -4940,6 +4951,7 @@ _mesa_unpack_index_span( struct gl_context *ctx, >>>> GLuint n, >>>> srcType == GL_UNSIGNED_INT || >>>> srcType == GL_INT || >>>> srcType == GL_HALF_FLOAT_ARB || >>>> + srcType == GL_HALF_FLOAT_OES || >>>> srcType == GL_FLOAT); >>>> >>>> ASSERT(dstType == GL_UNSIGNED_BYTE || >>>> @@ -5111,6 +5123,7 @@ _mesa_pack_index_span( struct gl_context *ctx, >>>> GLuint n, >>>> } >>>> break; >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> { >>>> GLhalfARB *dst = (GLhalfARB *) dest; >>>> GLuint i; >>>> @@ -5160,6 +5173,7 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, >>>> GLuint n, >>>> srcType == GL_INT || >>>> srcType == GL_UNSIGNED_INT_24_8_EXT || >>>> srcType == GL_HALF_FLOAT_ARB || >>>> + srcType == GL_HALF_FLOAT_OES || >>>> srcType == GL_FLOAT || >>>> srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); >>>> >>>> @@ -5350,6 +5364,7 @@ _mesa_pack_stencil_span( struct gl_context *ctx, >>>> GLuint n, >>>> } >>>> break; >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> { >>>> GLhalfARB *dst = (GLhalfARB *) dest; >>>> GLuint i; >>>> @@ -5567,6 +5582,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, >>>> GLuint n, >>>> needClamp = GL_TRUE; >>>> break; >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> { >>>> GLuint i; >>>> const GLhalfARB *src = (const GLhalfARB *) source; >>>> @@ -5756,6 +5772,7 @@ _mesa_pack_depth_span( struct gl_context *ctx, >>>> GLuint n, GLvoid *dest, >>>> } >>>> break; >>>> case GL_HALF_FLOAT_ARB: >>>> + case GL_HALF_FLOAT_OES: >>>> { >>>> GLhalfARB *dst = (GLhalfARB *) dest; >>>> GLuint i; >>>> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c >>>> index c7f301c..d06d7d0 100644 >>>> --- a/src/mesa/main/teximage.c >>>> +++ b/src/mesa/main/teximage.c >>>> @@ -61,6 +61,57 @@ >>>> #define NEW_COPY_TEX_STATE (_NEW_BUFFERS | _NEW_PIXEL) >>>> >>>> >>>> +/** >>>> + * Modify a texture format from as expected by GL_OES_texture_float >>>> + * and/or GL_OES_texture_half_float to as expected by GLES3 or GL3 >>>> + */ >>>> +static void >>>> +adjust_for_oes_float_texture(GLenum *internalFormat, >>>> + GLenum *format, GLenum *type) >>>> +{ >>>> + if (*format == *internalFormat) >>>> + switch (*type) { >>>> + case GL_FLOAT: >>>> + switch (*format) { >>>> + case GL_RGBA: >>>> + *internalFormat = GL_RGBA32F; >>>> + break; >>>> + case GL_RGB: >>>> + *internalFormat = GL_RGB32F; >>>> + break; >>>> + case GL_ALPHA: >>>> + *internalFormat = GL_ALPHA32F_ARB; >>>> + break; >>>> + case GL_LUMINANCE: >>>> + *internalFormat = GL_LUMINANCE32F_ARB; >>>> + break; >>>> + case GL_LUMINANCE_ALPHA: >>>> + *internalFormat = GL_LUMINANCE_ALPHA32F_ARB; >>>> + break; >>>> + } >>>> + break; >>>> + >>>> + case GL_HALF_FLOAT_OES: >>>> + switch (*format) { >>>> + case GL_RGBA: >>>> + *internalFormat = GL_RGBA16F; >>>> + break; >>>> + case GL_RGB: >>>> + *internalFormat = GL_RGB16F; >>>> + break; >>>> + case GL_ALPHA: >>>> + *internalFormat = GL_ALPHA16F_ARB; >>>> + break; >>>> + case GL_LUMINANCE: >>>> + *internalFormat = GL_LUMINANCE16F_ARB; >>>> + break; >>>> + case GL_LUMINANCE_ALPHA: >>>> + *internalFormat = GL_LUMINANCE_ALPHA16F_ARB; >>>> + break; >>>> + } >>>> + break; >>>> + } >>>> +} >>>> >>>> /** >>>> * Return the simple base format for a given internal texture format. >>>> @@ -2976,6 +3027,14 @@ _mesa_choose_texture_format(struct gl_context *ctx, >>>> { >>>> mesa_format f; >>>> >>>> + /* Change internalFormat and type to support floating >>>> + * point textures from GLES2 extensions >>>> + * GL_OES_texture_half_float and GL_OES_texture_float >>>> + */ >>>> + if (_mesa_is_gles(ctx)) { >>>> + adjust_for_oes_float_texture(&internalFormat, &format, &type); >>>> + } >>>> + >>>> /* see if we've already chosen a format for the previous level */ >>>> if (level > 0) { >>>> struct gl_texture_image *prevImage = >>>> -- >>>> 1.8.1.2 >>>> >>>> _______________________________________________ >>>> mesa-dev mailing list >>>> [email protected] >>>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev > _______________________________________________ > mesa-dev mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
