mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader: Validate "compile_info" in vkd3d_shader_preprocess().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
committed by
Alexandre Julliard
parent
f4bbbb2975
commit
5065cb6c1f
@@ -252,7 +252,8 @@ static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser)
|
|||||||
free_shader_desc(&parser->shader_desc);
|
free_shader_desc(&parser->shader_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info)
|
static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info,
|
||||||
|
bool validate_target_type)
|
||||||
{
|
{
|
||||||
const enum vkd3d_shader_source_type *source_types;
|
const enum vkd3d_shader_source_type *source_types;
|
||||||
const enum vkd3d_shader_target_type *target_types;
|
const enum vkd3d_shader_target_type *target_types;
|
||||||
@@ -276,16 +277,19 @@ static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_
|
|||||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
target_types = vkd3d_shader_get_supported_target_types(compile_info->source_type, &count);
|
if (validate_target_type)
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
{
|
{
|
||||||
if (target_types[i] == compile_info->target_type)
|
target_types = vkd3d_shader_get_supported_target_types(compile_info->source_type, &count);
|
||||||
break;
|
for (i = 0; i < count; ++i)
|
||||||
}
|
{
|
||||||
if (i == count)
|
if (target_types[i] == compile_info->target_type)
|
||||||
{
|
break;
|
||||||
WARN("Invalid shader target type %#x.\n", compile_info->target_type);
|
}
|
||||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
if (i == count)
|
||||||
|
{
|
||||||
|
WARN("Invalid shader target type %#x.\n", compile_info->target_type);
|
||||||
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return VKD3D_OK;
|
return VKD3D_OK;
|
||||||
@@ -832,7 +836,7 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char
|
|||||||
if (messages)
|
if (messages)
|
||||||
*messages = NULL;
|
*messages = NULL;
|
||||||
|
|
||||||
if ((ret = vkd3d_shader_validate_compile_info(compile_info)) < 0)
|
if ((ret = vkd3d_shader_validate_compile_info(compile_info, true)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name);
|
vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name);
|
||||||
@@ -933,7 +937,7 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
|||||||
if (messages)
|
if (messages)
|
||||||
*messages = NULL;
|
*messages = NULL;
|
||||||
|
|
||||||
if ((ret = vkd3d_shader_validate_compile_info(compile_info)) < 0)
|
if ((ret = vkd3d_shader_validate_compile_info(compile_info, true)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name);
|
vkd3d_shader_message_context_init(&message_context, compile_info->log_level, compile_info->source_name);
|
||||||
@@ -1150,10 +1154,15 @@ const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types(
|
|||||||
int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info,
|
int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info,
|
||||||
struct vkd3d_shader_code *out, char **messages)
|
struct vkd3d_shader_code *out, char **messages)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
TRACE("compile_info %p, out %p, messages %p.\n", compile_info, out, messages);
|
TRACE("compile_info %p, out %p, messages %p.\n", compile_info, out, messages);
|
||||||
|
|
||||||
if (messages)
|
if (messages)
|
||||||
*messages = NULL;
|
*messages = NULL;
|
||||||
|
|
||||||
|
if ((ret = vkd3d_shader_validate_compile_info(compile_info, false)) < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
return VKD3D_ERROR_NOT_IMPLEMENTED;
|
return VKD3D_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user