Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- libs/vkd3d-shader/trace.c | 30 ++++++++++++++---------- libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index d7495ee..b2512ac 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -1557,21 +1557,13 @@ static void shader_dump_instruction(struct vkd3d_string_buffer *buffer, shader_addline(buffer, "\n"); }
-void vkd3d_shader_trace(void *data) +void vkd3d_shader_dump_to_buffer(void *data, struct vkd3d_string_buffer *buffer) { struct vkd3d_shader_version shader_version; - struct vkd3d_string_buffer buffer; - const char *p, *q; const DWORD *ptr;
- if (!vkd3d_string_buffer_init(&buffer)) - { - ERR("Failed to initialize string buffer.\n"); - return; - } - shader_sm4_read_header(data, &ptr, &shader_version); - shader_addline(&buffer, "%s_%u_%u\n", + shader_addline(buffer, "%s_%u_%u\n", shader_get_type_prefix(shader_version.type), shader_version.major, shader_version.minor);
while (!shader_sm4_is_end(data, &ptr)) @@ -1582,13 +1574,27 @@ void vkd3d_shader_trace(void *data) if (ins.handler_idx == VKD3DSIH_INVALID) { WARN("Skipping unrecognized instruction.\n"); - shader_addline(&buffer, "<unrecognized instruction>\n"); + shader_addline(buffer, "<unrecognized instruction>\n"); continue; }
- shader_dump_instruction(&buffer, &ins, &shader_version); + shader_dump_instruction(buffer, &ins, &shader_version); + } +} + +void vkd3d_shader_trace(void *data) +{ + struct vkd3d_string_buffer buffer; + const char *p, *q; + + if (!vkd3d_string_buffer_init(&buffer)) + { + ERR("Failed to initialize string buffer.\n"); + return; }
+ vkd3d_shader_dump_to_buffer(data, &buffer); + for (p = buffer.buffer; *p; p = q) { if (!(q = strstr(p, "\n"))) diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 00b2441..9ed8be2 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -830,6 +830,7 @@ struct vkd3d_string_buffer unsigned int content_size; };
+void vkd3d_shader_dump_to_buffer(void *data, struct vkd3d_string_buffer *buffer) DECLSPEC_HIDDEN; void vkd3d_string_buffer_cleanup(struct vkd3d_string_buffer *buffer) DECLSPEC_HIDDEN; bool vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer) DECLSPEC_HIDDEN; int vkd3d_string_buffer_vprintf(struct vkd3d_string_buffer *buffer, const char *format, va_list args) DECLSPEC_HIDDEN;
Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- include/vkd3d_shader.h | 1 + libs/vkd3d-shader/vkd3d_shader_main.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 3efd355..0eead7c 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -466,6 +466,7 @@ enum vkd3d_shader_target_type */ VKD3D_SHADER_TARGET_SPIRV_BINARY, VKD3D_SHADER_TARGET_SPIRV_TEXT, + VKD3D_SHADER_TARGET_D3D_ASM,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TARGET_TYPE), }; diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 16d895f..d5e72b3 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -338,6 +338,25 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
vkd3d_shader_dump_shader(parser.shader_version.type, &compile_info->source);
+ if (compile_info->target_type == VKD3D_SHADER_TARGET_D3D_ASM) + { + struct vkd3d_string_buffer buffer; + + if (!vkd3d_string_buffer_init(&buffer)) + { + ERR("Failed to initialize string buffer.\n"); + ret = VKD3D_ERROR; + } + else + { + vkd3d_shader_dump_to_buffer(parser.data, &buffer); + out->code = buffer.buffer; + out->size = buffer.content_size; + vkd3d_shader_parser_destroy(&parser); + } + goto done; + } + if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser.shader_version, &parser.shader_desc, compile_info, &scan_descriptor_info, &message_context))) { @@ -1074,6 +1093,7 @@ const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types( #ifdef HAVE_SPIRV_TOOLS VKD3D_SHADER_TARGET_SPIRV_TEXT, #endif + VKD3D_SHADER_TARGET_D3D_ASM, };
TRACE("source_type %#x, count %p.\n", source_type, count);
Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- programs/vkd3d-compiler/main.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index 5f4f9db..fdf3faf 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -72,6 +72,9 @@ target_type_info[] = {VKD3D_SHADER_TARGET_SPIRV_TEXT, "spirv-text", "A SPIR-V shader in text form.\n", false}, + {VKD3D_SHADER_TARGET_D3D_ASM, + "d3d-asm", "A shader in Direct3D assembly form.\n", + false}, };
static bool read_shader(struct vkd3d_shader_code *shader, FILE *f)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=79183
Your paranoid android.
=== debiant (build log) ===
Task: Patch failed to apply
=== debiant (build log) ===
Task: Patch failed to apply
On Wed, 23 Sep 2020 at 11:23, Isabella Bosia ibosia@codeweavers.com wrote:
-void vkd3d_shader_trace(void *data) +void vkd3d_shader_dump_to_buffer(void *data, struct vkd3d_string_buffer *buffer) { struct vkd3d_shader_version shader_version;
struct vkd3d_string_buffer buffer;
const char *p, *q; const DWORD *ptr;
if (!vkd3d_string_buffer_init(&buffer))
{
ERR("Failed to initialize string buffer.\n");
return;
}
shader_sm4_read_header(data, &ptr, &shader_version);
shader_addline(&buffer, "%s_%u_%u\n",
shader_addline(buffer, "%s_%u_%u\n", shader_get_type_prefix(shader_version.type), shader_version.major, shader_version.minor);
while (!shader_sm4_is_end(data, &ptr))
@@ -1582,13 +1574,27 @@ void vkd3d_shader_trace(void *data) if (ins.handler_idx == VKD3DSIH_INVALID) { WARN("Skipping unrecognized instruction.\n");
shader_addline(&buffer, "<unrecognized instruction>\n");
shader_addline(buffer, "<unrecognized instruction>\n"); continue; }
shader_dump_instruction(&buffer, &ins, &shader_version);
shader_dump_instruction(buffer, &ins, &shader_version);
- }
+}
I would prefer the helper to look like this:
int vkd3d_dxbc_binary_to_text(void *data, struct vkd3d_shader_code *out) { ... }
I.e., outputting to a vkd3d_shader_code structure, analogous to vkd3d_spirv_binary_to_text(). That would also avoid the vkd3d_string_buffer_init() call in the second patch in this series.