Module: vkd3d
Branch: master
Commit: 72984bddcdce65ea643e02a9a8d338c4e7473816
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=72984bddcdce65ea643e02a…
Author: Zebediah Figura <z.figura12(a)gmail.com>
Date: Mon Aug 31 20:34:30 2020 -0500
include: Document struct vkd3d_shader_interface_info.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
include/vkd3d_shader.h | 154 +++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 143 insertions(+), 11 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h
index 7e011e3..cc5615c 100644
--- a/include/vkd3d_shader.h
+++ b/include/vkd3d_shader.h
@@ -105,15 +105,23 @@ struct vkd3d_shader_compile_option
unsigned int value;
};
+/** Describes which shader stages a resource is visible to. */
enum vkd3d_shader_visibility
{
+ /** The resource is visible to all shader stages. */
VKD3D_SHADER_VISIBILITY_ALL = 0,
+ /** The resource is visible only to the vertex shader. */
VKD3D_SHADER_VISIBILITY_VERTEX = 1,
+ /** The resource is visible only to the hull shader. */
VKD3D_SHADER_VISIBILITY_HULL = 2,
+ /** The resource is visible only to the domain shader. */
VKD3D_SHADER_VISIBILITY_DOMAIN = 3,
+ /** The resource is visible only to the geometry shader. */
VKD3D_SHADER_VISIBILITY_GEOMETRY = 4,
+ /** The resource is visible only to the pixel shader. */
VKD3D_SHADER_VISIBILITY_PIXEL = 5,
+ /** The resource is visible only to the compute shader. */
VKD3D_SHADER_VISIBILITY_COMPUTE = 1000000000,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_VISIBILITY),
@@ -128,21 +136,51 @@ struct vkd3d_shader_code
size_t size;
};
+/** The type of a shader resource descriptor. */
enum vkd3d_shader_descriptor_type
{
- VKD3D_SHADER_DESCRIPTOR_TYPE_SRV = 0x0, /* t# */
- VKD3D_SHADER_DESCRIPTOR_TYPE_UAV = 0x1, /* u# */
- VKD3D_SHADER_DESCRIPTOR_TYPE_CBV = 0x2, /* cb# */
- VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER = 0x3, /* s# */
+ /**
+ * The descriptor is a shader resource view. In Direct3D assembly, this is
+ * bound to a t# register.
+ */
+ VKD3D_SHADER_DESCRIPTOR_TYPE_SRV = 0x0,
+ /**
+ * The descriptor is an unordered access view. In Direct3D assembly, this is
+ * bound to a u# register.
+ */
+ VKD3D_SHADER_DESCRIPTOR_TYPE_UAV = 0x1,
+ /**
+ * The descriptor is a constant buffer view. In Direct3D assembly, this is
+ * bound to a cb# register.
+ */
+ VKD3D_SHADER_DESCRIPTOR_TYPE_CBV = 0x2,
+ /**
+ * The descriptor is a sampler. In Direct3D assembly, this is bound to an s#
+ * register.
+ */
+ VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER = 0x3,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_TYPE),
};
+/**
+ * A common structure describing the bind point of a descriptor or descriptor
+ * array in the target environment.
+ */
struct vkd3d_shader_descriptor_binding
{
+ /**
+ * The set of the descriptor. If the target environment does not support
+ * descriptor sets, this value must be set to 0.
+ */
unsigned int set;
+ /** The binding index of the descriptor. */
unsigned int binding;
- unsigned int count; /* This must be 1 in this version of vkd3d-shader. */
+ /**
+ * The size of this descriptor array. Descriptor arrays are not supported in
+ * this version of vkd3d-shader, and therefore this value must be 1.
+ */
+ unsigned int count;
};
enum vkd3d_shader_binding_flag
@@ -203,67 +241,161 @@ struct vkd3d_shader_parameter
} u;
};
+/**
+ * Describes the mapping of a single resource or resource array to its binding
+ * point in the target environment.
+ *
+ * For example, to map a Direct3D SRV with register space 2, register "t3" to
+ * a Vulkan descriptor in set 4 and with binding 5, set the following members:
+ * - \a type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV
+ * - \a register_space = 2
+ * - \a register_index = 3
+ * - \a binding.set = 4
+ * - \a binding.binding = 5
+ * - \a binding.count = 1
+ *
+ * This structure is used in struct vkd3d_shader_interface_info.
+ */
struct vkd3d_shader_resource_binding
{
+ /** The type of this descriptor. */
enum vkd3d_shader_descriptor_type type;
+ /**
+ * Register space of the Direct3D resource. If the source format does not
+ * support multiple register spaces, this parameter must be set to 0.
+ */
unsigned int register_space;
+ /** Register index of the DXBC resource. */
unsigned int register_index;
+ /** Shader stage(s) to which the resource is visible. */
enum vkd3d_shader_visibility shader_visibility;
- unsigned int flags; /* vkd3d_shader_binding_flag */
+ /** A combination of zero or more elements of vkd3d_shader_binding_flag. */
+ unsigned int flags;
+ /** The binding in the target environment. */
struct vkd3d_shader_descriptor_binding binding;
};
#define VKD3D_SHADER_DUMMY_SAMPLER_INDEX ~0u
+/**
+ * Describes the mapping of a Direct3D resource-sampler pair to a combined
+ * sampler (i.e. sampled image).
+ *
+ * This structure is used in struct vkd3d_shader_interface_info.
+ */
struct vkd3d_shader_combined_resource_sampler
{
+ /**
+ * Register space of the Direct3D resource. If the source format does not
+ * support multiple register spaces, this parameter must be set to 0.
+ */
unsigned int resource_space;
+ /** Register index of the Direct3D resource. */
unsigned int resource_index;
+ /**
+ * Register space of the Direct3D sampler. If the source format does not
+ * support multiple register spaces, this parameter must be set to 0.
+ */
unsigned int sampler_space;
+ /** Register index of the Direct3D sampler. */
unsigned int sampler_index;
+ /** Shader stage(s) to which the resource is visible. */
enum vkd3d_shader_visibility shader_visibility;
- unsigned int flags; /* vkd3d_shader_binding_flag */
+ /** A combination of zero or more elements of vkd3d_shader_binding_flag. */
+ unsigned int flags;
+ /** The binding in the target environment. */
struct vkd3d_shader_descriptor_binding binding;
};
+/**
+ * Describes the mapping of a single Direct3D UAV counter.
+ *
+ * This structure is used in struct vkd3d_shader_interface_info.
+ */
struct vkd3d_shader_uav_counter_binding
{
+ /**
+ * Register space of the Direct3D UAV descriptor. If the source format does
+ * not support multiple register spaces, this parameter must be set to 0.
+ */
unsigned int register_space;
- unsigned int register_index; /* u# */
+ /** Register index of the Direct3D UAV descriptor. */
+ unsigned int register_index;
+ /** Shader stage(s) to which the UAV counter is visible. */
enum vkd3d_shader_visibility shader_visibility;
+ /** The binding in the target environment. */
struct vkd3d_shader_descriptor_binding binding;
unsigned int offset;
};
+/**
+ * Describes the mapping of a Direct3D constant buffer to a range of push
+ * constants in the target environment.
+ *
+ * This structure is used in struct vkd3d_shader_interface_info.
+ */
struct vkd3d_shader_push_constant_buffer
{
+ /**
+ * Register space of the Direct3D resource. If the source format does not
+ * support multiple register spaces, this parameter must be set to 0.
+ */
unsigned int register_space;
+ /** Register index of the Direct3D resource. */
unsigned int register_index;
+ /** Shader stage(s) to which the resource is visible. */
enum vkd3d_shader_visibility shader_visibility;
- unsigned int offset; /* in bytes */
- unsigned int size; /* in bytes */
+ /** Offset, in bytes, of the target push constants. */
+ unsigned int offset;
+ /** Size, in bytes, of the target push constants. */
+ unsigned int size;
};
-/* Extends vkd3d_shader_compile_info. */
+/**
+ * A chained structure describing the interface between a compiled shader and
+ * the target environment.
+ *
+ * For example, when compiling Direct3D shader byte code to SPIR-V, this
+ * structure contains mappings from Direct3D descriptor registers to SPIR-V
+ * descriptor bindings.
+ *
+ * This structure is optional. If omitted, vkd3d_shader_compile() will use a
+ * default mapping, in which resources are mapped to sequential bindings in
+ * register set 0.
+ *
+ * This structure extends vkd3d_shader_compile_info.
+ *
+ * This structure contains only input parameters.
+ */
struct vkd3d_shader_interface_info
{
+ /** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO. */
enum vkd3d_shader_structure_type type;
+ /** Optional pointer to a structure containing further parameters. */
const void *next;
+ /** Pointer to an array of bindings for shader resource descriptors. */
const struct vkd3d_shader_resource_binding *bindings;
+ /** Size, in elements, of \ref bindings. */
unsigned int binding_count;
+ /** Pointer to an array of bindings for push constant buffers. */
const struct vkd3d_shader_push_constant_buffer *push_constant_buffers;
+ /** Size, in elements, of \ref push_constant_buffers. */
unsigned int push_constant_buffer_count;
+ /** Pointer to an array of bindings for combined samplers. */
const struct vkd3d_shader_combined_resource_sampler *combined_samplers;
+ /** Size, in elements, of \ref combined_samplers. */
unsigned int combined_sampler_count;
+ /** Pointer to an array of bindings for UAV counters. */
const struct vkd3d_shader_uav_counter_binding *uav_counters;
+ /** Size, in elements, of \ref uav_counters. */
unsigned int uav_counter_count;
};
Module: vkd3d
Branch: master
Commit: e61242b6261d4137e73b66022dc21c4e6740eff0
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=e61242b6261d4137e73b660…
Author: Zebediah Figura <z.figura12(a)gmail.com>
Date: Mon Aug 31 20:34:29 2020 -0500
include: Document vkd3d-shader compilation and scanning functions.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
include/vkd3d_shader.h | 110 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h
index 9150f14..7e011e3 100644
--- a/include/vkd3d_shader.h
+++ b/include/vkd3d_shader.h
@@ -864,13 +864,99 @@ static inline uint32_t vkd3d_shader_create_swizzle(enum vkd3d_shader_swizzle_com
#ifndef VKD3D_SHADER_NO_PROTOTYPES
const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor);
+/**
+ * Returns the source types supported, with any target type, by
+ * vkd3d_shader_compile().
+ *
+ * Use vkd3d_shader_get_supported_target_types() to determine which target types
+ * are supported for each source type.
+ *
+ * \param count Output location for the size, in elements, of the returned
+ * array.
+ *
+ * \return Pointer to an array of source types supported by this version of
+ * vkd3d-shader. This array may be a pointer to static data in libvkd3d-shader;
+ * it should not be freed.
+ */
const enum vkd3d_shader_source_type *vkd3d_shader_get_supported_source_types(unsigned int *count);
+/**
+ * Returns the target types supported, with the given source type, by
+ * vkd3d_shader_compile().
+ *
+ * \param source_type Source type for which to enumerate supported target types.
+ *
+ * \param count Output location for the size, in elements, of the returned
+ * array.
+ *
+ * \return Pointer to an array of target types supported by this version of
+ * vkd3d-shader. This array may be a pointer to static data in libvkd3d-shader;
+ * it should not be freed.
+ */
const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types(
enum vkd3d_shader_source_type source_type, unsigned int *count);
+/**
+ * Transform a form of GPU shader source code or byte code into another form of
+ * source code or byte code.
+ *
+ * This version of vkd3d-shader supports the following transformations:
+ * - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_SPIRV_BINARY
+ *
+ * Supported transformations can also be detected at runtime with the functions
+ * vkd3d_shader_get_supported_source_types() and
+ * vkd3d_shader_get_supported_target_types().
+ *
+ * Depending on the source and target types, this function may support the
+ * following chained structures:
+ * - vkd3d_shader_interface_info
+ * - vkd3d_shader_spirv_domain_shader_target_info
+ * - vkd3d_shader_spirv_target_info
+ * - vkd3d_shader_transform_feedback_info
+ *
+ * \param compile_info A chained structure containing compilation parameters.
+ *
+ * \param out A pointer to a vkd3d_shader_code structure in which the compiled
+ * code will be stored.
+ * \n
+ * The compiled shader 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 string is null-terminated and UTF-8 encoded.
+ * \n
+ * The messages are allocated by vkd3d-shader and should be freed with
+ * vkd3d_shader_free_messages() when no longer needed.
+ * \n
+ * The messages returned can be regulated with the \a log_level member of struct
+ * vkd3d_shader_compile_info. Regardless of the requested level, if this
+ * parameter is NULL, no compilation messages will be returned.
+ * \n
+ * If no compilation messages are produced by the compiler, this parameter may
+ * receive NULL instead of a valid string pointer.
+ *
+ * \return A member of \ref vkd3d_result.
+ */
int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out, char **messages);
+/**
+ * Free shader messages allocated by another vkd3d-shader function, such as
+ * vkd3d_shader_compile().
+ *
+ * \param messages Messages to free. This pointer is optional and may be NULL,
+ * in which case no action will be taken.
+ */
void vkd3d_shader_free_messages(char *messages);
+/**
+ * Free shader code allocated by another vkd3d-shader function, such as
+ * vkd3d_shader_compile().
+ *
+ * This function frees the \ref vkd3d_shader_code.code member, but does not free
+ * the structure itself.
+ *
+ * \param code Code to free.
+ */
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);
int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
@@ -883,6 +969,30 @@ int vkd3d_shader_serialize_root_signature(const struct vkd3d_shader_versioned_ro
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);
+/**
+ * Parse shader source code or byte code, returning various types of requested
+ * information.
+ *
+ * Currently this function supports the following code types:
+ * - VKD3D_SHADER_SOURCE_DXBC_TPF
+ *
+ * \param compile_info A chained structure containing scan parameters.
+ * \n
+ * The DXBC_TPF scanner supports the following chained structures:
+ * - vkd3d_shader_scan_descriptor_info
+ * \n
+ * Although the \a compile_info parameter is read-only, chained structures
+ * passed to this function need not be, and may serve as output parameters,
+ * depending on their structure type.
+ *
+ * \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_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages);
void vkd3d_shader_free_scan_descriptor_info(struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);