From 258487370fd840b018a404225277d74f74899c59 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 13 Sep 2017 03:09:48 +0200 Subject: vo_gpu: vulkan: generalize SPIR-V compiler In addition to the built-in nvidia compiler, we now also support a backend based on libshaderc. shaderc is sort of like glslang except it has a C API and is available as a dynamic library. The generated SPIR-V is now cached alongside the VkPipeline in the cached_program. We use a special cache header to ensure validity of this cache before passing it blindly to the vulkan implementation, since passing invalid SPIR-V can cause all sorts of nasty things. It's also designed to self-invalidate if the compiler gets better, by offering a catch-all `int compiler_version` that implementations can use as a cache invalidation marker. --- video/out/gpu/context.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'video/out/gpu/context.c') diff --git a/video/out/gpu/context.c b/video/out/gpu/context.c index 25e2a754bf..69f322c422 100644 --- a/video/out/gpu/context.c +++ b/video/out/gpu/context.c @@ -31,6 +31,7 @@ #include "video/out/vo.h" #include "context.h" +#include "spirv.h" extern const struct ra_ctx_fns ra_ctx_glx; extern const struct ra_ctx_fns ra_ctx_glx_probe; @@ -185,10 +186,17 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, const char *context_type, return NULL; } -void ra_ctx_destroy(struct ra_ctx **ctx) +void ra_ctx_destroy(struct ra_ctx **ctx_ptr) { - if (*ctx) - (*ctx)->fns->uninit(*ctx); - talloc_free(*ctx); - *ctx = NULL; + struct ra_ctx *ctx = *ctx_ptr; + if (!ctx) + return; + + if (ctx->spirv && ctx->spirv->fns->uninit) + ctx->spirv->fns->uninit(ctx); + + ctx->fns->uninit(ctx); + talloc_free(ctx); + + *ctx_ptr = NULL; } -- cgit v1.2.3