mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader: Use a separate allocation for the "semantic_name" field of shader signature elements.
For tpf shader this would previously be a pointer into the original shader code, and for d3dbc shaders we'd use static strings. Unfortunately the dxil parser creates shader signatures where these are pointers to metadata strings, and those go away when we call sm6_parser_cleanup(). We could conceivably store a flag in the shader signature to indicate whether shader_signature_cleanup()/vkd3d_shader_free_shader_signature() should free the "semantic_name" field. It'd be a little ugly, and seems unlikely to be worth it, but I'd be willing to be convinced.
This commit is contained in:
committed by
Alexandre Julliard
parent
105ef28273
commit
b5ac6ac636
Notes:
Alexandre Julliard
2024-05-23 23:23:55 +02:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/880
@@ -360,7 +360,7 @@ static int shader_parse_signature(const struct vkd3d_shader_dxbc_section_desc *s
|
||||
uint32_t count, header_size;
|
||||
struct signature_element *e;
|
||||
const char *ptr = data;
|
||||
unsigned int i;
|
||||
unsigned int i, j;
|
||||
|
||||
if (!require_space(0, 2, sizeof(uint32_t), section->data.size))
|
||||
{
|
||||
@@ -403,6 +403,7 @@ static int shader_parse_signature(const struct vkd3d_shader_dxbc_section_desc *s
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
size_t name_offset;
|
||||
const char *name;
|
||||
uint32_t mask;
|
||||
|
||||
e[i].sort_index = i;
|
||||
@@ -413,9 +414,14 @@ static int shader_parse_signature(const struct vkd3d_shader_dxbc_section_desc *s
|
||||
e[i].stream_index = 0;
|
||||
|
||||
name_offset = read_u32(&ptr);
|
||||
if (!(e[i].semantic_name = shader_get_string(data, section->data.size, name_offset)))
|
||||
if (!(name = shader_get_string(data, section->data.size, name_offset))
|
||||
|| !(e[i].semantic_name = vkd3d_strdup(name)))
|
||||
{
|
||||
WARN("Invalid name offset %#zx (data size %#zx).\n", name_offset, section->data.size);
|
||||
for (j = 0; j < i; ++j)
|
||||
{
|
||||
vkd3d_free((void *)e[j].semantic_name);
|
||||
}
|
||||
vkd3d_free(e);
|
||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
Reference in New Issue
Block a user