vo_opengl: fix the renderpass target format at creation time

Required for vulkan.
This commit is contained in:
Niklas Haas committed 2017-08-27 14:37:47 +02:00
1 parent 7baa18d5f8
commit cc79d48d22
3 files changed
+19 -4

No files matched your search

+5 -1
View File
@@ -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;
+1
View File
@@ -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),
+13 -3
View File
@@ -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;