vkd3d-shader/hlsl: Parse the shader 'compile' syntax.

The hlsl_ir_compile node is introduced to represent the "compile"
syntax, and later the CompileShader() and ConstructGSWithSO()
constructs.

It basically represents a function call that remembers its arguments
using hlsl_srcs and keeps its own instruction block, which is discarded
when working on non-effect shaders.

For shader compilations it can be asserted that args_count is 1, and
that this argument (and the last node in hlsl_ir_effect_call.instrs)
is a regular hlsl_ir_call pointing to the declaration of the function
to be compiled.
This commit is contained in:
Francisco Casas
2024-06-24 17:30:46 -04:00
committed by Henri Verbeet
parent 379cd9b7b5
commit 45f18a7838
Notes: Henri Verbeet 2024-09-04 18:48:35 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/943
6 changed files with 339 additions and 46 deletions

View File

@@ -324,6 +324,8 @@ enum hlsl_ir_node_type
HLSL_IR_STORE,
HLSL_IR_SWIZZLE,
HLSL_IR_SWITCH,
HLSL_IR_COMPILE,
HLSL_IR_STATEBLOCK_CONSTANT,
HLSL_IR_VSIR_INSTRUCTION_REF,
@@ -864,6 +866,27 @@ struct hlsl_ir_string_constant
char *string;
};
/* Represents shader compilation call for effects, such as "CompileShader()".
*
* Unlike hlsl_ir_call, it is not flattened, thus, it keeps track of its
* arguments and maintains its own instruction block. */
struct hlsl_ir_compile
{
struct hlsl_ir_node node;
/* Special field to store the profile argument. */
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()"
* args[0] is an hlsl_ir_call to the specified function. */
struct hlsl_src *args;
unsigned int args_count;
};
/* Stateblock constants are undeclared values found on state blocks or technique passes descriptions,
* that do not concern regular pixel, vertex, or compute shaders, except for parsing. */
struct hlsl_ir_stateblock_constant
@@ -1170,6 +1193,12 @@ static inline struct hlsl_ir_switch *hlsl_ir_switch(const struct hlsl_ir_node *n
return CONTAINING_RECORD(node, struct hlsl_ir_switch, node);
}
static inline struct hlsl_ir_compile *hlsl_ir_compile(const struct hlsl_ir_node *node)
{
VKD3D_ASSERT(node->type == HLSL_IR_COMPILE);
return CONTAINING_RECORD(node, struct hlsl_ir_compile, node);
}
static inline struct hlsl_ir_stateblock_constant *hlsl_ir_stateblock_constant(const struct hlsl_ir_node *node)
{
VKD3D_ASSERT(node->type == HLSL_IR_STATEBLOCK_CONSTANT);
@@ -1455,6 +1484,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_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,
@@ -1523,6 +1555,7 @@ unsigned int hlsl_type_minor_size(const struct hlsl_type *type);
unsigned int hlsl_type_major_size(const struct hlsl_type *type);
unsigned int hlsl_type_element_count(const struct hlsl_type *type);
bool hlsl_type_is_resource(const struct hlsl_type *type);
bool hlsl_type_is_shader(const struct hlsl_type *type);
unsigned int hlsl_type_get_sm4_offset(const struct hlsl_type *type, unsigned int offset);
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2);