Signed-off-by: Zebediah Figura z.figura12@gmail.com --- include/vkd3d_shader.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index cc5615c9..527d5789 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -961,7 +961,7 @@ struct vkd3d_shader_signature unsigned int element_count; };
-/* swizzle bits fields: wwzzyyxx */ +/** Possible values for a single component of a vkd3d-shader swizzle. */ enum vkd3d_shader_swizzle_component { VKD3D_SHADER_SWIZZLE_X = 0x0, @@ -972,17 +972,33 @@ enum vkd3d_shader_swizzle_component VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SWIZZLE_COMPONENT), };
+/** + * A mask selecting one component from a vkd3d-shader swizzle. The component has + * type \ref vkd3d_shader_swizzle_component. + */ #define VKD3D_SHADER_SWIZZLE_MASK (0xffu) +/** The offset, in bits, of the nth parameter of a vkd3d-shader swizzle. */ #define VKD3D_SHADER_SWIZZLE_SHIFT(idx) (8u * (idx))
+/** + * A helper macro which returns a vkd3d-shader swizzle with the given + * components. The components are specified as the suffixes to members of + * \ref vkd3d_shader_swizzle_component. For example, the swizzle ".xwyy" can be + * represented as: + * \code + * VKD3D_SHADER_SWIZZLE(X, W, Y, Y) + * \endcode + */ #define VKD3D_SHADER_SWIZZLE(x, y, z, w) \ vkd3d_shader_create_swizzle(VKD3D_SHADER_SWIZZLE_ ## x, \ VKD3D_SHADER_SWIZZLE_ ## y, \ VKD3D_SHADER_SWIZZLE_ ## z, \ VKD3D_SHADER_SWIZZLE_ ## w)
+/** The identity swizzle, ie ".xyzw". */ #define VKD3D_SHADER_NO_SWIZZLE VKD3D_SHADER_SWIZZLE(X, Y, Z, W)
+/** Programmatically build a vkd3d-shader swizzle with the given components. */ static inline uint32_t vkd3d_shader_create_swizzle(enum vkd3d_shader_swizzle_component x, enum vkd3d_shader_swizzle_component y, enum vkd3d_shader_swizzle_component z, enum vkd3d_shader_swizzle_component w)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- include/vkd3d_shader.h | 77 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 527d5789..c48270f4 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -840,61 +840,125 @@ struct vkd3d_shader_versioned_root_signature_desc } u; };
+/** + * The dimension of a shader resource, returned as part of + * struct vkd3d_shader_descriptor_info. + */ enum vkd3d_shader_resource_type { + /** + * The dimension is invalid or not applicable for this resource. This value + * is returned for samplers. + */ VKD3D_SHADER_RESOURCE_NONE = 0x0, + /** Dimensionless buffer. */ VKD3D_SHADER_RESOURCE_BUFFER = 0x1, + /** 1-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_1D = 0x2, + /** 2-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2D = 0x3, + /** Multisampled 2-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2DMS = 0x4, + /** 3-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_3D = 0x5, + /** Cubemap texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_CUBE = 0x6, + /** 1-dimensional array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY = 0x7, + /** 2-dimensional array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY = 0x8, + /** Multisampled 2-dimensional array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY = 0x9, + /** Cubemap array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY = 0xa,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_TYPE), };
+/** + * The format of a shader resource, returned as part of + * struct vkd3d_shader_descriptor_info. All formats are 32-bit. + */ enum vkd3d_shader_resource_data_type { + /** Unsigned normalized integer. */ VKD3D_SHADER_RESOURCE_DATA_UNORM = 0x1, + /** Signed normalized integer. */ VKD3D_SHADER_RESOURCE_DATA_SNORM = 0x2, + /** Signed integer. */ VKD3D_SHADER_RESOURCE_DATA_INT = 0x3, + /** Unsigned integer. */ VKD3D_SHADER_RESOURCE_DATA_UINT = 0x4, + /** IEEE floating-point. */ VKD3D_SHADER_RESOURCE_DATA_FLOAT = 0x5,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_DATA_TYPE), };
+/** + * Additional flags describing a shader resource; returned as part of + * struct vkd3d_shader_descriptor_info. + */ enum vkd3d_shader_descriptor_info_flag { + /** + * The counter associated with this UAV resource is read from or written to + * by the shader. + */ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER = 0x00000001, + /** This UAV resource is read from by the shader. */ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ = 0x00000002, + /** This sampler is a comparison sampler. */ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE = 0x00000004,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_INFO_FLAG), };
+/** + * Describes a single shader resource; returned as part of + * struct vkd3d_shader_scan_descriptor_info. + */ struct vkd3d_shader_descriptor_info { + /** Type of this resource (eg SRV, CBV, UAV, or sampler). */ enum vkd3d_shader_descriptor_type type; + /** + * Register space of the resource, or 0 if the shader does not + * support multiple register spaces. + */ unsigned int register_space; + /** Register index of the resource. */ unsigned int register_index; + /** Dimension of the resource. */ enum vkd3d_shader_resource_type resource_type; + /** Format of the data contained in the resource (eg float or integer). */ enum vkd3d_shader_resource_data_type resource_data_type; - unsigned int flags; /* vkd3d_shader_descriptor_info_flag */ + /** + * Bitwise combination of zero or more members of + * \ref vkd3d_shader_descriptor_info_flag. + */ + unsigned int flags; + /** Size of this descriptor array, or 1 if a single descriptor. */ unsigned int count; };
-/* Extends vkd3d_shader_compile_info. */ +/** + * A chained structure enumerating the descriptors declared by a shader. + * + * This structure extends vkd3d_shader_compile_info. + */ struct vkd3d_shader_scan_descriptor_info { + /** + * Input; must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_DESCRIPTOR_INFO. + */ enum vkd3d_shader_structure_type type; + /** Input; optional pointer to a structure containing further parameters. */ const void *next;
+ /** Output; returns a pointer to an array of descriptors. */ struct vkd3d_shader_descriptor_info *descriptors; + /** Output; size, in elements, of \ref descriptors. */ unsigned int descriptor_count; };
@@ -1142,6 +1206,15 @@ int vkd3d_shader_convert_root_signature(struct vkd3d_shader_versioned_root_signa * \return A member of \ref vkd3d_result. */ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages); +/** + * Free members of struct vkd3d_shader_scan_descriptor_info() allocated by + * vkd3d_shader_scan(). + * + * This function may free members of vkd3d_shader_scan_descriptor_info, but + * does not free the structure itself. + * + * \param scan_descriptor_info Descriptor information to free. + */ void vkd3d_shader_free_scan_descriptor_info(struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);
int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
On Thu, 3 Sep 2020 at 05:41, Zebediah Figura z.figura12@gmail.com wrote:
+/**
- The dimension of a shader resource, returned as part of
- struct vkd3d_shader_descriptor_info.
- */
enum vkd3d_shader_resource_type {
/**
* The dimension is invalid or not applicable for this resource. This value
* is returned for samplers.
*/
VKD3D_SHADER_RESOURCE_NONE = 0x0,
/** Dimensionless buffer. */ VKD3D_SHADER_RESOURCE_BUFFER = 0x1,
/** 1-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_1D = 0x2,
/** 2-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2D = 0x3,
/** Multisampled 2-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2DMS = 0x4,
/** 3-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_3D = 0x5,
/** Cubemap texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_CUBE = 0x6,
/** 1-dimensional array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY = 0x7,
/** 2-dimensional array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY = 0x8,
/** Multisampled 2-dimensional array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY = 0x9,
/** Cubemap array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY = 0xa,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_TYPE),
};
It's possible to describe this in terms of dimension (although it's a bit of a stretch to include multisample and arrays there; at that point "topology" would perhaps be more appropriate), but in that case it's a little awkward that the enumeration is called "vkd3d_shader_resource_type".
+/**
- The format of a shader resource, returned as part of
- struct vkd3d_shader_descriptor_info. All formats are 32-bit.
- */
enum vkd3d_shader_resource_data_type {
/** Unsigned normalized integer. */ VKD3D_SHADER_RESOURCE_DATA_UNORM = 0x1,
/** Signed normalized integer. */ VKD3D_SHADER_RESOURCE_DATA_SNORM = 0x2,
/** Signed integer. */ VKD3D_SHADER_RESOURCE_DATA_INT = 0x3,
/** Unsigned integer. */ VKD3D_SHADER_RESOURCE_DATA_UINT = 0x4,
/** IEEE floating-point. */ VKD3D_SHADER_RESOURCE_DATA_FLOAT = 0x5,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_DATA_TYPE),
};
"Format" tends to have a specific association in the context of these kinds of APIs. (I.e., VkFormat/DXGI_FORMAT/etc.) What this describes is more like the type of format; what SPIR-V calls the "sampled type" (as opposed to the "image format"), and GLSL calls "sampler type"/"internal texture format"
+/**
- Additional flags describing a shader resource; returned as part of
- struct vkd3d_shader_descriptor_info.
- */
enum vkd3d_shader_descriptor_info_flag {
/**
* The counter associated with this UAV resource is read from or written to
* by the shader.
*/
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER = 0x00000001,
/** This UAV resource is read from by the shader. */ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ = 0x00000002,
/** This sampler is a comparison sampler. */ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE = 0x00000004,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_INFO_FLAG),
};
Well, they're *descriptor* flags. The SAMPLER_COMPARISON_MODE flag in particular applies to sampler descriptors, not resource view descriptors.
+/**
- Describes a single shader resource; returned as part of
- struct vkd3d_shader_scan_descriptor_info.
- */
struct vkd3d_shader_descriptor_info {
- /** Type of this resource (eg SRV, CBV, UAV, or sampler). */ enum vkd3d_shader_descriptor_type type;
- /**
* Register space of the resource, or 0 if the shader does not
* support multiple register spaces.
unsigned int register_space;*/
- /** Register index of the resource. */ unsigned int register_index;
- /** Dimension of the resource. */ enum vkd3d_shader_resource_type resource_type;
- /** Format of the data contained in the resource (eg float or integer). */ enum vkd3d_shader_resource_data_type resource_data_type;
- unsigned int flags; /* vkd3d_shader_descriptor_info_flag */
- /**
* Bitwise combination of zero or more members of
* \ref vkd3d_shader_descriptor_info_flag.
*/
- unsigned int flags;
- /** Size of this descriptor array, or 1 if a single descriptor. */ unsigned int count;
};
A bunch more descriptor/resource conflation here. (And, to complicate it a little more, note that e.g. VKD3D_SHADER_DESCRIPTOR_TYPE_CBV refers to a descriptor for a *view* into a buffer resource.)
On 9/3/20 10:08 AM, Henri Verbeet wrote:
On Thu, 3 Sep 2020 at 05:41, Zebediah Figura z.figura12@gmail.com wrote:
+/**
- The dimension of a shader resource, returned as part of
- struct vkd3d_shader_descriptor_info.
- */
enum vkd3d_shader_resource_type {
/**
* The dimension is invalid or not applicable for this resource. This value
* is returned for samplers.
*/
VKD3D_SHADER_RESOURCE_NONE = 0x0,
/** Dimensionless buffer. */ VKD3D_SHADER_RESOURCE_BUFFER = 0x1,
/** 1-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_1D = 0x2,
/** 2-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2D = 0x3,
/** Multisampled 2-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2DMS = 0x4,
/** 3-dimensional texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_3D = 0x5,
/** Cubemap texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_CUBE = 0x6,
/** 1-dimensional array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY = 0x7,
/** 2-dimensional array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY = 0x8,
/** Multisampled 2-dimensional array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY = 0x9,
/** Cubemap array texture. */ VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY = 0xa,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_TYPE),
};
It's possible to describe this in terms of dimension (although it's a bit of a stretch to include multisample and arrays there; at that point "topology" would perhaps be more appropriate), but in that case it's a little awkward that the enumeration is called "vkd3d_shader_resource_type".
I was mostly trying to find a nice way to distinguish it from vkd3d_shader_resource_data_type. The term "type" is quite overloaded.
Suggestions welcome, and if not I'll just rely on the enums to explain themselves.
+/**
- The format of a shader resource, returned as part of
- struct vkd3d_shader_descriptor_info. All formats are 32-bit.
- */
enum vkd3d_shader_resource_data_type {
/** Unsigned normalized integer. */ VKD3D_SHADER_RESOURCE_DATA_UNORM = 0x1,
/** Signed normalized integer. */ VKD3D_SHADER_RESOURCE_DATA_SNORM = 0x2,
/** Signed integer. */ VKD3D_SHADER_RESOURCE_DATA_INT = 0x3,
/** Unsigned integer. */ VKD3D_SHADER_RESOURCE_DATA_UINT = 0x4,
/** IEEE floating-point. */ VKD3D_SHADER_RESOURCE_DATA_FLOAT = 0x5,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_DATA_TYPE),
};
"Format" tends to have a specific association in the context of these kinds of APIs. (I.e., VkFormat/DXGI_FORMAT/etc.) What this describes is more like the type of format; what SPIR-V calls the "sampled type" (as opposed to the "image format"), and GLSL calls "sampler type"/"internal texture format"
Same problem as the above, plus misreading OpenGL documentation :-/
+/**
- Additional flags describing a shader resource; returned as part of
- struct vkd3d_shader_descriptor_info.
- */
enum vkd3d_shader_descriptor_info_flag {
/**
* The counter associated with this UAV resource is read from or written to
* by the shader.
*/
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER = 0x00000001,
/** This UAV resource is read from by the shader. */ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ = 0x00000002,
/** This sampler is a comparison sampler. */ VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE = 0x00000004,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_INFO_FLAG),
};
Well, they're *descriptor* flags. The SAMPLER_COMPARISON_MODE flag in particular applies to sampler descriptors, not resource view descriptors.
Sure. I guess I already used "resource" to describe views + samplers in enum vkd3d_shader_descriptor_type, although that's certainly not quite accurate. I guess that should be changed too.
+/**
- Describes a single shader resource; returned as part of
- struct vkd3d_shader_scan_descriptor_info.
- */
struct vkd3d_shader_descriptor_info {
- /** Type of this resource (eg SRV, CBV, UAV, or sampler). */ enum vkd3d_shader_descriptor_type type;
- /**
* Register space of the resource, or 0 if the shader does not
* support multiple register spaces.
unsigned int register_space;*/
- /** Register index of the resource. */ unsigned int register_index;
- /** Dimension of the resource. */ enum vkd3d_shader_resource_type resource_type;
- /** Format of the data contained in the resource (eg float or integer). */ enum vkd3d_shader_resource_data_type resource_data_type;
- unsigned int flags; /* vkd3d_shader_descriptor_info_flag */
- /**
* Bitwise combination of zero or more members of
* \ref vkd3d_shader_descriptor_info_flag.
*/
- unsigned int flags;
- /** Size of this descriptor array, or 1 if a single descriptor. */ unsigned int count;
};
A bunch more descriptor/resource conflation here. (And, to complicate it a little more, note that e.g. VKD3D_SHADER_DESCRIPTOR_TYPE_CBV refers to a descriptor for a *view* into a buffer resource.)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- include/vkd3d_shader.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index c48270f4..630f2dfd 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -1075,6 +1075,17 @@ static inline uint32_t vkd3d_shader_create_swizzle(enum vkd3d_shader_swizzle_com
#ifndef VKD3D_SHADER_NO_PROTOTYPES
+/** + * Returns the current version of this library. + * + * \param major Output location for the major version of this library. + * + * \param minor Output location for the minor version of this library. + * + * \return A human-readable string describing the library name and version. This + * string is null-terminated and UTF-8 encoded. This may be a pointer to static + * data in libvkd3d-shader; it should not be freed. + */ const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor); /** * Returns the source types supported, with any target type, by
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- include/vkd3d_shader.h | 84 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 630f2dfd..9b0ce9a0 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -1182,13 +1182,95 @@ void vkd3d_shader_free_messages(char *messages); */ void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);
+/** + * Convert a byte code description of a shader root signature to a structural + * description which can be easily parsed by C code. + * + * This function corresponds to + * ID3D12VersionedRootSignatureDeserializer::GetUnconvertedRootSignatureDesc(). + * + * This function performs the reverse transformation of + * vkd3d_shader_serialize_root_signature(). + * + * This function parses a standalone root signature, and should not be confused + * with vkd3d_shader_parse_input_signature(). + * + * \param dxbc Compiled byte code, in DXBC format. + * + * \param root_signature Output location in which the decompiled root signature + * will be stored. + * \n + * Members of \a root_signature may be allocated by vkd3d-shader. The signature + * should be freed with vkd3d_shader_free_root_signature() when no longer + * needed. + * + * \param messages Optional output location for error or informational messages + * produced by the compiler. + * \n + * This parameter behaves identically to the \a messages parameter of + * vkd3d_shader_compile(). + * + * \return A member of \ref vkd3d_result. + */ int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages); +/** + * Free a structural representation of a shader root signature allocated by + * vkd3d_shader_convert_root_signature() or vkd3d_shader_parse_root_signature(). + * + * This function may free members of struct + * vkd3d_shader_versioned_root_signature_desc, but does not free the structure + * itself. + * + * \param root_signature Signature description to free. + */ void vkd3d_shader_free_root_signature(struct vkd3d_shader_versioned_root_signature_desc *root_signature);
+/** + * Convert a structural description of a shader root signature to a byte code + * format capable of being read by ID3D12Device::CreateRootSignature. The + * compiled signature is compatible with Microsoft D3D 12. + * + * This function corresponds to D3D12SerializeVersionedRootSignature(). + * + * \param root_signature Description of the root signature. + * + * \param dxbc A pointer to a vkd3d_shader_code structure in which the compiled + * code will be stored. + * \n + * The compiled signature is allocated by vkd3d-shader and should be freed with + * vkd3d_shader_free_shader_code() when no longer needed. + * + * \param messages Optional output location for error or informational messages + * produced by the compiler. + * \n + * This parameter behaves identically to the \a messages parameter of + * vkd3d_shader_compile(). + * + * \return A member of \ref vkd3d_result. + */ int vkd3d_shader_serialize_root_signature(const struct vkd3d_shader_versioned_root_signature_desc *root_signature, struct vkd3d_shader_code *dxbc, char **messages); - +/** + * Convert a structural representation of a root signature to a different + * version of structural representation. + * + * This function corresponds to + * ID3D12VersionedRootSignatureDeserializer::GetRootSignatureDescAtVersion(). + * + * \param dst A pointer to a vkd3d_shader_versioned_root_signature_desc + * structure in which the converted signature will be stored. + * \n + * Members of \a dst may be allocated by vkd3d-shader. The signature should be + * freed with vkd3d_shader_free_root_signature() when no longer needed. + * + * \param version The desired version to convert \a src to. This version must + * not be equal to \a src->version. + * + * \param src Input root signature description. + * + * \return A member of \ref vkd3d_result. + */ int vkd3d_shader_convert_root_signature(struct vkd3d_shader_versioned_root_signature_desc *dst, enum vkd3d_shader_root_signature_version version, const struct vkd3d_shader_versioned_root_signature_desc *src);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- include/vkd3d_shader.h | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 9b0ce9a0..277b469b 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -1310,11 +1310,61 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char */ void vkd3d_shader_free_scan_descriptor_info(struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);
+/** + * Read the input signature of a compiled shader, returning a structural + * description which can be easily parsed by C code. + * + * This function parses a compiled shader. To parse a standalone root signature, + * use vkd3d_shader_parse_root_signature(). + * + * \param dxbc Compiled byte code, in DXBC format. + * + * \param signature Output location in which the parsed root signature will be + * stored. + * \n + * Members of \a signature may be allocated by vkd3d-shader. The signature + * should be freed with vkd3d_shader_free_shader_signature() when no longer + * needed. + * + * \param messages Optional output location for error or informational messages + * produced by the compiler. + * \n + * This parameter behaves identically to the \a messages parameter of + * vkd3d_shader_compile(). + * + * \return A member of \ref vkd3d_result. + */ int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_signature *signature, char **messages); +/** + * Find a single element of a parsed input signature. + * + * \param signature The parsed input signature. This structure is normally + * populated by vkd3d_shader_parse_input_signature(). + * + * \param semantic_name Semantic name of the desired element. This function + * performs a case-insensitive comparison with respect to the ASCII plane. + * + * \param semantic_index Semantic index of the desired element. + * + * \param stream_index Stream index of the desired element. + * + * \return A description of the element matching the requested parameters, or + * NULL if no such element was found. If not NULL, the return value points into + * the \a signature parameter and should not be explicitly freed. + */ struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element( const struct vkd3d_shader_signature *signature, const char *semantic_name, unsigned int semantic_index, unsigned int stream_index); +/** + * Free a structural representation of a shader input signature allocated by + * vkd3d_shader_parse_input_signature(). + * + * This function may free members of struct vkd3d_shader_signature, but does not + * free the structure itself. + * + * \param signature Signature description to free. + */ void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature);
#endif /* VKD3D_SHADER_NO_PROTOTYPES */
On Thu, 3 Sep 2020 at 05:41, Zebediah Figura z.figura12@gmail.com wrote:
+/**
- A helper macro which returns a vkd3d-shader swizzle with the given
- components. The components are specified as the suffixes to members of
- \ref vkd3d_shader_swizzle_component. For example, the swizzle ".xwyy" can be
- represented as:
- \code
- VKD3D_SHADER_SWIZZLE(X, W, Y, Y)
- \endcode
- */
#define VKD3D_SHADER_SWIZZLE(x, y, z, w) \ vkd3d_shader_create_swizzle(VKD3D_SHADER_SWIZZLE_ ## x, \ VKD3D_SHADER_SWIZZLE_ ## y, \ VKD3D_SHADER_SWIZZLE_ ## z, \ VKD3D_SHADER_SWIZZLE_ ## w)
+/** The identity swizzle, ie ".xyzw". */ #define VKD3D_SHADER_NO_SWIZZLE VKD3D_SHADER_SWIZZLE(X, Y, Z, W)
"i.e."
+/** Programmatically build a vkd3d-shader swizzle with the given components. */ static inline uint32_t vkd3d_shader_create_swizzle(enum vkd3d_shader_swizzle_component x, enum vkd3d_shader_swizzle_component y, enum vkd3d_shader_swizzle_component z, enum vkd3d_shader_swizzle_component w)
"Programmatically", as opposed to what? If this is about distinguishing it from VKD3D_SHADER_SWIZZLE, it probably makes more sense to describe that one explicitly as a convenience macro in terms of vkd3d_shader_create_swizzle().
On 9/3/20 10:08 AM, Henri Verbeet wrote:
On Thu, 3 Sep 2020 at 05:41, Zebediah Figura z.figura12@gmail.com wrote:
+/**
- A helper macro which returns a vkd3d-shader swizzle with the given
- components. The components are specified as the suffixes to members of
- \ref vkd3d_shader_swizzle_component. For example, the swizzle ".xwyy" can be
- represented as:
- \code
- VKD3D_SHADER_SWIZZLE(X, W, Y, Y)
- \endcode
- */
#define VKD3D_SHADER_SWIZZLE(x, y, z, w) \ vkd3d_shader_create_swizzle(VKD3D_SHADER_SWIZZLE_ ## x, \ VKD3D_SHADER_SWIZZLE_ ## y, \ VKD3D_SHADER_SWIZZLE_ ## z, \ VKD3D_SHADER_SWIZZLE_ ## w)
+/** The identity swizzle, ie ".xyzw". */ #define VKD3D_SHADER_NO_SWIZZLE VKD3D_SHADER_SWIZZLE(X, Y, Z, W)
"i.e."
Yeah, I know; unfortunately that confuses doxygen, which thinks it's the end of a sentence. I'll try harder to see if there's a way around it.
+/** Programmatically build a vkd3d-shader swizzle with the given components. */ static inline uint32_t vkd3d_shader_create_swizzle(enum vkd3d_shader_swizzle_component x, enum vkd3d_shader_swizzle_component y, enum vkd3d_shader_swizzle_component z, enum vkd3d_shader_swizzle_component w)
"Programmatically", as opposed to what? If this is about distinguishing it from VKD3D_SHADER_SWIZZLE, it probably makes more sense to describe that one explicitly as a convenience macro in terms of vkd3d_shader_create_swizzle().
Yeah, there's not really much reason for that word to be there.