Module: vkd3d
Branch: master
Commit: 3fbe272659c3b96757028521afa867fc2141d90f
URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/3fbe272659c3b96757028521afa86…
Author: Francisco Casas <fcasas(a)codeweavers.com>
Date: Tue Nov 15 00:37:07 2022 -0300
vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_src.
---
libs/vkd3d-shader/hlsl.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 41dc3295..f365f588 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -270,9 +270,16 @@ struct hlsl_block
struct list instrs;
};
+/* A reference to an instruction node (struct hlsl_ir_node), usable as a field in other structs.
+ * struct hlsl_src is more powerful than a mere pointer to an hlsl_ir_node because it also
+ * contains a linked list item entry, which is used by the referenced instruction node to keep
+ * track of all the hlsl_src·s that reference it.
+ * This allows replacing any hlsl_ir_node with any other in all the places it is used, or checking
+ * that a node has no uses before it is removed. */
struct hlsl_src
{
struct hlsl_ir_node *node;
+ /* Item entry for node->uses. */
struct list entry;
};
Module: vkd3d
Branch: master
Commit: 04108c0e215566de68d575f4cc0bf20ff822abf8
URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/04108c0e215566de68d575f4cc0bf…
Author: Francisco Casas <fcasas(a)codeweavers.com>
Date: Mon Nov 14 22:46:17 2022 -0300
vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_ir_node.
---
libs/vkd3d-shader/hlsl.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index e32351ce..41dc3295 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -217,6 +217,11 @@ struct hlsl_reg
bool allocated;
};
+/* Types of instruction nodes for the IR.
+ * Each type of instruction node is associated to a struct with the same name in lower case.
+ * e.g. for HLSL_IR_CONSTANT there exists struct hlsl_ir_constant.
+ * Each one of these structs start with a struct hlsl_ir_node field, so pointers to values of these
+ * types can be casted seamlessly to (struct hlsl_ir_node *) and vice-versa. */
enum hlsl_ir_node_type
{
HLSL_IR_CONSTANT,
@@ -231,12 +236,22 @@ enum hlsl_ir_node_type
HLSL_IR_SWIZZLE,
};
+/* Common data for every type of IR instruction node. */
struct hlsl_ir_node
{
+ /* Item entry for storing the instruction in a list of instructions. */
struct list entry;
+
+ /* Type of node, which means that a pointer to this struct hlsl_ir_node can be casted to a
+ * pointer to the struct with the same name. */
enum hlsl_ir_node_type type;
+ /* HLSL data type of the node, when used by other nodes as a source (through an hlsl_src).
+ * HLSL_IR_CONSTANT, HLSL_IR_EXPR, HLSL_IR_LOAD, HLSL_IR_RESOURCE_LOAD, and HLSL_IR_SWIZZLE
+ * have a data type and can be used through an hlsl_src; other types of node don't. */
struct hlsl_type *data_type;
+ /* List containing all the struct hlsl_src·s that point to this node; linked by the
+ * hlsl_src.entry fields. */
struct list uses;
struct vkd3d_shader_location loc;
@@ -246,6 +261,7 @@ struct hlsl_ir_node
* true even for loops, since currently we can't have a reference to a
* value generated in an earlier iteration of the loop. */
unsigned int index, last_read;
+ /* Temp. register allocated to store the result of this instruction (if any). */
struct hlsl_reg reg;
};
Module: vkd3d
Branch: master
Commit: 9157a5e73f9eba03d49b01d2d7deed252fd22613
URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/9157a5e73f9eba03d49b01d2d7dee…
Author: Francisco Casas <fcasas(a)codeweavers.com>
Date: Mon Nov 14 18:03:37 2022 -0300
vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_ctx.
---
libs/vkd3d-shader/hlsl.h | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index e001924d..e32351ce 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -573,48 +573,88 @@ struct hlsl_ctx
const char **source_files;
unsigned int source_files_count;
+ /* Current location being read in the HLSL source, updated while parsing. */
struct vkd3d_shader_location location;
+ /* Stores the logging messages and logging configuration. */
struct vkd3d_shader_message_context *message_context;
+ /* Cache for temporary string allocations. */
struct vkd3d_string_buffer_cache string_buffers;
+ /* A value from enum vkd3d_result with the current success/failure result of the whole
+ * compilation.
+ * It is initialized to VKD3D_OK and set to an error code in case a call to hlsl_fixme() or
+ * hlsl_error() is triggered, or in case of a memory allocation error.
+ * The value of this field is checked between compilation stages to stop execution in case of
+ * failure. */
int result;
+ /* Pointer to an opaque data structure managed by FLEX (during lexing), that encapsulates the
+ * current state of the scanner. This pointer is required by all FLEX API functions when the
+ * scanner is declared as reentrant, which is the case. */
void *scanner;
+ /* Pointer to the current scope; changes as the parser reads the code. */
struct hlsl_scope *cur_scope;
+ /* Scope of global variables. */
struct hlsl_scope *globals;
+ /* List of all the scopes in the program; linked by the hlsl_scope.entry fields. */
struct list scopes;
+ /* List of all the extern variables; linked by the hlsl_ir_var.extern_entry fields.
+ * This exists as a convenience because it is often necessary to iterate all extern variables
+ * and these can be declared in global scope, as function parameters, or as the function
+ * return value. */
struct list extern_vars;
+ /* List containing both the built-in HLSL buffers ($Globals and $Params) and the ones declared
+ * in the shader; linked by the hlsl_buffer.entry fields. */
struct list buffers;
+ /* Current buffer (changes as the parser reads the code), $Globals buffer, and $Params buffer,
+ * respectively. */
struct hlsl_buffer *cur_buffer, *globals_buffer, *params_buffer;
+ /* List containing all created hlsl_types, except builtin_types; linked by the hlsl_type.entry
+ * fields. */
struct list types;
+ /* Tree map for the declared functions, using hlsl_ir_function.name as key.
+ * The functions are attached through the hlsl_ir_function.entry fields. */
struct rb_tree functions;
+ /* Pointer to the current function; changes as the parser reads the code. */
const struct hlsl_ir_function_decl *cur_function;
+ /* Default matrix majority for matrix types. Can be set by a pragma within the HLSL source. */
enum hlsl_matrix_majority matrix_majority;
+ /* Basic data types stored for convenience. */
struct
{
struct hlsl_type *scalar[HLSL_TYPE_LAST_SCALAR + 1];
struct hlsl_type *vector[HLSL_TYPE_LAST_SCALAR + 1][4];
- /* matrix[float][2][4] is a float4x2, i.e. dimx = 2, dimy = 4 */
+ /* matrix[HLSL_TYPE_FLOAT][1][3] is a float4x2, i.e. dimx = 2, dimy = 4 */
struct hlsl_type *matrix[HLSL_TYPE_LAST_SCALAR + 1][4][4];
struct hlsl_type *sampler[HLSL_SAMPLER_DIM_LAST_SAMPLER + 1];
struct hlsl_type *Void;
} builtin_types;
+ /* List of the instruction nodes for initializing static variables; linked by the
+ * hlsl_ir_node.entry fields. */
struct list static_initializers;
+ /* Dynamic array of constant values that appear in the shader, associated to the 'c' registers.
+ * Only used for SM1 profiles. */
struct hlsl_constant_defs
{
struct hlsl_vec4 *values;
size_t count, size;
} constant_defs;
+ /* Number of temp. registers required for the shader to run, i.e. the largest temp register
+ * index that will be used in the output bytecode (+1). */
uint32_t temp_count;
+ /* Number of threads to be executed (on the X, Y, and Z dimensions) in a single thread group in
+ * compute shader profiles. It is set using the numthreads() attribute in the entry point. */
uint32_t thread_count[3];
+ /* Whether the parser is inside an state block (effects' metadata) inside a variable declarition. */
uint32_t in_state_block : 1;
+ /* Whether the numthreads() attribute has been provided in the entry-point function. */
uint32_t found_numthreads : 1;
};
Module: vkd3d
Branch: master
Commit: 8ff3698699c450b8dd3eea97db40233e73ec195d
URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/8ff3698699c450b8dd3eea97db402…
Author: Francisco Casas <fcasas(a)codeweavers.com>
Date: Mon Nov 14 17:14:03 2022 -0300
vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_ir_var.
---
libs/vkd3d-shader/hlsl.h | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index d0a345aa..e001924d 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -303,13 +303,40 @@ struct hlsl_ir_var
struct vkd3d_shader_location loc;
const char *name;
struct hlsl_semantic semantic;
+ /* Buffer where the variable's value is stored, in case it is uniform. */
struct hlsl_buffer *buffer;
+ /* Bitfield for storage modifiers (type modifiers are stored in data_type->modifiers). */
unsigned int storage_modifiers;
+ /* Optional register to be used as a starting point for the variable allocation, specified
+ * by the user via the register(·) syntax. */
struct hlsl_reg_reservation reg_reservation;
- struct list scope_entry, param_entry, extern_entry;
+ /* Item entry in hlsl_scope.vars. Specifically hlsl_ctx.globals.vars if the variable is global. */
+ struct list scope_entry;
+ /* Item entry in hlsl_ir_function_decl.parameters, if the variable is a function parameter. */
+ struct list param_entry;
+ /* Item entry in hlsl_ctx.extern_vars, if the variable is extern. */
+ struct list extern_entry;
+
+ /* Indexes of the IR instructions where the variable is first written and last read (liveness
+ * range). The IR instructions are numerated starting from 2, because 0 means unused, and 1
+ * means function entry. */
unsigned int first_write, last_read;
+ /* Offset where the variable's value is stored within its buffer in numeric register components.
+ * This in case the variable is uniform. */
unsigned int buffer_offset;
+ /* Register to which the variable is allocated during its lifetime.
+ * In case that the variable spans multiple registers, this is set to the start of the register
+ * range.
+ * The register type is inferred from the data type and the storage of the variable.
+ * Builtin semantics don't use the field.
+ * In SM4, uniforms don't use the field because they are located using the buffer's hlsl_reg
+ * and the buffer_offset instead.
+ * If the variable is an input semantic copy, the register is 'v'.
+ * If the variable is an output semantic copy, the register is 'o'.
+ * Textures are stored on 's' registers in SM1, and 't' registers in SM4.
+ * Samplers are stored on 's' registers.
+ * UAVs are stored on 'u' registers. */
struct hlsl_reg reg;
uint32_t is_input_semantic : 1;
Module: vkd3d
Branch: master
Commit: 0a2732428c0df1419f88e747d6180cdeb118575c
URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/0a2732428c0df1419f88e747d6180…
Author: Francisco Casas <fcasas(a)codeweavers.com>
Date: Mon Nov 14 14:25:24 2022 -0300
vkd3d-shader/hlsl: Add field-level documentation to struct hlsl_struct_field.
---
libs/vkd3d-shader/hlsl.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index d672de0b..d0a345aa 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -191,15 +191,22 @@ struct hlsl_semantic
uint32_t index;
};
+/* A field within a struct type declaration, used in hlsl_type.e.fields. */
struct hlsl_struct_field
{
struct vkd3d_shader_location loc;
struct hlsl_type *type;
const char *name;
struct hlsl_semantic semantic;
+
+ /* Bitfield for storing modifiers that are not in HLSL_TYPE_MODIFIERS_MASK (these are stored in
+ * type->modifiers instead) and that also are specific to the field and not the whole variable.
+ * In particular, interpolation modifiers. */
unsigned int storage_modifiers;
+ /* Offset of the field within the type it belongs to, in numeric register components. */
unsigned int reg_offset;
+ /* Offset where the fields's name starts in the output bytecode, in bytes. */
size_t name_bytecode_offset;
};