X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fglformats.c;h=4f240206ff45d221e94ca867976f8b669c23c1a9;hb=6fa34de8308fd4abc2fb23aa9071a35cb08552c9;hp=96ab393c0e1ac63b48541797117ed0944ee5b05a;hpb=2c3f95d6aaab38cd66dd3dee1b089d5c91928eea;p=mesa.git diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 96ab393c0e1..4f240206ff4 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -546,6 +546,7 @@ _mesa_bytes_per_vertex_attrib(GLint comps, 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_DOUBLE: return comps * sizeof(GLdouble); @@ -823,10 +824,10 @@ _mesa_is_enum_format_signed_int(GLenum format) } /** - * Test if the given format is an ASTC format. + * Test if the given format is an ASTC 2D format. */ -GLboolean -_mesa_is_astc_format(GLenum internalFormat) +static bool +is_astc_2d_format(GLenum internalFormat) { switch (internalFormat) { case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: @@ -863,6 +864,71 @@ _mesa_is_astc_format(GLenum internalFormat) } } +/** + * Test if the given format is an ASTC 3D format. + */ +static bool +is_astc_3d_format(GLenum internalFormat) +{ + switch (internalFormat) { + case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: + case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: + case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: + case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: + case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: + case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: + case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: + case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: + case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: + case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: + return true; + default: + return false; + } +} + +/** + * Test if the given format is an ASTC format. + */ +GLboolean +_mesa_is_astc_format(GLenum internalFormat) +{ + return is_astc_2d_format(internalFormat) || + is_astc_3d_format(internalFormat); +} + +/** + * Test if the given format is an ETC2 format. + */ +GLboolean +_mesa_is_etc2_format(GLenum internalFormat) +{ + switch (internalFormat) { + case GL_COMPRESSED_RGB8_ETC2: + case GL_COMPRESSED_SRGB8_ETC2: + case GL_COMPRESSED_RGBA8_ETC2_EAC: + case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: + case GL_COMPRESSED_R11_EAC: + case GL_COMPRESSED_RG11_EAC: + case GL_COMPRESSED_SIGNED_R11_EAC: + case GL_COMPRESSED_SIGNED_RG11_EAC: + case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: + case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: + return true; + default: + return false; + } +} /** * Test if the given format is an integer (non-normalized) format. @@ -1569,6 +1635,7 @@ GLint _mesa_base_format_component_count(GLenum base_format) { switch (base_format) { + case GL_LUMINANCE: case GL_RED: case GL_ALPHA: case GL_INTENSITY: @@ -2345,8 +2412,10 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat) return base_compressed; } - if (ctx->Extensions.KHR_texture_compression_astc_ldr && - _mesa_is_astc_format(internalFormat)) + if ((ctx->Extensions.KHR_texture_compression_astc_ldr && + is_astc_2d_format(internalFormat)) || + (ctx->Extensions.OES_texture_compression_astc && + is_astc_3d_format(internalFormat))) return GL_RGBA; if (ctx->Extensions.MESA_ycbcr_texture) { @@ -2450,7 +2519,6 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat) case GL_RGBA8I_EXT: case GL_RGBA16I_EXT: case GL_RGBA32I_EXT: - case GL_RGB10_A2UI: return GL_RGBA; case GL_RGB8UI_EXT: case GL_RGB16UI_EXT: @@ -2462,6 +2530,13 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat) } } + if (ctx->Extensions.ARB_texture_rgb10_a2ui) { + switch (internalFormat) { + case GL_RGB10_A2UI: + return GL_RGBA; + } + } + if (ctx->Extensions.EXT_texture_integer) { switch (internalFormat) { case GL_ALPHA8UI_EXT: @@ -3557,6 +3632,21 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type) unreachable("Unsupported format"); } +uint32_t +_mesa_tex_format_from_format_and_type(const struct gl_context *ctx, + GLenum gl_format, GLenum type) +{ + mesa_format format = _mesa_format_from_format_and_type(gl_format, type); + + if (_mesa_format_is_mesa_array_format(format)) + format = _mesa_format_from_array_format(format); + + if (format == MESA_FORMAT_NONE || !ctx->TextureFormatSupported[format]) + return MESA_FORMAT_NONE; + + return format; +} + /** * Returns true if \p internal_format is a sized internal format that * is marked "Color Renderable" in Table 8.10 of the ES 3.2 specification. @@ -3611,7 +3701,8 @@ _mesa_is_es3_color_renderable(GLenum internal_format) * is marked "Texture Filterable" in Table 8.10 of the ES 3.2 specification. */ bool -_mesa_is_es3_texture_filterable(GLenum internal_format) +_mesa_is_es3_texture_filterable(const struct gl_context *ctx, + GLenum internal_format) { switch (internal_format) { case GL_R8: @@ -3635,6 +3726,20 @@ _mesa_is_es3_texture_filterable(GLenum internal_format) case GL_R11F_G11F_B10F: case GL_RGB9_E5: return true; + case GL_R32F: + case GL_RG32F: + case GL_RGB32F: + case GL_RGBA32F: + /* The OES_texture_float_linear spec says: + * + * "When implemented against OpenGL ES 3.0 or later versions, sized + * 32-bit floating-point formats become texture-filterable. This + * should be noted by, for example, checking the ``TF'' column of + * table 8.13 in the ES 3.1 Specification (``Correspondence of sized + * internal formats to base internal formats ... and use cases ...'') + * for the R32F, RG32F, RGB32F, and RGBA32F formats." + */ + return ctx->Extensions.OES_texture_float_linear; default: return false; }