[Mesa-dev] [PATCH 07/15] mesa: Add error condition for using compressed internalformat in glTexStorage3D()

Roland Scheidegger sroland at vmware.com
Wed Jul 30 15:24:45 PDT 2014


Am 30.07.2014 23:29, schrieb Ian Romanick:
> On 07/29/2014 05:02 PM, Jason Ekstrand wrote:
>>
>>
>>
>> On Fri, Jun 6, 2014 at 4:57 PM, Anuj Phogat <anuj.phogat at gmail.com
>> <mailto:anuj.phogat at gmail.com>> wrote:
>>
>>     Fixes gles3 Khronos CTS test: texture_storage_texture_internal_formats
>>
>>     Cc: <mesa-stable at lists.freedesktop.org
>>     <mailto:mesa-stable at lists.freedesktop.org>>
>>     Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com
>>     <mailto:anuj.phogat at gmail.com>>
>>     ---
>>      src/mesa/main/texstorage.c | 18 ++++++++++++++++++
>>      1 file changed, 18 insertions(+)
>>
>>     diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
>>     index 44b5374..897d589 100644
>>     --- a/src/mesa/main/texstorage.c
>>     +++ b/src/mesa/main/texstorage.c
>>     @@ -41,6 +41,7 @@
>>      #include "texstorage.h"
>>      #include "textureview.h"
>>      #include "mtypes.h"
>>     +#include "glformats.h"
>>
>>
>>
>>     @@ -301,6 +302,23 @@ tex_storage_error_check(struct gl_context *ctx,
>>     GLuint dims, GLenum target,
>>            return GL_TRUE;
>>         }
>>
>>     +   /* From section 3.8.6, page 146 of OpenGL ES 3.0 spec:
>>     +    *
>>     +    *    "The ETC2/EAC texture compression algorithm supports only
>>     +    *     two-dimensional images. If internalformat is an ETC2/EAC
>>     format,
>>     +    *     CompressedTexImage3D will generate an INVALID_OPERATION
>>     error if
>>     +    *     target is not TEXTURE_2D_ARRAY."
>>     +    *
>>     +    * This should also be applicable for glTexStorage3D().
>>     +    */
>>     +   if (_mesa_is_compressed_format(ctx, internalformat)
>>     +       && !_mesa_target_can_be_compressed(ctx, target,
>>     internalformat)) {
>>     +      _mesa_error(ctx, _mesa_is_desktop_gl(ctx)?
>>     +                  GL_INVALID_ENUM : GL_INVALID_OPERATION,
>>     +                  "glTexStorage3D(internalformat = %s)",
>>     +                  _mesa_lookup_enum_by_nr(internalformat));
>>     +   }
>>
>>
>> It seems to me as if the mesa_target_can_be_compressed function
>> completely disallows 3D texture formats, but the spec implies that they
>> are allowed in some cases.  What's going on here?
> 
> It is possible to have a compressed format that supports 3D, but, of the
> formats that Mesa supports, none do.  I believe
> NV_texture_compression_vtc and KHR_texture_compression_astc_hdr are the
> only ones.
> 
It is sort of an artificial restriction imposed by OpenGL though,
technically all compressed 2d formats could be used for compressing 3d
textures too, though it might not be the most bandwidth efficient way of
packing (hence NV_texture_compression_vtc interleaving the blocks rather
than just storing as independent slices).
In fact using 2d compression algorithms for 3d textures in the dumb
obvious way works on all modern hardware at least for s3tc based formats
as it is what d3d10 requires...

Roland



More information about the mesa-dev mailing list