summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/formats.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-07-26 11:19:51 +0200
committerwm4 <wm4@nowhere>2017-07-26 11:31:43 +0200
commit81851febc4766e053cc17134c779959f5942025a (patch)
tree48e6aedcdb3889e641dfb169e1fff8c144b01bfa /video/out/opengl/formats.c
parent5904eddb38f20bf794aadff659050c0b32479054 (diff)
downloadmpv-81851febc4766e053cc17134c779959f5942025a.tar.bz2
mpv-81851febc4766e053cc17134c779959f5942025a.tar.xz
vo_opengl: start work on rendering API abstraction
This starts work on moving OpenGL-specific code out of the general renderer code, so that we can support other other GPU APIs. This is in a very early stage and it's only a proof of concept. It's unknown whether this will succeed or result in other backends. For now, the GL rendering API ("ra") and its only provider (ra_gl) does texture creation/upload/destruction only. And it's used for the main video texture only. All other code is still hardcoded to GL. There is some duplication with ra_format and gl_format handling. In the end, only the ra variants will be needed (plus the gl_format table of course). For now, this is simpler, because for some reason lots of hwdec code still requires the GL variants, and would have to be updated to use the ra ones. Currently, the video.c code accesses private ra_gl fields. In the end, it should not do that of course, and it would not include ra_gl.h. Probably adds bugs, but you can keep them.
Diffstat (limited to 'video/out/opengl/formats.c')
-rw-r--r--video/out/opengl/formats.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/video/out/opengl/formats.c b/video/out/opengl/formats.c
index 2cbc130170..41b7f459e3 100644
--- a/video/out/opengl/formats.c
+++ b/video/out/opengl/formats.c
@@ -10,56 +10,56 @@ enum {
// List of allowed formats, and their usability for bilinear filtering and FBOs.
// This is limited to combinations that are useful for our renderer.
-static const struct gl_format gl_formats[] = {
+const struct gl_format gl_formats[] = {
// These are used for desktop GL 3+, and GLES 3+ with GL_EXT_texture_norm16.
- {GL_R8, GL_RED, T_U8, F_CF | F_GL3 | F_GL2F | F_ES3},
- {GL_RG8, GL_RG, T_U8, F_CF | F_GL3 | F_GL2F | F_ES3},
- {GL_RGB8, GL_RGB, T_U8, F_CF | F_GL3 | F_GL2F | F_ES3},
- {GL_RGBA8, GL_RGBA, T_U8, F_CF | F_GL3 | F_GL2F | F_ES3},
- {GL_R16, GL_RED, T_U16, F_CF | F_GL3 | F_GL2F | F_EXT16},
- {GL_RG16, GL_RG, T_U16, F_CF | F_GL3 | F_GL2F | F_EXT16},
- {GL_RGB16, GL_RGB, T_U16, F_CF | F_GL3 | F_GL2F},
- {GL_RGBA16, GL_RGBA, T_U16, F_CF | F_GL3 | F_GL2F | F_EXT16},
+ {"r8", GL_R8, GL_RED, T_U8, F_CF | F_GL3 | F_GL2F | F_ES3},
+ {"rg8", GL_RG8, GL_RG, T_U8, F_CF | F_GL3 | F_GL2F | F_ES3},
+ {"rgb8", GL_RGB8, GL_RGB, T_U8, F_CF | F_GL3 | F_GL2F | F_ES3},
+ {"rgba8", GL_RGBA8, GL_RGBA, T_U8, F_CF | F_GL3 | F_GL2F | F_ES3},
+ {"r16", GL_R16, GL_RED, T_U16, F_CF | F_GL3 | F_GL2F | F_EXT16},
+ {"rg16", GL_RG16, GL_RG, T_U16, F_CF | F_GL3 | F_GL2F | F_EXT16},
+ {"rgb16", GL_RGB16, GL_RGB, T_U16, F_CF | F_GL3 | F_GL2F},
+ {"rgba16", GL_RGBA16, GL_RGBA, T_U16, F_CF | F_GL3 | F_GL2F | F_EXT16},
// Specifically not color-renderable.
- {GL_RGB16, GL_RGB, T_U16, F_TF | F_EXT16},
+ {"rgb16", GL_RGB16, GL_RGB, T_U16, F_TF | F_EXT16},
// GL2 legacy. Ignores possibly present FBO extensions (no CF flag set).
- {GL_LUMINANCE8, GL_LUMINANCE, T_U8, F_TF | F_GL2},
- {GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, T_U8, F_TF | F_GL2},
- {GL_RGB8, GL_RGB, T_U8, F_TF | F_GL2},
- {GL_RGBA8, GL_RGBA, T_U8, F_TF | F_GL2},
- {GL_LUMINANCE16, GL_LUMINANCE, T_U16, F_TF | F_GL2},
- {GL_LUMINANCE16_ALPHA16, GL_LUMINANCE_ALPHA, T_U16, F_TF | F_GL2},
- {GL_RGB16, GL_RGB, T_U16, F_TF | F_GL2},
- {GL_RGBA16, GL_RGBA, T_U16, F_TF | F_GL2},
+ {"l8", GL_LUMINANCE8, GL_LUMINANCE, T_U8, F_TF | F_GL2},
+ {"la8", GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, T_U8, F_TF | F_GL2},
+ {"rgb8", GL_RGB8, GL_RGB, T_U8, F_TF | F_GL2},
+ {"rgba8", GL_RGBA8, GL_RGBA, T_U8, F_TF | F_GL2},
+ {"l16", GL_LUMINANCE16, GL_LUMINANCE, T_U16, F_TF | F_GL2},
+ {"la16", GL_LUMINANCE16_ALPHA16, GL_LUMINANCE_ALPHA, T_U16, F_TF | F_GL2},
+ {"rgb16", GL_RGB16, GL_RGB, T_U16, F_TF | F_GL2},
+ {"rgba16", GL_RGBA16, GL_RGBA, T_U16, F_TF | F_GL2},
// ES2 legacy
- {GL_LUMINANCE, GL_LUMINANCE, T_U8, F_TF | F_ES2},
- {GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, T_U8, F_TF | F_ES2},
- {GL_RGB, GL_RGB, T_U8, F_TF | F_ES2},
- {GL_RGBA, GL_RGBA, T_U8, F_TF | F_ES2},
+ {"l" , GL_LUMINANCE,GL_LUMINANCE, T_U8, F_TF | F_ES2},
+ {"la",GL_LUMINANCE_ALPHA,GL_LUMINANCE_ALPHA, T_U8, F_TF | F_ES2},
+ {"rgb", GL_RGB, GL_RGB, T_U8, F_TF | F_ES2},
+ {"rgba", GL_RGBA, GL_RGBA, T_U8, F_TF | F_ES2},
// Non-normalized integer formats.
// Follows ES 3.0 as to which are color-renderable.
- {GL_R8UI, GL_RED_INTEGER, T_U8, F_CR | F_GL3 | F_ES3},
- {GL_RG8UI, GL_RG_INTEGER, T_U8, F_CR | F_GL3 | F_ES3},
- {GL_RGB8UI, GL_RGB_INTEGER, T_U8, F_GL3 | F_ES3},
- {GL_RGBA8UI, GL_RGBA_INTEGER, T_U8, F_CR | F_GL3 | F_ES3},
- {GL_R16UI, GL_RED_INTEGER, T_U16, F_CR | F_GL3 | F_ES3},
- {GL_RG16UI, GL_RG_INTEGER, T_U16, F_CR | F_GL3 | F_ES3},
- {GL_RGB16UI, GL_RGB_INTEGER, T_U16, F_GL3 | F_ES3},
- {GL_RGBA16UI, GL_RGBA_INTEGER, T_U16, F_CR | F_GL3 | F_ES3},
+ {"r8ui", GL_R8UI, GL_RED_INTEGER, T_U8, F_CR | F_GL3 | F_ES3},
+ {"rg8ui", GL_RG8UI, GL_RG_INTEGER, T_U8, F_CR | F_GL3 | F_ES3},
+ {"rgb8ui", GL_RGB8UI, GL_RGB_INTEGER, T_U8, F_GL3 | F_ES3},
+ {"rgba8ui", GL_RGBA8UI, GL_RGBA_INTEGER, T_U8, F_CR | F_GL3 | F_ES3},
+ {"r16ui", GL_R16UI, GL_RED_INTEGER, T_U16, F_CR | F_GL3 | F_ES3},
+ {"rg16ui", GL_RG16UI, GL_RG_INTEGER, T_U16, F_CR | F_GL3 | F_ES3},
+ {"rgb16ui", GL_RGB16UI, GL_RGB_INTEGER, T_U16, F_GL3 | F_ES3},
+ {"rgba16ui",GL_RGBA16UI, GL_RGBA_INTEGER, T_U16, F_CR | F_GL3 | F_ES3},
// On GL3+ or GL2.1 with GL_ARB_texture_float, floats work fully.
- {GL_R16F, GL_RED, T_FL, F_F16 | F_CF | F_GL3 | F_GL2F},
- {GL_RG16F, GL_RG, T_FL, F_F16 | F_CF | F_GL3 | F_GL2F},
- {GL_RGB16F, GL_RGB, T_FL, F_F16 | F_CF | F_GL3 | F_GL2F},
- {GL_RGBA16F, GL_RGBA, T_FL, F_F16 | F_CF | F_GL3 | F_GL2F},
- {GL_R32F, GL_RED, T_FL, F_CF | F_GL3 | F_GL2F},
- {GL_RG32F, GL_RG, T_FL, F_CF | F_GL3 | F_GL2F},
- {GL_RGB32F, GL_RGB, T_FL, F_CF | F_GL3 | F_GL2F},
- {GL_RGBA32F, GL_RGBA, T_FL, F_CF | F_GL3 | F_GL2F},
+ {"r16f", GL_R16F, GL_RED, T_FL, F_F16 | F_CF | F_GL3 | F_GL2F},
+ {"rg16f", GL_RG16F, GL_RG, T_FL, F_F16 | F_CF | F_GL3 | F_GL2F},
+ {"rgb16f", GL_RGB16F, GL_RGB, T_FL, F_F16 | F_CF | F_GL3 | F_GL2F},
+ {"rgba16f", GL_RGBA16F, GL_RGBA, T_FL, F_F16 | F_CF | F_GL3 | F_GL2F},
+ {"r32f", GL_R32F, GL_RED, T_FL, F_CF | F_GL3 | F_GL2F},
+ {"rg32f", GL_RG32F, GL_RG, T_FL, F_CF | F_GL3 | F_GL2F},
+ {"rgb32f", GL_RGB32F, GL_RGB, T_FL, F_CF | F_GL3 | F_GL2F},
+ {"rgba32f", GL_RGBA32F, GL_RGBA, T_FL, F_CF | F_GL3 | F_GL2F},
// Note: we simply don't support float anything on ES2, despite extensions.
// We also don't bother with non-filterable float formats, and we ignore
@@ -67,28 +67,28 @@ static const struct gl_format gl_formats[] = {
// On ES3.2+, both 16 bit floats work fully (except 3-component formats).
// F_EXTF16 implies extensions that also enable 16 bit floats fully.
- {GL_R16F, GL_RED, T_FL, F_F16 | F_CF | F_ES32 | F_EXTF16},
- {GL_RG16F, GL_RG, T_FL, F_F16 | F_CF | F_ES32 | F_EXTF16},
- {GL_RGB16F, GL_RGB, T_FL, F_F16 | F_TF | F_ES32 | F_EXTF16},
- {GL_RGBA16F, GL_RGBA, T_FL, F_F16 | F_CF | F_ES32 | F_EXTF16},
+ {"r16f", GL_R16F, GL_RED, T_FL, F_F16 | F_CF | F_ES32 | F_EXTF16},
+ {"rg16f", GL_RG16F, GL_RG, T_FL, F_F16 | F_CF | F_ES32 | F_EXTF16},
+ {"rgb16f", GL_RGB16F, GL_RGB, T_FL, F_F16 | F_TF | F_ES32 | F_EXTF16},
+ {"rgba16f", GL_RGBA16F, GL_RGBA, T_FL, F_F16 | F_CF | F_ES32 | F_EXTF16},
// On ES3.0+, 16 bit floats are texture-filterable.
// Don't bother with 32 bit floats; they exist but are neither CR nor TF.
- {GL_R16F, GL_RED, T_FL, F_F16 | F_TF | F_ES3},
- {GL_RG16F, GL_RG, T_FL, F_F16 | F_TF | F_ES3},
- {GL_RGB16F, GL_RGB, T_FL, F_F16 | F_TF | F_ES3},
- {GL_RGBA16F, GL_RGBA, T_FL, F_F16 | F_TF | F_ES3},
+ {"r16f", GL_R16F, GL_RED, T_FL, F_F16 | F_TF | F_ES3},
+ {"rg16f", GL_RG16F, GL_RG, T_FL, F_F16 | F_TF | F_ES3},
+ {"rgb16f", GL_RGB16F, GL_RGB, T_FL, F_F16 | F_TF | F_ES3},
+ {"rgba16f", GL_RGBA16F, GL_RGBA, T_FL, F_F16 | F_TF | F_ES3},
// These might be useful as FBO formats.
- {GL_RGB10_A2, GL_RGBA,
+ {"rgb10_a2",GL_RGB10_A2, GL_RGBA,
GL_UNSIGNED_INT_2_10_10_10_REV, F_CF | F_GL3 | F_ES3},
- {GL_RGBA12, GL_RGBA, T_U16, F_CF | F_GL2 | F_GL3},
- {GL_RGB10, GL_RGB, T_U16, F_CF | F_GL2 | F_GL3},
+ {"rgba12", GL_RGBA12, GL_RGBA, T_U16, F_CF | F_GL2 | F_GL3},
+ {"rgb10", GL_RGB10, GL_RGB, T_U16, F_CF | F_GL2 | F_GL3},
// Special formats.
- {GL_RGB8, GL_RGB,
+ {"rgb565", GL_RGB8, GL_RGB,
GL_UNSIGNED_SHORT_5_6_5, F_TF | F_GL2 | F_GL3},
- {GL_RGB, GL_RGB_422_APPLE,
+ {"ashit", GL_RGB, GL_RGB_422_APPLE,
GL_UNSIGNED_SHORT_8_8_APPLE, F_TF | F_APPL},
{0}