Re: [Mesa-dev] [PATCH] mesa/texformat: Use format conversion function in _mesa_choose_tex_format

2015-08-26 Thread Nanley Chery
On Tue, Aug 25, 2015 at 4:19 PM, Chad Versace chad.vers...@intel.com
wrote:

 On Sun 16 Aug 2015, Nanley Chery wrote:
  The last line of the commit message should say:
 
 GL_RGBA4_S3TC  (0x83A3)  - COMPRESSED_RGBA_S3TC_DXT5_EXT (0x83F3)

 There's another weird line too, see below.

  On Wed, Aug 12, 2015 at 4:19 PM, Nanley Chery nanleych...@gmail.com
 wrote:
 
   From: Nanley Chery nanley.g.ch...@intel.com
  
   This function's cases for non-generic compressed formats duplicate
   the GL to MESA translation in _mesa_glenum_to_compressed_format().
   This patch replaces the switch cases with a call to the translation
   function. There are no behavioral changes except for the RGB[A]4
 formats:
  
  case GL_RGB4_S3TC:
return MESA_FORMAT_RGB_DXT1  (old) - MESA_FORMAT_RGBA_DXT1 (new)
  ^

 I have trouble believing this line is correct. It adds an alpha channel.
 Can you provide the documentation for that translation?

 Since this mapping is nowhere explicitly defined, I was leaning on the
fact that _mesa_glenum_to_compressed_format() uses this mapping and the
last byte of the enums (coincidentally) match up. I did some more/better
research however and I now think that _mesa_choose_tex_format() had the
correct mapping for several reasons:

 * The GL_RGB4_S3TC and GL_RGBA4_S3TC formats are formats that the driver
can chose if the user passes in GL_RGB_S3TC and GL_RGBA_S3TC respectively.
Therefore, it's not a problem for the formats to map to the same
mesa_format (according to
http://homepage.ntlworld.com/neal.tringham/OpenGLGameDev/s3tcoglext.htm)

* MESA_FORMAT_RGBA_DXT5 should be reserved for the RGBA[4]_DXT5_S3TC cases
we currently aren't handling (
https://www.opengl.org/registry/specs/S3/s3tc.txt)

* The mapping in _mesa_choose_tex_format() can also be found
in nouveau_choose_tex_format(), radeonChooseTextureFormat(), and in
st_format.c's format_map[].

Thank you for the feedback. I will send out another patch to correct
_mesa_glenum_to_compressed_format() and (if R-b'd) will omit the note about
the behavioral change in this patch. I could also send out a v2 with an
updated commit message if you'd prefer.

Thanks,
Nanley

 case GL_RGBA4_S3TC:
return MESA_FORMAT_RGBA_DXT3 (old) - MESA_FORMAT_RGBA_DXT5 (new)
  
   Although unclear, the old behavior was likely a bug, given that online
   documentation (few and far between) imply a format mapping of the
   following:
  
  GL_RGB_S3TC(0x83A0)  - COMPRESSED_RGB_S3TC_DXT1_EXT  (0x83F0)
  GL_RGB4_S3TC   (0x83A1)  - COMPRESSED_RGBA_S3TC_DXT1_EXT (0x83F1)
  GL_RGBA_S3TC   (0x83A2)  - COMPRESSED_RGBA_S3TC_DXT3_EXT (0x83F2)
  GL_RGBA4_S3TC  (0x83A2)  - COMPRESSED_RGBA_S3TC_DXT5_EXT (0x83F2)
  
   Cc: Brian Paul bri...@vmware.com
   Cc: Ian Romanick ian.d.roman...@intel.com
   Signed-off-by: Nanley Chery nanley.g.ch...@intel.com
   ---
src/mesa/main/texformat.c | 94
   +++
1 file changed, 13 insertions(+), 81 deletions(-)

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa/texformat: Use format conversion function in _mesa_choose_tex_format

2015-08-25 Thread Chad Versace
On Sun 16 Aug 2015, Nanley Chery wrote:
 The last line of the commit message should say:
 
GL_RGBA4_S3TC  (0x83A3)  - COMPRESSED_RGBA_S3TC_DXT5_EXT (0x83F3)

There's another weird line too, see below.

 On Wed, Aug 12, 2015 at 4:19 PM, Nanley Chery nanleych...@gmail.com wrote:
 
  From: Nanley Chery nanley.g.ch...@intel.com
 
  This function's cases for non-generic compressed formats duplicate
  the GL to MESA translation in _mesa_glenum_to_compressed_format().
  This patch replaces the switch cases with a call to the translation
  function. There are no behavioral changes except for the RGB[A]4 formats:
 
 case GL_RGB4_S3TC:
   return MESA_FORMAT_RGB_DXT1  (old) - MESA_FORMAT_RGBA_DXT1 (new)
 ^

I have trouble believing this line is correct. It adds an alpha channel.
Can you provide the documentation for that translation?

 case GL_RGBA4_S3TC:
   return MESA_FORMAT_RGBA_DXT3 (old) - MESA_FORMAT_RGBA_DXT5 (new)
 
  Although unclear, the old behavior was likely a bug, given that online
  documentation (few and far between) imply a format mapping of the
  following:
 
 GL_RGB_S3TC(0x83A0)  - COMPRESSED_RGB_S3TC_DXT1_EXT  (0x83F0)
 GL_RGB4_S3TC   (0x83A1)  - COMPRESSED_RGBA_S3TC_DXT1_EXT (0x83F1)
 GL_RGBA_S3TC   (0x83A2)  - COMPRESSED_RGBA_S3TC_DXT3_EXT (0x83F2)
 GL_RGBA4_S3TC  (0x83A2)  - COMPRESSED_RGBA_S3TC_DXT5_EXT (0x83F2)
 
  Cc: Brian Paul bri...@vmware.com
  Cc: Ian Romanick ian.d.roman...@intel.com
  Signed-off-by: Nanley Chery nanley.g.ch...@intel.com
  ---
   src/mesa/main/texformat.c | 94
  +++
   1 file changed, 13 insertions(+), 81 deletions(-)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa/texformat: Use format conversion function in _mesa_choose_tex_format

2015-08-16 Thread Nanley Chery
The last line of the commit message should say:

   GL_RGBA4_S3TC  (0x83A3)  - COMPRESSED_RGBA_S3TC_DXT5_EXT (0x83F3)

On Wed, Aug 12, 2015 at 4:19 PM, Nanley Chery nanleych...@gmail.com wrote:

 From: Nanley Chery nanley.g.ch...@intel.com

 This function's cases for non-generic compressed formats duplicate
 the GL to MESA translation in _mesa_glenum_to_compressed_format().
 This patch replaces the switch cases with a call to the translation
 function. There are no behavioral changes except for the RGB[A]4 formats:

case GL_RGB4_S3TC:
  return MESA_FORMAT_RGB_DXT1  (old) - MESA_FORMAT_RGBA_DXT1 (new)
case GL_RGBA4_S3TC:
  return MESA_FORMAT_RGBA_DXT3 (old) - MESA_FORMAT_RGBA_DXT5 (new)

 Although unclear, the old behavior was likely a bug, given that online
 documentation (few and far between) imply a format mapping of the
 following:

GL_RGB_S3TC(0x83A0)  - COMPRESSED_RGB_S3TC_DXT1_EXT  (0x83F0)
GL_RGB4_S3TC   (0x83A1)  - COMPRESSED_RGBA_S3TC_DXT1_EXT (0x83F1)
GL_RGBA_S3TC   (0x83A2)  - COMPRESSED_RGBA_S3TC_DXT3_EXT (0x83F2)
GL_RGBA4_S3TC  (0x83A2)  - COMPRESSED_RGBA_S3TC_DXT5_EXT (0x83F2)

 Cc: Brian Paul bri...@vmware.com
 Cc: Ian Romanick ian.d.roman...@intel.com
 Signed-off-by: Nanley Chery nanley.g.ch...@intel.com
 ---
  src/mesa/main/texformat.c | 94
 +++
  1 file changed, 13 insertions(+), 81 deletions(-)

 diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
 index f4d17e1..fd9f335 100644
 --- a/src/mesa/main/texformat.c
 +++ b/src/mesa/main/texformat.c
 @@ -38,6 +38,7 @@
  #include mtypes.h
  #include texcompress.h
  #include texformat.h
 +#include glformats.h

  #define RETURN_IF_SUPPORTED(f) do {\
 if (ctx-TextureFormatSupported[f]) \
 @@ -276,87 +277,6 @@ _mesa_choose_tex_format(struct gl_context *ctx,
 GLenum target,
   RETURN_IF_SUPPORTED(MESA_FORMAT_YCBCR_REV);
break;

 -   /* For non-generic compressed format we assert two things:
 -*
 -* 1. The format has already been validated against the set of
 available
 -*extensions.
 -*
 -* 2. The driver only enables the extension if it supports all of the
 -*formats that are part of that extension.
 -*/
 -   case GL_COMPRESSED_RGB_FXT1_3DFX:
 -  return MESA_FORMAT_RGB_FXT1;
 -   case GL_COMPRESSED_RGBA_FXT1_3DFX:
 -  return MESA_FORMAT_RGBA_FXT1;
 -   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
 -   case GL_RGB_S3TC:
 -   case GL_RGB4_S3TC:
 -  return MESA_FORMAT_RGB_DXT1;
 -   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
 -  return MESA_FORMAT_RGBA_DXT1;
 -   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
 -   case GL_RGBA_S3TC:
 -   case GL_RGBA4_S3TC:
 -  return MESA_FORMAT_RGBA_DXT3;
 -   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
 -  return MESA_FORMAT_RGBA_DXT5;
 -   case GL_COMPRESSED_RED_RGTC1:
 -  return MESA_FORMAT_R_RGTC1_UNORM;
 -   case GL_COMPRESSED_SIGNED_RED_RGTC1:
 -  return MESA_FORMAT_R_RGTC1_SNORM;
 -   case GL_COMPRESSED_RG_RGTC2:
 -  return MESA_FORMAT_RG_RGTC2_UNORM;
 -   case GL_COMPRESSED_SIGNED_RG_RGTC2:
 -  return MESA_FORMAT_RG_RGTC2_SNORM;
 -   case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
 -  return MESA_FORMAT_L_LATC1_UNORM;
 -   case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
 -  return MESA_FORMAT_L_LATC1_SNORM;
 -   case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
 -  return MESA_FORMAT_LA_LATC2_UNORM;
 -   case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
 -  return MESA_FORMAT_LA_LATC2_SNORM;
 -   case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
 -  return MESA_FORMAT_LA_LATC2_UNORM;
 -   case GL_ETC1_RGB8_OES:
 -  return MESA_FORMAT_ETC1_RGB8;
 -   case GL_COMPRESSED_RGB8_ETC2:
 -  return MESA_FORMAT_ETC2_RGB8;
 -   case GL_COMPRESSED_SRGB8_ETC2:
 -  return MESA_FORMAT_ETC2_SRGB8;
 -   case GL_COMPRESSED_RGBA8_ETC2_EAC:
 -  return MESA_FORMAT_ETC2_RGBA8_EAC;
 -   case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
 -  return MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC;
 -   case GL_COMPRESSED_R11_EAC:
 -  return MESA_FORMAT_ETC2_R11_EAC;
 -   case GL_COMPRESSED_RG11_EAC:
 -  return MESA_FORMAT_ETC2_RG11_EAC;
 -   case GL_COMPRESSED_SIGNED_R11_EAC:
 -  return MESA_FORMAT_ETC2_SIGNED_R11_EAC;
 -   case GL_COMPRESSED_SIGNED_RG11_EAC:
 -  return MESA_FORMAT_ETC2_SIGNED_RG11_EAC;
 -   case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
 -  return MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1;
 -   case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
 -  return MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1;
 -   case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
 -  return MESA_FORMAT_SRGB_DXT1;
 -   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
 -  return MESA_FORMAT_SRGBA_DXT1;
 -   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
 -  return MESA_FORMAT_SRGBA_DXT3;
 -   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
 -  return MESA_FORMAT_SRGBA_DXT5;
 -   case GL_COMPRESSED_RGBA_BPTC_UNORM:
 -  return 

[Mesa-dev] [PATCH] mesa/texformat: Use format conversion function in _mesa_choose_tex_format

2015-08-12 Thread Nanley Chery
From: Nanley Chery nanley.g.ch...@intel.com

This function's cases for non-generic compressed formats duplicate
the GL to MESA translation in _mesa_glenum_to_compressed_format().
This patch replaces the switch cases with a call to the translation
function. There are no behavioral changes except for the RGB[A]4 formats:

   case GL_RGB4_S3TC:
 return MESA_FORMAT_RGB_DXT1  (old) - MESA_FORMAT_RGBA_DXT1 (new)
   case GL_RGBA4_S3TC:
 return MESA_FORMAT_RGBA_DXT3 (old) - MESA_FORMAT_RGBA_DXT5 (new)

Although unclear, the old behavior was likely a bug, given that online
documentation (few and far between) imply a format mapping of the following:

   GL_RGB_S3TC(0x83A0)  - COMPRESSED_RGB_S3TC_DXT1_EXT  (0x83F0)
   GL_RGB4_S3TC   (0x83A1)  - COMPRESSED_RGBA_S3TC_DXT1_EXT (0x83F1)
   GL_RGBA_S3TC   (0x83A2)  - COMPRESSED_RGBA_S3TC_DXT3_EXT (0x83F2)
   GL_RGBA4_S3TC  (0x83A2)  - COMPRESSED_RGBA_S3TC_DXT5_EXT (0x83F2)

Cc: Brian Paul bri...@vmware.com
Cc: Ian Romanick ian.d.roman...@intel.com
Signed-off-by: Nanley Chery nanley.g.ch...@intel.com
---
 src/mesa/main/texformat.c | 94 +++
 1 file changed, 13 insertions(+), 81 deletions(-)

diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index f4d17e1..fd9f335 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -38,6 +38,7 @@
 #include mtypes.h
 #include texcompress.h
 #include texformat.h
+#include glformats.h
 
 #define RETURN_IF_SUPPORTED(f) do {\
if (ctx-TextureFormatSupported[f]) \
@@ -276,87 +277,6 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum 
target,
  RETURN_IF_SUPPORTED(MESA_FORMAT_YCBCR_REV);
   break;
 
-   /* For non-generic compressed format we assert two things:
-*
-* 1. The format has already been validated against the set of available
-*extensions.
-*
-* 2. The driver only enables the extension if it supports all of the
-*formats that are part of that extension.
-*/
-   case GL_COMPRESSED_RGB_FXT1_3DFX:
-  return MESA_FORMAT_RGB_FXT1;
-   case GL_COMPRESSED_RGBA_FXT1_3DFX:
-  return MESA_FORMAT_RGBA_FXT1;
-   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-   case GL_RGB_S3TC:
-   case GL_RGB4_S3TC:
-  return MESA_FORMAT_RGB_DXT1;
-   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-  return MESA_FORMAT_RGBA_DXT1;
-   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-   case GL_RGBA_S3TC:
-   case GL_RGBA4_S3TC:
-  return MESA_FORMAT_RGBA_DXT3;
-   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-  return MESA_FORMAT_RGBA_DXT5;
-   case GL_COMPRESSED_RED_RGTC1:
-  return MESA_FORMAT_R_RGTC1_UNORM;
-   case GL_COMPRESSED_SIGNED_RED_RGTC1:
-  return MESA_FORMAT_R_RGTC1_SNORM;
-   case GL_COMPRESSED_RG_RGTC2:
-  return MESA_FORMAT_RG_RGTC2_UNORM;
-   case GL_COMPRESSED_SIGNED_RG_RGTC2:
-  return MESA_FORMAT_RG_RGTC2_SNORM;
-   case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
-  return MESA_FORMAT_L_LATC1_UNORM;
-   case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
-  return MESA_FORMAT_L_LATC1_SNORM;
-   case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
-  return MESA_FORMAT_LA_LATC2_UNORM;
-   case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
-  return MESA_FORMAT_LA_LATC2_SNORM;
-   case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
-  return MESA_FORMAT_LA_LATC2_UNORM;
-   case GL_ETC1_RGB8_OES:
-  return MESA_FORMAT_ETC1_RGB8;
-   case GL_COMPRESSED_RGB8_ETC2:
-  return MESA_FORMAT_ETC2_RGB8;
-   case GL_COMPRESSED_SRGB8_ETC2:
-  return MESA_FORMAT_ETC2_SRGB8;
-   case GL_COMPRESSED_RGBA8_ETC2_EAC:
-  return MESA_FORMAT_ETC2_RGBA8_EAC;
-   case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
-  return MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC;
-   case GL_COMPRESSED_R11_EAC:
-  return MESA_FORMAT_ETC2_R11_EAC;
-   case GL_COMPRESSED_RG11_EAC:
-  return MESA_FORMAT_ETC2_RG11_EAC;
-   case GL_COMPRESSED_SIGNED_R11_EAC:
-  return MESA_FORMAT_ETC2_SIGNED_R11_EAC;
-   case GL_COMPRESSED_SIGNED_RG11_EAC:
-  return MESA_FORMAT_ETC2_SIGNED_RG11_EAC;
-   case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
-  return MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1;
-   case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
-  return MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1;
-   case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
-  return MESA_FORMAT_SRGB_DXT1;
-   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
-  return MESA_FORMAT_SRGBA_DXT1;
-   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
-  return MESA_FORMAT_SRGBA_DXT3;
-   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
-  return MESA_FORMAT_SRGBA_DXT5;
-   case GL_COMPRESSED_RGBA_BPTC_UNORM:
-  return MESA_FORMAT_BPTC_RGBA_UNORM;
-   case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
-  return MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM;
-   case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
-  return MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT;
-   case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
-  return