summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
Diffstat (limited to 'video/out')
-rw-r--r--video/out/opengl/ra.c21
-rw-r--r--video/out/opengl/ra_gl.c3
-rw-r--r--video/out/opengl/video.c27
3 files changed, 22 insertions, 29 deletions
diff --git a/video/out/opengl/ra.c b/video/out/opengl/ra.c
index 12d944f29c..df27f723c2 100644
--- a/video/out/opengl/ra.c
+++ b/video/out/opengl/ra.c
@@ -20,7 +20,7 @@ static bool ra_format_is_regular(const struct ra_format *fmt)
return true;
}
-// Return a regular format using RA_CTYPE_UNORM.
+// Return a regular filterable format using RA_CTYPE_UNORM.
const struct ra_format *ra_find_unorm_format(struct ra *ra,
int bytes_per_component,
int n_components)
@@ -30,7 +30,7 @@ const struct ra_format *ra_find_unorm_format(struct ra *ra,
if (fmt->ctype == RA_CTYPE_UNORM && fmt->num_components == n_components &&
fmt->pixel_size == bytes_per_component * n_components &&
fmt->component_depth[0] == bytes_per_component * 8 &&
- ra_format_is_regular(fmt))
+ fmt->linear_filter && ra_format_is_regular(fmt))
return fmt;
}
return NULL;
@@ -52,7 +52,7 @@ const struct ra_format *ra_find_uint_format(struct ra *ra,
return NULL;
}
-// Return a regular format that uses float16 internally, but does 32 bit
+// Return a filterable regular format that uses float16 internally, but does 32 bit
// transfer. (This is just so we don't need 32->16 bit conversion on CPU,
// which would be ok but messy.)
const struct ra_format *ra_find_float16_format(struct ra *ra, int n_components)
@@ -62,15 +62,15 @@ const struct ra_format *ra_find_float16_format(struct ra *ra, int n_components)
if (fmt->ctype == RA_CTYPE_FLOAT && fmt->num_components == n_components &&
fmt->pixel_size == sizeof(float) * n_components &&
fmt->component_depth[0] == 16 &&
- ra_format_is_regular(fmt))
+ fmt->linear_filter && ra_format_is_regular(fmt))
return fmt;
}
return NULL;
}
-// Like ra_find_unorm_format(), but takes bits (not bytes), and if no fixed
-// point format is available, return an unsigned integer format.
+// Like ra_find_unorm_format(), but if no fixed point format is available,
+// return an unsigned integer format.
static const struct ra_format *find_plane_format(struct ra *ra, int bytes,
int n_channels)
{
@@ -94,6 +94,7 @@ bool ra_get_imgfmt_desc(struct ra *ra, int imgfmt, struct ra_imgfmt_desc *out)
struct mp_regular_imgfmt regfmt;
if (mp_get_regular_imgfmt(&regfmt, imgfmt)) {
+ enum ra_ctype ctype = RA_CTYPE_UNKNOWN;
res.num_planes = regfmt.num_planes;
res.component_bits = regfmt.component_size * 8;
res.component_pad = regfmt.component_pad;
@@ -105,6 +106,14 @@ bool ra_get_imgfmt_desc(struct ra *ra, int imgfmt, struct ra_imgfmt_desc *out)
return false;
for (int i = 0; i < plane->num_components; i++)
res.components[n][i] = plane->components[i];
+ // Dropping LSBs when shifting will lead to dropped MSBs.
+ if (res.component_bits > res.planes[n]->component_depth[0] &&
+ res.component_pad < 0)
+ return false;
+ // Renderer restriction, but actually an unwanted corner case.
+ if (ctype != RA_CTYPE_UNKNOWN && ctype != res.planes[n]->ctype)
+ return false;
+ ctype = res.planes[n]->ctype;
}
res.chroma_w = regfmt.chroma_w;
res.chroma_h = regfmt.chroma_h;
diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c
index bf926a197e..01f1fcd6e5 100644
--- a/video/out/opengl/ra_gl.c
+++ b/video/out/opengl/ra_gl.c
@@ -22,7 +22,10 @@ int ra_init_gl(struct ra *ra, GL *gl)
ra->caps |= RA_CAP_TEX_3D;
int gl_fmt_features = gl_format_feature_flags(gl);
+
+ // Test whether we can use 10 bit.
int depth16 = gl_determine_16bit_tex_depth(gl);
+ MP_VERBOSE(ra, "16 bit texture depth: %d.\n", depth16);
for (int n = 0; gl_formats[n].internal_format; n++) {
const struct gl_format *gl_fmt = &gl_formats[n];
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 1a55d8393d..ac8c9462ee 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -193,7 +193,6 @@ struct gl_video {
struct gl_lcms *cms;
bool gl_debug;
- int texture_16bit_depth; // actual bits available in 16 bit textures
int fb_depth; // actual bits available in GL main framebuffer
struct gl_shader_cache *sc;
@@ -3611,11 +3610,6 @@ static void init_gl(struct gl_video *p)
gl_video_set_gl_state(p);
- // Test whether we can use 10 bit.
- p->texture_16bit_depth = gl_determine_16bit_tex_depth(gl);
- if (p->texture_16bit_depth > 0)
- MP_VERBOSE(p, "16 bit texture depth: %d.\n", p->texture_16bit_depth);
-
p->upload_timer = gl_timer_create(gl);
p->blit_timer = gl_timer_create(gl);
@@ -3689,25 +3683,12 @@ bool gl_video_showing_interpolated_frame(struct gl_video *p)
}
static bool is_imgfmt_desc_supported(struct gl_video *p,
- const struct gl_imgfmt_desc *desc)
+ const struct ra_imgfmt_desc *desc)
{
if (!desc->num_planes)
return false;
- if (desc->component_bits > 8 && desc->component_bits < 16 &&
- desc->component_pad < 0 && p->texture_16bit_depth < 16)
- return false;
-
- int use_integer = -1;
- for (int n = 0; n < desc->num_planes; n++) {
- int use_int_plane = gl_is_integer_format(desc->planes[n]->format);
- if (use_integer < 0)
- use_integer = use_int_plane;
- if (use_integer != use_int_plane)
- return false; // mixed planes not supported
- }
-
- if (use_integer && p->forced_dumb_mode)
+ if (desc->planes[0]->ctype == RA_CTYPE_UINT && p->forced_dumb_mode)
return false;
return true;
@@ -3715,8 +3696,8 @@ static bool is_imgfmt_desc_supported(struct gl_video *p,
bool gl_video_check_format(struct gl_video *p, int mp_format)
{
- struct gl_imgfmt_desc desc;
- if (gl_get_imgfmt_desc(p->gl, mp_format, &desc) &&
+ struct ra_imgfmt_desc desc;
+ if (ra_get_imgfmt_desc(p->ra, mp_format, &desc) &&
is_imgfmt_desc_supported(p, &desc))
return true;
if (p->hwdec && gl_hwdec_test_format(p->hwdec, mp_format))