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.