/*1* Copyright 2017-2019 Józef Kucia for CodeWeavers2*3* This library is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2.1 of the License, or (at your option) any later version.7*8* This library is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with this library; if not, write to the Free Software15* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA16*/1718#ifndef __VKD3D_SHADER_H19#define __VKD3D_SHADER_H2021#include <stdbool.h>22#include <stdint.h>23#include <stddef.h>24#include <vkd3d_types.h>2526#ifdef __cplusplus27extern "C" {28#endif /* __cplusplus */2930/**31* \file vkd3d_shader.h32*33* This file contains definitions for the vkd3d-shader library.34*35* The vkd3d-shader library provides multiple utilities related to the36* compilation, transformation, and reflection of GPU shaders.37*38* \since 1.239*/4041/** \since 1.3 */42enum vkd3d_shader_api_version43{44VKD3D_SHADER_API_VERSION_1_0,45VKD3D_SHADER_API_VERSION_1_1,46VKD3D_SHADER_API_VERSION_1_2,47VKD3D_SHADER_API_VERSION_1_3,48VKD3D_SHADER_API_VERSION_1_4,49VKD3D_SHADER_API_VERSION_1_5,50VKD3D_SHADER_API_VERSION_1_6,51VKD3D_SHADER_API_VERSION_1_7,52VKD3D_SHADER_API_VERSION_1_8,53VKD3D_SHADER_API_VERSION_1_9,54VKD3D_SHADER_API_VERSION_1_10,55VKD3D_SHADER_API_VERSION_1_11,56VKD3D_SHADER_API_VERSION_1_12,57VKD3D_SHADER_API_VERSION_1_13,58VKD3D_SHADER_API_VERSION_1_14,59VKD3D_SHADER_API_VERSION_1_15,60VKD3D_SHADER_API_VERSION_1_16,61VKD3D_SHADER_API_VERSION_1_17,6263VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_API_VERSION),64};6566/** The type of a chained structure. */67enum vkd3d_shader_structure_type68{69/** The structure is a vkd3d_shader_compile_info structure. */70VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO,71/** The structure is a vkd3d_shader_interface_info structure. */72VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO,73/** The structure is a vkd3d_shader_scan_descriptor_info structure. */74VKD3D_SHADER_STRUCTURE_TYPE_SCAN_DESCRIPTOR_INFO,75/** The structure is a vkd3d_shader_spirv_domain_shader_target_info structure. */76VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_DOMAIN_SHADER_TARGET_INFO,77/** The structure is a vkd3d_shader_spirv_target_info structure. */78VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_TARGET_INFO,79/** The structure is a vkd3d_shader_transform_feedback_info structure. */80VKD3D_SHADER_STRUCTURE_TYPE_TRANSFORM_FEEDBACK_INFO,8182/**83* The structure is a vkd3d_shader_hlsl_source_info structure.84* \since 1.385*/86VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO,87/**88* The structure is a vkd3d_shader_preprocess_info structure.89* \since 1.390*/91VKD3D_SHADER_STRUCTURE_TYPE_PREPROCESS_INFO,92/**93* The structure is a vkd3d_shader_descriptor_offset_info structure.94* \since 1.395*/96VKD3D_SHADER_STRUCTURE_TYPE_DESCRIPTOR_OFFSET_INFO,97/**98* The structure is a vkd3d_shader_scan_signature_info structure.99* \since 1.9100*/101VKD3D_SHADER_STRUCTURE_TYPE_SCAN_SIGNATURE_INFO,102/**103* The structure is a vkd3d_shader_varying_map_info structure.104* \since 1.9105*/106VKD3D_SHADER_STRUCTURE_TYPE_VARYING_MAP_INFO,107/**108* The structure is a vkd3d_shader_scan_combined_resource_sampler_info structure.109* \since 1.10110*/111VKD3D_SHADER_STRUCTURE_TYPE_SCAN_COMBINED_RESOURCE_SAMPLER_INFO,112/**113* The structure is a vkd3d_shader_parameter_info structure.114* \since 1.13115*/116VKD3D_SHADER_STRUCTURE_TYPE_PARAMETER_INFO,117/**118* The structure is a vkd3d_shader_scan_hull_shader_tessellation_info structure.119* \since 1.15120*/121VKD3D_SHADER_STRUCTURE_TYPE_SCAN_HULL_SHADER_TESSELLATION_INFO,122123VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STRUCTURE_TYPE),124};125126/**127* Determines how buffer UAVs are stored.128*129* This also affects UAV counters in Vulkan environments. In OpenGL130* environments, atomic counter buffers are always used for UAV counters.131*/132enum vkd3d_shader_compile_option_buffer_uav133{134/** Use buffer textures for buffer UAVs. This is the default value. */135VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV_STORAGE_TEXEL_BUFFER = 0x00000000,136/** Use storage buffers for buffer UAVs. */137VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV_STORAGE_BUFFER = 0x00000001,138139VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV),140};141142/**143* Determines how typed UAVs are declared.144* \since 1.5145*/146enum vkd3d_shader_compile_option_typed_uav147{148/** Use R32(u)i/R32f format for UAVs which are read from. This is the default value. */149VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV_READ_FORMAT_R32 = 0x00000000,150/**151* Use Unknown format for UAVs which are read from. This should only be set if152* shaderStorageImageReadWithoutFormat is enabled in the target environment.153*/154VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV_READ_FORMAT_UNKNOWN = 0x00000001,155156VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV),157};158159enum vkd3d_shader_compile_option_formatting_flags160{161VKD3D_SHADER_COMPILE_OPTION_FORMATTING_NONE = 0x00000000,162VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR = 0x00000001,163VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT = 0x00000002,164VKD3D_SHADER_COMPILE_OPTION_FORMATTING_OFFSETS = 0x00000004,165VKD3D_SHADER_COMPILE_OPTION_FORMATTING_HEADER = 0x00000008,166VKD3D_SHADER_COMPILE_OPTION_FORMATTING_RAW_IDS = 0x00000010,167/**168* Emit the signatures when disassembling a shader.169*170* \since 1.12171*/172VKD3D_SHADER_COMPILE_OPTION_FORMATTING_IO_SIGNATURES = 0x00000020,173174VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FLAGS),175};176177/** Determines how matrices are stored. \since 1.9 */178enum vkd3d_shader_compile_option_pack_matrix_order179{180VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ROW_MAJOR = 0x00000001,181VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR = 0x00000002,182183VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER),184};185186/** Individual options to enable various backward compatibility features. \since 1.10 */187enum vkd3d_shader_compile_option_backward_compatibility188{189/**190* Causes compiler to convert SM1-3 semantics to corresponding System Value semantics,191* when compiling HLSL sources for SM4+ targets.192*193* This option does the following conversions:194*195* - POSITION to SV_Position for vertex shader outputs, pixel shader inputs,196* and geometry shader inputs and outputs;197* - COLORN to SV_TargetN for pixel shader outputs;198* - DEPTH to SV_Depth for pixel shader outputs.199*/200VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES = 0x00000001,201/**202* Causes 'double' to behave as an alias for 'float'. This option only203* applies to HLSL sources with shader model 1-3 target profiles. Without204* this option using the 'double' type produces compilation errors in205* these target profiles.206*207* This option is disabled by default.208*209* \since 1.14210*/211VKD3D_SHADER_COMPILE_OPTION_DOUBLE_AS_FLOAT_ALIAS = 0x00000002,212213VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY),214};215216/**217* Determines the origin of fragment coordinates.218*219* \since 1.10220*/221enum vkd3d_shader_compile_option_fragment_coordinate_origin222{223/** Fragment coordinates originate from the upper-left. This is the224* default; it's also the only value supported by Vulkan environments. */225VKD3D_SHADER_COMPILE_OPTION_FRAGMENT_COORDINATE_ORIGIN_UPPER_LEFT = 0x00000000,226/** Fragment coordinates originate from the lower-left. This matches the227* traditional behaviour of OpenGL environments. */228VKD3D_SHADER_COMPILE_OPTION_FRAGMENT_COORDINATE_ORIGIN_LOWER_LEFT = 0x00000001,229230VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FRAGMENT_COORDINATE_ORIGIN),231};232233/** Advertises feature availability. \since 1.11 */234enum vkd3d_shader_compile_option_feature_flags235{236/** The SPIR-V target environment supports 64-bit integer types. This237* corresponds to the "shaderInt64" feature in the Vulkan API, and the238* "GL_ARB_gpu_shader_int64" extension in the OpenGL API. */239VKD3D_SHADER_COMPILE_OPTION_FEATURE_INT64 = 0x00000001,240/** The SPIR-V target environment supports 64-bit floating-point types.241* This corresponds to the "shaderFloat64" feature in the Vulkan API, and242* the "GL_ARB_gpu_shader_fp64" extension in the OpenGL API. */243VKD3D_SHADER_COMPILE_OPTION_FEATURE_FLOAT64 = 0x00000002,244/** The SPIR-V target environment supports wave operations.245* This flag is valid only in VKD3D_SHADER_SPIRV_ENVIRONMENT_VULKAN_1_1246* or greater, and corresponds to the following minimum requirements in247* VkPhysicalDeviceSubgroupProperties:248* - subgroupSize >= 4.249* - supportedOperations has BASIC, VOTE, ARITHMETIC, BALLOT, SHUFFLE and250* QUAD bits set.251* - supportedStages include COMPUTE and FRAGMENT. \since 1.12 */252VKD3D_SHADER_COMPILE_OPTION_FEATURE_WAVE_OPS = 0x00000004,253/** The SPIR-V target environment supports zero-initializing workgroup254* memory. This corresponds to the "shaderZeroInitializeWorkgroupMemory"255* Vulkan feature. \since 1.16 */256VKD3D_SHADER_COMPILE_OPTION_FEATURE_ZERO_INITIALIZE_WORKGROUP_MEMORY = 0x00000008,257258VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FEATURE_FLAGS),259};260261/**262* Flags for vkd3d_shader_parse_dxbc().263*264* \since 1.12265*/266enum vkd3d_shader_parse_dxbc_flags267{268/** Ignore the checksum and continue parsing even if it is269* incorrect. */270VKD3D_SHADER_PARSE_DXBC_IGNORE_CHECKSUM = 0x00000001,271272VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARSE_DXBC_FLAGS),273};274275enum vkd3d_shader_compile_option_name276{277/**278* If \a value is nonzero, do not include debug information in the279* compiled shader. The default value is zero.280*281* This option is supported by vkd3d_shader_compile(). However, not all282* compilers support generating debug information.283*/284VKD3D_SHADER_COMPILE_OPTION_STRIP_DEBUG = 0x00000001,285/** \a value is a member of enum vkd3d_shader_compile_option_buffer_uav. */286VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV = 0x00000002,287/** \a value is a member of enum vkd3d_shader_compile_option_formatting_flags. */288VKD3D_SHADER_COMPILE_OPTION_FORMATTING = 0x00000003,289/** \a value is a member of enum vkd3d_shader_api_version. \since 1.3 */290VKD3D_SHADER_COMPILE_OPTION_API_VERSION = 0x00000004,291/** \a value is a member of enum vkd3d_shader_compile_option_typed_uav. \since 1.5 */292VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV = 0x00000005,293/**294* If \a value is nonzero, write the point size for Vulkan tessellation and295* geometry shaders. This option should be enabled if and only if the296* shaderTessellationAndGeometryPointSize feature is enabled. The default297* value is nonzero, i.e. write the point size.298*299* This option is supported by vkd3d_shader_compile() for the SPIR-V target300* type and Vulkan targets; it should not be enabled otherwise.301*302* \since 1.7303*/304VKD3D_SHADER_COMPILE_OPTION_WRITE_TESS_GEOM_POINT_SIZE = 0x00000006,305/**306* This option specifies default matrix packing order for HLSL sources.307* Explicit variable modifiers or pragmas will take precedence.308*309* \a value is a member of enum vkd3d_shader_compile_option_pack_matrix_order.310*311* \since 1.9312*/313VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER = 0x00000007,314/**315* This option is used to enable various backward compatibility features.316*317* \a value is a mask of values from enum vkd3d_shader_compile_option_backward_compatibility.318*319* \since 1.10320*/321VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY = 0x00000008,322/**323* This option specifies the origin of fragment coordinates for SPIR-V324* targets.325*326* \a value is a member of enum327* vkd3d_shader_compile_option_fragment_coordinate_origin.328*329* \since 1.10330*/331VKD3D_SHADER_COMPILE_OPTION_FRAGMENT_COORDINATE_ORIGIN = 0x00000009,332/**333* This option specifies the shader features available in the target334* environment. These are not extensions, i.e. they are always supported335* by the driver, but may not be supported by the available hardware.336*337* \a value is a member of enum vkd3d_shader_compile_option_feature_flags.338*339* \since 1.11340*/341VKD3D_SHADER_COMPILE_OPTION_FEATURE = 0x0000000a,342/**343* If \a value is non-zero compilation will produce a child effect using344* shared object descriptions, as instructed by the "shared" modifier.345* Child effects are supported with fx_4_0, and fx_4_1 profiles. This option346* and "shared" modifiers are ignored for the fx_5_0 profile and non-fx profiles.347* The fx_2_0 profile does not have a separate concept of child effects, variables348* marked with "shared" modifier will be marked as such in a binary.349*350* \since 1.12351*/352VKD3D_SHADER_COMPILE_OPTION_CHILD_EFFECT = 0x0000000b,353/**354* If \a value is nonzero, emit a compile warning warn when vectors or355* matrices are truncated in an implicit conversion.356* If warnings are disabled, this option has no effect.357* This option has no effects for targets other than HLSL.358*359* The default value is nonzero, i.e. enable implicit truncation warnings.360*361* \since 1.12362*/363VKD3D_SHADER_COMPILE_OPTION_WARN_IMPLICIT_TRUNCATION = 0x0000000c,364/**365* If \a value is nonzero, empty constant buffers descriptions are366* written out in the output effect binary. This option applies only367* to fx_4_0 and fx_4_1 profiles and is otherwise ignored.368*369* \since 1.12370*/371VKD3D_SHADER_COMPILE_OPTION_INCLUDE_EMPTY_BUFFERS_IN_EFFECTS = 0x0000000d,372373VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_NAME),374};375376/**377* Various settings which may affect shader compilation or scanning, passed as378* part of struct vkd3d_shader_compile_info. For more details, see the379* documentation for individual options.380*/381struct vkd3d_shader_compile_option382{383/** Name of the option. */384enum vkd3d_shader_compile_option_name name;385/**386* A value associated with the option. The type and interpretation of the387* value depends on the option in question.388*/389unsigned int value;390};391392/** Describes which shader stages a resource is visible to. */393enum vkd3d_shader_visibility394{395/** The resource is visible to all shader stages. */396VKD3D_SHADER_VISIBILITY_ALL = 0,397/** The resource is visible only to the vertex shader. */398VKD3D_SHADER_VISIBILITY_VERTEX = 1,399/** The resource is visible only to the hull shader. */400VKD3D_SHADER_VISIBILITY_HULL = 2,401/** The resource is visible only to the domain shader. */402VKD3D_SHADER_VISIBILITY_DOMAIN = 3,403/** The resource is visible only to the geometry shader. */404VKD3D_SHADER_VISIBILITY_GEOMETRY = 4,405/** The resource is visible only to the pixel shader. */406VKD3D_SHADER_VISIBILITY_PIXEL = 5,407408/** The resource is visible only to the compute shader. */409VKD3D_SHADER_VISIBILITY_COMPUTE = 1000000000,410411VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_VISIBILITY),412};413414/** A generic structure containing a GPU shader, in text or byte-code format. */415struct vkd3d_shader_code416{417/**418* Pointer to the code. Note that textual formats are not null-terminated.419* Therefore \a size should not include a null terminator, when this420* structure is passed as input to a vkd3d-shader function, and the421* allocated string will not include a null terminator when this structure422* is used as output.423*/424const void *code;425/** Size of \a code, in bytes. */426size_t size;427};428429/** The type of a shader resource descriptor. */430enum vkd3d_shader_descriptor_type431{432/**433* The descriptor is a shader resource view. In Direct3D assembly, this is434* bound to a t# register.435*/436VKD3D_SHADER_DESCRIPTOR_TYPE_SRV = 0x0,437/**438* The descriptor is an unordered access view. In Direct3D assembly, this is439* bound to a u# register.440*/441VKD3D_SHADER_DESCRIPTOR_TYPE_UAV = 0x1,442/**443* The descriptor is a constant buffer view. In Direct3D assembly, this is444* bound to a cb# register.445*/446VKD3D_SHADER_DESCRIPTOR_TYPE_CBV = 0x2,447/**448* The descriptor is a sampler. In Direct3D assembly, this is bound to an s#449* register.450*/451VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER = 0x3,452453VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_TYPE),454};455456/**457* A common structure describing the bind point of a descriptor or descriptor458* array in the target environment.459*/460struct vkd3d_shader_descriptor_binding461{462/**463* The set of the descriptor. If the target environment does not support464* descriptor sets, this value must be set to 0.465*/466unsigned int set;467/** The binding index of the descriptor. */468unsigned int binding;469/**470* The size of this descriptor array. If an offset is specified for this471* binding by the vkd3d_shader_descriptor_offset_info structure, counting472* starts at that offset.473*/474unsigned int count;475};476477enum vkd3d_shader_binding_flag478{479VKD3D_SHADER_BINDING_FLAG_BUFFER = 0x00000001,480VKD3D_SHADER_BINDING_FLAG_IMAGE = 0x00000002,481482VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_BINDING_FLAG),483};484485/**486* The factor used to interpolate the fragment output colour with fog.487*488* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for specification of the489* interpolation factor as defined here.490*491* The following variables may be used to determine the interpolation factor:492*493* c = The fog coordinate value output from the vertex shader. This is an494* inter-stage varying with the semantic name "FOG" and semantic index 0.495* It may be modified by VKD3D_SHADER_PARAMETER_NAME_FOG_SOURCE.496* E = The value of VKD3D_SHADER_PARAMETER_NAME_FOG_END.497* k = The value of VKD3D_SHADER_PARAMETER_NAME_FOG_SCALE.498*499* \since 1.15500*/501enum vkd3d_shader_fog_fragment_mode502{503/**504* No fog interpolation is applied;505* the output colour is passed through unmodified.506* Equivalently, the fog interpolation factor is 1.507*/508VKD3D_SHADER_FOG_FRAGMENT_NONE = 0x0,509/**510* The fog interpolation factor is 2^-(k * c).511*512* In order to implement traditional exponential fog, as present in513* Direct3D and OpenGL, i.e.514*515* e^-(density * c)516*517* set518*519* k = density * log₂(e)520*/521VKD3D_SHADER_FOG_FRAGMENT_EXP = 0x1,522/**523* The fog interpolation factor is 2^-((k * c)²).524*525* In order to implement traditional square-exponential fog, as present in526* Direct3D and OpenGL, i.e.527*528* e^-((density * c)²)529*530* set531*532* k = density * √log₂(e)533*/534VKD3D_SHADER_FOG_FRAGMENT_EXP2 = 0x2,535/**536* The fog interpolation factor is (E - c) * k.537*538* In order to implement traditional linear fog, as present in Direct3D and539* OpenGL, i.e.540*541* (end - c) / (end - start)542*543* set544*545* E = end546* k = 1 / (end - start)547*/548VKD3D_SHADER_FOG_FRAGMENT_LINEAR = 0x3,549550VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_FOG_FRAGMENT_MODE),551};552553/**554* The source of the fog varying output by a pre-rasterization shader.555* The fog varying is defined as the output varying with the semantic name "FOG"556* and semantic index 0.557*558* See VKD3D_SHADER_PARAMETER_NAME_FOG_SOURCE for further documentation of this559* parameter.560*561* \since 1.15562*/563enum vkd3d_shader_fog_source564{565/**566* The source shader is not modified. That is, the fog varying in the target567* shader is the original fog varying if and only if present.568*/569VKD3D_SHADER_FOG_SOURCE_FOG = 0x0,570/**571* If the source shader has a fog varying, it is not modified.572* Otherwise, if the source shader outputs a varying with semantic name573* "COLOR" and semantic index 1 whose index includes a W component,574* said W component is output as fog varying.575* Otherwise, no fog varying is output.576*/577VKD3D_SHADER_FOG_SOURCE_FOG_OR_SPECULAR_W = 0x1,578/**579* The fog source is the Z component of the position output by the vertex580* shader.581*/582VKD3D_SHADER_FOG_SOURCE_Z = 0x2,583/**584* The fog source is the W component of the position output by the vertex585* shader.586*/587VKD3D_SHADER_FOG_SOURCE_W = 0x3,588589VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_FOG_SOURCE),590};591592/**593* The manner in which a parameter value is provided to the shader, used in594* struct vkd3d_shader_parameter and struct vkd3d_shader_parameter1.595*/596enum vkd3d_shader_parameter_type597{598VKD3D_SHADER_PARAMETER_TYPE_UNKNOWN,599/** The parameter value is embedded directly in the shader. */600VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT,601/**602* The parameter value is provided to the shader via specialization603* constants. This value is only supported for the SPIR-V target type.604*/605VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT,606/**607* The parameter value is provided to the shader as part of a uniform608* buffer.609*610* \since 1.13611*/612VKD3D_SHADER_PARAMETER_TYPE_BUFFER,613614VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARAMETER_TYPE),615};616617/**618* The format of data provided to the shader, used in619* struct vkd3d_shader_parameter and struct vkd3d_shader_parameter1.620*/621enum vkd3d_shader_parameter_data_type622{623VKD3D_SHADER_PARAMETER_DATA_TYPE_UNKNOWN,624/** The parameter is provided as a 32-bit unsigned integer. */625VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32,626/** The parameter is provided as a 32-bit float. \since 1.13 */627VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32,628/**629* The parameter is provided as a 4-dimensional vector of 32-bit floats.630* This parameter must be used with struct vkd3d_shader_parameter1;631* it cannot be used with struct vkd3d_shader_parameter.632* \since 1.14633*/634VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4,635636VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARAMETER_DATA_TYPE),637};638639/**640* Names a specific shader parameter, used in641* struct vkd3d_shader_parameter and struct vkd3d_shader_parameter1.642*/643enum vkd3d_shader_parameter_name644{645VKD3D_SHADER_PARAMETER_NAME_UNKNOWN,646/**647* The sample count of the framebuffer, as returned by the HLSL function648* GetRenderTargetSampleCount() or the GLSL builtin gl_NumSamples.649*650* This parameter should be specified when compiling to SPIR-V, which651* provides no builtin ability to query this information from the shader.652*653* The default value is 1.654*655* The data type for this parameter must be656* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.657*/658VKD3D_SHADER_PARAMETER_NAME_RASTERIZER_SAMPLE_COUNT,659/**660* Alpha test comparison function. When this parameter is provided, if the661* alpha component of the pixel shader colour output at location 0 fails the662* test, as defined by this function and the reference value provided by663* VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_REF, the fragment will be664* discarded.665*666* This parameter, along with VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_REF,667* can be used to implement fixed function alpha test, as present in668* Direct3D versions up to 9, if the target environment does not support669* alpha test as part of its own fixed-function API (as Vulkan and core670* OpenGL).671*672* The default value is VKD3D_SHADER_COMPARISON_FUNC_ALWAYS.673*674* The data type for this parameter must be675* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32. The value specified must be676* a member of enum vkd3d_shader_comparison_func.677*678* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this679* version of vkd3d-shader.680*681* \since 1.13682*/683VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_FUNC,684/**685* Alpha test reference value.686* See VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_FUNC for documentation of687* alpha test.688*689* The default value is zero.690*691* \since 1.13692*/693VKD3D_SHADER_PARAMETER_NAME_ALPHA_TEST_REF,694/**695* Whether to use flat interpolation for fragment shader colour inputs.696* If the value is nonzero, inputs whose semantic usage is COLOR will use697* flat interpolation instead of linear.698* This parameter is ignored if the shader model is 4 or greater, since only699* shader model 3 and below do not specify the interpolation mode in the700* shader bytecode.701*702* This parameter can be used to implement fixed function shade mode, as703* present in Direct3D versions up to 9, if the target environment does not704* support shade mode as part of its own fixed-function API (as Vulkan and705* core OpenGL).706*707* The data type for this parameter must be708* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.709*710* The default value is zero, i.e. use linear interpolation.711*712* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this713* version of vkd3d-shader.714*715* \since 1.13716*/717VKD3D_SHADER_PARAMETER_NAME_FLAT_INTERPOLATION,718/**719* A mask of enabled clip planes.720*721* When this parameter is provided to a vertex shader, for each nonzero bit722* of this mask, a user clip distance will be generated from vertex position723* in clip space, and the clip plane defined by the indexed vector, taken724* from the VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_# parameter.725*726* Regardless of the specific clip planes which are enabled, the clip727* distances which are output are a contiguous array starting from clip728* distance 0. This affects the interface of OpenGL. For example, if only729* clip planes 1 and 3 are enabled (and so the value of the mask is 0xa),730* the user should enable only GL_CLIP_DISTANCE0 and GL_CLIP_DISTANCE1.731*732* The default value is zero, i.e. do not enable any clip planes.733*734* The data type for this parameter must be735* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.736*737* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this738* version of vkd3d-shader.739*740* If the source shader writes clip distances and this parameter is nonzero,741* compilation fails.742*743* \since 1.14744*/745VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_MASK,746/**747* Clip plane values.748* See VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_MASK for documentation of749* clip planes.750*751* These enum values are contiguous and arithmetic may safely be performed752* on them. That is, VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_[n] is753* VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_0 plus n.754*755* The data type for each parameter must be756* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4.757*758* The default value for each plane is a (0, 0, 0, 0) vector.759*760* \since 1.14761*/762VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_0,763VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_1,764VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_2,765VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_3,766VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_4,767VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_5,768VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_6,769VKD3D_SHADER_PARAMETER_NAME_CLIP_PLANE_7,770/**771* Point size.772*773* When this parameter is provided to a vertex, tessellation, or geometry774* shader, and the source shader does not write point size, it specifies a775* uniform value which will be written to point size.776* If the source shader writes point size, this parameter is ignored.777*778* This parameter can be used to implement fixed function point size, as779* present in Direct3D versions 8 and 9, if the target environment does not780* support point size as part of its own fixed-function API (as Vulkan and781* core OpenGL).782*783* The data type for this parameter must be784* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.785*786* \since 1.14787*/788VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE,789/**790* Minimum point size.791*792* When this parameter is provided to a vertex, tessellation, or geometry793* shader, and the source shader writes point size or uses the794* VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE parameter, the point size will795* be clamped to the provided minimum value.796* If point size is not written in one of these ways,797* this parameter is ignored.798* If this parameter is not provided, the point size will not be clamped799* to a minimum size by vkd3d-shader.800*801* This parameter can be used to implement fixed function point size, as802* present in Direct3D versions 8 and 9, if the target environment does not803* support point size as part of its own fixed-function API (as Vulkan and804* core OpenGL).805*806* The data type for this parameter must be807* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.808*809* \since 1.14810*/811VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MIN,812/**813* Maximum point size.814*815* This parameter has identical behaviour to816* VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MIN, except that it provides817* the maximum size rather than the minimum.818*819* \since 1.14820*/821VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MAX,822/**823* Whether texture coordinate inputs should take their values from the824* point coordinate.825*826* When this parameter is provided to a pixel shader, and the value is827* nonzero, any fragment shader input with the semantic name "TEXCOORD"828* takes its value from the point coordinates instead of from the previous829* shader. The point coordinates here are defined as a four-component vector830* whose X and Y components are the X and Y coordinates of the fragment831* within a point being rasterized, and whose Z and W components are zero.832*833* In GLSL, the X and Y components are drawn from gl_PointCoord; in SPIR-V,834* they are drawn from a variable with the BuiltinPointCoord decoration.835*836* This includes t# fragment shader inputs in shader model 2 shaders,837* as well as texture sampling in shader model 1 shaders.838*839* This parameter can be used to implement fixed function point sprite, as840* present in Direct3D versions 8 and 9, if the target environment does not841* support point sprite as part of its own fixed-function API (as Vulkan and842* core OpenGL).843*844* The data type for this parameter must be845* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.846*847* The default value is zero, i.e. use the original varyings.848*849* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this850* version of vkd3d-shader.851*852* \since 1.14853*/854VKD3D_SHADER_PARAMETER_NAME_POINT_SPRITE,855/**856* Fog mode used in fragment shaders.857*858* The value specified by this parameter must be a member of859* enum vkd3d_shader_fog_fragment_mode.860*861* If not VKD3D_SHADER_FOG_FRAGMENT_NONE, the pixel shader colour output at862* location 0 is linearly interpolated with the fog colour defined by863* VKD3D_SHADER_PARAMETER_NAME_FOG_COLOUR. The interpolation factor is864* defined according to the enumerant selected by this parameter.865* The interpolated value is then outputted instead of the original value at866* location 0.867*868* An interpolation factor of 0 specifies to use the fog colour; a factor of869* 1 specifies to use the original colour output. The interpolation factor870* is clamped to the [0, 1] range before interpolating.871*872* The default value is VKD3D_SHADER_FOG_FRAGMENT_NONE.873*874* The data type for this parameter must be875* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.876*877* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this878* version of vkd3d-shader.879*880* \since 1.15881*/882VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE,883/**884* Fog colour.885* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for documentation of886* fog.887*888* The data type for this parameter must be889* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4.890*891* The default value is transparent black, i.e. the vector {0, 0, 0, 0}.892*893* \since 1.15894*/895VKD3D_SHADER_PARAMETER_NAME_FOG_COLOUR,896/**897* End coordinate for linear fog.898* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for documentation of899* fog.900*901* The data type for this parameter must be902* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.903*904* The default value is 1.0.905*906* \since 1.15907*/908VKD3D_SHADER_PARAMETER_NAME_FOG_END,909/**910* Scale value for fog.911* See VKD3D_SHADER_PARAMETER_NAME_FOG_FRAGMENT_MODE for documentation of912* fog.913*914* The data type for this parameter must be915* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.916*917* The default value is 1.0.918*919* \since 1.15920*/921VKD3D_SHADER_PARAMETER_NAME_FOG_SCALE,922/**923* Fog source. The value specified by this parameter must be a member of924* enum vkd3d_shader_fog_source.925*926* This parameter replaces or suppletes the fog varying output by a927* pre-rasterization shader. The fog varying is defined as the output928* varying with the semantic name "FOG" and semantic index 0.929*930* Together with other fog parameters, this parameter can be used to931* implement fixed function fog, as present in Direct3D versions up to 9,932* if the target environment does not support fog as part of its own933* fixed-function API (as Vulkan and core OpenGL).934*935* The default value is VKD3D_SHADER_FOG_SOURCE_FOG.936*937* The data type for this parameter must be938* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.939*940* Only VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT is supported in this941* version of vkd3d-shader.942*943* \since 1.15944*/945VKD3D_SHADER_PARAMETER_NAME_FOG_SOURCE,946947VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_PARAMETER_NAME),948};949950/**951* The value of an immediate constant parameter, used in952* struct vkd3d_shader_parameter.953*/954struct vkd3d_shader_parameter_immediate_constant955{956union957{958/**959* The value if the parameter's data type is960* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.961*/962uint32_t u32;963/**964* The value if the parameter's data type is965* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.966*967* \since 1.13968*/969float f32;970} u;971};972973/**974* The value of an immediate constant parameter, used in975* struct vkd3d_shader_parameter1.976*977* \since 1.13978*/979struct vkd3d_shader_parameter_immediate_constant1980{981union982{983/**984* The value if the parameter's data type is985* VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32.986*/987uint32_t u32;988/**989* The value if the parameter's data type is990* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32.991*/992float f32;993/**994* A pointer to the value if the parameter's data type is995* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4.996*997* \since 1.14998*/999float f32_vec4[4];1000void *_pointer_pad;1001uint32_t _pad[4];1002} u;1003};10041005/**1006* The linkage of a specialization constant parameter, used in1007* struct vkd3d_shader_parameter and struct vkd3d_shader_parameter1.1008*/1009struct vkd3d_shader_parameter_specialization_constant1010{1011/**1012* The ID of the specialization constant.1013* If the type comprises more than one constant, such as1014* VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32_VEC4, then a contiguous1015* array of specialization constants should be used, one for each component,1016* and this ID should point to the first component.1017*/1018uint32_t id;1019};10201021/**1022* The linkage of a parameter specified through a uniform buffer, used in1023* struct vkd3d_shader_parameter1.1024*/1025struct vkd3d_shader_parameter_buffer1026{1027/**1028* The set of the uniform buffer descriptor. If the target environment does1029* not support descriptor sets, this value must be set to 0.1030*/1031unsigned int set;1032/** The binding index of the uniform buffer descriptor. */1033unsigned int binding;1034/** The byte offset of the parameter within the buffer. */1035uint32_t offset;1036};10371038/**1039* An individual shader parameter.1040*1041* This structure is an earlier version of struct vkd3d_shader_parameter11042* which supports fewer parameter types;1043* refer to that structure for usage information.1044*1045* Only the following types may be used with this structure:1046*1047* - VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT1048* - VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT1049*/1050struct vkd3d_shader_parameter1051{1052enum vkd3d_shader_parameter_name name;1053enum vkd3d_shader_parameter_type type;1054enum vkd3d_shader_parameter_data_type data_type;1055union1056{1057struct vkd3d_shader_parameter_immediate_constant immediate_constant;1058struct vkd3d_shader_parameter_specialization_constant specialization_constant;1059} u;1060};10611062/**1063* An individual shader parameter.1064*1065* This structure is used in struct vkd3d_shader_parameter_info; see there for1066* explanation of shader parameters.1067*1068* For example, to specify the rasterizer sample count to the shader via an1069* unsigned integer specialization constant with ID 3,1070* set the following members:1071*1072* - \a name = VKD3D_SHADER_PARAMETER_NAME_RASTERIZER_SAMPLE_COUNT1073* - \a type = VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT1074* - \a data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT321075* - \a u.specialization_constant.id = 31076*1077* This structure is an extended version of struct vkd3d_shader_parameter.1078*/1079struct vkd3d_shader_parameter11080{1081/** The builtin parameter to be mapped. */1082enum vkd3d_shader_parameter_name name;1083/** How the parameter will be provided to the shader. */1084enum vkd3d_shader_parameter_type type;1085/**1086* The data type of the supplied parameter, which determines how it is to1087* be interpreted.1088*/1089enum vkd3d_shader_parameter_data_type data_type;1090union1091{1092/**1093* Additional information if \a type is1094* VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT.1095*/1096struct vkd3d_shader_parameter_immediate_constant1 immediate_constant;1097/**1098* Additional information if \a type is1099* VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT.1100*/1101struct vkd3d_shader_parameter_specialization_constant specialization_constant;1102/**1103* Additional information if \a type is1104* VKD3D_SHADER_PARAMETER_TYPE_BUFFER.1105*/1106struct vkd3d_shader_parameter_buffer buffer;1107void *_pointer_pad;1108uint32_t _pad[4];1109} u;1110};11111112/**1113* Symbolic register indices for mapping uniform constant register sets in1114* legacy Direct3D bytecode to constant buffer views in the target environment.1115*1116* Members of this enumeration are used in1117* \ref vkd3d_shader_resource_binding.register_index.1118*1119* \since 1.91120*/1121enum vkd3d_shader_d3dbc_constant_register1122{1123/** The float constant register set, c# in Direct3D assembly. */1124VKD3D_SHADER_D3DBC_FLOAT_CONSTANT_REGISTER = 0x0,1125/** The integer constant register set, i# in Direct3D assembly. */1126VKD3D_SHADER_D3DBC_INT_CONSTANT_REGISTER = 0x1,1127/** The boolean constant register set, b# in Direct3D assembly. */1128VKD3D_SHADER_D3DBC_BOOL_CONSTANT_REGISTER = 0x2,11291130VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_D3DBC_CONSTANT_REGISTER),1131};11321133/**1134* Describes the mapping of a single resource or resource array to its binding1135* point in the target environment.1136*1137* For example, to map a Direct3D SRV with register space 2, register "t3" to1138* a Vulkan descriptor in set 4 and with binding 5, set the following members:1139* - \a type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV1140* - \a register_space = 21141* - \a register_index = 31142* - \a binding.set = 41143* - \a binding.binding = 51144* - \a binding.count = 11145*1146* This structure is used in struct vkd3d_shader_interface_info.1147*/1148struct vkd3d_shader_resource_binding1149{1150/** The type of this descriptor. */1151enum vkd3d_shader_descriptor_type type;1152/**1153* Register space of the Direct3D resource. If the source format does not1154* support multiple register spaces, this parameter must be set to 0.1155*/1156unsigned int register_space;1157/**1158* Register index of the Direct3D resource.1159*1160* For legacy Direct3D shaders, vkd3d-shader maps each constant register1161* set to a single constant buffer view. This parameter names the register1162* set to map, and must be a member of1163* enum vkd3d_shader_d3dbc_constant_register.1164*/1165unsigned int register_index;1166/** Shader stage(s) to which the resource is visible. */1167enum vkd3d_shader_visibility shader_visibility;1168/** A combination of zero or more elements of vkd3d_shader_binding_flag. */1169unsigned int flags;11701171/** The binding in the target environment. */1172struct vkd3d_shader_descriptor_binding binding;1173};11741175#define VKD3D_SHADER_DUMMY_SAMPLER_INDEX ~0u11761177/**1178* Describes the mapping of a Direct3D resource-sampler pair to a combined1179* sampler (i.e. sampled image).1180*1181* This structure is used in struct vkd3d_shader_interface_info.1182*/1183struct vkd3d_shader_combined_resource_sampler1184{1185/**1186* Register space of the Direct3D resource. If the source format does not1187* support multiple register spaces, this parameter must be set to 0.1188*/1189unsigned int resource_space;1190/** Register index of the Direct3D resource. */1191unsigned int resource_index;1192/**1193* Register space of the Direct3D sampler. If the source format does not1194* support multiple register spaces, this parameter must be set to 0.1195*/1196unsigned int sampler_space;1197/** Register index of the Direct3D sampler. */1198unsigned int sampler_index;1199/** Shader stage(s) to which the resource is visible. */1200enum vkd3d_shader_visibility shader_visibility;1201/** A combination of zero or more elements of vkd3d_shader_binding_flag. */1202unsigned int flags;12031204/** The binding in the target environment. */1205struct vkd3d_shader_descriptor_binding binding;1206};12071208/**1209* Describes the mapping of a single Direct3D UAV counter.1210*1211* This structure is used in struct vkd3d_shader_interface_info.1212*/1213struct vkd3d_shader_uav_counter_binding1214{1215/**1216* Register space of the Direct3D UAV descriptor. If the source format does1217* not support multiple register spaces, this parameter must be set to 0.1218*/1219unsigned int register_space;1220/** Register index of the Direct3D UAV descriptor. */1221unsigned int register_index;1222/** Shader stage(s) to which the UAV counter is visible. */1223enum vkd3d_shader_visibility shader_visibility;12241225/** The binding in the target environment. */1226struct vkd3d_shader_descriptor_binding binding;1227unsigned int offset;1228};12291230/**1231* Describes the mapping of a Direct3D constant buffer to a range of push1232* constants in the target environment.1233*1234* This structure is used in struct vkd3d_shader_interface_info.1235*/1236struct vkd3d_shader_push_constant_buffer1237{1238/**1239* Register space of the Direct3D resource. If the source format does not1240* support multiple register spaces, this parameter must be set to 0.1241*/1242unsigned int register_space;1243/** Register index of the Direct3D resource. */1244unsigned int register_index;1245/** Shader stage(s) to which the resource is visible. */1246enum vkd3d_shader_visibility shader_visibility;12471248/** Offset, in bytes, of the target push constants. */1249unsigned int offset;1250/** Size, in bytes, of the target push constants. */1251unsigned int size;1252};12531254/**1255* A chained structure describing the interface between a compiled shader and1256* the target environment.1257*1258* For example, when compiling Direct3D shader byte code to SPIR-V, this1259* structure contains mappings from Direct3D descriptor registers to SPIR-V1260* descriptor bindings.1261*1262* This structure is optional. If omitted, vkd3d_shader_compile() will use a1263* default mapping, in which resources are mapped to sequential bindings in1264* register set 0.1265*1266* This structure extends vkd3d_shader_compile_info.1267*1268* This structure contains only input parameters.1269*/1270struct vkd3d_shader_interface_info1271{1272/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO. */1273enum vkd3d_shader_structure_type type;1274/** Optional pointer to a structure containing further parameters. */1275const void *next;12761277/** Pointer to an array of bindings for shader resource descriptors. */1278const struct vkd3d_shader_resource_binding *bindings;1279/** Size, in elements, of \ref bindings. */1280unsigned int binding_count;12811282/** Pointer to an array of bindings for push constant buffers. */1283const struct vkd3d_shader_push_constant_buffer *push_constant_buffers;1284/** Size, in elements, of \ref push_constant_buffers. */1285unsigned int push_constant_buffer_count;12861287/** Pointer to an array of bindings for combined samplers. */1288const struct vkd3d_shader_combined_resource_sampler *combined_samplers;1289/** Size, in elements, of \ref combined_samplers. */1290unsigned int combined_sampler_count;12911292/** Pointer to an array of bindings for UAV counters. */1293const struct vkd3d_shader_uav_counter_binding *uav_counters;1294/** Size, in elements, of \ref uav_counters. */1295unsigned int uav_counter_count;1296};12971298struct vkd3d_shader_transform_feedback_element1299{1300unsigned int stream_index;1301const char *semantic_name;1302unsigned int semantic_index;1303uint8_t component_index;1304uint8_t component_count;1305uint8_t output_slot;1306};13071308/* Extends vkd3d_shader_interface_info. */1309struct vkd3d_shader_transform_feedback_info1310{1311enum vkd3d_shader_structure_type type;1312const void *next;13131314const struct vkd3d_shader_transform_feedback_element *elements;1315unsigned int element_count;1316const unsigned int *buffer_strides;1317unsigned int buffer_stride_count;1318};13191320struct vkd3d_shader_descriptor_offset1321{1322unsigned int static_offset;1323unsigned int dynamic_offset_index;1324};13251326/**1327* A chained structure containing descriptor offsets.1328*1329* This structure is optional.1330*1331* This structure extends vkd3d_shader_interface_info.1332*1333* This structure contains only input parameters.1334*1335* \since 1.31336*/1337struct vkd3d_shader_descriptor_offset_info1338{1339/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_DESCRIPTOR_OFFSET_INFO. */1340enum vkd3d_shader_structure_type type;1341/** Optional pointer to a structure containing further parameters. */1342const void *next;13431344/**1345* Byte offset within the push constants of an array of 32-bit1346* descriptor array offsets. See the description of 'binding_offsets'1347* below.1348*/1349unsigned int descriptor_table_offset;1350/** Size, in elements, of the descriptor table push constant array. */1351unsigned int descriptor_table_count;13521353/**1354* Pointer to an array of struct vkd3d_shader_descriptor_offset objects.1355* The 'static_offset' field contains an offset into the descriptor arrays1356* referenced by the 'bindings' array in struct vkd3d_shader_interface_info.1357* This allows mapping multiple shader resource arrays to a single binding1358* point in the target environment.1359*1360* 'dynamic_offset_index' in struct vkd3d_shader_descriptor_offset allows1361* offsets to be set at runtime. The 32-bit descriptor table push constant1362* at this index will be added to 'static_offset' to calculate the final1363* binding offset.1364*1365* If runtime offsets are not required, set all 'dynamic_offset_index'1366* values to \c ~0u and 'descriptor_table_count' to zero.1367*1368* For example, to map Direct3D constant buffer registers 'cb0[0:3]' and1369* 'cb1[6:7]' to descriptors 8-12 and 4-5 in the Vulkan descriptor array in1370* descriptor set 3 and with binding 2, set the following values in the1371* 'bindings' array in struct vkd3d_shader_interface_info:1372*1373* \code1374* type = VKD3D_SHADER_DESCRIPTOR_TYPE_CBV1375* register_space = 01376* register_index = 01377* binding.set = 31378* binding.binding = 21379* binding.count = 41380*1381* type = VKD3D_SHADER_DESCRIPTOR_TYPE_CBV1382* register_space = 01383* register_index = 61384* binding.set = 31385* binding.binding = 21386* binding.count = 21387* \endcode1388*1389* and then pass \c {8, \c 4} as static binding offsets here.1390*1391* This field may be NULL, in which case the corresponding offsets are1392* specified to be 0.1393*/1394const struct vkd3d_shader_descriptor_offset *binding_offsets;13951396/**1397* Pointer to an array of offsets into the descriptor arrays referenced by1398* the 'uav_counters' array in struct vkd3d_shader_interface_info. This1399* works the same way as \ref binding_offsets above.1400*/1401const struct vkd3d_shader_descriptor_offset *uav_counter_offsets;1402};14031404/** The format of a shader to be compiled or scanned. */1405enum vkd3d_shader_source_type1406{1407/**1408* The shader has no type or is to be ignored. This is not a valid value1409* for vkd3d_shader_compile() or vkd3d_shader_scan().1410*/1411VKD3D_SHADER_SOURCE_NONE,1412/**1413* A 'Tokenized Program Format' shader embedded in a DXBC container. This is1414* the format used for Direct3D shader model 4 and 5 shaders.1415*/1416VKD3D_SHADER_SOURCE_DXBC_TPF,1417/** High-Level Shader Language source code. \since 1.3 */1418VKD3D_SHADER_SOURCE_HLSL,1419/**1420* Legacy Direct3D byte-code. This is the format used for Direct3D shader1421* model 1, 2, and 3 shaders. \since 1.31422*/1423VKD3D_SHADER_SOURCE_D3D_BYTECODE,1424/**1425* A 'DirectX Intermediate Language' shader embedded in a DXBC container. This is1426* the format used for Direct3D shader model 6 shaders. \since 1.91427*/1428VKD3D_SHADER_SOURCE_DXBC_DXIL,1429/**1430* Binary format used by Direct3D 9/10.x/11 effects.1431* Input is a raw FX section without container. \since 1.141432*/1433VKD3D_SHADER_SOURCE_FX,1434/**1435* A D3DX texture shader. This is the format used for the 'tx_1_0' HLSL1436* target profile. \since 1.171437*/1438VKD3D_SHADER_SOURCE_TX,14391440VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SOURCE_TYPE),1441};14421443/** The output format of a compiled shader. */1444enum vkd3d_shader_target_type1445{1446/**1447* The shader has no type or is to be ignored. This is not a valid value1448* for vkd3d_shader_compile().1449*/1450VKD3D_SHADER_TARGET_NONE,1451/**1452* A SPIR-V shader in binary form. This is the format used for Vulkan1453* shaders.1454*/1455VKD3D_SHADER_TARGET_SPIRV_BINARY,1456VKD3D_SHADER_TARGET_SPIRV_TEXT,1457/**1458* Direct3D shader assembly. \since 1.31459*/1460VKD3D_SHADER_TARGET_D3D_ASM,1461/**1462* Legacy Direct3D byte-code. This is the format used for Direct3D shader1463* model 1, 2, and 3 shaders. \since 1.31464*/1465VKD3D_SHADER_TARGET_D3D_BYTECODE,1466/**1467* A 'Tokenized Program Format' shader embedded in a DXBC container. This is1468* the format used for Direct3D shader model 4 and 5 shaders. \since 1.31469*/1470VKD3D_SHADER_TARGET_DXBC_TPF,1471/**1472* An 'OpenGL Shading Language' shader. \since 1.31473*/1474VKD3D_SHADER_TARGET_GLSL,1475/**1476* Binary format used by Direct3D 9/10.x/11 effects profiles.1477* Output is a raw FX section without container. \since 1.111478*/1479VKD3D_SHADER_TARGET_FX,1480/**1481* A 'Metal Shading Language' shader. \since 1.141482*/1483VKD3D_SHADER_TARGET_MSL,14841485VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TARGET_TYPE),1486};14871488/**1489* Describes the minimum severity of compilation messages returned by1490* vkd3d_shader_compile() and similar functions.1491*/1492enum vkd3d_shader_log_level1493{1494/** No messages will be returned. */1495VKD3D_SHADER_LOG_NONE,1496/** Only fatal errors which prevent successful compilation will be returned. */1497VKD3D_SHADER_LOG_ERROR,1498/** Non-fatal warnings and fatal errors will be returned. */1499VKD3D_SHADER_LOG_WARNING,1500/**1501* All messages, including general informational messages, will be returned.1502*/1503VKD3D_SHADER_LOG_INFO,15041505VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_LOG_LEVEL),1506};15071508/**1509* A chained structure containing compilation parameters.1510*/1511struct vkd3d_shader_compile_info1512{1513/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO. */1514enum vkd3d_shader_structure_type type;1515/**1516* Optional pointer to a structure containing further parameters. For a list1517* of valid structures, refer to the respective function documentation. If1518* no further parameters are needed, this field should be set to NULL.1519*/1520const void *next;15211522/** Input source code or byte code. */1523struct vkd3d_shader_code source;15241525/** Format of the input code passed in \ref source. */1526enum vkd3d_shader_source_type source_type;1527/** Desired output format. */1528enum vkd3d_shader_target_type target_type;15291530/**1531* Pointer to an array of compilation options. This field is ignored if1532* \ref option_count is zero, but must be valid otherwise.1533*1534* If the same option is specified multiple times, only the last value is1535* used.1536*1537* Options not relevant to or not supported by a particular shader compiler1538* or scanner will be ignored.1539*/1540const struct vkd3d_shader_compile_option *options;1541/** Size, in elements, of \ref options. */1542unsigned int option_count;15431544/** Minimum severity of messages returned from the shader function. */1545enum vkd3d_shader_log_level log_level;1546/**1547* Name of the initial source file, which may be used in error messages or1548* debug information. This parameter is optional and may be NULL.1549*/1550const char *source_name;1551};15521553enum vkd3d_shader_spirv_environment1554{1555VKD3D_SHADER_SPIRV_ENVIRONMENT_NONE,1556VKD3D_SHADER_SPIRV_ENVIRONMENT_OPENGL_4_5,1557VKD3D_SHADER_SPIRV_ENVIRONMENT_VULKAN_1_0, /* default target */1558/** \since 1.12 */1559VKD3D_SHADER_SPIRV_ENVIRONMENT_VULKAN_1_1,15601561VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SPIRV_ENVIRONMENT),1562};15631564enum vkd3d_shader_spirv_extension1565{1566VKD3D_SHADER_SPIRV_EXTENSION_NONE,1567VKD3D_SHADER_SPIRV_EXTENSION_EXT_DEMOTE_TO_HELPER_INVOCATION,1568/** \since 1.3 */1569VKD3D_SHADER_SPIRV_EXTENSION_EXT_DESCRIPTOR_INDEXING,1570/** \since 1.3 */1571VKD3D_SHADER_SPIRV_EXTENSION_EXT_STENCIL_EXPORT,1572/** \since 1.11 */1573VKD3D_SHADER_SPIRV_EXTENSION_EXT_VIEWPORT_INDEX_LAYER,1574/** \since 1.12 */1575VKD3D_SHADER_SPIRV_EXTENSION_EXT_FRAGMENT_SHADER_INTERLOCK,15761577VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SPIRV_EXTENSION),1578};15791580/* Extends vkd3d_shader_compile_info. */1581struct vkd3d_shader_spirv_target_info1582{1583enum vkd3d_shader_structure_type type;1584const void *next;15851586const char *entry_point; /* "main" if NULL. */15871588enum vkd3d_shader_spirv_environment environment;15891590const enum vkd3d_shader_spirv_extension *extensions;1591unsigned int extension_count;15921593const struct vkd3d_shader_parameter *parameters;1594unsigned int parameter_count;15951596bool dual_source_blending;1597const unsigned int *output_swizzles;1598unsigned int output_swizzle_count;1599};16001601enum vkd3d_shader_tessellator_output_primitive1602{1603VKD3D_SHADER_TESSELLATOR_OUTPUT_POINT = 0x1,1604VKD3D_SHADER_TESSELLATOR_OUTPUT_LINE = 0x2,1605VKD3D_SHADER_TESSELLATOR_OUTPUT_TRIANGLE_CW = 0x3,1606VKD3D_SHADER_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 0x4,16071608VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TESSELLATOR_OUTPUT_PRIMITIVE),1609};16101611enum vkd3d_shader_tessellator_partitioning1612{1613VKD3D_SHADER_TESSELLATOR_PARTITIONING_INTEGER = 0x1,1614VKD3D_SHADER_TESSELLATOR_PARTITIONING_POW2 = 0x2,1615VKD3D_SHADER_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 0x3,1616VKD3D_SHADER_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 0x4,16171618VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TESSELLATOR_PARTITIONING),1619};16201621/* Extends vkd3d_shader_spirv_target_info. */1622struct vkd3d_shader_spirv_domain_shader_target_info1623{1624enum vkd3d_shader_structure_type type;1625const void *next;16261627enum vkd3d_shader_tessellator_output_primitive output_primitive;1628enum vkd3d_shader_tessellator_partitioning partitioning;1629};16301631/**1632* A single preprocessor macro, passed as part of struct1633* vkd3d_shader_preprocess_info.1634*/1635struct vkd3d_shader_macro1636{1637/**1638* Pointer to a null-terminated string containing the name of a macro. This1639* macro must not be a parameterized (i.e. function-like) macro. If this1640* field is not a valid macro identifier, this macro will be ignored.1641*/1642const char *name;1643/**1644* Optional pointer to a null-terminated string containing the expansion of1645* the macro. This field may be set to NULL, in which case the macro has an1646* empty expansion.1647*/1648const char *value;1649};16501651/**1652* Type of a callback function which will be used to open preprocessor includes.1653*1654* This callback function is passed as part of struct1655* vkd3d_shader_preprocess_info.1656*1657* If this function fails, vkd3d-shader will emit a compilation error, and the1658* \a pfn_close_include callback will not be called.1659*1660* \param filename Unquoted string used as an argument to the \#include1661* directive.1662*1663* \param local Whether the \#include directive is requesting a local (i.e.1664* double-quoted) or system (i.e. angle-bracketed) include.1665*1666* \param parent_data Unprocessed source code of the file in which this1667* \#include directive is evaluated. This parameter may be NULL.1668*1669* \param context The user-defined pointer passed to struct1670* vkd3d_shader_preprocess_info.1671*1672* \param out Output location for the full contents of the included file. The1673* code need not be allocated using standard vkd3d functions, but must remain1674* valid until the corresponding call to \a pfn_close_include. If this function1675* fails, the contents of this parameter are ignored.1676*1677* \return A member of \ref vkd3d_result.1678*/1679typedef int (*PFN_vkd3d_shader_open_include)(const char *filename, bool local,1680const char *parent_data, void *context, struct vkd3d_shader_code *out);1681/**1682* Type of a callback function which will be used to close preprocessor1683* includes.1684*1685* This callback function is passed as part of struct1686* vkd3d_shader_preprocess_info.1687*1688* \param code Contents of the included file, which were allocated by the1689* vkd3d_shader_preprocess_info.pfn_open_include callback.1690* The user must free them.1691*1692* \param context The user-defined pointer passed to struct1693* vkd3d_shader_preprocess_info.1694*/1695typedef void (*PFN_vkd3d_shader_close_include)(const struct vkd3d_shader_code *code, void *context);16961697/**1698* A chained structure containing preprocessing parameters.1699*1700* This structure is optional.1701*1702* This structure extends vkd3d_shader_compile_info.1703*1704* This structure contains only input parameters.1705*1706* \since 1.31707*/1708struct vkd3d_shader_preprocess_info1709{1710/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_PREPROCESS_INFO. */1711enum vkd3d_shader_structure_type type;1712/** Optional pointer to a structure containing further parameters. */1713const void *next;17141715/**1716* Pointer to an array of predefined macros. Each macro in this array will1717* be expanded as if a corresponding \#define statement were prepended to1718* the source code.1719*1720* If the same macro is specified multiple times, only the last value is1721* used.1722*/1723const struct vkd3d_shader_macro *macros;1724/** Size, in elements, of \ref macros. */1725unsigned int macro_count;17261727/**1728* Optional pointer to a callback function, which will be called in order to1729* evaluate \#include directives. The function receives parameters1730* corresponding to the directive's arguments, and should return the1731* complete text of the included file.1732*1733* If this field is set to NULL, or if this structure is omitted,1734* vkd3d-shader will attempt to open included files using POSIX file APIs.1735*1736* If this field is set to NULL, the \ref pfn_close_include field must also1737* be set to NULL.1738*/1739PFN_vkd3d_shader_open_include pfn_open_include;1740/**1741* Optional pointer to a callback function, which will be called whenever an1742* included file is closed. This function will be called exactly once for1743* each successful call to \ref pfn_open_include, and should be used to free1744* any resources allocated thereby.1745*1746* If this field is set to NULL, the \ref pfn_open_include field must also1747* be set to NULL.1748*/1749PFN_vkd3d_shader_close_include pfn_close_include;1750/**1751* User-defined pointer which will be passed unmodified to the1752* \ref pfn_open_include and \ref pfn_close_include callbacks.1753*/1754void *include_context;1755};17561757/**1758* A chained structure containing HLSL compilation parameters.1759*1760* This structure is optional.1761*1762* This structure extends vkd3d_shader_compile_info.1763*1764* This structure contains only input parameters.1765*1766* \since 1.31767*/1768struct vkd3d_shader_hlsl_source_info1769{1770/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO. */1771enum vkd3d_shader_structure_type type;1772/** Optional pointer to a structure containing further parameters. */1773const void *next;17741775/**1776* Optional pointer to a null-terminated string containing the shader entry1777* point.1778*1779* If this parameter is NULL, vkd3d-shader uses the entry point "main".1780*/1781const char *entry_point;1782struct vkd3d_shader_code secondary_code;1783/**1784* Pointer to a null-terminated string containing the target shader1785* profile.1786*/1787const char *profile;1788};17891790/* root signature 1.0 */1791enum vkd3d_shader_filter1792{1793VKD3D_SHADER_FILTER_MIN_MAG_MIP_POINT = 0x000,1794VKD3D_SHADER_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x001,1795VKD3D_SHADER_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x004,1796VKD3D_SHADER_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x005,1797VKD3D_SHADER_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x010,1798VKD3D_SHADER_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x011,1799VKD3D_SHADER_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x014,1800VKD3D_SHADER_FILTER_MIN_MAG_MIP_LINEAR = 0x015,1801VKD3D_SHADER_FILTER_ANISOTROPIC = 0x055,1802VKD3D_SHADER_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x080,1803VKD3D_SHADER_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x081,1804VKD3D_SHADER_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x084,1805VKD3D_SHADER_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x085,1806VKD3D_SHADER_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x090,1807VKD3D_SHADER_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x091,1808VKD3D_SHADER_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x094,1809VKD3D_SHADER_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x095,1810VKD3D_SHADER_FILTER_COMPARISON_ANISOTROPIC = 0x0d5,1811VKD3D_SHADER_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100,1812VKD3D_SHADER_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101,1813VKD3D_SHADER_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104,1814VKD3D_SHADER_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105,1815VKD3D_SHADER_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x110,1816VKD3D_SHADER_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x111,1817VKD3D_SHADER_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x114,1818VKD3D_SHADER_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR = 0x115,1819VKD3D_SHADER_FILTER_MINIMUM_ANISOTROPIC = 0x155,1820VKD3D_SHADER_FILTER_MAXIMUM_MIN_MAG_MIP_POINT = 0x180,1821VKD3D_SHADER_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x181,1822VKD3D_SHADER_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x184,1823VKD3D_SHADER_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x185,1824VKD3D_SHADER_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x190,1825VKD3D_SHADER_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x191,1826VKD3D_SHADER_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x194,1827VKD3D_SHADER_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR = 0x195,1828VKD3D_SHADER_FILTER_MAXIMUM_ANISOTROPIC = 0x1d5,18291830VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_FILTER),1831};18321833enum vkd3d_shader_texture_address_mode1834{1835VKD3D_SHADER_TEXTURE_ADDRESS_MODE_WRAP = 0x1,1836VKD3D_SHADER_TEXTURE_ADDRESS_MODE_MIRROR = 0x2,1837VKD3D_SHADER_TEXTURE_ADDRESS_MODE_CLAMP = 0x3,1838VKD3D_SHADER_TEXTURE_ADDRESS_MODE_BORDER = 0x4,1839VKD3D_SHADER_TEXTURE_ADDRESS_MODE_MIRROR_ONCE = 0x5,18401841VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TEXTURE_ADDRESS_MODE),1842};18431844enum vkd3d_shader_comparison_func1845{1846VKD3D_SHADER_COMPARISON_FUNC_NEVER = 0x1,1847VKD3D_SHADER_COMPARISON_FUNC_LESS = 0x2,1848VKD3D_SHADER_COMPARISON_FUNC_EQUAL = 0x3,1849VKD3D_SHADER_COMPARISON_FUNC_LESS_EQUAL = 0x4,1850VKD3D_SHADER_COMPARISON_FUNC_GREATER = 0x5,1851VKD3D_SHADER_COMPARISON_FUNC_NOT_EQUAL = 0x6,1852VKD3D_SHADER_COMPARISON_FUNC_GREATER_EQUAL = 0x7,1853VKD3D_SHADER_COMPARISON_FUNC_ALWAYS = 0x8,18541855VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPARISON_FUNC),1856};18571858enum vkd3d_shader_static_border_colour1859{1860VKD3D_SHADER_STATIC_BORDER_COLOUR_TRANSPARENT_BLACK = 0x0,1861VKD3D_SHADER_STATIC_BORDER_COLOUR_OPAQUE_BLACK = 0x1,1862VKD3D_SHADER_STATIC_BORDER_COLOUR_OPAQUE_WHITE = 0x2,18631864VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STATIC_BORDER_COLOUR),1865};18661867struct vkd3d_shader_static_sampler_desc1868{1869enum vkd3d_shader_filter filter;1870enum vkd3d_shader_texture_address_mode address_u;1871enum vkd3d_shader_texture_address_mode address_v;1872enum vkd3d_shader_texture_address_mode address_w;1873float mip_lod_bias;1874unsigned int max_anisotropy;1875enum vkd3d_shader_comparison_func comparison_func;1876enum vkd3d_shader_static_border_colour border_colour;1877float min_lod;1878float max_lod;1879unsigned int shader_register;1880unsigned int register_space;1881enum vkd3d_shader_visibility shader_visibility;1882};18831884struct vkd3d_shader_descriptor_range1885{1886enum vkd3d_shader_descriptor_type range_type;1887unsigned int descriptor_count;1888unsigned int base_shader_register;1889unsigned int register_space;1890unsigned int descriptor_table_offset;1891};18921893struct vkd3d_shader_root_descriptor_table1894{1895unsigned int descriptor_range_count;1896const struct vkd3d_shader_descriptor_range *descriptor_ranges;1897};18981899struct vkd3d_shader_root_constants1900{1901unsigned int shader_register;1902unsigned int register_space;1903unsigned int value_count;1904};19051906struct vkd3d_shader_root_descriptor1907{1908unsigned int shader_register;1909unsigned int register_space;1910};19111912enum vkd3d_shader_root_parameter_type1913{1914VKD3D_SHADER_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE = 0x0,1915VKD3D_SHADER_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS = 0x1,1916VKD3D_SHADER_ROOT_PARAMETER_TYPE_CBV = 0x2,1917VKD3D_SHADER_ROOT_PARAMETER_TYPE_SRV = 0x3,1918VKD3D_SHADER_ROOT_PARAMETER_TYPE_UAV = 0x4,19191920VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_ROOT_PARAMETER_TYPE),1921};19221923struct vkd3d_shader_root_parameter1924{1925enum vkd3d_shader_root_parameter_type parameter_type;1926union1927{1928struct vkd3d_shader_root_descriptor_table descriptor_table;1929struct vkd3d_shader_root_constants constants;1930struct vkd3d_shader_root_descriptor descriptor;1931} u;1932enum vkd3d_shader_visibility shader_visibility;1933};19341935enum vkd3d_shader_root_signature_flags1936{1937VKD3D_SHADER_ROOT_SIGNATURE_FLAG_NONE = 0x00,1938VKD3D_SHADER_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT = 0x01,1939VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS = 0x02,1940VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS = 0x04,1941VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS = 0x08,1942VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS = 0x10,1943VKD3D_SHADER_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS = 0x20,1944VKD3D_SHADER_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT = 0x40,19451946VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_ROOT_SIGNATURE_FLAGS),1947};19481949struct vkd3d_shader_root_signature_desc1950{1951unsigned int parameter_count;1952const struct vkd3d_shader_root_parameter *parameters;1953unsigned int static_sampler_count;1954const struct vkd3d_shader_static_sampler_desc *static_samplers;1955enum vkd3d_shader_root_signature_flags flags;1956};19571958/* root signature 1.1 */1959enum vkd3d_shader_root_descriptor_flags1960{1961VKD3D_SHADER_ROOT_DESCRIPTOR_FLAG_NONE = 0x0,1962VKD3D_SHADER_ROOT_DESCRIPTOR_FLAG_DATA_VOLATILE = 0x2,1963VKD3D_SHADER_ROOT_DESCRIPTOR_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4,1964VKD3D_SHADER_ROOT_DESCRIPTOR_FLAG_DATA_STATIC = 0x8,19651966VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_ROOT_DESCRIPTOR_FLAGS),1967};19681969enum vkd3d_shader_descriptor_range_flags1970{1971VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_NONE = 0x0,1972VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE = 0x1,1973VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE = 0x2,1974VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4,1975VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DATA_STATIC = 0x8,1976/** \since 1.11 */1977VKD3D_SHADER_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS = 0x10000,19781979VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_RANGE_FLAGS),1980};19811982struct vkd3d_shader_descriptor_range11983{1984enum vkd3d_shader_descriptor_type range_type;1985unsigned int descriptor_count;1986unsigned int base_shader_register;1987unsigned int register_space;1988enum vkd3d_shader_descriptor_range_flags flags;1989unsigned int descriptor_table_offset;1990};19911992struct vkd3d_shader_root_descriptor_table11993{1994unsigned int descriptor_range_count;1995const struct vkd3d_shader_descriptor_range1 *descriptor_ranges;1996};19971998struct vkd3d_shader_root_descriptor11999{2000unsigned int shader_register;2001unsigned int register_space;2002enum vkd3d_shader_root_descriptor_flags flags;2003};20042005struct vkd3d_shader_root_parameter12006{2007enum vkd3d_shader_root_parameter_type parameter_type;2008union2009{2010struct vkd3d_shader_root_descriptor_table1 descriptor_table;2011struct vkd3d_shader_root_constants constants;2012struct vkd3d_shader_root_descriptor1 descriptor;2013} u;2014enum vkd3d_shader_visibility shader_visibility;2015};20162017struct vkd3d_shader_root_signature_desc12018{2019unsigned int parameter_count;2020const struct vkd3d_shader_root_parameter1 *parameters;2021unsigned int static_sampler_count;2022const struct vkd3d_shader_static_sampler_desc *static_samplers;2023enum vkd3d_shader_root_signature_flags flags;2024};20252026enum vkd3d_shader_root_signature_version2027{2028VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_0 = 0x1,2029VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_1 = 0x2,20302031VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_ROOT_SIGNATURE_VERSION),2032};20332034struct vkd3d_shader_versioned_root_signature_desc2035{2036enum vkd3d_shader_root_signature_version version;2037union2038{2039struct vkd3d_shader_root_signature_desc v_1_0;2040struct vkd3d_shader_root_signature_desc1 v_1_1;2041} u;2042};20432044/**2045* The type of a shader resource, returned as part of struct2046* vkd3d_shader_descriptor_info.2047*/2048enum vkd3d_shader_resource_type2049{2050/**2051* The type is invalid or not applicable for this descriptor. This value is2052* returned for samplers.2053*/2054VKD3D_SHADER_RESOURCE_NONE = 0x0,2055/** Dimensionless buffer. */2056VKD3D_SHADER_RESOURCE_BUFFER = 0x1,2057/** 1-dimensional texture. */2058VKD3D_SHADER_RESOURCE_TEXTURE_1D = 0x2,2059/** 2-dimensional texture. */2060VKD3D_SHADER_RESOURCE_TEXTURE_2D = 0x3,2061/** Multisampled 2-dimensional texture. */2062VKD3D_SHADER_RESOURCE_TEXTURE_2DMS = 0x4,2063/** 3-dimensional texture. */2064VKD3D_SHADER_RESOURCE_TEXTURE_3D = 0x5,2065/** Cubemap texture. */2066VKD3D_SHADER_RESOURCE_TEXTURE_CUBE = 0x6,2067/** 1-dimensional array texture. */2068VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY = 0x7,2069/** 2-dimensional array texture. */2070VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY = 0x8,2071/** Multisampled 2-dimensional array texture. */2072VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY = 0x9,2073/** Cubemap array texture. */2074VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY = 0xa,20752076VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_TYPE),2077};20782079/**2080* The type of the data contained in a shader resource, returned as part of2081* struct vkd3d_shader_descriptor_info. All formats are 32-bit.2082*/2083enum vkd3d_shader_resource_data_type2084{2085/**2086* The descriptor has no relevant data type. This value is returned for2087* samplers. \since 1.162088*/2089VKD3D_SHADER_RESOURCE_DATA_NONE = 0x0,2090/** Unsigned normalized integer. */2091VKD3D_SHADER_RESOURCE_DATA_UNORM = 0x1,2092/** Signed normalized integer. */2093VKD3D_SHADER_RESOURCE_DATA_SNORM = 0x2,2094/** Signed integer. */2095VKD3D_SHADER_RESOURCE_DATA_INT = 0x3,2096/** Unsigned integer. */2097VKD3D_SHADER_RESOURCE_DATA_UINT = 0x4,2098/** IEEE single-precision floating-point. */2099VKD3D_SHADER_RESOURCE_DATA_FLOAT = 0x5,2100/** Undefined/type-less. \since 1.3 */2101VKD3D_SHADER_RESOURCE_DATA_MIXED = 0x6,2102/** IEEE double-precision floating-point. \since 1.3 */2103VKD3D_SHADER_RESOURCE_DATA_DOUBLE = 0x7,2104/** Continuation of the previous component. For example, 64-bit2105* double-precision floating-point data may be returned as two 32-bit2106* components, with the first component (containing the LSB) specified as2107* VKD3D_SHADER_RESOURCE_DATA_DOUBLE, and the second component specified2108* as VKD3D_SHADER_RESOURCE_DATA_CONTINUED. \since 1.3 */2109VKD3D_SHADER_RESOURCE_DATA_CONTINUED = 0x8,21102111VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_DATA_TYPE),2112};21132114/**2115* Additional flags describing a shader descriptor, returned as part of struct2116* vkd3d_shader_descriptor_info.2117*/2118enum vkd3d_shader_descriptor_info_flag2119{2120/**2121* The descriptor is a UAV resource, whose counter is read from or written2122* to by the shader.2123*/2124VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER = 0x00000001,2125/** The descriptor is a UAV resource, which is read from by the shader. */2126VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ = 0x00000002,2127/** The descriptor is a comparison sampler. */2128VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE = 0x00000004,2129/** The descriptor is a UAV resource, on which the shader performs2130* atomic ops. \since 1.6 */2131VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_ATOMICS = 0x00000008,2132/** The descriptor is a raw (byte-addressed) buffer. \since 1.9 */2133VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_RAW_BUFFER = 0x00000010,21342135VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_INFO_FLAG),2136};21372138/**2139* Describes a single shader descriptor; returned as part of2140* struct vkd3d_shader_scan_descriptor_info.2141*/2142struct vkd3d_shader_descriptor_info2143{2144/** Type of the descriptor (for example, SRV, CBV, UAV, or sampler). */2145enum vkd3d_shader_descriptor_type type;2146/**2147* Register space of the resource, or 0 if the shader does not2148* support multiple register spaces.2149*/2150unsigned int register_space;2151/** Register index of the descriptor. */2152unsigned int register_index;2153/** Resource type, if applicable, including its dimension. */2154enum vkd3d_shader_resource_type resource_type;2155/** Data type contained in the resource (for example, float or integer). */2156enum vkd3d_shader_resource_data_type resource_data_type;2157/**2158* Bitwise combination of zero or more members of2159* \ref vkd3d_shader_descriptor_info_flag.2160*/2161unsigned int flags;2162/**2163* Size of this descriptor array, or 1 if a single descriptor.2164* For an unbounded array this value is ~0u.2165*/2166unsigned int count;2167};21682169/**2170* A chained structure enumerating the descriptors declared by a shader.2171*2172* This structure extends vkd3d_shader_compile_info.2173*2174* When scanning a legacy Direct3D shader, vkd3d-shader enumerates descriptors2175* as follows:2176*2177* - Each constant register set used by the shader is scanned as a single2178* constant buffer descriptor.2179* There may therefore be up to three such descriptors, one for each register2180* set used by the shader: float, integer, and boolean.2181* The fields are set as follows:2182* * The \ref vkd3d_shader_descriptor_info.type field is set to2183* VKD3D_SHADER_DESCRIPTOR_TYPE_CBV.2184* * The \ref vkd3d_shader_descriptor_info.register_space field is set to zero.2185* * The \ref vkd3d_shader_descriptor_info.register_index field is set to a2186* member of enum vkd3d_shader_d3dbc_constant_register denoting which set2187* is used.2188* * The \ref vkd3d_shader_descriptor_info.count field is set to one.2189* - Each sampler used by the shader is scanned as two separate descriptors,2190* one representing the texture, and one representing the sampler state.2191* If desired, these may be mapped back into a single combined sampler using2192* struct vkd3d_shader_combined_resource_sampler.2193* The fields are set as follows:2194* * The \ref vkd3d_shader_descriptor_info.type field is set to2195* VKD3D_SHADER_DESCRIPTOR_TYPE_SRV and VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER2196* respectively.2197* * The \ref vkd3d_shader_descriptor_info.register_space field is set to zero.2198* * The \ref vkd3d_shader_descriptor_info.register_index field is set to the2199* binding index of the original sampler, for both descriptors.2200* * The \ref vkd3d_shader_descriptor_info.count field is set to one.2201*/2202struct vkd3d_shader_scan_descriptor_info2203{2204/**2205* Input; must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_DESCRIPTOR_INFO.2206*/2207enum vkd3d_shader_structure_type type;2208/** Input; optional pointer to a structure containing further parameters. */2209const void *next;22102211/** Output; returns a pointer to an array of descriptors. */2212struct vkd3d_shader_descriptor_info *descriptors;2213/** Output; size, in elements, of \ref descriptors. */2214unsigned int descriptor_count;2215};22162217/**2218* This structure describes a single resource-sampler pair. It is returned as2219* part of struct vkd3d_shader_scan_combined_resource_sampler_info.2220*2221* \since 1.102222*/2223struct vkd3d_shader_combined_resource_sampler_info2224{2225unsigned int resource_space;2226unsigned int resource_index;2227unsigned int sampler_space;2228unsigned int sampler_index;2229};22302231/**2232* A chained structure describing the resource-sampler pairs used by a shader.2233*2234* This structure extends vkd3d_shader_compile_info.2235*2236* The information returned in this structure can be used to populate the2237* \ref vkd3d_shader_interface_info.combined_samplers field. This is2238* particularly useful when targeting environments without separate binding2239* points for samplers and resources, like OpenGL.2240*2241* No resource-sampler pairs are returned for dynamic accesses to2242* resource/sampler descriptor arrays, as can occur in Direct3D shader model2243* 5.1 shaders.2244*2245* Members of this structure are allocated by vkd3d-shader and should be freed2246* with vkd3d_shader_free_scan_combined_resource_sampler_info() when no longer2247* needed.2248*2249* \since 1.102250*/2251struct vkd3d_shader_scan_combined_resource_sampler_info2252{2253/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_COMBINED_RESOURCE_SAMPLER_INFO. */2254enum vkd3d_shader_structure_type type;2255/** Optional pointer to a structure containing further parameters. */2256const void *next;22572258/** Pointer to an array of resource-sampler pairs. */2259struct vkd3d_shader_combined_resource_sampler_info *combined_samplers;2260/** The number of resource-sampler pairs in \ref combined_samplers. */2261unsigned int combined_sampler_count;2262};22632264/**2265* A chained structure describing the tessellation information in a hull shader.2266*2267* This structure extends vkd3d_shader_compile_info.2268*2269* \since 1.152270*/2271struct vkd3d_shader_scan_hull_shader_tessellation_info2272{2273/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_HULL_SHADER_TESSELLATION_INFO. */2274enum vkd3d_shader_structure_type type;2275/** Optional pointer to a structure containing further parameters. */2276const void *next;22772278/** The tessellation output primitive. */2279enum vkd3d_shader_tessellator_output_primitive output_primitive;2280/** The tessellation partitioning mode. */2281enum vkd3d_shader_tessellator_partitioning partitioning;2282};22832284/**2285* Data type of a shader varying, returned as part of struct2286* vkd3d_shader_signature_element.2287*/2288enum vkd3d_shader_component_type2289{2290/** The varying has no type. */2291VKD3D_SHADER_COMPONENT_VOID = 0x0,2292/** 32-bit unsigned integer. */2293VKD3D_SHADER_COMPONENT_UINT = 0x1,2294/** 32-bit signed integer. */2295VKD3D_SHADER_COMPONENT_INT = 0x2,2296/** 32-bit IEEE floating-point. */2297VKD3D_SHADER_COMPONENT_FLOAT = 0x3,2298/** Boolean. */2299VKD3D_SHADER_COMPONENT_BOOL = 0x4,2300/** 64-bit IEEE floating-point. */2301VKD3D_SHADER_COMPONENT_DOUBLE = 0x5,2302/** 64-bit unsigned integer. \since 1.11 */2303VKD3D_SHADER_COMPONENT_UINT64 = 0x6,2304/** 64-bit signed integer. \since 1.16 */2305VKD3D_SHADER_COMPONENT_INT64 = 0x7,2306/** 16-bit IEEE floating-point. \since 1.16 */2307VKD3D_SHADER_COMPONENT_FLOAT16 = 0x8,2308/** 16-bit unsigned integer. \since 1.16 */2309VKD3D_SHADER_COMPONENT_UINT16 = 0x9,2310/** 16-bit signed integer. \since 1.16 */2311VKD3D_SHADER_COMPONENT_INT16 = 0xa,23122313VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPONENT_TYPE),2314};23152316/** System value semantic, returned as part of struct vkd3d_shader_signature. */2317enum vkd3d_shader_sysval_semantic2318{2319/** No system value. */2320VKD3D_SHADER_SV_NONE = 0x00,2321/** Vertex position; SV_Position in Direct3D. */2322VKD3D_SHADER_SV_POSITION = 0x01,2323/** Clip distance; SV_ClipDistance in Direct3D. */2324VKD3D_SHADER_SV_CLIP_DISTANCE = 0x02,2325/** Cull distance; SV_CullDistance in Direct3D. */2326VKD3D_SHADER_SV_CULL_DISTANCE = 0x03,2327/** Render target layer; SV_RenderTargetArrayIndex in Direct3D. */2328VKD3D_SHADER_SV_RENDER_TARGET_ARRAY_INDEX = 0x04,2329/** Viewport index; SV_ViewportArrayIndex in Direct3D. */2330VKD3D_SHADER_SV_VIEWPORT_ARRAY_INDEX = 0x05,2331/** Vertex ID; SV_VertexID in Direct3D. */2332VKD3D_SHADER_SV_VERTEX_ID = 0x06,2333/** Primitive ID; SV_PrimitiveID in Direct3D. */2334VKD3D_SHADER_SV_PRIMITIVE_ID = 0x07,2335/** Instance ID; SV_InstanceID in Direct3D. */2336VKD3D_SHADER_SV_INSTANCE_ID = 0x08,2337/** Whether the triangle is front-facing; SV_IsFrontFace in Direct3D. */2338VKD3D_SHADER_SV_IS_FRONT_FACE = 0x09,2339/** Sample index; SV_SampleIndex in Direct3D. */2340VKD3D_SHADER_SV_SAMPLE_INDEX = 0x0a,2341VKD3D_SHADER_SV_TESS_FACTOR_QUADEDGE = 0x0b,2342VKD3D_SHADER_SV_TESS_FACTOR_QUADINT = 0x0c,2343VKD3D_SHADER_SV_TESS_FACTOR_TRIEDGE = 0x0d,2344VKD3D_SHADER_SV_TESS_FACTOR_TRIINT = 0x0e,2345VKD3D_SHADER_SV_TESS_FACTOR_LINEDET = 0x0f,2346VKD3D_SHADER_SV_TESS_FACTOR_LINEDEN = 0x10,2347/** Render target; SV_Target in Direct3D. \since 1.9 */2348VKD3D_SHADER_SV_TARGET = 0x40,2349/** Depth; SV_Depth in Direct3D. \since 1.9 */2350VKD3D_SHADER_SV_DEPTH = 0x41,2351/** Sample mask; SV_Coverage in Direct3D. \since 1.9 */2352VKD3D_SHADER_SV_COVERAGE = 0x42,2353/**2354* Depth, which is guaranteed to be greater than or equal to the current2355* depth; SV_DepthGreaterEqual in Direct3D. \since 1.92356*/2357VKD3D_SHADER_SV_DEPTH_GREATER_EQUAL = 0x43,2358/**2359* Depth, which is guaranteed to be less than or equal to the current2360* depth; SV_DepthLessEqual in Direct3D. \since 1.92361*/2362VKD3D_SHADER_SV_DEPTH_LESS_EQUAL = 0x44,2363/** Stencil reference; SV_StencilRef in Direct3D. \since 1.9 */2364VKD3D_SHADER_SV_STENCIL_REF = 0x45,23652366VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SYSVAL_SEMANTIC),2367};23682369/**2370* Minimum interpolation precision of a shader varying, returned as part of2371* struct vkd3d_shader_signature_element.2372*/2373enum vkd3d_shader_minimum_precision2374{2375VKD3D_SHADER_MINIMUM_PRECISION_NONE = 0,2376/** 16-bit floating-point. */2377VKD3D_SHADER_MINIMUM_PRECISION_FLOAT_16 = 1,2378/** 10-bit fixed point (2 integer and 8 fractional bits). */2379VKD3D_SHADER_MINIMUM_PRECISION_FIXED_8_2 = 2,2380/** 16-bit signed integer. */2381VKD3D_SHADER_MINIMUM_PRECISION_INT_16 = 4,2382/** 16-bit unsigned integer. */2383VKD3D_SHADER_MINIMUM_PRECISION_UINT_16 = 5,23842385VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_MINIMUM_PRECISION),2386};23872388/**2389* A single shader varying, returned as part of struct vkd3d_shader_signature.2390*/2391struct vkd3d_shader_signature_element2392{2393/** Semantic name. */2394const char *semantic_name;2395/** Semantic index, or 0 if the semantic is not indexed. */2396unsigned int semantic_index;2397/**2398* Stream index of a geometry shader output semantic. If the signature is2399* not a geometry shader output signature, this field will be set to 0.2400*/2401unsigned int stream_index;2402/**2403* System value semantic. If the varying is not a system value, this field2404* will be set to VKD3D_SHADER_SV_NONE.2405*/2406enum vkd3d_shader_sysval_semantic sysval_semantic;2407/** Data type. */2408enum vkd3d_shader_component_type component_type;2409/** Register index. */2410unsigned int register_index;2411/** Mask of the register components allocated to this varying. */2412unsigned int mask;2413/**2414* Subset of \ref mask which the shader reads from or writes to. Unlike2415* Direct3D shader bytecode, the mask for output and tessellation signatures2416* is not inverted, i.e. bits set in this field denote components which are2417* written to.2418*/2419unsigned int used_mask;2420/** Minimum interpolation precision. */2421enum vkd3d_shader_minimum_precision min_precision;2422};24232424/**2425* Description of a shader input or output signature. This structure is2426* populated by vkd3d_shader_parse_input_signature().2427*2428* The helper function vkd3d_shader_find_signature_element() will look up a2429* varying element by its semantic name, semantic index, and stream index.2430*/2431struct vkd3d_shader_signature2432{2433/** Pointer to an array of varyings. */2434struct vkd3d_shader_signature_element *elements;2435/** Size, in elements, of \ref elements. */2436unsigned int element_count;2437};24382439/** Possible values for a single component of a vkd3d-shader swizzle. */2440enum vkd3d_shader_swizzle_component2441{2442VKD3D_SHADER_SWIZZLE_X = 0x0,2443VKD3D_SHADER_SWIZZLE_Y = 0x1,2444VKD3D_SHADER_SWIZZLE_Z = 0x2,2445VKD3D_SHADER_SWIZZLE_W = 0x3,24462447VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_SWIZZLE_COMPONENT),2448};24492450/**2451* A description of a DXBC section.2452*2453* \since 1.72454*/2455struct vkd3d_shader_dxbc_section_desc2456{2457/** The section tag. */2458uint32_t tag;2459/** The contents of the section. */2460struct vkd3d_shader_code data;2461};24622463/**2464* A description of a DXBC blob, as returned by vkd3d_shader_parse_dxbc().2465*2466* \since 1.72467*/2468struct vkd3d_shader_dxbc_desc2469{2470/**2471* The DXBC tag. This will always be "DXBC" in structures returned by2472* this version of vkd3d-shader.2473*/2474uint32_t tag;2475/** A checksum of the DXBC contents. */2476uint32_t checksum[4];2477/**2478* The DXBC version. This will always be 1 in structures returned by this2479* version of vkd3d-shader.2480*/2481unsigned int version;2482/** The total size of the DXBC blob. */2483size_t size;2484/** The number of sections contained in the DXBC. */2485size_t section_count;2486/** Descriptions of the sections contained in the DXBC. */2487struct vkd3d_shader_dxbc_section_desc *sections;2488};24892490/**2491* A mask selecting one component from a vkd3d-shader swizzle. The component has2492* type \ref vkd3d_shader_swizzle_component.2493*/2494#define VKD3D_SHADER_SWIZZLE_MASK (0xffu)2495/** The offset, in bits, of the nth parameter of a vkd3d-shader swizzle. */2496#define VKD3D_SHADER_SWIZZLE_SHIFT(idx) (8u * (idx))24972498/**2499* A helper macro which returns a vkd3d-shader swizzle with the given2500* components. The components are specified as the suffixes to members of2501* \ref vkd3d_shader_swizzle_component. For example, the swizzle ".xwyy" can be2502* represented as:2503* \code2504* VKD3D_SHADER_SWIZZLE(X, W, Y, Y)2505* \endcode2506*/2507#define VKD3D_SHADER_SWIZZLE(x, y, z, w) \2508(VKD3D_SHADER_SWIZZLE_ ## x << VKD3D_SHADER_SWIZZLE_SHIFT(0) \2509| VKD3D_SHADER_SWIZZLE_ ## y << VKD3D_SHADER_SWIZZLE_SHIFT(1) \2510| VKD3D_SHADER_SWIZZLE_ ## z << VKD3D_SHADER_SWIZZLE_SHIFT(2) \2511| VKD3D_SHADER_SWIZZLE_ ## w << VKD3D_SHADER_SWIZZLE_SHIFT(3))25122513/** The identity swizzle ".xyzw". */2514#define VKD3D_SHADER_NO_SWIZZLE VKD3D_SHADER_SWIZZLE(X, Y, Z, W)25152516/** Build a vkd3d-shader swizzle with the given components. */2517static inline uint32_t vkd3d_shader_create_swizzle(enum vkd3d_shader_swizzle_component x,2518enum vkd3d_shader_swizzle_component y, enum vkd3d_shader_swizzle_component z,2519enum vkd3d_shader_swizzle_component w)2520{2521return ((x & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(0))2522| ((y & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(1))2523| ((z & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(2))2524| ((w & VKD3D_SHADER_SWIZZLE_MASK) << VKD3D_SHADER_SWIZZLE_SHIFT(3));2525}25262527/**2528* A chained structure containing descriptions of shader inputs and outputs.2529*2530* This structure is currently implemented only for DXBC and legacy D3D bytecode2531* source types.2532* For DXBC shaders, the returned information is parsed directly from the2533* signatures embedded in the DXBC shader.2534* For legacy D3D shaders, the returned information is synthesized based on2535* registers declared or used by shader instructions.2536* For all other shader types, the structure is zeroed.2537*2538* All members (except for \ref type and \ref next) are output-only.2539*2540* This structure is passed to vkd3d_shader_scan() and extends2541* vkd3d_shader_compile_info.2542*2543* Members of this structure are allocated by vkd3d-shader and should be freed2544* with vkd3d_shader_free_scan_signature_info() when no longer needed.2545*2546* All signatures may contain pointers into the input shader, and should only2547* be accessed while the input shader remains valid.2548*2549* Signature elements are synthesized from legacy Direct3D bytecode as follows:2550* - The \ref vkd3d_shader_signature_element.semantic_name field is set to an2551* uppercase string corresponding to the HLSL name for the usage, e.g.2552* "POSITION", "BLENDWEIGHT", "COLOR", "PSIZE", etc.2553* - The \ref vkd3d_shader_signature_element.semantic_index field is set to the2554* usage index.2555* - The \ref vkd3d_shader_signature_element.stream_index is always 0.2556*2557* Signature elements are synthesized for any input or output register declared2558* or used in a legacy Direct3D bytecode shader, including the following:2559* - Shader model 1 and 2 colour and texture coordinate registers.2560* - The shader model 1 pixel shader output register.2561* - Shader model 1 and 2 vertex shader output registers (position, fog, and2562* point size).2563* - Shader model 3 pixel shader system value input registers (pixel position2564* and face).2565*2566* \since 1.92567*/2568struct vkd3d_shader_scan_signature_info2569{2570/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_SCAN_SIGNATURE_INFO. */2571enum vkd3d_shader_structure_type type;2572/** Optional pointer to a structure containing further parameters. */2573const void *next;25742575/** The shader input varyings. */2576struct vkd3d_shader_signature input;25772578/** The shader output varyings. */2579struct vkd3d_shader_signature output;25802581/** The shader patch constant varyings. */2582struct vkd3d_shader_signature patch_constant;2583};25842585/**2586* Describes the mapping of a output varying register in a shader stage,2587* to an input varying register in the following shader stage.2588*2589* This structure is used in struct vkd3d_shader_varying_map_info.2590*/2591struct vkd3d_shader_varying_map2592{2593/**2594* The signature index (in the output signature) of the output varying.2595* If greater than or equal to the number of elements in the output2596* signature, signifies that the varying is consumed by the next stage but2597* not written by this one.2598*/2599unsigned int output_signature_index;2600/** The register index of the input varying to map this register to. */2601unsigned int input_register_index;2602/** The mask consumed by the destination register. */2603unsigned int input_mask;2604};26052606/**2607* A chained structure which describes how output varyings in this shader stage2608* should be mapped to input varyings in the next stage.2609*2610* This structure is optional. It should not be provided if there is no shader2611* stage.2612* However, depending on the input and output formats, this structure may be2613* necessary in order to generate shaders which correctly match each other.2614*2615* If this structure is absent, vkd3d-shader will map varyings from one stage2616* to another based on their register index.2617* For Direct3D shader model 3.0, such a default mapping will be incorrect2618* unless the registers are allocated in the same order, and hence this2619* field is necessary to correctly match inter-stage varyings.2620* This mapping may also be necessary under other circumstances where the2621* varying interface does not match exactly.2622*2623* This structure is passed to vkd3d_shader_compile() and extends2624* vkd3d_shader_compile_info.2625*2626* This structure contains only input parameters.2627*2628* \since 1.92629*/2630struct vkd3d_shader_varying_map_info2631{2632/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_VARYING_MAP_INFO. */2633enum vkd3d_shader_structure_type type;2634/** Optional pointer to a structure containing further parameters. */2635const void *next;26362637/**2638* A mapping of output varyings in this shader stage to input varyings2639* in the next shader stage.2640*2641* This mapping should include exactly one element for each varying2642* consumed by the next shader stage.2643* If this shader stage outputs a varying that is not consumed by the next2644* shader stage, that varying should be absent from this array.2645*2646* This mapping may be constructed by vkd3d_shader_build_varying_map().2647*/2648const struct vkd3d_shader_varying_map *varying_map;2649/** The number of registers provided in \ref varying_map. */2650unsigned int varying_count;2651};26522653/**2654* Interface information regarding a builtin shader parameter.2655*2656* Like compile options specified with struct vkd3d_shader_compile_option,2657* parameters are used to specify certain values which are not part of the2658* source shader bytecode but which need to be specified in the shader bytecode2659* in the target format.2660* Unlike struct vkd3d_shader_compile_option, however, this structure allows2661* parameters to be specified in a variety of different ways, as described by2662* enum vkd3d_shader_parameter_type.2663*2664* This structure is an extended version of struct vkd3d_shader_parameter as2665* used in struct vkd3d_shader_spirv_target_info, which allows more parameter2666* types to be used, and also allows specifying parameters when compiling2667* shaders to target types other than SPIR-V. If this structure is chained2668* along with vkd3d_shader_spirv_target_info, any parameters specified in the2669* latter structure are ignored.2670*2671* This structure is passed to vkd3d_shader_compile() and extends2672* vkd3d_shader_compile_info.2673*2674* This structure contains only input parameters.2675*2676* \since 1.132677*/2678struct vkd3d_shader_parameter_info2679{2680/** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_PARAMETER_INFO. */2681enum vkd3d_shader_structure_type type;2682/** Optional pointer to a structure containing further parameters. */2683const void *next;26842685/** Pointer to an array of dynamic parameters for this shader instance. */2686const struct vkd3d_shader_parameter1 *parameters;2687/** Size, in elements, of \ref parameters. */2688unsigned int parameter_count;2689};26902691#ifdef LIBVKD3D_SHADER_SOURCE2692# define VKD3D_SHADER_API VKD3D_EXPORT2693#else2694# define VKD3D_SHADER_API VKD3D_IMPORT2695#endif26962697#ifndef VKD3D_SHADER_NO_PROTOTYPES26982699/**2700* Returns the current version of this library.2701*2702* \param major Output location for the major version of this library.2703*2704* \param minor Output location for the minor version of this library.2705*2706* \return A human-readable string describing the library name and version. This2707* string is null-terminated and UTF-8 encoded. This may be a pointer to static2708* data in libvkd3d-shader; it should not be freed.2709*/2710VKD3D_SHADER_API const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor);2711/**2712* Returns the source types supported, with any target type, by2713* vkd3d_shader_compile(). Future versions of the library may introduce2714* additional source types; callers should ignore unrecognised source types.2715*2716* Use vkd3d_shader_get_supported_target_types() to determine which target types2717* are supported for each source type.2718*2719* \param count Output location for the size, in elements, of the returned2720* array.2721*2722* \return Pointer to an array of source types supported by this version of2723* vkd3d-shader. This array may be a pointer to static data in libvkd3d-shader;2724* it should not be freed.2725*/2726VKD3D_SHADER_API const enum vkd3d_shader_source_type *vkd3d_shader_get_supported_source_types(unsigned int *count);2727/**2728* Returns the target types supported, with the given source type, by2729* vkd3d_shader_compile(). Future versions of the library may introduce2730* additional target types; callers should ignore unrecognised target types.2731*2732* \param source_type Source type for which to enumerate supported target types.2733*2734* \param count Output location for the size, in elements, of the returned2735* array.2736*2737* \return Pointer to an array of target types supported by this version of2738* vkd3d-shader. This array may be a pointer to static data in libvkd3d-shader;2739* it should not be freed.2740*/2741VKD3D_SHADER_API const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types(2742enum vkd3d_shader_source_type source_type, unsigned int *count);27432744/**2745* Transform a form of GPU shader source code or byte code into another form of2746* source code or byte code.2747*2748* This version of vkd3d-shader supports the following transformations:2749* - VKD3D_SHADER_SOURCE_DXBC_DXIL to VKD3D_SHADER_TARGET_SPIRV_BINARY2750* - VKD3D_SHADER_SOURCE_DXBC_DXIL to VKD3D_SHADER_TARGET_SPIRV_TEXT2751* (if vkd3d was compiled with SPIRV-Tools)2752* - VKD3D_SHADER_SOURCE_DXBC_DXIL to VKD3D_SHADER_TARGET_D3D_ASM2753* - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_SPIRV_BINARY2754* - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_SPIRV_TEXT2755* (if vkd3d was compiled with SPIRV-Tools)2756* - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_D3D_ASM2757* - VKD3D_SHADER_SOURCE_D3D_BYTECODE to VKD3D_SHADER_TARGET_SPIRV_BINARY2758* - VKD3D_SHADER_SOURCE_D3D_BYTECODE to VKD3D_SHADER_TARGET_SPIRV_TEXT2759* (if vkd3d was compiled with SPIRV-Tools)2760* - VKD3D_SHADER_SOURCE_D3D_BYTECODE to VKD3D_SHADER_TARGET_D3D_ASM2761* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_SPIRV_BINARY2762* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_SPIRV_TEXT2763* (if vkd3d was compiled with SPIRV-Tools)2764* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_D3D_ASM2765* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_D3D_BYTECODE2766* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_DXBC_TPF2767* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_FX2768* - VKD3D_SHADER_SOURCE_FX to VKD3D_SHADER_TARGET_D3D_ASM2769* - VKD3D_SHADER_SOURCE_TX to VKD3D_SHADER_TARGET_D3D_ASM2770*2771* Supported transformations can also be detected at runtime with the functions2772* vkd3d_shader_get_supported_source_types() and2773* vkd3d_shader_get_supported_target_types().2774*2775* Depending on the source and target types, this function may support the2776* following chained structures:2777* - vkd3d_shader_descriptor_offset_info2778* - vkd3d_shader_hlsl_source_info2779* - vkd3d_shader_interface_info2780* - vkd3d_shader_parameter_info2781* - vkd3d_shader_preprocess_info2782* - vkd3d_shader_scan_combined_resource_sampler_info2783* - vkd3d_shader_scan_descriptor_info2784* - vkd3d_shader_scan_hull_shader_tessellation_info2785* - vkd3d_shader_scan_signature_info2786* - vkd3d_shader_spirv_domain_shader_target_info2787* - vkd3d_shader_spirv_target_info2788* - vkd3d_shader_transform_feedback_info2789* - vkd3d_shader_varying_map_info2790*2791* \param compile_info A chained structure containing compilation parameters.2792*2793* \param out A pointer to a vkd3d_shader_code structure in which the compiled2794* code will be stored.2795* \n2796* The compiled shader is allocated by vkd3d-shader and should be freed with2797* vkd3d_shader_free_shader_code() when no longer needed.2798*2799* \param messages Optional output location for error or informational messages2800* produced by the compiler.2801* \n2802* This string is null-terminated and UTF-8 encoded.2803* \n2804* The messages are allocated by vkd3d-shader and should be freed with2805* vkd3d_shader_free_messages() when no longer needed.2806* \n2807* The messages returned can be regulated with the \a log_level member of struct2808* vkd3d_shader_compile_info. Regardless of the requested level, if this2809* parameter is NULL, no compilation messages will be returned.2810* \n2811* If no messages are produced by the compiler, this parameter may2812* receive NULL instead of a valid string pointer.2813*2814* \return A member of \ref vkd3d_result.2815*/2816VKD3D_SHADER_API int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,2817struct vkd3d_shader_code *out, char **messages);2818/**2819* Free shader messages allocated by another vkd3d-shader function, such as2820* vkd3d_shader_compile().2821*2822* \param messages Messages to free. This pointer is optional and may be NULL,2823* in which case no action will be taken.2824*/2825VKD3D_SHADER_API void vkd3d_shader_free_messages(char *messages);2826/**2827* Free shader code allocated by another vkd3d-shader function, such as2828* vkd3d_shader_compile().2829*2830* This function frees the \ref vkd3d_shader_code.code member, but does not free2831* the structure itself.2832*2833* \param code Code to free.2834*/2835VKD3D_SHADER_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);28362837/**2838* Convert a byte code description of a shader root signature to a structural2839* description which can be easily parsed by C code.2840*2841* This function corresponds to2842* ID3D12VersionedRootSignatureDeserializer::GetUnconvertedRootSignatureDesc().2843*2844* This function performs the reverse transformation of2845* vkd3d_shader_serialize_root_signature().2846*2847* This function parses a standalone root signature, and should not be confused2848* with vkd3d_shader_parse_input_signature().2849*2850* \param dxbc Compiled byte code, in DXBC format.2851*2852* \param root_signature Output location in which the decompiled root signature2853* will be stored.2854* \n2855* Members of \a root_signature may be allocated by vkd3d-shader. The signature2856* should be freed with vkd3d_shader_free_root_signature() when no longer2857* needed.2858*2859* \param messages Optional output location for error or informational messages2860* produced by the parser.2861* \n2862* This string is null-terminated and UTF-8 encoded.2863* \n2864* The messages are allocated by vkd3d-shader and should be freed with2865* vkd3d_shader_free_messages() when no longer needed.2866* \n2867* If no messages are produced by the parser, this parameter may2868* receive NULL instead of a valid string pointer.2869*2870* \return A member of \ref vkd3d_result.2871*/2872VKD3D_SHADER_API int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,2873struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages);2874/**2875* Free a structural representation of a shader root signature allocated by2876* vkd3d_shader_convert_root_signature() or vkd3d_shader_parse_root_signature().2877*2878* This function may free members of struct2879* vkd3d_shader_versioned_root_signature_desc, but does not free the structure2880* itself.2881*2882* \param root_signature Signature description to free.2883*/2884VKD3D_SHADER_API void vkd3d_shader_free_root_signature(2885struct vkd3d_shader_versioned_root_signature_desc *root_signature);28862887/**2888* Convert a structural description of a shader root signature to a byte code2889* format capable of being read by ID3D12Device::CreateRootSignature. The2890* compiled signature is compatible with Microsoft D3D 12.2891*2892* This function corresponds to D3D12SerializeVersionedRootSignature().2893*2894* \param root_signature Description of the root signature.2895*2896* \param dxbc A pointer to a vkd3d_shader_code structure in which the compiled2897* code will be stored.2898* \n2899* The compiled signature is allocated by vkd3d-shader and should be freed with2900* vkd3d_shader_free_shader_code() when no longer needed.2901*2902* \param messages Optional output location for error or informational messages2903* produced by the serializer.2904* \n2905* This string is null-terminated and UTF-8 encoded.2906* \n2907* The messages are allocated by vkd3d-shader and should be freed with2908* vkd3d_shader_free_messages() when no longer needed.2909* \n2910* If no messages are produced by the serializer, this parameter may2911* receive NULL instead of a valid string pointer.2912*2913* \return A member of \ref vkd3d_result.2914*/2915VKD3D_SHADER_API int vkd3d_shader_serialize_root_signature(2916const struct vkd3d_shader_versioned_root_signature_desc *root_signature,2917struct vkd3d_shader_code *dxbc, char **messages);2918/**2919* Convert a structural representation of a root signature to a different2920* version of structural representation.2921*2922* This function corresponds to2923* ID3D12VersionedRootSignatureDeserializer::GetRootSignatureDescAtVersion().2924*2925* \param dst A pointer to a vkd3d_shader_versioned_root_signature_desc2926* structure in which the converted signature will be stored.2927* \n2928* Members of \a dst may be allocated by vkd3d-shader. The signature should be2929* freed with vkd3d_shader_free_root_signature() when no longer needed.2930*2931* \param version The desired version to convert \a src to. This version must2932* not be equal to \a src->version.2933*2934* \param src Input root signature description.2935*2936* \return A member of \ref vkd3d_result.2937*/2938VKD3D_SHADER_API int vkd3d_shader_convert_root_signature(struct vkd3d_shader_versioned_root_signature_desc *dst,2939enum vkd3d_shader_root_signature_version version, const struct vkd3d_shader_versioned_root_signature_desc *src);29402941/**2942* Parse shader source code or byte code, returning various types of requested2943* information.2944*2945* The \a source_type member of \a compile_info must be set to the type of the2946* shader.2947*2948* The \a target_type member may be set to VKD3D_SHADER_TARGET_NONE, in which2949* case vkd3d_shader_scan() will return information about the shader in2950* isolation. Alternatively, it may be set to a valid compilation target for the2951* shader, in which case vkd3d_shader_scan() will return information that2952* reflects the interface for a shader as it will be compiled to that target.2953* In this case other chained structures may be appended to \a compile_info as2954* they would be passed to vkd3d_shader_compile(), and interpreted accordingly,2955* such as vkd3d_shader_spirv_target_info.2956*2957* (For a hypothetical example, suppose the source shader distinguishes float2958* and integer texture data, but the target environment does not support integer2959* textures. In this case vkd3d_shader_compile() might translate integer2960* operations to float. Accordingly using VKD3D_SHADER_TARGET_NONE would2961* accurately report whether the texture expects integer or float data, but2962* using the relevant specific target type would report2963* VKD3D_SHADER_RESOURCE_DATA_FLOAT.)2964*2965* Currently this function supports the following code types:2966* - VKD3D_SHADER_SOURCE_DXBC_DXIL2967* - VKD3D_SHADER_SOURCE_DXBC_TPF2968* - VKD3D_SHADER_SOURCE_D3D_BYTECODE2969* - VKD3D_SHADER_SOURCE_HLSL2970*2971* \param compile_info A chained structure containing scan parameters.2972* \n2973* The scanner supports the following chained structures:2974* - vkd3d_shader_scan_combined_resource_sampler_info2975* - vkd3d_shader_scan_descriptor_info2976* - vkd3d_shader_scan_hull_shader_tessellation_info2977* - vkd3d_shader_scan_signature_info2978* \n2979* Although the \a compile_info parameter is read-only, chained structures2980* passed to this function need not be, and may serve as output parameters,2981* depending on their structure type.2982*2983* \param messages Optional output location for error or informational messages2984* produced by the parser.2985* \n2986* This string is null-terminated and UTF-8 encoded.2987* \n2988* The messages are allocated by vkd3d-shader and should be freed with2989* vkd3d_shader_free_messages() when no longer needed.2990* \n2991* The messages returned can be regulated with the \a log_level member of struct2992* vkd3d_shader_compile_info. Regardless of the requested level, if this2993* parameter is NULL, no compilation messages will be returned.2994* \n2995* If no messages are produced by the parser, this parameter may2996* receive NULL instead of a valid string pointer.2997*2998* \return A member of \ref vkd3d_result.2999*/3000VKD3D_SHADER_API int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages);3001/**3002* Free members of struct vkd3d_shader_scan_descriptor_info() allocated by3003* vkd3d_shader_scan().3004*3005* This function may free members of vkd3d_shader_scan_descriptor_info, but3006* does not free the structure itself.3007*3008* \param scan_descriptor_info Descriptor information to free.3009*/3010VKD3D_SHADER_API void vkd3d_shader_free_scan_descriptor_info(3011struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);30123013/**3014* Read the input signature of a compiled DXBC shader, returning a structural3015* description which can be easily parsed by C code.3016*3017* This function parses a compiled shader. To parse a standalone root signature,3018* use vkd3d_shader_parse_root_signature().3019*3020* This function only parses DXBC shaders, and only retrieves the input3021* signature. To retrieve signatures from other shader types, or other signature3022* types, use vkd3d_shader_scan() and struct vkd3d_shader_scan_signature_info.3023* This function returns the same input signature that is returned in3024* struct vkd3d_shader_scan_signature_info for dxbc-tpf shaders, but may return3025* different information for dxbc-dxil shaders.3026*3027* \param dxbc Compiled byte code, in DXBC format.3028*3029* \param signature Output location in which the parsed root signature will be3030* stored.3031* \n3032* Members of \a signature may be allocated by vkd3d-shader. The signature3033* should be freed with vkd3d_shader_free_shader_signature() when no longer3034* needed.3035* \n3036* The signature may contain pointers into the input shader, and should only be3037* accessed while the input shader remains valid.3038*3039* \param messages Optional output location for error or informational messages3040* produced by the parser.3041* \n3042* This string is null-terminated and UTF-8 encoded.3043* \n3044* The messages are allocated by vkd3d-shader and should be freed with3045* vkd3d_shader_free_messages() when no longer needed.3046* \n3047* If no messages are produced by the parser, this parameter may3048* receive NULL instead of a valid string pointer.3049*3050* \return A member of \ref vkd3d_result.3051*/3052VKD3D_SHADER_API int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,3053struct vkd3d_shader_signature *signature, char **messages);3054/**3055* Find a single element of a parsed input signature.3056*3057* \param signature The parsed input signature. This structure is normally3058* populated by vkd3d_shader_parse_input_signature().3059*3060* \param semantic_name Semantic name of the desired element. This function3061* performs a case-insensitive comparison with respect to the ASCII plane.3062*3063* \param semantic_index Semantic index of the desired element.3064*3065* \param stream_index Geometry shader stream index of the desired element. If3066* the signature is not a geometry shader output signature, this parameter must3067* be set to 0.3068*3069* \return A description of the element matching the requested parameters, or3070* NULL if no such element was found. If not NULL, the return value points into3071* the \a signature parameter and should not be explicitly freed.3072*/3073VKD3D_SHADER_API struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(3074const struct vkd3d_shader_signature *signature, const char *semantic_name,3075unsigned int semantic_index, unsigned int stream_index);3076/**3077* Free a structural representation of a shader input signature allocated by3078* vkd3d_shader_parse_input_signature().3079*3080* This function may free members of struct vkd3d_shader_signature, but does not3081* free the structure itself.3082*3083* \param signature Signature description to free.3084*/3085VKD3D_SHADER_API void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature);30863087/* 1.3 */30883089/**3090* Preprocess the given source code.3091*3092* This function supports the following chained structures:3093* - vkd3d_shader_preprocess_info3094*3095* \param compile_info A chained structure containing compilation parameters.3096*3097* \param out A pointer to a vkd3d_shader_code structure in which the3098* preprocessed code will be stored.3099* \n3100* The preprocessed shader is allocated by vkd3d-shader and should be freed with3101* vkd3d_shader_free_shader_code() when no longer needed.3102*3103* \param messages Optional output location for error or informational messages3104* produced by the preprocessor.3105* \n3106* This string is null-terminated and UTF-8 encoded.3107* \n3108* The messages are allocated by vkd3d-shader and should be freed with3109* vkd3d_shader_free_messages() when no longer needed.3110* \n3111* The messages returned can be regulated with the \a log_level member of struct3112* vkd3d_shader_compile_info. Regardless of the requested level, if this3113* parameter is NULL, no compilation messages will be returned.3114* \n3115* If no messages are produced by the preprocessor, this parameter may3116* receive NULL instead of a valid string pointer.3117*3118* \return A member of \ref vkd3d_result.3119*3120* \since 1.33121*/3122VKD3D_SHADER_API int vkd3d_shader_preprocess(const struct vkd3d_shader_compile_info *compile_info,3123struct vkd3d_shader_code *out, char **messages);31243125/**3126* Set a callback to be called when vkd3d-shader outputs debug logging.3127*3128* If NULL, or if this function has not been called, libvkd3d-shader will print3129* all enabled log output to stderr.3130*3131* \param callback Callback function to set.3132*3133* \since 1.43134*/3135VKD3D_SHADER_API void vkd3d_shader_set_log_callback(PFN_vkd3d_log callback);31363137/**3138* Free the contents of a vkd3d_shader_dxbc_desc structure allocated by3139* another vkd3d-shader function, such as vkd3d_shader_parse_dxbc().3140*3141* This function may free the \ref vkd3d_shader_dxbc_desc.sections member, but3142* does not free the structure itself.3143*3144* \param dxbc The vkd3d_shader_dxbc_desc structure to free.3145*3146* \since 1.73147*/3148VKD3D_SHADER_API void vkd3d_shader_free_dxbc(struct vkd3d_shader_dxbc_desc *dxbc);31493150/**3151* Parse a DXBC blob contained in a vkd3d_shader_code structure.3152*3153* \param dxbc A vkd3d_shader_code structure containing the DXBC blob to parse.3154*3155* \param flags A combination of zero or more elements of enum3156* vkd3d_shader_parse_dxbc_flags.3157*3158* \param desc A vkd3d_shader_dxbc_desc structure describing the contents of3159* the DXBC blob. Its vkd3d_shader_dxbc_section_desc structures will contain3160* pointers into the input blob; its contents are only valid while the input3161* blob is valid. The contents of this structure should be freed with3162* vkd3d_shader_free_dxbc() when no longer needed.3163*3164* \param messages Optional output location for error or informational messages3165* produced by the parser.3166* \n3167* This string is null-terminated and UTF-8 encoded.3168* \n3169* The messages are allocated by vkd3d-shader and should be freed with3170* vkd3d_shader_free_messages() when no longer needed.3171* \n3172* If no messages are produced by the parser, this parameter may3173* receive NULL instead of a valid string pointer.3174*3175* \return A member of \ref vkd3d_result.3176*3177* \since 1.73178*/3179VKD3D_SHADER_API int vkd3d_shader_parse_dxbc(const struct vkd3d_shader_code *dxbc,3180uint32_t flags, struct vkd3d_shader_dxbc_desc *desc, char **messages);31813182/**3183* Serialize a DXBC description into a blob stored in a vkd3d_shader_code3184* structure.3185*3186* \param section_count The number of DXBC sections to serialize.3187*3188* \param sections An array of vkd3d_shader_dxbc_section_desc structures3189* to serialize.3190*3191* \param dxbc A pointer to a vkd3d_shader_code structure in which the3192* serialized blob will be stored.3193* \n3194* The output blob is allocated by vkd3d-shader and should be freed with3195* vkd3d_shader_free_shader_code() when no longer needed.3196*3197* \param messages Optional output location for error or informational messages3198* produced by the serializer.3199* \n3200* This string is null-terminated and UTF-8 encoded.3201* \n3202* The messages are allocated by vkd3d-shader and should be freed with3203* vkd3d_shader_free_messages() when no longer needed.3204* \n3205* If no messages are produced by the serializer, this parameter may3206* receive NULL instead of a valid string pointer.3207*3208* \return A member of \ref vkd3d_result.3209*3210* \since 1.73211*/3212VKD3D_SHADER_API int vkd3d_shader_serialize_dxbc(size_t section_count,3213const struct vkd3d_shader_dxbc_section_desc *sections, struct vkd3d_shader_code *dxbc, char **messages);32143215/**3216* Free members of struct vkd3d_shader_scan_signature_info allocated by3217* vkd3d_shader_scan().3218*3219* This function may free members of vkd3d_shader_scan_signature_info, but3220* does not free the structure itself.3221*3222* \param info Scan information to free.3223*3224* \since 1.93225*/3226VKD3D_SHADER_API void vkd3d_shader_free_scan_signature_info(struct vkd3d_shader_scan_signature_info *info);32273228/**3229* Build a mapping of output varyings in a shader stage to input varyings in3230* the following shader stage.3231*3232* This mapping should be used in struct vkd3d_shader_varying_map_info to3233* compile the first shader.3234*3235* \param output_signature The output signature of the first shader.3236*3237* \param input_signature The input signature of the second shader.3238*3239* \param count On output, contains the number of entries written into3240* "varyings".3241*3242* \param varyings Pointer to an output array of varyings.3243* This must point to space for N varyings, where N is the number of elements3244* in the input signature.3245*3246* \remark Valid legacy Direct3D pixel shaders have at most 12 varying inputs:3247* 10 inter-stage varyings, face, and position.3248* Therefore, in practice, it is safe to call this function with a3249* pre-allocated array with a fixed size of 12.3250*3251* \since 1.93252*/3253VKD3D_SHADER_API void vkd3d_shader_build_varying_map(const struct vkd3d_shader_signature *output_signature,3254const struct vkd3d_shader_signature *input_signature,3255unsigned int *count, struct vkd3d_shader_varying_map *varyings);32563257/**3258* Free members of struct vkd3d_shader_scan_combined_resource_sampler_info3259* allocated by vkd3d_shader_scan().3260*3261* This function may free members of3262* vkd3d_shader_scan_combined_resource_sampler_info, but does not free the3263* structure itself.3264*3265* \param info Combined resource-sampler information to free.3266*3267* \since 1.103268*/3269VKD3D_SHADER_API void vkd3d_shader_free_scan_combined_resource_sampler_info(3270struct vkd3d_shader_scan_combined_resource_sampler_info *info);32713272#endif /* VKD3D_SHADER_NO_PROTOTYPES */32733274/** Type of vkd3d_shader_get_version(). */3275typedef const char *(*PFN_vkd3d_shader_get_version)(unsigned int *major, unsigned int *minor);3276/** Type of vkd3d_shader_get_supported_source_types(). */3277typedef const enum vkd3d_shader_source_type *(*PFN_vkd3d_shader_get_supported_source_types)(unsigned int *count);3278/** Type of vkd3d_shader_get_supported_target_types(). */3279typedef const enum vkd3d_shader_target_type *(*PFN_vkd3d_shader_get_supported_target_types)(3280enum vkd3d_shader_source_type source_type, unsigned int *count);32813282/** Type of vkd3d_shader_compile(). */3283typedef int (*PFN_vkd3d_shader_compile)(const struct vkd3d_shader_compile_info *compile_info,3284struct vkd3d_shader_code *out, char **messages);3285/** Type of vkd3d_shader_free_messages(). */3286typedef void (*PFN_vkd3d_shader_free_messages)(char *messages);3287/** Type of vkd3d_shader_free_shader_code(). */3288typedef void (*PFN_vkd3d_shader_free_shader_code)(struct vkd3d_shader_code *code);32893290/** Type of vkd3d_shader_parse_root_signature(). */3291typedef int (*PFN_vkd3d_shader_parse_root_signature)(const struct vkd3d_shader_code *dxbc,3292struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages);3293/** Type of vkd3d_shader_free_root_signature(). */3294typedef void (*PFN_vkd3d_shader_free_root_signature)(struct vkd3d_shader_versioned_root_signature_desc *root_signature);32953296/** Type of vkd3d_shader_serialize_root_signature(). */3297typedef int (*PFN_vkd3d_shader_serialize_root_signature)(3298const struct vkd3d_shader_versioned_root_signature_desc *root_signature,3299struct vkd3d_shader_code *dxbc, char **messages);33003301/** Type of vkd3d_shader_convert_root_signature(). */3302typedef int (*PFN_vkd3d_shader_convert_root_signature)(struct vkd3d_shader_versioned_root_signature_desc *dst,3303enum vkd3d_shader_root_signature_version version, const struct vkd3d_shader_versioned_root_signature_desc *src);33043305/** Type of vkd3d_shader_scan(). */3306typedef int (*PFN_vkd3d_shader_scan)(const struct vkd3d_shader_compile_info *compile_info, char **messages);3307/** Type of vkd3d_shader_free_scan_descriptor_info(). */3308typedef void (*PFN_vkd3d_shader_free_scan_descriptor_info)(3309struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info);33103311/** Type of vkd3d_shader_parse_input_signature(). */3312typedef int (*PFN_vkd3d_shader_parse_input_signature)(const struct vkd3d_shader_code *dxbc,3313struct vkd3d_shader_signature *signature, char **messages);3314/** Type of vkd3d_shader_find_signature_element(). */3315typedef struct vkd3d_shader_signature_element * (*PFN_vkd3d_shader_find_signature_element)(3316const struct vkd3d_shader_signature *signature, const char *semantic_name,3317unsigned int semantic_index, unsigned int stream_index);3318/** Type of vkd3d_shader_free_shader_signature(). */3319typedef void (*PFN_vkd3d_shader_free_shader_signature)(struct vkd3d_shader_signature *signature);33203321/** Type of vkd3d_shader_preprocess(). \since 1.3 */3322typedef void (*PFN_vkd3d_shader_preprocess)(struct vkd3d_shader_compile_info *compile_info,3323struct vkd3d_shader_code *out, char **messages);33243325/** Type of vkd3d_shader_set_log_callback(). \since 1.4 */3326typedef void (*PFN_vkd3d_shader_set_log_callback)(PFN_vkd3d_log callback);33273328/** Type of vkd3d_shader_free_dxbc(). \since 1.7 */3329typedef void (*PFN_vkd3d_shader_free_dxbc)(struct vkd3d_shader_dxbc_desc *dxbc);3330/** Type of vkd3d_shader_parse_dxbc(). \since 1.7 */3331typedef int (*PFN_vkd3d_shader_parse_dxbc)(const struct vkd3d_shader_code *dxbc,3332uint32_t flags, struct vkd3d_shader_dxbc_desc *desc, char **messages);3333/** Type of vkd3d_shader_serialize_dxbc(). \since 1.7 */3334typedef int (*PFN_vkd3d_shader_serialize_dxbc)(size_t section_count,3335const struct vkd3d_shader_dxbc_section_desc *sections, struct vkd3d_shader_code *dxbc, char **messages);33363337/** Type of vkd3d_shader_build_varying_map(). \since 1.9 */3338typedef void (*PFN_vkd3d_shader_build_varying_map)(const struct vkd3d_shader_signature *output_signature,3339const struct vkd3d_shader_signature *input_signature,3340unsigned int *count, struct vkd3d_shader_varying_map *varyings);3341/** Type of vkd3d_shader_free_scan_signature_info(). \since 1.9 */3342typedef void (*PFN_vkd3d_shader_free_scan_signature_info)(struct vkd3d_shader_scan_signature_info *info);33433344/** Type of vkd3d_shader_free_scan_combined_resource_sampler_info(). \since 1.10 */3345typedef void (*PFN_vkd3d_shader_free_scan_combined_resource_sampler_info)(3346struct vkd3d_shader_scan_combined_resource_sampler_info *info);33473348#ifdef __cplusplus3349}3350#endif /* __cplusplus */33513352#endif /* __VKD3D_SHADER_H */335333543355