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:
Zebediah Figura 2021-05-21 00:32:23 -05:00 committed by Alexandre Julliard
parent ba1cc670e6
commit 6493953516
3 changed files with 11 additions and 10 deletions

View File

@ -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);
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,
@ -1648,10 +1649,10 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d
return VKD3D_ERROR_OUT_OF_MEMORY;
}
if (ctx.failed)
if (ctx.result)
{
hlsl_ctx_cleanup(&ctx);
return VKD3D_ERROR_INVALID_SHADER;
return ctx.result;
}
if (!(entry_func = hlsl_get_func_decl(&ctx, entry_point)))

View File

@ -428,7 +428,7 @@ struct hlsl_ctx
struct vkd3d_shader_location location;
struct vkd3d_shader_message_context *message_context;
struct vkd3d_string_buffer_cache string_buffers;
bool failed;
int result;
void *scanner;
@ -544,7 +544,7 @@ static inline void *hlsl_alloc(struct hlsl_ctx *ctx, size_t size)
void *ptr = vkd3d_calloc(1, size);
if (!ptr)
ctx->failed = true;
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
return ptr;
}
@ -553,7 +553,7 @@ static inline char *hlsl_strdup(struct hlsl_ctx *ctx, const char *string)
char *ptr = vkd3d_strdup(string);
if (!ptr)
ctx->failed = true;
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
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);
if (!ret)
ctx->failed = true;
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
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);
if (!ret)
ctx->failed = true;
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
return ret;
}

View File

@ -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_semantic_registers(ctx);
if (ctx->failed)
return VKD3D_ERROR_INVALID_SHADER;
if (ctx->result)
return ctx->result;
if (ctx->profile->major_version < 4)
return write_sm1_shader(ctx, entry_func, out);