mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader: Distinguish between resource exhaustion and invalid shaders when returning failure.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
committed by
Alexandre Julliard
parent
ba1cc670e6
commit
6493953516
@@ -39,7 +39,8 @@ void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
|
|||||||
vkd3d_shader_verror(ctx->message_context, &loc, error, fmt, args);
|
vkd3d_shader_verror(ctx->message_context, &loc, error, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
ctx->failed = true;
|
if (!ctx->result)
|
||||||
|
ctx->result = VKD3D_ERROR_INVALID_SHADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
|
void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
|
||||||
@@ -1648,10 +1649,10 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d
|
|||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.failed)
|
if (ctx.result)
|
||||||
{
|
{
|
||||||
hlsl_ctx_cleanup(&ctx);
|
hlsl_ctx_cleanup(&ctx);
|
||||||
return VKD3D_ERROR_INVALID_SHADER;
|
return ctx.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(entry_func = hlsl_get_func_decl(&ctx, entry_point)))
|
if (!(entry_func = hlsl_get_func_decl(&ctx, entry_point)))
|
||||||
|
@@ -428,7 +428,7 @@ struct hlsl_ctx
|
|||||||
struct vkd3d_shader_location location;
|
struct vkd3d_shader_location location;
|
||||||
struct vkd3d_shader_message_context *message_context;
|
struct vkd3d_shader_message_context *message_context;
|
||||||
struct vkd3d_string_buffer_cache string_buffers;
|
struct vkd3d_string_buffer_cache string_buffers;
|
||||||
bool failed;
|
int result;
|
||||||
|
|
||||||
void *scanner;
|
void *scanner;
|
||||||
|
|
||||||
@@ -544,7 +544,7 @@ static inline void *hlsl_alloc(struct hlsl_ctx *ctx, size_t size)
|
|||||||
void *ptr = vkd3d_calloc(1, size);
|
void *ptr = vkd3d_calloc(1, size);
|
||||||
|
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
ctx->failed = true;
|
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +553,7 @@ static inline char *hlsl_strdup(struct hlsl_ctx *ctx, const char *string)
|
|||||||
char *ptr = vkd3d_strdup(string);
|
char *ptr = vkd3d_strdup(string);
|
||||||
|
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
ctx->failed = true;
|
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,7 +563,7 @@ static inline bool hlsl_array_reserve(struct hlsl_ctx *ctx, void **elements,
|
|||||||
bool ret = vkd3d_array_reserve(elements, capacity, element_count, element_size);
|
bool ret = vkd3d_array_reserve(elements, capacity, element_count, element_size);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ctx->failed = true;
|
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,7 +572,7 @@ static inline struct vkd3d_string_buffer *hlsl_get_string_buffer(struct hlsl_ctx
|
|||||||
struct vkd3d_string_buffer *ret = vkd3d_string_buffer_get(&ctx->string_buffers);
|
struct vkd3d_string_buffer *ret = vkd3d_string_buffer_get(&ctx->string_buffers);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ctx->failed = true;
|
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1968,8 +1968,8 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun
|
|||||||
allocate_const_registers(ctx, entry_func);
|
allocate_const_registers(ctx, entry_func);
|
||||||
allocate_semantic_registers(ctx);
|
allocate_semantic_registers(ctx);
|
||||||
|
|
||||||
if (ctx->failed)
|
if (ctx->result)
|
||||||
return VKD3D_ERROR_INVALID_SHADER;
|
return ctx->result;
|
||||||
|
|
||||||
if (ctx->profile->major_version < 4)
|
if (ctx->profile->major_version < 4)
|
||||||
return write_sm1_shader(ctx, entry_func, out);
|
return write_sm1_shader(ctx, entry_func, out);
|
||||||
|
Reference in New Issue
Block a user