diff options
author | Niklas Haas <git@haasn.xyz> | 2017-09-24 16:09:24 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2017-09-26 17:25:46 +0200 |
commit | a4e951e80c9a23c5a2bfcec44798c22e6d6b44ca (patch) | |
tree | edb603c245564cfe637ad91e9e0a693965bd4326 /video/out | |
parent | 47af509e1fad3e9ce30e3e339d8cd705fcd44ef2 (diff) | |
download | mpv-a4e951e80c9a23c5a2bfcec44798c22e6d6b44ca.tar.bz2 mpv-a4e951e80c9a23c5a2bfcec44798c22e6d6b44ca.tar.xz |
vo_gpu: explicitly label storage image formats
This is apparently required to get storage images working on
windows/vulkan, and probably good practice either way. Not entirely sure
if it's the best idea to be always storing the value as 32-bit float,
but it should hardly matter in practice (since we're only writing one
sample per thread).
(Leaving them implicit requires the shaderStorageImageWriteWithoutFormat
feature to be enabled, which the windows nvidia vulkan driver doesn't
support, at least not for a GTX 670)
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/gpu/shader_cache.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/video/out/gpu/shader_cache.c b/video/out/gpu/shader_cache.c index 4e9acc9e3e..0c09daefab 100644 --- a/video/out/gpu/shader_cache.c +++ b/video/out/gpu/shader_cache.c @@ -720,7 +720,6 @@ static void add_uniforms(struct gl_shader_cache *sc, bstr *dst) assert(sc->ra->caps & RA_CAP_GLOBAL_UNIFORM); // fall through case RA_VARTYPE_TEX: - case RA_VARTYPE_IMG_W: // Vulkan requires explicitly assigning the bindings in the shader // source. For OpenGL it's optional, but requires higher GL version // so we don't do it (and instead have ra_gl update the bindings @@ -737,6 +736,28 @@ static void add_uniforms(struct gl_shader_cache *sc, bstr *dst) ADD(dst, "layout(std430, binding=%d) buffer %s { %s };\n", u->input.binding, u->input.name, u->buffer_format); 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]; + + if (sc->ra->glsl_vulkan) { + ADD(dst, "layout(binding=%d, %s) ", u->input.binding, fmt); + } else { + ADD(dst, "layout(%s) ", fmt); + } + ADD(dst, "uniform %s %s;\n", u->glsl_type, u->input.name); + } } } } |