mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Introduce enum hlsl_compile_type.
This commit is contained in:
parent
4c03cda3c7
commit
02b249d5e7
Notes:
Henri Verbeet
2024-09-14 16:53:12 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1057
@ -1847,30 +1847,36 @@ struct hlsl_ir_node *hlsl_new_swizzle(struct hlsl_ctx *ctx, uint32_t s, unsigned
|
||||
return &swizzle->node;
|
||||
}
|
||||
|
||||
struct hlsl_ir_node *hlsl_new_compile(struct hlsl_ctx *ctx, const char *profile_name,
|
||||
struct hlsl_ir_node **args, unsigned int args_count, struct hlsl_block *args_instrs,
|
||||
const struct vkd3d_shader_location *loc)
|
||||
struct hlsl_ir_node *hlsl_new_compile(struct hlsl_ctx *ctx, enum hlsl_compile_type compile_type,
|
||||
const char *profile_name, struct hlsl_ir_node **args, unsigned int args_count,
|
||||
struct hlsl_block *args_instrs, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
const struct hlsl_profile_info *profile_info = NULL;
|
||||
struct hlsl_ir_compile *compile;
|
||||
struct hlsl_type *type = NULL;
|
||||
unsigned int i;
|
||||
|
||||
if (!(profile_info = hlsl_get_target_info(profile_name)))
|
||||
switch (compile_type)
|
||||
{
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_PROFILE, "Unknown profile \"%s\".", profile_name);
|
||||
return NULL;
|
||||
}
|
||||
case HLSL_COMPILE_TYPE_COMPILE:
|
||||
if (!(profile_info = hlsl_get_target_info(profile_name)))
|
||||
{
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_PROFILE, "Unknown profile \"%s\".", profile_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (profile_info->type == VKD3D_SHADER_TYPE_PIXEL)
|
||||
type = hlsl_get_type(ctx->cur_scope, "PixelShader", true, true);
|
||||
else if (profile_info->type == VKD3D_SHADER_TYPE_VERTEX)
|
||||
type = hlsl_get_type(ctx->cur_scope, "VertexShader", true, true);
|
||||
if (profile_info->type == VKD3D_SHADER_TYPE_PIXEL)
|
||||
type = hlsl_get_type(ctx->cur_scope, "PixelShader", true, true);
|
||||
else if (profile_info->type == VKD3D_SHADER_TYPE_VERTEX)
|
||||
type = hlsl_get_type(ctx->cur_scope, "VertexShader", true, true);
|
||||
|
||||
if (!type)
|
||||
{
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_PROFILE, "Invalid profile \"%s\".", profile_name);
|
||||
return NULL;
|
||||
if (!type)
|
||||
{
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_PROFILE, "Invalid profile \"%s\".", profile_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(compile = hlsl_alloc(ctx, sizeof(*compile))))
|
||||
@ -1878,6 +1884,7 @@ struct hlsl_ir_node *hlsl_new_compile(struct hlsl_ctx *ctx, const char *profile_
|
||||
|
||||
init_node(&compile->node, HLSL_IR_COMPILE, type, loc);
|
||||
|
||||
compile->compile_type = compile_type;
|
||||
compile->profile = profile_info;
|
||||
|
||||
hlsl_block_init(&compile->instrs);
|
||||
@ -2271,7 +2278,8 @@ static struct hlsl_ir_node *clone_compile(struct hlsl_ctx *ctx,
|
||||
if (compile->profile)
|
||||
profile_name = compile->profile->name;
|
||||
|
||||
if (!(node = hlsl_new_compile(ctx, profile_name, args, compile->args_count, &block, &compile->node.loc)))
|
||||
if (!(node = hlsl_new_compile(ctx, compile->compile_type, profile_name,
|
||||
args, compile->args_count, &block, &compile->node.loc)))
|
||||
{
|
||||
hlsl_block_cleanup(&block);
|
||||
vkd3d_free(args);
|
||||
@ -3300,7 +3308,12 @@ static void dump_ir_compile(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *bu
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
vkd3d_string_buffer_printf(buffer, "compile %s {\n", compile->profile->name);
|
||||
switch (compile->compile_type)
|
||||
{
|
||||
case HLSL_COMPILE_TYPE_COMPILE:
|
||||
vkd3d_string_buffer_printf(buffer, "compile %s {\n", compile->profile->name);
|
||||
break;
|
||||
}
|
||||
|
||||
dump_block(ctx, buffer, &compile->instrs);
|
||||
|
||||
|
@ -875,14 +875,20 @@ struct hlsl_ir_compile
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
|
||||
/* Special field to store the profile argument. */
|
||||
enum hlsl_compile_type
|
||||
{
|
||||
/* A shader compilation through the CompileShader() function or the "compile" syntax. */
|
||||
HLSL_COMPILE_TYPE_COMPILE,
|
||||
} compile_type;
|
||||
|
||||
/* Special field to store the profile argument for HLSL_COMPILE_TYPE_COMPILE. */
|
||||
const struct hlsl_profile_info *profile;
|
||||
|
||||
/* Block containing the instructions required by the arguments of the
|
||||
* compilation call. */
|
||||
struct hlsl_block instrs;
|
||||
|
||||
/* Arguments to the compilation call. For a "compile" or "CompileShader()"
|
||||
/* Arguments to the compilation call. For HLSL_COMPILE_TYPE_COMPILE
|
||||
* args[0] is an hlsl_ir_call to the specified function. */
|
||||
struct hlsl_src *args;
|
||||
unsigned int args_count;
|
||||
@ -1491,9 +1497,9 @@ bool hlsl_index_is_noncontiguous(struct hlsl_ir_index *index);
|
||||
bool hlsl_index_is_resource_access(struct hlsl_ir_index *index);
|
||||
bool hlsl_index_chain_has_resource_access(struct hlsl_ir_index *index);
|
||||
|
||||
struct hlsl_ir_node *hlsl_new_compile(struct hlsl_ctx *ctx, const char *profile_name,
|
||||
struct hlsl_ir_node **args, unsigned int args_count, struct hlsl_block *args_instrs,
|
||||
const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_new_compile(struct hlsl_ctx *ctx, enum hlsl_compile_type compile_type,
|
||||
const char *profile_name, struct hlsl_ir_node **args, unsigned int args_count,
|
||||
struct hlsl_block *args_instrs, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_new_index(struct hlsl_ctx *ctx, struct hlsl_ir_node *val,
|
||||
struct hlsl_ir_node *idx, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_new_loop(struct hlsl_ctx *ctx,
|
||||
|
@ -5224,7 +5224,8 @@ static struct hlsl_block *add_shader_compilation(struct hlsl_ctx *ctx, const cha
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(compile = hlsl_new_compile(ctx, profile_name, &call_to_compile, 1, args->instrs, loc)))
|
||||
if (!(compile = hlsl_new_compile(ctx, HLSL_COMPILE_TYPE_COMPILE,
|
||||
profile_name, &call_to_compile, 1, args->instrs, loc)))
|
||||
{
|
||||
free_parse_initializer(args);
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user