Commit c8bd5876 authored by Niklas Haas's avatar Niklas Haas

renderer: force caching to intermediate FBO on non-computable targets

This fixes an issue where you can't directly do texture storage on
swapchain images on some vulkan implementations.
parent 6314864b
...@@ -80,6 +80,7 @@ struct pl_renderer { ...@@ -80,6 +80,7 @@ struct pl_renderer {
struct pl_shader_obj *lut3d_state; struct pl_shader_obj *lut3d_state;
const struct pl_tex *main_scale_fbo; const struct pl_tex *main_scale_fbo;
const struct pl_tex *deband_fbos[PLANE_COUNT]; const struct pl_tex *deband_fbos[PLANE_COUNT];
const struct pl_tex *output_fbo;
struct sampler samplers[SCALER_COUNT]; struct sampler samplers[SCALER_COUNT];
struct sampler *osd_samplers; struct sampler *osd_samplers;
int num_osd_samplers; int num_osd_samplers;
...@@ -173,6 +174,7 @@ void pl_renderer_destroy(struct pl_renderer **p_rr) ...@@ -173,6 +174,7 @@ void pl_renderer_destroy(struct pl_renderer **p_rr)
pl_tex_destroy(rr->gpu, &rr->main_scale_fbo); pl_tex_destroy(rr->gpu, &rr->main_scale_fbo);
for (int i = 0; i < PL_ARRAY_SIZE(rr->deband_fbos); i++) for (int i = 0; i < PL_ARRAY_SIZE(rr->deband_fbos); i++)
pl_tex_destroy(rr->gpu, &rr->deband_fbos[i]); pl_tex_destroy(rr->gpu, &rr->deband_fbos[i]);
pl_tex_destroy(rr->gpu, &rr->output_fbo);
// Free all shader resource objects // Free all shader resource objects
pl_shader_obj_destroy(&rr->peak_detect_state); pl_shader_obj_destroy(&rr->peak_detect_state);
...@@ -891,6 +893,20 @@ fallback: ...@@ -891,6 +893,20 @@ fallback:
target->color, &rr->peak_detect_state, false); target->color, &rr->peak_detect_state, false);
} }
bool is_comp = pl_shader_is_compute(sh);
if (is_comp && !fbo->params.storable) {
bool ok = finalize_img(rr, &pass->cur_img, rr->fbofmt, &rr->output_fbo);
if (!ok) {
PL_ERR(rr, "Failed dispatching compute shader to intermediate FBO?");
return false;
}
sh = pass->cur_img.sh = pl_dispatch_begin(rr->dp);
pl_shader_sample_direct(sh, &(struct pl_sample_src) {
.tex = rr->output_fbo,
});
}
pl_shader_encode_color(sh, &target->repr); pl_shader_encode_color(sh, &target->repr);
// FIXME: Technically we should try dithering before bit shifting if we're // FIXME: Technically we should try dithering before bit shifting if we're
...@@ -910,12 +926,6 @@ fallback: ...@@ -910,12 +926,6 @@ fallback:
pl_shader_dither(sh, depth, &rr->dither_state, params->dither_params); pl_shader_dither(sh, depth, &rr->dither_state, params->dither_params);
} }
bool is_comp = pl_shader_is_compute(sh);
if (is_comp && !fbo->params.storable) {
// TODO: force caching
abort();
}
pl_assert(fbo->params.renderable); pl_assert(fbo->params.renderable);
return pl_dispatch_finish(rr->dp, &pass->cur_img.sh, fbo, return pl_dispatch_finish(rr->dp, &pass->cur_img.sh, fbo,
&target->dst_rect, NULL); &target->dst_rect, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment