summaryrefslogtreecommitdiffstats
path: root/video/out/gpu/shader_cache.c
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossy@jrg.systems>2017-10-22 01:18:31 +1100
committerJames Ross-Gowan <rossy@jrg.systems>2017-11-07 20:27:13 +1100
commit8020a62953926cd6d672e9151290bd4d65e8ee08 (patch)
tree2271615c7f6c3e7370e0e7399338abfc33c3a744 /video/out/gpu/shader_cache.c
parent41dff03f8d856273e4a87293f87887d9940009fa (diff)
downloadmpv-8020a62953926cd6d672e9151290bd4d65e8ee08.tar.bz2
mpv-8020a62953926cd6d672e9151290bd4d65e8ee08.tar.xz
vo_gpu: export the GLSL format qualifier for ra_format
Backported from @haasn's change to libplacebo, except in the current RA, there's nothing to indicate an ra_format can be bound as a storage image, so there's no way to force all of these formats to have a glsl_format. Instead, the layout qualifier will be removed if glsl_format is NULL. This is needed for the upcoming ra_d3d11 backend. In Direct3D 11, while loading float values from unorm images often works as expected, it's technically undefined behaviour, and in Windows 10, it will cause the debug layer to spam the log with error messages. Also, apparently in GLSL, the format name must match the image's format exactly (but in Direct3D, it just has to have the same component type.)
Diffstat (limited to 'video/out/gpu/shader_cache.c')
-rw-r--r--video/out/gpu/shader_cache.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/video/out/gpu/shader_cache.c b/video/out/gpu/shader_cache.c
index f191a7198c..83ca11d7ad 100644
--- a/video/out/gpu/shader_cache.c
+++ b/video/out/gpu/shader_cache.c
@@ -710,22 +710,16 @@ static void add_uniforms(struct gl_shader_cache *sc, bstr *dst)
break;
case RA_VARTYPE_IMG_W: {
// For better compatibility, we have to explicitly label the
- // type of data we will be reading/writing to this image. For
- // simplicity, just pick 32-bit float with however many components.
- static const char *fmt_mapping[] = {
- [1] = "r32f",
- [2] = "rg32f",
- [3] = "rgba32f", // rgb32f doesn't exist
- [4] = "rgba32f",
- };
-
- const struct ra_format *format = u->v.tex->params.format;
- assert(format->num_components < MP_ARRAY_SIZE(fmt_mapping));
- const char *fmt = fmt_mapping[format->num_components];
+ // type of data we will be reading/writing to this image.
+ const char *fmt = u->v.tex->params.format->glsl_format;
if (sc->ra->glsl_vulkan) {
- ADD(dst, "layout(binding=%d, %s) ", u->input.binding, fmt);
- } else {
+ if (fmt) {
+ ADD(dst, "layout(binding=%d, %s) ", u->input.binding, fmt);
+ } else {
+ ADD(dst, "layout(binding=%d) ", u->input.binding);
+ }
+ } else if (fmt) {
ADD(dst, "layout(%s) ", fmt);
}
ADD(dst, "uniform %s %s;\n", u->glsl_type, u->input.name);