2016-05-12 18:08:49 +00:00
|
|
|
#ifndef MPGL_FORMATS_H_
|
|
|
|
#define MPGL_FORMATS_H_
|
|
|
|
|
|
|
|
#include "common.h"
|
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.
2017-07-26 09:19:51 +00:00
|
|
|
#include "ra.h"
|
2016-05-12 18:08:49 +00:00
|
|
|
|
|
|
|
struct gl_format {
|
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.
2017-07-26 09:19:51 +00:00
|
|
|
const char *name; // symbolic name for user interaction/debugging
|
2016-05-12 18:08:49 +00:00
|
|
|
GLint internal_format; // glTexImage argument
|
|
|
|
GLenum format; // glTexImage argument
|
|
|
|
GLenum type; // e.g. GL_UNSIGNED_SHORT
|
2017-04-14 15:35:27 +00:00
|
|
|
int flags; // F_* flags
|
2016-05-12 18:08:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
// --- gl_format.flags
|
|
|
|
|
|
|
|
// Version flags. If at least 1 flag matches, the format entry is considered
|
|
|
|
// supported on the current GL context.
|
|
|
|
F_GL2 = 1 << 0, // GL2.1-only
|
|
|
|
F_GL3 = 1 << 1, // GL3.0 or later
|
|
|
|
F_ES2 = 1 << 2, // ES2-only
|
|
|
|
F_ES3 = 1 << 3, // ES3.0 or later
|
|
|
|
F_ES32 = 1 << 4, // ES3.2 or later
|
|
|
|
F_EXT16 = 1 << 5, // ES with GL_EXT_texture_norm16
|
2016-05-23 17:29:08 +00:00
|
|
|
F_EXTF16 = 1 << 6, // GL_EXT_color_buffer_half_float
|
2016-05-12 18:08:49 +00:00
|
|
|
F_GL2F = 1 << 7, // GL2.1-only with texture_rg + texture_float + FBOs
|
|
|
|
F_APPL = 1 << 8, // GL_APPLE_rgb_422
|
|
|
|
|
|
|
|
// Feature flags. They are additional and signal presence of features.
|
|
|
|
F_CR = 1 << 16, // color-renderable
|
|
|
|
F_TF = 1 << 17, // texture-filterable with GL_LINEAR
|
|
|
|
F_CF = F_CR | F_TF,
|
|
|
|
F_F16 = 1 << 18, // uses half-floats (16 bit) internally, even though
|
|
|
|
// the format is still GL_FLOAT (32 bit)
|
|
|
|
|
|
|
|
// --- Other constants.
|
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.
2017-07-26 09:19:51 +00:00
|
|
|
MPGL_TYPE_UNORM = RA_CTYPE_UNORM, // normalized integer (fixed point) formats
|
|
|
|
MPGL_TYPE_UINT = RA_CTYPE_UINT, // full integer formats
|
|
|
|
MPGL_TYPE_FLOAT = RA_CTYPE_FLOAT, // float formats (both full and half)
|
2016-05-12 18:08:49 +00:00
|
|
|
};
|
|
|
|
|
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.
2017-07-26 09:19:51 +00:00
|
|
|
extern const struct gl_format gl_formats[];
|
|
|
|
|
2016-05-12 18:08:49 +00:00
|
|
|
int gl_format_feature_flags(GL *gl);
|
|
|
|
const struct gl_format *gl_find_internal_format(GL *gl, GLint internal_format);
|
|
|
|
const struct gl_format *gl_find_format(GL *gl, int type, int flags,
|
|
|
|
int bytes_per_component, int n_components);
|
|
|
|
const struct gl_format *gl_find_unorm_format(GL *gl, int bytes_per_component,
|
|
|
|
int n_components);
|
|
|
|
const struct gl_format *gl_find_uint_format(GL *gl, int bytes_per_component,
|
|
|
|
int n_components);
|
|
|
|
const struct gl_format *gl_find_float16_format(GL *gl, int n_components);
|
|
|
|
int gl_format_type(const struct gl_format *format);
|
2017-02-17 16:20:33 +00:00
|
|
|
bool gl_format_is_regular(const struct gl_format *format);
|
2016-05-12 18:08:49 +00:00
|
|
|
GLenum gl_integer_format_to_base(GLenum format);
|
2017-02-17 14:46:11 +00:00
|
|
|
bool gl_is_integer_format(GLenum format);
|
2016-05-12 18:08:49 +00:00
|
|
|
int gl_component_size(GLenum type);
|
|
|
|
int gl_format_components(GLenum format);
|
|
|
|
int gl_bytes_per_pixel(GLenum format, GLenum type);
|
|
|
|
|
2017-02-17 15:16:29 +00:00
|
|
|
struct gl_imgfmt_desc {
|
|
|
|
int num_planes;
|
|
|
|
const struct gl_format *planes[4];
|
2017-06-30 15:13:58 +00:00
|
|
|
// Chroma pixel size (1x1 is 4:4:4)
|
|
|
|
uint8_t chroma_w, chroma_h;
|
2017-06-30 14:57:17 +00:00
|
|
|
// Component storage size in bits (possibly padded). For formats with
|
|
|
|
// different sizes per component, this is arbitrary. For padded formats
|
|
|
|
// like P010 or YUV420P10, padding is included.
|
|
|
|
int component_bits;
|
|
|
|
// Like mp_regular_imgfmt.component_pad.
|
|
|
|
int component_pad;
|
|
|
|
// For each texture and each texture output (rgba order) describe what
|
|
|
|
// component it returns.
|
|
|
|
// The values are like the values in mp_regular_imgfmt_plane.components[].
|
|
|
|
// Access as components[plane_nr][component_index]. Set unused items to 0.
|
|
|
|
// This pretends GL_RG is used instead of GL_LUMINANCE_ALPHA. The renderer
|
|
|
|
// fixes this later.
|
|
|
|
uint8_t components[4][4];
|
2017-02-17 15:16:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool gl_get_imgfmt_desc(GL *gl, int imgfmt, struct gl_imgfmt_desc *out);
|
|
|
|
|
2016-05-12 18:08:49 +00:00
|
|
|
#endif
|