From b9c12868936a8b99d282647e9885c341c1eca286 Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Sun, 29 Oct 2017 00:16:03 +1100 Subject: vo_gpu: d3d11: log shader compilation times Some shaders take a _long_ time to compile with the Direct3D compiler. The ANGLE backend had this problem too, to a certain extent. Logging should help identify which shaders cause long stalls and could also help with benchmarking ways of reducing compile times. --- video/out/d3d11/ra_d3d11.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/video/out/d3d11/ra_d3d11.c b/video/out/d3d11/ra_d3d11.c index 806ce9ad52..19b94ed55e 100644 --- a/video/out/d3d11/ra_d3d11.c +++ b/video/out/d3d11/ra_d3d11.c @@ -9,6 +9,7 @@ #include "common/msg.h" #include "osdep/io.h" #include "osdep/subprocess.h" +#include "osdep/timer.h" #include "osdep/windows_utils.h" #include "video/out/gpu/spirv.h" #include "video/out/gpu/utils.h" @@ -783,6 +784,16 @@ static const char *get_shader_target(struct ra *ra, enum glsl_shader type) return NULL; } +static const char *shader_type_name(enum glsl_shader type) +{ + switch (type) { + case GLSL_SHADER_VERTEX: return "vertex"; + case GLSL_SHADER_FRAGMENT: return "fragment"; + case GLSL_SHADER_COMPUTE: return "compute"; + default: return "unknown"; + } +} + static bool setup_clear_rpass(struct ra *ra) { struct ra_d3d11 *p = ra->priv; @@ -1187,10 +1198,14 @@ static bool compile_glsl(struct ra *ra, enum glsl_shader type, cross_shader_model = 40; } + int64_t start_us = mp_time_us(); + bstr spv_module; if (!spirv->fns->compile_glsl(spirv, ta_ctx, type, glsl, &spv_module)) goto done; + int64_t shaderc_us = mp_time_us(); + cross = crossc_hlsl_create((uint32_t*)spv_module.start, spv_module.len / sizeof(uint32_t)); @@ -1203,6 +1218,8 @@ static bool compile_glsl(struct ra *ra, enum glsl_shader type, goto done; } + int64_t cross_us = mp_time_us(); + hr = p->D3DCompile(hlsl, strlen(hlsl), NULL, NULL, NULL, "main", get_shader_target(ra, type), D3DCOMPILE_OPTIMIZATION_LEVEL3, 0, out, &errors); @@ -1213,6 +1230,15 @@ static bool compile_glsl(struct ra *ra, enum glsl_shader type, goto done; } + int64_t d3dcompile_us = mp_time_us(); + + MP_VERBOSE(ra, "Compiled a %s shader in %lldus\n", shader_type_name(type), + d3dcompile_us - start_us); + MP_VERBOSE(ra, "shaderc: %lldus, SPIRV-Cross: %lldus, D3DCompile: %lldus\n", + shaderc_us - start_us, + cross_us - shaderc_us, + d3dcompile_us - cross_us); + success = true; done:; int level = success ? MSGL_DEBUG : MSGL_ERR; -- cgit v1.2.3