mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/dxbc: Add flag to ignore the DXBC checksum.
This commit is contained in:
parent
23259263cf
commit
75bc68962d
Notes:
Alexandre Julliard
2024-03-11 23:05:11 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/582
@ -218,6 +218,20 @@ enum vkd3d_shader_compile_option_feature_flags
|
||||
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FEATURE_FLAGS),
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags for vkd3d_shader_parse_dxbc().
|
||||
*
|
||||
* \since 1.12
|
||||
*/
|
||||
enum vkd3d_shader_parse_dxbc_flags
|
||||
{
|
||||
/** Ignore the checksum and continue parsing even if it is
|
||||
* incorrect. */
|
||||
VKD3D_SHADER_PARSE_DXBC_IGNORE_CHECKSUM = 0x00000001,
|
||||
|
||||
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARSE_DXBC_FLAGS),
|
||||
};
|
||||
|
||||
enum vkd3d_shader_compile_option_name
|
||||
{
|
||||
/**
|
||||
@ -2385,9 +2399,8 @@ VKD3D_SHADER_API void vkd3d_shader_free_dxbc(struct vkd3d_shader_dxbc_desc *dxbc
|
||||
*
|
||||
* \param dxbc A vkd3d_shader_code structure containing the DXBC blob to parse.
|
||||
*
|
||||
* \param flags A set of flags modifying the behaviour of the function. No
|
||||
* flags are defined for this version of vkd3d-shader, and this parameter
|
||||
* should be set to 0.
|
||||
* \param flags A combination of zero or more elements of enum
|
||||
* vkd3d_shader_parse_dxbc_flags.
|
||||
*
|
||||
* \param desc A vkd3d_shader_dxbc_desc structure describing the contents of
|
||||
* the DXBC blob. Its vkd3d_shader_dxbc_section_desc structures will contain
|
||||
|
@ -150,7 +150,7 @@ static const char *shader_get_string(const char *data, size_t data_size, size_t
|
||||
}
|
||||
|
||||
static int parse_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_message_context *message_context,
|
||||
const char *source_name, struct vkd3d_shader_dxbc_desc *desc)
|
||||
const char *source_name, uint32_t flags, struct vkd3d_shader_dxbc_desc *desc)
|
||||
{
|
||||
const struct vkd3d_shader_location location = {.source_name = source_name};
|
||||
struct vkd3d_shader_dxbc_section_desc *sections, *section;
|
||||
@ -186,17 +186,20 @@ static int parse_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_
|
||||
checksum[1] = read_u32(&ptr);
|
||||
checksum[2] = read_u32(&ptr);
|
||||
checksum[3] = read_u32(&ptr);
|
||||
vkd3d_compute_dxbc_checksum(data, data_size, calculated_checksum);
|
||||
if (memcmp(checksum, calculated_checksum, sizeof(checksum)))
|
||||
if (!(flags & VKD3D_SHADER_PARSE_DXBC_IGNORE_CHECKSUM))
|
||||
{
|
||||
WARN("Checksum {0x%08x, 0x%08x, 0x%08x, 0x%08x} does not match "
|
||||
"calculated checksum {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n",
|
||||
checksum[0], checksum[1], checksum[2], checksum[3],
|
||||
calculated_checksum[0], calculated_checksum[1],
|
||||
calculated_checksum[2], calculated_checksum[3]);
|
||||
vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXBC_INVALID_CHECKSUM,
|
||||
"Invalid DXBC checksum.");
|
||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||
vkd3d_compute_dxbc_checksum(data, data_size, calculated_checksum);
|
||||
if (memcmp(checksum, calculated_checksum, sizeof(checksum)))
|
||||
{
|
||||
WARN("Checksum {0x%08x, 0x%08x, 0x%08x, 0x%08x} does not match "
|
||||
"calculated checksum {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n",
|
||||
checksum[0], checksum[1], checksum[2], checksum[3],
|
||||
calculated_checksum[0], calculated_checksum[1],
|
||||
calculated_checksum[2], calculated_checksum[3]);
|
||||
vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_DXBC_INVALID_CHECKSUM,
|
||||
"Invalid DXBC checksum.");
|
||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
}
|
||||
|
||||
version = read_u32(&ptr);
|
||||
@ -287,7 +290,7 @@ static int for_each_dxbc_section(const struct vkd3d_shader_code *dxbc,
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
if ((ret = parse_dxbc(dxbc, message_context, source_name, &desc)) < 0)
|
||||
if ((ret = parse_dxbc(dxbc, message_context, source_name, 0, &desc)) < 0)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < desc.section_count; ++i)
|
||||
@ -313,7 +316,7 @@ int vkd3d_shader_parse_dxbc(const struct vkd3d_shader_code *dxbc,
|
||||
*messages = NULL;
|
||||
vkd3d_shader_message_context_init(&message_context, VKD3D_SHADER_LOG_INFO);
|
||||
|
||||
ret = parse_dxbc(dxbc, &message_context, NULL, desc);
|
||||
ret = parse_dxbc(dxbc, &message_context, NULL, flags, desc);
|
||||
|
||||
vkd3d_shader_message_context_trace_messages(&message_context);
|
||||
if (!vkd3d_shader_message_context_copy_messages(&message_context, messages) && ret >= 0)
|
||||
|
Loading…
Reference in New Issue
Block a user