mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Split hlsl_sm4_write().
Similarly to the already done split from HLSL IR -> d3dbc to HLSL IR -> vsir -> d3bc we now start splitting the HLSL IR -> tpf translation into HLSL IR -> vsir -> tpf So hlsl_sm4_write is split into two functions, sm4_generate_vsir() and tpf_compile(). This translation should be completed once tpf_compile() no longer needs the hlsl_ctx and entry_func parameters.
This commit is contained in:
parent
3601397703
commit
5b21cc67f1
Notes:
Henri Verbeet
2024-10-16 21:46:52 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1152
@ -1633,7 +1633,10 @@ bool sysval_semantic_from_hlsl(enum vkd3d_shader_sysval_semantic *semantic,
|
||||
struct hlsl_ctx *ctx, const struct hlsl_semantic *hlsl_semantic, bool output);
|
||||
bool hlsl_sm4_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic,
|
||||
bool output, enum vkd3d_shader_register_type *type, bool *has_idx);
|
||||
int hlsl_sm4_write(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func, struct vkd3d_shader_code *out);
|
||||
|
||||
int tpf_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context,
|
||||
struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func);
|
||||
|
||||
struct hlsl_ir_function_decl *hlsl_compile_internal_function(struct hlsl_ctx *ctx, const char *name, const char *hlsl);
|
||||
|
||||
|
@ -7282,9 +7282,6 @@ static void sm1_generate_vsir_block(struct hlsl_ctx *ctx, struct hlsl_block *blo
|
||||
}
|
||||
}
|
||||
|
||||
/* OBJECTIVE: Translate all the information from ctx and entry_func to the
|
||||
* vsir_program and ctab blob, so they 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_code *ctab)
|
||||
{
|
||||
@ -7321,6 +7318,25 @@ static void sm1_generate_vsir(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
|
||||
sm1_generate_vsir_block(ctx, &entry_func->body, program);
|
||||
}
|
||||
|
||||
/* OBJECTIVE: Translate all the information from ctx and entry_func to the
|
||||
* vsir_program, so it can be used as input to tpf_compile() without relying
|
||||
* on ctx and entry_func. */
|
||||
static void sm4_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, NULL, &version, 0, VSIR_CF_STRUCTURED))
|
||||
{
|
||||
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static struct hlsl_ir_jump *loop_unrolling_find_jump(struct hlsl_block *block, struct hlsl_ir_node *stop_point,
|
||||
struct hlsl_block **found_block)
|
||||
{
|
||||
@ -7850,7 +7866,22 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
|
||||
}
|
||||
|
||||
case VKD3D_SHADER_TARGET_DXBC_TPF:
|
||||
return hlsl_sm4_write(ctx, entry_func, out);
|
||||
{
|
||||
uint32_t config_flags = vkd3d_shader_init_config_flags();
|
||||
struct vsir_program program;
|
||||
int result;
|
||||
|
||||
sm4_generate_vsir(ctx, entry_func, config_flags, &program);
|
||||
if (ctx->result)
|
||||
{
|
||||
vsir_program_cleanup(&program);
|
||||
return ctx->result;
|
||||
}
|
||||
|
||||
result = tpf_compile(&program, config_flags, out, ctx->message_context, ctx, entry_func);
|
||||
vsir_program_cleanup(&program);
|
||||
return result;
|
||||
}
|
||||
|
||||
default:
|
||||
ERR("Unsupported shader target type %#x.\n", target_type);
|
||||
|
@ -1405,6 +1405,7 @@ struct sm4_stat
|
||||
|
||||
struct tpf_writer
|
||||
{
|
||||
/* OBJECTIVE: We want to get rid of this HLSL IR specific field. */
|
||||
struct hlsl_ctx *ctx;
|
||||
struct vkd3d_bytecode_buffer *buffer;
|
||||
struct vkd3d_sm4_lookup_tables lookup;
|
||||
@ -6564,7 +6565,12 @@ static void write_sm4_stat(struct hlsl_ctx *ctx, const struct sm4_stat *stat, st
|
||||
add_section(ctx, dxbc, TAG_STAT, &buffer);
|
||||
}
|
||||
|
||||
int hlsl_sm4_write(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func, struct vkd3d_shader_code *out)
|
||||
/* OBJECTIVE: Stop relying on ctx and entry_func on this function, receiving
|
||||
* data from the other parameters instead, so they can be removed from the
|
||||
* arguments and this function can be independent of HLSL structs. */
|
||||
int tpf_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context,
|
||||
struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
|
||||
{
|
||||
struct sm4_stat stat = {0};
|
||||
struct dxbc_writer dxbc;
|
||||
|
Loading…
Reference in New Issue
Block a user