mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader: Add compiler option to specify matrix majority.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
acc68aef94
commit
bd3d4a6c06
Notes:
Alexandre Julliard
2023-07-24 22:55:13 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/261
@ -139,6 +139,14 @@ enum vkd3d_shader_compile_option_formatting_flags
|
|||||||
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FLAGS),
|
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FLAGS),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum vkd3d_shader_compile_option_pack_matrix_order
|
||||||
|
{
|
||||||
|
VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ROW_MAJOR = 0x00000001,
|
||||||
|
VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR = 0x00000002,
|
||||||
|
|
||||||
|
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER),
|
||||||
|
};
|
||||||
|
|
||||||
enum vkd3d_shader_compile_option_name
|
enum vkd3d_shader_compile_option_name
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -169,6 +177,15 @@ enum vkd3d_shader_compile_option_name
|
|||||||
* \since 1.7
|
* \since 1.7
|
||||||
*/
|
*/
|
||||||
VKD3D_SHADER_COMPILE_OPTION_WRITE_TESS_GEOM_POINT_SIZE = 0x00000006,
|
VKD3D_SHADER_COMPILE_OPTION_WRITE_TESS_GEOM_POINT_SIZE = 0x00000006,
|
||||||
|
/**
|
||||||
|
* This option specifies default matrix packing order. It's only supported for HLSL source type.
|
||||||
|
* Explicit variable modifiers or pragmas will take precedence.
|
||||||
|
*
|
||||||
|
* \a value is a member of enum vkd3d_shader_compile_option_pack_matrix_order.
|
||||||
|
*
|
||||||
|
* \since 1.9
|
||||||
|
*/
|
||||||
|
VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER = 0x00000007,
|
||||||
|
|
||||||
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_NAME),
|
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_NAME),
|
||||||
};
|
};
|
||||||
|
@ -3296,9 +3296,11 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const char *source_name,
|
static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compile_info *compile_info,
|
||||||
const struct hlsl_profile_info *profile, struct vkd3d_shader_message_context *message_context)
|
const struct hlsl_profile_info *profile, struct vkd3d_shader_message_context *message_context)
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
|
|
||||||
ctx->profile = profile;
|
ctx->profile = profile;
|
||||||
@ -3307,7 +3309,7 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const char *source_name,
|
|||||||
|
|
||||||
if (!(ctx->source_files = hlsl_alloc(ctx, sizeof(*ctx->source_files))))
|
if (!(ctx->source_files = hlsl_alloc(ctx, sizeof(*ctx->source_files))))
|
||||||
return false;
|
return false;
|
||||||
if (!(ctx->source_files[0] = hlsl_strdup(ctx, source_name ? source_name : "<anonymous>")))
|
if (!(ctx->source_files[0] = hlsl_strdup(ctx, compile_info->source_name ? compile_info->source_name : "<anonymous>")))
|
||||||
{
|
{
|
||||||
vkd3d_free(ctx->source_files);
|
vkd3d_free(ctx->source_files);
|
||||||
return false;
|
return false;
|
||||||
@ -3346,6 +3348,19 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const char *source_name,
|
|||||||
return false;
|
return false;
|
||||||
ctx->cur_buffer = ctx->globals_buffer;
|
ctx->cur_buffer = ctx->globals_buffer;
|
||||||
|
|
||||||
|
for (i = 0; i < compile_info->option_count; ++i)
|
||||||
|
{
|
||||||
|
const struct vkd3d_shader_compile_option *option = &compile_info->options[i];
|
||||||
|
|
||||||
|
if (option->name == VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER)
|
||||||
|
{
|
||||||
|
if (option->value == VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ROW_MAJOR)
|
||||||
|
ctx->matrix_majority = HLSL_MODIFIER_ROW_MAJOR;
|
||||||
|
else if (option->value == VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR)
|
||||||
|
ctx->matrix_majority = HLSL_MODIFIER_COLUMN_MAJOR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3423,7 +3438,7 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d
|
|||||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hlsl_ctx_init(&ctx, compile_info->source_name, profile, message_context))
|
if (!hlsl_ctx_init(&ctx, compile_info, profile, message_context))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if ((ret = hlsl_lexer_compile(&ctx, hlsl)) == 2)
|
if ((ret = hlsl_lexer_compile(&ctx, hlsl)) == 2)
|
||||||
|
@ -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_preprocess_info preprocess_info;
|
||||||
struct vkd3d_shader_hlsl_source_info hlsl_info;
|
struct vkd3d_shader_hlsl_source_info hlsl_info;
|
||||||
struct vkd3d_shader_compile_option options[2];
|
struct vkd3d_shader_compile_option options[3];
|
||||||
struct vkd3d_shader_compile_info compile_info;
|
struct vkd3d_shader_compile_info compile_info;
|
||||||
struct vkd3d_shader_compile_option *option;
|
struct vkd3d_shader_compile_option *option;
|
||||||
struct vkd3d_shader_code byte_code;
|
struct vkd3d_shader_code byte_code;
|
||||||
@ -198,7 +198,7 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
|
|||||||
debugstr_a(profile), flags, effect_flags, secondary_flags, secondary_data,
|
debugstr_a(profile), flags, effect_flags, secondary_flags, secondary_data,
|
||||||
secondary_data_size, shader_blob, messages_blob);
|
secondary_data_size, shader_blob, messages_blob);
|
||||||
|
|
||||||
if (flags & ~D3DCOMPILE_DEBUG)
|
if (flags & ~(D3DCOMPILE_DEBUG | D3DCOMPILE_PACK_MATRIX_ROW_MAJOR | D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR))
|
||||||
FIXME("Ignoring flags %#x.\n", flags);
|
FIXME("Ignoring flags %#x.\n", flags);
|
||||||
if (effect_flags)
|
if (effect_flags)
|
||||||
FIXME("Ignoring effect flags %#x.\n", effect_flags);
|
FIXME("Ignoring effect flags %#x.\n", effect_flags);
|
||||||
@ -262,6 +262,17 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
|
|||||||
option->value = true;
|
option->value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & (D3DCOMPILE_PACK_MATRIX_ROW_MAJOR | D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR))
|
||||||
|
{
|
||||||
|
option = &options[compile_info.option_count++];
|
||||||
|
option->name = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER;
|
||||||
|
option->value = 0;
|
||||||
|
if (flags & D3DCOMPILE_PACK_MATRIX_ROW_MAJOR)
|
||||||
|
option->value |= VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ROW_MAJOR;
|
||||||
|
if (flags & D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR)
|
||||||
|
option->value |= VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR;
|
||||||
|
}
|
||||||
|
|
||||||
ret = vkd3d_shader_compile(&compile_info, &byte_code, &messages);
|
ret = vkd3d_shader_compile(&compile_info, &byte_code, &messages);
|
||||||
|
|
||||||
if (messages && messages_blob)
|
if (messages && messages_blob)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user