vkd3d-shader/d3dbc: Split hlsl_sm1_write().

The idea is to start splitting the

    HLSL IR -> d3dbc

translation into

    HLSL IR -> vsir -> d3dbc

So hlsl_sm1_write is split into two functions, sm1_generate_vsir()
which should handle the first part and d3dbc_compile() which should
handle the second part.

This translation should be completed once the hlsl_ctx and entry_func
are no longer used in d3dbc_compile().
This commit is contained in:
Francisco Casas
2024-05-17 18:30:59 -04:00
committed by Henri Verbeet
parent 6db2bc3eff
commit 130b3335cb
Notes: Henri Verbeet 2024-07-09 21:08:22 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/877
3 changed files with 47 additions and 3 deletions

View File

@@ -5522,6 +5522,24 @@ void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
} while (progress);
}
/* OBJECTIVE: Translate all the information from ctx and entry_func to the
* vsir_program, so it can be used as input to d3dbc_compile() without relying
* on ctx and entry_func. */
static void sm1_generate_vsir(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func,
uint64_t config_flags, struct vsir_program *program)
{
struct vkd3d_shader_version version = {0};
version.major = ctx->profile->major_version;
version.minor = ctx->profile->minor_version;
version.type = ctx->profile->type;
if (!vsir_program_init(program, &version, 0))
{
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
return;
}
}
int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func,
enum vkd3d_shader_target_type target_type, struct vkd3d_shader_code *out)
{
@@ -5704,7 +5722,22 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
switch (target_type)
{
case VKD3D_SHADER_TARGET_D3D_BYTECODE:
return hlsl_sm1_write(ctx, entry_func, out);
{
uint32_t config_flags = vkd3d_shader_init_config_flags();
struct vsir_program program;
int result;
sm1_generate_vsir(ctx, entry_func, config_flags, &program);
if (ctx->result)
{
vsir_program_cleanup(&program);
return ctx->result;
}
result = d3dbc_compile(&program, config_flags, NULL, out, ctx->message_context, ctx, entry_func);
vsir_program_cleanup(&program);
return result;
}
case VKD3D_SHADER_TARGET_DXBC_TPF:
return hlsl_sm4_write(ctx, entry_func, out);