diff options
author | Topi Pohjolainen <[email protected]> | 2016-11-26 18:03:56 +0200 |
---|---|---|
committer | Topi Pohjolainen <[email protected]> | 2017-01-27 08:57:26 +0200 |
commit | a283a4ee2fba6c8efa4f4e4eeea6b3d7b21df4d0 (patch) | |
tree | f6729e86b366ace5de0dfd91a8cc2b10fdb284f3 /src/mesa/main | |
parent | 542bb8504991c91d50f2b0302c2d04f58003030f (diff) |
meta: Refactor texture format translation
Reviewed-by: Anuj Phogat <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Signed-off-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/glformats.c | 15 | ||||
-rw-r--r-- | src/mesa/main/glformats.h | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index a95909c9bc9..4f240206ff4 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -3632,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. diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h index 763307f2593..5c9d8263ed1 100644 --- a/src/mesa/main/glformats.h +++ b/src/mesa/main/glformats.h @@ -148,6 +148,10 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat ); extern uint32_t _mesa_format_from_format_and_type(GLenum format, GLenum type); +extern uint32_t +_mesa_tex_format_from_format_and_type(const struct gl_context *ctx, + GLenum gl_format, GLenum type); + extern bool _mesa_is_es3_color_renderable(GLenum internal_format); |