vkd3d-shader: Remove the bytecode fields from vkd3d_shader_desc.

This commit is contained in:
Giovanni Mascellani 2024-03-01 14:25:30 +01:00 committed by Alexandre Julliard
parent 204c8afb9c
commit 1690b0b554
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
4 changed files with 4 additions and 21 deletions

View File

@ -1236,7 +1236,6 @@ static enum vkd3d_result shader_sm1_init(struct vkd3d_shader_sm1_parser *sm1,
const struct vkd3d_shader_location location = {.source_name = compile_info->source_name}; const struct vkd3d_shader_location location = {.source_name = compile_info->source_name};
const uint32_t *code = compile_info->source.code; const uint32_t *code = compile_info->source.code;
size_t code_size = compile_info->source.size; size_t code_size = compile_info->source.size;
struct vkd3d_shader_desc *shader_desc;
struct vkd3d_shader_version version; struct vkd3d_shader_version version;
uint16_t shader_type; uint16_t shader_type;
size_t token_count; size_t token_count;
@ -1289,9 +1288,6 @@ static enum vkd3d_result shader_sm1_init(struct vkd3d_shader_sm1_parser *sm1,
if (!vkd3d_shader_parser_init(&sm1->p, message_context, compile_info->source_name, &version, &shader_sm1_parser_ops, if (!vkd3d_shader_parser_init(&sm1->p, message_context, compile_info->source_name, &version, &shader_sm1_parser_ops,
code_size != ~(size_t)0 ? token_count / 4u + 4 : 16)) code_size != ~(size_t)0 ? token_count / 4u + 4 : 16))
return VKD3D_ERROR_OUT_OF_MEMORY; return VKD3D_ERROR_OUT_OF_MEMORY;
shader_desc = &sm1->p.shader_desc;
shader_desc->byte_code = code;
shader_desc->byte_code_size = code_size;
sm1->ptr = sm1->start; sm1->ptr = sm1->start;
return VKD3D_OK; return VKD3D_OK;

View File

@ -8431,7 +8431,6 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const char *sou
int vkd3d_shader_sm6_parser_create(const struct vkd3d_shader_compile_info *compile_info, 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) 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}; struct dxbc_shader_desc dxbc_desc = {0};
uint32_t *byte_code = NULL; uint32_t *byte_code = NULL;
struct sm6_parser *sm6; struct sm6_parser *sm6;
@ -8454,15 +8453,11 @@ int vkd3d_shader_sm6_parser_create(const struct vkd3d_shader_compile_info *compi
return ret; return ret;
} }
shader_desc = &sm6->p.shader_desc; if (((uintptr_t)dxbc_desc.byte_code & (VKD3D_DXBC_CHUNK_ALIGNMENT - 1)))
shader_desc->byte_code = dxbc_desc.byte_code;
shader_desc->byte_code_size = dxbc_desc.byte_code_size;
if (((uintptr_t)shader_desc->byte_code & (VKD3D_DXBC_CHUNK_ALIGNMENT - 1)))
{ {
/* LLVM bitcode should be 32-bit aligned, but before dxc v1.7.2207 this was not always the case in the DXBC /* LLVM bitcode should be 32-bit aligned, but before dxc v1.7.2207 this was not always the case in the DXBC
* container due to missing padding after signature names. Get an aligned copy to prevent unaligned access. */ * container due to missing padding after signature names. Get an aligned copy to prevent unaligned access. */
if (!(byte_code = vkd3d_malloc(align(shader_desc->byte_code_size, VKD3D_DXBC_CHUNK_ALIGNMENT)))) if (!(byte_code = vkd3d_malloc(align(dxbc_desc.byte_code_size, VKD3D_DXBC_CHUNK_ALIGNMENT))))
{ {
ERR("Failed to allocate aligned chunk.\n"); ERR("Failed to allocate aligned chunk.\n");
free_dxbc_shader_desc(&dxbc_desc); free_dxbc_shader_desc(&dxbc_desc);
@ -8470,7 +8465,7 @@ int vkd3d_shader_sm6_parser_create(const struct vkd3d_shader_compile_info *compi
return VKD3D_ERROR_OUT_OF_MEMORY; return VKD3D_ERROR_OUT_OF_MEMORY;
} }
memcpy(byte_code, shader_desc->byte_code, shader_desc->byte_code_size); memcpy(byte_code, dxbc_desc.byte_code, dxbc_desc.byte_code_size);
dxbc_desc.byte_code = byte_code; dxbc_desc.byte_code = byte_code;
} }

View File

@ -2647,7 +2647,6 @@ int vkd3d_shader_sm4_parser_create(const struct vkd3d_shader_compile_info *compi
struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_parser **parser) struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_parser **parser)
{ {
struct vkd3d_shader_instruction_array *instructions; struct vkd3d_shader_instruction_array *instructions;
struct vkd3d_shader_desc *shader_desc;
struct vkd3d_shader_instruction *ins; struct vkd3d_shader_instruction *ins;
struct vkd3d_shader_sm4_parser *sm4; struct vkd3d_shader_sm4_parser *sm4;
struct dxbc_shader_desc dxbc_desc = {0}; struct dxbc_shader_desc dxbc_desc = {0};
@ -2668,11 +2667,7 @@ int vkd3d_shader_sm4_parser_create(const struct vkd3d_shader_compile_info *compi
return ret; return ret;
} }
shader_desc = &sm4->p.shader_desc; if (!shader_sm4_init(sm4, dxbc_desc.byte_code, dxbc_desc.byte_code_size,
shader_desc->byte_code = dxbc_desc.byte_code;
shader_desc->byte_code_size = dxbc_desc.byte_code_size;
if (!shader_sm4_init(sm4, shader_desc->byte_code, shader_desc->byte_code_size,
compile_info->source_name, message_context)) compile_info->source_name, message_context))
{ {
WARN("Failed to initialise shader parser.\n"); WARN("Failed to initialise shader parser.\n");

View File

@ -1040,9 +1040,6 @@ struct dxbc_shader_desc
struct vkd3d_shader_desc struct vkd3d_shader_desc
{ {
const uint32_t *byte_code;
size_t byte_code_size;
struct struct
{ {
uint32_t used, external; uint32_t used, external;