[PATCH v2 0/2] MR1340: d3dcompiler: Print message output with ERR().
Currently it's not obvious when the HLSL compiler fails, either due to a missing feature or incorrectly coded error check, which can unnecessarily complicate debugging. It's legal for well-behaved programs to try to compile invalid shaders, but that should be a rare enough case that it's worth printing it to Wine debug output regardless. -- v2: d3dcompiler: Print message output with ERR() in D3DPreprocess(). d3dcompiler: Print message output with ERR() in D3DCompile2(). https://gitlab.winehq.org/wine/wine/-/merge_requests/1340
From: Zebediah Figura <zfigura(a)codeweavers.com> --- dlls/d3dcompiler_43/compiler.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index bb9b7ce54eb..ef7bde9aa7f 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -173,6 +173,23 @@ static void close_include(const struct vkd3d_shader_code *code, void *context) ID3DInclude_Close(iface, code->code); } +static const char *get_line(const char **ptr) +{ + const char *p, *q; + + p = *ptr; + if (!(q = strstr(p, "\n"))) + { + if (!*p) + return NULL; + *ptr += strlen(p); + return p; + } + *ptr = q + 1; + + return p; +} + static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader_blob, ID3DBlob **messages_blob) @@ -486,8 +503,25 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen } ret = vkd3d_shader_compile(&compile_info, &byte_code, &messages); + + if (ret) + ERR("Failed to compile shader, vkd3d result %d.\n", ret); + if (messages) { + if (*messages && ERR_ON(d3dcompiler)) + { + const char *ptr = messages; + const char *line; + + ERR("Shader log:\n"); + while ((line = get_line(&ptr))) + { + ERR(" %.*s", (int)(ptr - line), line); + } + ERR("\n"); + } + if (messages_blob) { size_t size = strlen(messages); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1340
From: Zebediah Figura <zfigura(a)codeweavers.com> --- dlls/d3dcompiler_43/compiler.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index ef7bde9aa7f..174fbc98280 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -235,8 +235,25 @@ static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char preprocess_info.include_context = include; ret = vkd3d_shader_preprocess(&compile_info, &byte_code, &messages); + + if (ret) + ERR("Failed to preprocess shader, vkd3d result %d.\n", ret); + if (messages) { + if (*messages && ERR_ON(d3dcompiler)) + { + const char *ptr = messages; + const char *line; + + ERR("Shader log:\n"); + while ((line = get_line(&ptr))) + { + ERR(" %.*s", (int)(ptr - line), line); + } + ERR("\n"); + } + if (messages_blob) { size_t size = strlen(messages); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1340
This merge request was approved by Matteo Bruni. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1340
participants (3)
-
Matteo Bruni (@Mystral) -
Zebediah Figura -
Zebediah Figura (@zfigura)