mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/dxbc: Decouple vkd3d_shader_desc from DXBC parsing.
This commit is contained in:
parent
5204b92fa0
commit
56dc0c9842
Notes:
Alexandre Julliard
2024-03-11 23:06:10 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/680
@ -488,7 +488,7 @@ int shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
|
||||
static int shdr_handler(const struct vkd3d_shader_dxbc_section_desc *section,
|
||||
struct vkd3d_shader_message_context *message_context, void *context)
|
||||
{
|
||||
struct vkd3d_shader_desc *desc = context;
|
||||
struct dxbc_shader_desc *desc = context;
|
||||
int ret;
|
||||
|
||||
switch (section->tag)
|
||||
@ -553,6 +553,13 @@ static int shdr_handler(const struct vkd3d_shader_dxbc_section_desc *section,
|
||||
return VKD3D_OK;
|
||||
}
|
||||
|
||||
void free_dxbc_shader_desc(struct dxbc_shader_desc *desc)
|
||||
{
|
||||
shader_signature_cleanup(&desc->input_signature);
|
||||
shader_signature_cleanup(&desc->output_signature);
|
||||
shader_signature_cleanup(&desc->patch_constant_signature);
|
||||
}
|
||||
|
||||
void free_shader_desc(struct vkd3d_shader_desc *desc)
|
||||
{
|
||||
shader_signature_cleanup(&desc->input_signature);
|
||||
@ -561,7 +568,7 @@ void free_shader_desc(struct vkd3d_shader_desc *desc)
|
||||
}
|
||||
|
||||
int shader_extract_from_dxbc(const struct vkd3d_shader_code *dxbc,
|
||||
struct vkd3d_shader_message_context *message_context, const char *source_name, struct vkd3d_shader_desc *desc)
|
||||
struct vkd3d_shader_message_context *message_context, const char *source_name, struct dxbc_shader_desc *desc)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -572,7 +579,7 @@ int shader_extract_from_dxbc(const struct vkd3d_shader_code *dxbc,
|
||||
if (ret < 0)
|
||||
{
|
||||
WARN("Failed to parse shader, vkd3d result %d.\n", ret);
|
||||
free_shader_desc(desc);
|
||||
free_dxbc_shader_desc(desc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -8427,6 +8427,7 @@ int vkd3d_shader_sm6_parser_create(const struct vkd3d_shader_compile_info *compi
|
||||
struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_parser **parser)
|
||||
{
|
||||
struct vkd3d_shader_desc *shader_desc;
|
||||
struct dxbc_shader_desc dxbc_desc = {0};
|
||||
uint32_t *byte_code = NULL;
|
||||
struct sm6_parser *sm6;
|
||||
int ret;
|
||||
@ -8439,18 +8440,23 @@ int vkd3d_shader_sm6_parser_create(const struct vkd3d_shader_compile_info *compi
|
||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
shader_desc = &sm6->p.shader_desc;
|
||||
shader_desc->is_dxil = true;
|
||||
dxbc_desc.is_dxil = true;
|
||||
if ((ret = shader_extract_from_dxbc(&compile_info->source, message_context, compile_info->source_name,
|
||||
shader_desc)) < 0)
|
||||
&dxbc_desc)) < 0)
|
||||
{
|
||||
WARN("Failed to extract shader, vkd3d result %d.\n", ret);
|
||||
vkd3d_free(sm6);
|
||||
return ret;
|
||||
}
|
||||
|
||||
sm6->p.shader_desc = *shader_desc;
|
||||
shader_desc = &sm6->p.shader_desc;
|
||||
shader_desc->is_dxil = true;
|
||||
shader_desc->byte_code = dxbc_desc.byte_code;
|
||||
shader_desc->byte_code_size = dxbc_desc.byte_code_size;
|
||||
shader_desc->input_signature = dxbc_desc.input_signature;
|
||||
shader_desc->output_signature = dxbc_desc.output_signature;
|
||||
shader_desc->patch_constant_signature = dxbc_desc.patch_constant_signature;
|
||||
memset(&dxbc_desc, 0, sizeof(dxbc_desc));
|
||||
|
||||
if (((uintptr_t)shader_desc->byte_code & (VKD3D_DXBC_CHUNK_ALIGNMENT - 1)))
|
||||
{
|
||||
|
@ -2651,6 +2651,7 @@ int vkd3d_shader_sm4_parser_create(const struct vkd3d_shader_compile_info *compi
|
||||
struct vkd3d_shader_desc *shader_desc;
|
||||
struct vkd3d_shader_instruction *ins;
|
||||
struct vkd3d_shader_sm4_parser *sm4;
|
||||
struct dxbc_shader_desc dxbc_desc = {0};
|
||||
int ret;
|
||||
|
||||
if (!(sm4 = vkd3d_calloc(1, sizeof(*sm4))))
|
||||
@ -2659,16 +2660,24 @@ int vkd3d_shader_sm4_parser_create(const struct vkd3d_shader_compile_info *compi
|
||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
shader_desc = &sm4->p.shader_desc;
|
||||
shader_desc->is_dxil = false;
|
||||
dxbc_desc.is_dxil = false;
|
||||
if ((ret = shader_extract_from_dxbc(&compile_info->source,
|
||||
message_context, compile_info->source_name, shader_desc)) < 0)
|
||||
message_context, compile_info->source_name, &dxbc_desc)) < 0)
|
||||
{
|
||||
WARN("Failed to extract shader, vkd3d result %d.\n", ret);
|
||||
vkd3d_free(sm4);
|
||||
return ret;
|
||||
}
|
||||
|
||||
shader_desc = &sm4->p.shader_desc;
|
||||
shader_desc->is_dxil = false;
|
||||
shader_desc->byte_code = dxbc_desc.byte_code;
|
||||
shader_desc->byte_code_size = dxbc_desc.byte_code_size;
|
||||
shader_desc->input_signature = dxbc_desc.input_signature;
|
||||
shader_desc->output_signature = dxbc_desc.output_signature;
|
||||
shader_desc->patch_constant_signature = dxbc_desc.patch_constant_signature;
|
||||
memset(&dxbc_desc, 0, sizeof(dxbc_desc));
|
||||
|
||||
if (!shader_sm4_init(sm4, shader_desc->byte_code, shader_desc->byte_code_size,
|
||||
compile_info->source_name, message_context))
|
||||
{
|
||||
|
@ -1028,6 +1028,16 @@ struct signature_element *vsir_signature_find_element_for_reg(const struct shade
|
||||
unsigned int reg_idx, unsigned int write_mask);
|
||||
void shader_signature_cleanup(struct shader_signature *signature);
|
||||
|
||||
struct dxbc_shader_desc
|
||||
{
|
||||
const uint32_t *byte_code;
|
||||
size_t byte_code_size;
|
||||
bool is_dxil;
|
||||
struct shader_signature input_signature;
|
||||
struct shader_signature output_signature;
|
||||
struct shader_signature patch_constant_signature;
|
||||
};
|
||||
|
||||
struct vkd3d_shader_desc
|
||||
{
|
||||
const uint32_t *byte_code;
|
||||
@ -1487,10 +1497,11 @@ int vkd3d_shader_sm4_parser_create(const struct vkd3d_shader_compile_info *compi
|
||||
int vkd3d_shader_sm6_parser_create(const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_parser **parser);
|
||||
|
||||
void free_dxbc_shader_desc(struct dxbc_shader_desc *desc);
|
||||
void free_shader_desc(struct vkd3d_shader_desc *desc);
|
||||
|
||||
int shader_extract_from_dxbc(const struct vkd3d_shader_code *dxbc,
|
||||
struct vkd3d_shader_message_context *message_context, const char *source_name, struct vkd3d_shader_desc *desc);
|
||||
struct vkd3d_shader_message_context *message_context, const char *source_name, struct dxbc_shader_desc *desc);
|
||||
int shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
|
||||
struct vkd3d_shader_message_context *message_context, struct shader_signature *signature);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user