mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Generate CTAB outside d3dbc_compile().
There is no way to store this information from the vsir_program alone, so we make d3dbc_compile() expect the CTAB blob.
This commit is contained in:
parent
130b3335cb
commit
dd8aa2ec91
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
@ -1683,8 +1683,7 @@ static void sm1_sort_externs(struct hlsl_ctx *ctx)
|
||||
list_move_tail(&ctx->extern_vars, &sorted);
|
||||
}
|
||||
|
||||
static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
|
||||
struct hlsl_ir_function_decl *entry_func)
|
||||
void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer)
|
||||
{
|
||||
size_t ctab_offset, ctab_start, ctab_end, vars_start, size_offset, creator_offset, offset;
|
||||
unsigned int uniform_count = 0;
|
||||
@ -2784,7 +2783,7 @@ static void write_sm1_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *
|
||||
* 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,
|
||||
const struct vkd3d_shader_compile_info *compile_info, const struct vkd3d_shader_code *ctab,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context,
|
||||
struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
|
||||
{
|
||||
@ -2792,7 +2791,7 @@ int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
|
||||
put_u32(&buffer, sm1_version(ctx->profile->type, ctx->profile->major_version, ctx->profile->minor_version));
|
||||
|
||||
write_sm1_uniforms(ctx, &buffer, entry_func);
|
||||
bytecode_put_bytes(&buffer, ctab->code, ctab->size);
|
||||
|
||||
write_sm1_constant_defs(ctx, &buffer);
|
||||
write_sm1_semantic_dcls(ctx, &buffer);
|
||||
|
@ -1473,8 +1473,9 @@ bool hlsl_sm1_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_sem
|
||||
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);
|
||||
|
||||
void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer);
|
||||
int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
const struct vkd3d_shader_compile_info *compile_info,
|
||||
const struct vkd3d_shader_compile_info *compile_info, const struct vkd3d_shader_code *ctab,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context,
|
||||
struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func);
|
||||
|
||||
|
@ -5523,12 +5523,13 @@ void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
* 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)
|
||||
uint64_t config_flags, struct vsir_program *program, struct vkd3d_shader_code *ctab)
|
||||
{
|
||||
struct vkd3d_shader_version version = {0};
|
||||
struct vkd3d_bytecode_buffer buffer = {0};
|
||||
|
||||
version.major = ctx->profile->major_version;
|
||||
version.minor = ctx->profile->minor_version;
|
||||
@ -5538,6 +5539,16 @@ static void sm1_generate_vsir(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
|
||||
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
write_sm1_uniforms(ctx, &buffer);
|
||||
if (buffer.status)
|
||||
{
|
||||
vkd3d_free(buffer.data);
|
||||
ctx->result = buffer.status;
|
||||
return;
|
||||
}
|
||||
ctab->code = buffer.data;
|
||||
ctab->size = buffer.size;
|
||||
}
|
||||
|
||||
int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func,
|
||||
@ -5724,18 +5735,21 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
|
||||
case VKD3D_SHADER_TARGET_D3D_BYTECODE:
|
||||
{
|
||||
uint32_t config_flags = vkd3d_shader_init_config_flags();
|
||||
struct vkd3d_shader_code ctab = {0};
|
||||
struct vsir_program program;
|
||||
int result;
|
||||
|
||||
sm1_generate_vsir(ctx, entry_func, config_flags, &program);
|
||||
sm1_generate_vsir(ctx, entry_func, config_flags, &program, &ctab);
|
||||
if (ctx->result)
|
||||
{
|
||||
vsir_program_cleanup(&program);
|
||||
vkd3d_shader_free_shader_code(&ctab);
|
||||
return ctx->result;
|
||||
}
|
||||
|
||||
result = d3dbc_compile(&program, config_flags, NULL, out, ctx->message_context, ctx, entry_func);
|
||||
result = d3dbc_compile(&program, config_flags, NULL, &ctab, out, ctx->message_context, ctx, entry_func);
|
||||
vsir_program_cleanup(&program);
|
||||
vkd3d_shader_free_shader_code(&ctab);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user