mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/d3d-asm: Resolve SSA values when outputting SM<6 assembly.
In particular, since commit eaebef4265
we
may receive vsir generated from HLSL sources, which typically contains
SSA values.
This commit is contained in:
Notes:
Henri Verbeet
2025-08-13 16:27:46 +02:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1678
@@ -1961,7 +1961,7 @@ static void shader_print_descriptors(struct vkd3d_d3d_asm_compiler *compiler,
|
||||
}
|
||||
|
||||
enum vkd3d_result d3d_asm_compile(struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, enum vsir_asm_flags flags)
|
||||
struct vkd3d_shader_code *out, enum vsir_asm_flags flags, struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
const struct vkd3d_shader_version *shader_version = &program->shader_version;
|
||||
enum vkd3d_shader_compile_option_formatting_flags formatting;
|
||||
@@ -2029,6 +2029,14 @@ enum vkd3d_result d3d_asm_compile(struct vsir_program *program, const struct vkd
|
||||
if (formatting & VKD3D_SHADER_COMPILE_OPTION_FORMATTING_IO_SIGNATURES && shader_version->major >= 4)
|
||||
compiler.flags |= VSIR_ASM_FLAG_DUMP_SIGNATURES;
|
||||
|
||||
if (compiler.flags & VSIR_ASM_FLAG_ALLOCATE_TEMPS)
|
||||
{
|
||||
if ((result = vsir_allocate_temp_registers(program, message_context)) < 0)
|
||||
return result;
|
||||
if ((result = vsir_update_dcl_temps(program, message_context)))
|
||||
return result;
|
||||
}
|
||||
|
||||
buffer = &compiler.buffer;
|
||||
vkd3d_string_buffer_init(buffer);
|
||||
|
||||
@@ -2250,17 +2258,22 @@ void vsir_program_trace(struct vsir_program *program)
|
||||
{
|
||||
const unsigned int flags = VSIR_ASM_FLAG_DUMP_TYPES | VSIR_ASM_FLAG_DUMP_ALL_INDICES
|
||||
| VSIR_ASM_FLAG_DUMP_SIGNATURES | VSIR_ASM_FLAG_DUMP_DESCRIPTORS;
|
||||
struct vkd3d_shader_message_context message_context;
|
||||
struct vkd3d_shader_code code;
|
||||
const char *p, *q, *end;
|
||||
|
||||
vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_NONE);
|
||||
|
||||
trace_signature(&program->input_signature, "Input");
|
||||
trace_signature(&program->output_signature, "Output");
|
||||
trace_signature(&program->patch_constant_signature, "Patch-constant");
|
||||
trace_io_declarations(program);
|
||||
|
||||
if (d3d_asm_compile(program, NULL, &code, flags) != VKD3D_OK)
|
||||
if (d3d_asm_compile(program, NULL, &code, flags, &message_context) != VKD3D_OK)
|
||||
return;
|
||||
|
||||
vkd3d_shader_message_context_cleanup(&message_context);
|
||||
|
||||
end = (const char *)code.code + code.size;
|
||||
for (p = code.code; p < end; p = q)
|
||||
{
|
||||
|
@@ -1816,6 +1816,7 @@ static int vsir_program_compile(struct vsir_program *program, const struct vkd3d
|
||||
{
|
||||
struct vkd3d_shader_scan_combined_resource_sampler_info combined_sampler_info;
|
||||
struct vkd3d_shader_compile_info scan_info;
|
||||
enum vsir_asm_flags asm_flags;
|
||||
int ret;
|
||||
|
||||
scan_info = *compile_info;
|
||||
@@ -1825,7 +1826,11 @@ static int vsir_program_compile(struct vsir_program *program, const struct vkd3d
|
||||
case VKD3D_SHADER_TARGET_D3D_ASM:
|
||||
if ((ret = vsir_program_scan(program, &scan_info, message_context, true)) < 0)
|
||||
return ret;
|
||||
ret = d3d_asm_compile(program, compile_info, out, VSIR_ASM_FLAG_NONE);
|
||||
asm_flags = VSIR_ASM_FLAG_NONE;
|
||||
if (program->shader_version.major < 6 && compile_info->source_type != VKD3D_SHADER_SOURCE_DXBC_TPF
|
||||
&& compile_info->source_type != VKD3D_SHADER_SOURCE_D3D_BYTECODE)
|
||||
asm_flags |= VSIR_ASM_FLAG_ALLOCATE_TEMPS;
|
||||
ret = d3d_asm_compile(program, compile_info, out, asm_flags, message_context);
|
||||
break;
|
||||
|
||||
case VKD3D_SHADER_TARGET_D3D_BYTECODE:
|
||||
|
@@ -1685,11 +1685,12 @@ enum vsir_asm_flags
|
||||
VSIR_ASM_FLAG_DUMP_ALL_INDICES = 0x2,
|
||||
VSIR_ASM_FLAG_DUMP_SIGNATURES = 0x4,
|
||||
VSIR_ASM_FLAG_DUMP_DESCRIPTORS = 0x8,
|
||||
VSIR_ASM_FLAG_ALLOCATE_TEMPS = 0x10,
|
||||
};
|
||||
|
||||
enum vkd3d_result d3d_asm_compile(struct vsir_program *program,
|
||||
const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, enum vsir_asm_flags flags);
|
||||
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
|
||||
enum vsir_asm_flags flags, struct vkd3d_shader_message_context *message_context);
|
||||
void vkd3d_string_buffer_cleanup(struct vkd3d_string_buffer *buffer);
|
||||
struct vkd3d_string_buffer *vkd3d_string_buffer_get(struct vkd3d_string_buffer_cache *list);
|
||||
void vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer);
|
||||
|
Reference in New Issue
Block a user