mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
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:
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
@ -2779,7 +2779,14 @@ static void write_sm1_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *
|
||||
}
|
||||
}
|
||||
|
||||
int hlsl_sm1_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 it can be removed as an argument
|
||||
* and be declared in vkd3d_shader_private.h and used without relying on HLSL
|
||||
* IR structs. */
|
||||
int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context,
|
||||
struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
|
||||
{
|
||||
struct vkd3d_bytecode_buffer buffer = {0};
|
||||
|
||||
|
@ -1472,7 +1472,11 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type);
|
||||
bool hlsl_sm1_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic,
|
||||
bool output, enum vkd3d_shader_register_type *type, unsigned int *reg);
|
||||
bool hlsl_sm1_usage_from_semantic(const struct hlsl_semantic *semantic, D3DDECLUSAGE *usage, uint32_t *usage_idx);
|
||||
int hlsl_sm1_write(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func, struct vkd3d_shader_code *out);
|
||||
|
||||
int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context,
|
||||
struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func);
|
||||
|
||||
bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx,
|
||||
const struct hlsl_semantic *semantic, bool output, D3D_NAME *usage);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user