vkd3d-shader: Introduce VKD3D_SHADER_COMPILE_OPTION_API_VERSION.

Analogous to vkd3d_api_version for libvkd3d.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2022-02-28 12:23:44 +01:00 committed by Alexandre Julliard
parent f5c4c06090
commit 22b02ed59f
4 changed files with 40 additions and 9 deletions

View File

@ -38,6 +38,15 @@ extern "C" {
* compilation, transformation, and reflection of GPU shaders.
*/
/** \since 1.3 */
enum vkd3d_shader_api_version
{
VKD3D_SHADER_API_VERSION_1_0,
VKD3D_SHADER_API_VERSION_1_1,
VKD3D_SHADER_API_VERSION_1_2,
VKD3D_SHADER_API_VERSION_1_3,
};
/** The type of a chained structure. */
enum vkd3d_shader_structure_type
{
@ -115,6 +124,8 @@ enum vkd3d_shader_compile_option_name
VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV = 0x00000002,
/** \a value is a member of enum vkd3d_shader_compile_option_formatting_flags. */
VKD3D_SHADER_COMPILE_OPTION_FORMATTING = 0x00000003,
/** \a value is a member of enum vkd3d_shader_api_version. \since 1.3 */
VKD3D_SHADER_COMPILE_OPTION_API_VERSION = 0x00000004,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_NAME),
};

View File

@ -158,7 +158,7 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
{
struct vkd3d_shader_preprocess_info preprocess_info;
struct vkd3d_shader_hlsl_source_info hlsl_info;
struct vkd3d_shader_compile_option options[1];
struct vkd3d_shader_compile_option options[2];
struct vkd3d_shader_compile_info compile_info;
struct vkd3d_shader_compile_option *option;
struct vkd3d_shader_code byte_code;
@ -208,6 +208,10 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
if (messages_blob)
*messages_blob = NULL;
option = &options[0];
option->name = VKD3D_SHADER_COMPILE_OPTION_API_VERSION;
option->value = VKD3D_SHADER_API_VERSION_1_3;
compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
compile_info.next = &preprocess_info;
compile_info.source.code = data;
@ -215,7 +219,7 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
compile_info.source_type = VKD3D_SHADER_SOURCE_HLSL;
compile_info.target_type = VKD3D_SHADER_TARGET_DXBC_TPF;
compile_info.options = options;
compile_info.option_count = 0;
compile_info.option_count = 1;
compile_info.log_level = VKD3D_SHADER_LOG_INFO;
compile_info.source_name = filename;
@ -310,6 +314,11 @@ HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename
HRESULT hr;
int ret;
static const struct vkd3d_shader_compile_option options[] =
{
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_3},
};
TRACE("data %p, size %lu, filename %s, macros %p, include %p, preprocessed_blob %p, messages_blob %p.\n",
data, size, debugstr_a(filename), macros, include, preprocessed_blob, messages_blob);
@ -322,8 +331,8 @@ HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename
compile_info.source.size = size;
compile_info.source_type = VKD3D_SHADER_SOURCE_HLSL;
compile_info.target_type = VKD3D_SHADER_TARGET_NONE;
compile_info.options = NULL;
compile_info.option_count = 0;
compile_info.options = options;
compile_info.option_count = ARRAY_SIZE(options);
compile_info.log_level = VKD3D_SHADER_LOG_INFO;
compile_info.source_name = filename;

View File

@ -1768,6 +1768,11 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
VkResult vr;
int ret;
static const struct vkd3d_shader_compile_option options[] =
{
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_3},
};
stage_desc->sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
stage_desc->pNext = NULL;
stage_desc->flags = 0;
@ -1785,8 +1790,8 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
compile_info.source.size = code->BytecodeLength;
compile_info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
compile_info.target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY;
compile_info.options = NULL;
compile_info.option_count = 0;
compile_info.options = options;
compile_info.option_count = ARRAY_SIZE(options);
compile_info.log_level = VKD3D_SHADER_LOG_NONE;
compile_info.source_name = NULL;
@ -1814,14 +1819,19 @@ static int vkd3d_scan_dxbc(const D3D12_SHADER_BYTECODE *code,
{
struct vkd3d_shader_compile_info compile_info;
static const struct vkd3d_shader_compile_option options[] =
{
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_3},
};
compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
compile_info.next = descriptor_info;
compile_info.source.code = code->pShaderBytecode;
compile_info.source.size = code->BytecodeLength;
compile_info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
compile_info.target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY;
compile_info.options = NULL;
compile_info.option_count = 0;
compile_info.options = options;
compile_info.option_count = ARRAY_SIZE(options);
compile_info.log_level = VKD3D_SHADER_LOG_NONE;
compile_info.source_name = NULL;

View File

@ -34,7 +34,7 @@
#include <term.h>
#endif
#define MAX_COMPILE_OPTIONS 3
#define MAX_COMPILE_OPTIONS 4
enum
{
@ -729,6 +729,7 @@ int main(int argc, char **argv)
if (!options.explicit_colour && !getenv("NO_COLOUR") && !getenv("NO_COLOR") && has_colour(output))
options.formatting |= VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR;
add_compile_option(&options, VKD3D_SHADER_COMPILE_OPTION_FORMATTING, options.formatting);
add_compile_option(&options, VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_3);
info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
info.next = &hlsl_source_info;