summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-08-21 07:00:25 +0200
committerNiklas Haas <git@haasn.xyz>2017-08-27 14:37:47 +0200
commitcc79d48d2243f2a4f64e4ce7268eee92ee24bd7d (patch)
tree9886e8fc649747908d89525d42a1f3231a04b38d
parent7baa18d5f8a4c663cd20e709c059c44364020f47 (diff)
downloadmpv-cc79d48d2243f2a4f64e4ce7268eee92ee24bd7d.tar.bz2
mpv-cc79d48d2243f2a4f64e4ce7268eee92ee24bd7d.tar.xz
vo_opengl: fix the renderpass target format at creation time
Required for vulkan.
-rw-r--r--video/out/opengl/ra.h6
-rw-r--r--video/out/opengl/ra_gl.c1
-rw-r--r--video/out/opengl/shader_cache.c16
3 files changed, 19 insertions, 4 deletions
diff --git a/video/out/opengl/ra.h b/video/out/opengl/ra.h
index f78eff82c9..0f1f98c6f0 100644
--- a/video/out/opengl/ra.h
+++ b/video/out/opengl/ra.h
@@ -245,6 +245,9 @@ struct ra_renderpass_params {
int num_vertex_attribs;
int vertex_stride;
+ // Format of the target texture
+ const struct ra_format *target_format;
+
// Shader text, in GLSL. (Yes, you need a GLSL compiler.)
// These are complete shaders, including prelude and declarations.
const char *vertex_shader;
@@ -302,7 +305,8 @@ struct ra_renderpass_run_params {
// --- pass->params.type==RA_RENDERPASS_TYPE_RASTER only
- // target->params.render_dst must be true.
+ // target->params.render_dst must be true, and target->params.format must
+ // match pass->params.target_format.
struct ra_tex *target;
struct mp_rect viewport;
struct mp_rect scissors;
diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c
index bcc3f57760..401847e471 100644
--- a/video/out/opengl/ra_gl.c
+++ b/video/out/opengl/ra_gl.c
@@ -978,6 +978,7 @@ static void gl_renderpass_run(struct ra *ra,
case RA_RENDERPASS_TYPE_RASTER: {
struct ra_tex_gl *target_gl = params->target->priv;
assert(params->target->params.render_dst);
+ assert(params->target->params.format == pass->params.target_format);
gl->BindFramebuffer(GL_FRAMEBUFFER, target_gl->fbo);
gl->Viewport(params->viewport.x0, params->viewport.y0,
mp_rect_w(params->viewport),
diff --git a/video/out/opengl/shader_cache.c b/video/out/opengl/shader_cache.c
index 5612e8783a..f150bd7e44 100644
--- a/video/out/opengl/shader_cache.c
+++ b/video/out/opengl/shader_cache.c
@@ -684,7 +684,9 @@ static void add_uniforms(struct gl_shader_cache *sc, bstr *dst)
// 1. Unbind the program and all textures.
// 2. Reset the sc state and prepare for a new shader program. (All uniforms
// and fragment operations needed for the next program have to be re-added.)
-static void gl_sc_generate(struct gl_shader_cache *sc, enum ra_renderpass_type type)
+static void gl_sc_generate(struct gl_shader_cache *sc,
+ enum ra_renderpass_type type,
+ const struct ra_format *target_format)
{
int glsl_version = sc->ra->glsl_version;
int glsl_es = sc->ra->glsl_es ? glsl_version : 0;
@@ -788,6 +790,11 @@ static void gl_sc_generate(struct gl_shader_cache *sc, enum ra_renderpass_type t
ADD(frag, "gl_FragColor = color;\n");
}
ADD(frag, "}\n");
+
+ // We need to fix the format of the render dst at renderpass creation
+ // time
+ assert(target_format);
+ sc->params.target_format = target_format;
}
if (type == RA_RENDERPASS_TYPE_COMPUTE) {
@@ -831,6 +838,9 @@ static void gl_sc_generate(struct gl_shader_cache *sc, enum ra_renderpass_type t
sc->params.blend_src_alpha, sc->params.blend_dst_alpha);
}
+ if (sc->params.target_format)
+ ADD(hash_total, "format %s\n", sc->params.target_format->name);
+
struct sc_entry *entry = NULL;
for (int n = 0; n < sc->num_entries; n++) {
struct sc_entry *cur = sc->entries[n];
@@ -888,7 +898,7 @@ struct mp_pass_perf gl_sc_dispatch_draw(struct gl_shader_cache *sc,
{
struct timer_pool *timer = NULL;
- gl_sc_generate(sc, RA_RENDERPASS_TYPE_RASTER);
+ gl_sc_generate(sc, RA_RENDERPASS_TYPE_RASTER, target->params.format);
if (!sc->current_shader)
goto error;
@@ -921,7 +931,7 @@ struct mp_pass_perf gl_sc_dispatch_compute(struct gl_shader_cache *sc,
{
struct timer_pool *timer = NULL;
- gl_sc_generate(sc, RA_RENDERPASS_TYPE_COMPUTE);
+ gl_sc_generate(sc, RA_RENDERPASS_TYPE_COMPUTE, NULL);
if (!sc->current_shader)
goto error;