mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
updated vkd3d-latest patchset
This commit is contained in:
parent
ef36ee4399
commit
3695e09653
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,949 @@
|
||||
From f7442f283e45fca56616dc6dbbd9db472bebef3a Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Tue, 24 Sep 2024 08:29:40 +1000
|
||||
Subject: [PATCH] Updated vkd3d to a2aeb3a1421c5540b7f4d0e68ec3ff211e15f646.
|
||||
|
||||
---
|
||||
libs/vkd3d/include/vkd3d_shader.h | 11 +++
|
||||
libs/vkd3d/libs/vkd3d-shader/d3dbc.c | 13 ++-
|
||||
libs/vkd3d/libs/vkd3d-shader/fx.c | 2 +
|
||||
libs/vkd3d/libs/vkd3d-shader/glsl.c | 56 +++++++++++
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl.c | 39 ++++++--
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl.h | 13 +++
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl.l | 1 -
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl.y | 93 ++++++++++---------
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 36 ++++++-
|
||||
libs/vkd3d/libs/vkd3d-shader/spirv.c | 64 +++++--------
|
||||
libs/vkd3d/libs/vkd3d-shader/tpf.c | 1 +
|
||||
.../libs/vkd3d-shader/vkd3d_shader_private.h | 2 +
|
||||
libs/vkd3d/libs/vkd3d/state.c | 4 +-
|
||||
13 files changed, 234 insertions(+), 101 deletions(-)
|
||||
|
||||
diff --git a/libs/vkd3d/include/vkd3d_shader.h b/libs/vkd3d/include/vkd3d_shader.h
|
||||
index 46feff35138..115bb21b932 100644
|
||||
--- a/libs/vkd3d/include/vkd3d_shader.h
|
||||
+++ b/libs/vkd3d/include/vkd3d_shader.h
|
||||
@@ -190,6 +190,17 @@ enum vkd3d_shader_compile_option_backward_compatibility
|
||||
* - DEPTH to SV_Depth for pixel shader outputs.
|
||||
*/
|
||||
VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES = 0x00000001,
|
||||
+ /**
|
||||
+ * Causes 'double' to behave as an alias for 'float'. This option only
|
||||
+ * applies to HLSL sources with shader model 1-3 target profiles. Without
|
||||
+ * this option using the 'double' type produces compilation errors in
|
||||
+ * these target profiles.
|
||||
+ *
|
||||
+ * This option is disabled by default.
|
||||
+ *
|
||||
+ * \since 1.14
|
||||
+ */
|
||||
+ VKD3D_SHADER_COMPILE_OPTION_DOUBLE_AS_FLOAT_ALIAS = 0x00000002,
|
||||
|
||||
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY),
|
||||
};
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
index 10f2e5e5e6d..34752a1ab89 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
@@ -1522,6 +1522,7 @@ D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type)
|
||||
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_RASTERIZER_STATE:
|
||||
case HLSL_CLASS_RENDER_TARGET_VIEW:
|
||||
@@ -1627,6 +1628,7 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type)
|
||||
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_RASTERIZER_STATE:
|
||||
case HLSL_CLASS_RENDER_TARGET_VIEW:
|
||||
@@ -1719,7 +1721,7 @@ static void sm1_sort_externs(struct hlsl_ctx *ctx)
|
||||
|
||||
void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer)
|
||||
{
|
||||
- size_t ctab_offset, ctab_start, ctab_end, vars_start, size_offset, creator_offset, offset;
|
||||
+ size_t ctab_offset, ctab_start, ctab_end, vars_offset, vars_start, size_offset, creator_offset, offset;
|
||||
unsigned int uniform_count = 0;
|
||||
struct hlsl_ir_var *var;
|
||||
|
||||
@@ -1755,11 +1757,12 @@ void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buff
|
||||
creator_offset = put_u32(buffer, 0);
|
||||
put_u32(buffer, sm1_version(ctx->profile->type, ctx->profile->major_version, ctx->profile->minor_version));
|
||||
put_u32(buffer, uniform_count);
|
||||
- put_u32(buffer, sizeof(D3DXSHADER_CONSTANTTABLE)); /* offset of constants */
|
||||
+ vars_offset = put_u32(buffer, 0);
|
||||
put_u32(buffer, 0); /* FIXME: flags */
|
||||
put_u32(buffer, 0); /* FIXME: target string */
|
||||
|
||||
vars_start = bytecode_align(buffer);
|
||||
+ set_u32(buffer, vars_offset, vars_start - ctab_start);
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
||||
{
|
||||
@@ -1835,8 +1838,10 @@ void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buff
|
||||
switch (comp_type->e.numeric.type)
|
||||
{
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
- hlsl_fixme(ctx, &var->loc, "Write double default values.");
|
||||
- uni.u = 0;
|
||||
+ if (ctx->double_as_float_alias)
|
||||
+ uni.u = var->default_values[k].number.u;
|
||||
+ else
|
||||
+ uni.u = 0;
|
||||
break;
|
||||
|
||||
case HLSL_TYPE_INT:
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/fx.c b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
||||
index 1314bc09e73..7d4a9d2e2ff 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/fx.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
||||
@@ -665,6 +665,7 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
||||
|
||||
case HLSL_CLASS_ARRAY:
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_TECHNIQUE:
|
||||
case HLSL_CLASS_CONSTANT_BUFFER:
|
||||
@@ -1117,6 +1118,7 @@ static bool is_type_supported_fx_2(struct hlsl_ctx *ctx, const struct hlsl_type
|
||||
return false;
|
||||
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_TECHNIQUE:
|
||||
case HLSL_CLASS_CONSTANT_BUFFER:
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
index dd1c121d5a8..b29f13f2b19 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
@@ -305,6 +305,9 @@ static void glsl_src_init(struct glsl_src *glsl_src, struct vkd3d_glsl_generator
|
||||
{
|
||||
case VKD3DSPSM_NONE:
|
||||
break;
|
||||
+ case VKD3DSPSM_NEG:
|
||||
+ vkd3d_string_buffer_printf(glsl_src->str, "-%s", str->buffer);
|
||||
+ break;
|
||||
case VKD3DSPSM_ABS:
|
||||
vkd3d_string_buffer_printf(glsl_src->str, "abs(%s)", str->buffer);
|
||||
break;
|
||||
@@ -414,6 +417,22 @@ static void shader_glsl_binop(struct vkd3d_glsl_generator *gen,
|
||||
glsl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
}
|
||||
|
||||
+static void shader_glsl_intrinsic(struct vkd3d_glsl_generator *gen,
|
||||
+ const struct vkd3d_shader_instruction *ins, const char *op)
|
||||
+{
|
||||
+ struct glsl_src src;
|
||||
+ struct glsl_dst dst;
|
||||
+ uint32_t mask;
|
||||
+
|
||||
+ mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
|
||||
+ glsl_src_init(&src, gen, &ins->src[0], mask);
|
||||
+
|
||||
+ shader_glsl_print_assignment(gen, &dst, "%s(%s)", op, src.str->buffer);
|
||||
+
|
||||
+ glsl_src_cleanup(&src, &gen->string_buffers);
|
||||
+ glsl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
+}
|
||||
+
|
||||
static void shader_glsl_relop(struct vkd3d_glsl_generator *gen,
|
||||
const struct vkd3d_shader_instruction *ins, const char *scalar_op, const char *vector_op)
|
||||
{
|
||||
@@ -453,6 +472,31 @@ static void shader_glsl_mov(struct vkd3d_glsl_generator *gen, const struct vkd3d
|
||||
glsl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
}
|
||||
|
||||
+static void shader_glsl_movc(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
||||
+{
|
||||
+ unsigned int component_count;
|
||||
+ struct glsl_src src[3];
|
||||
+ struct glsl_dst dst;
|
||||
+ uint32_t mask;
|
||||
+
|
||||
+ mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
|
||||
+ glsl_src_init(&src[0], gen, &ins->src[0], mask);
|
||||
+ glsl_src_init(&src[1], gen, &ins->src[1], mask);
|
||||
+ glsl_src_init(&src[2], gen, &ins->src[2], mask);
|
||||
+
|
||||
+ if ((component_count = vsir_write_mask_component_count(mask)) > 1)
|
||||
+ shader_glsl_print_assignment(gen, &dst, "mix(%s, %s, bvec%u(%s))",
|
||||
+ src[2].str->buffer, src[1].str->buffer, component_count, src[0].str->buffer);
|
||||
+ else
|
||||
+ shader_glsl_print_assignment(gen, &dst, "mix(%s, %s, bool(%s))",
|
||||
+ src[2].str->buffer, src[1].str->buffer, src[0].str->buffer);
|
||||
+
|
||||
+ glsl_src_cleanup(&src[2], &gen->string_buffers);
|
||||
+ glsl_src_cleanup(&src[1], &gen->string_buffers);
|
||||
+ glsl_src_cleanup(&src[0], &gen->string_buffers);
|
||||
+ glsl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
+}
|
||||
+
|
||||
static void shader_glsl_print_sysval_name(struct vkd3d_string_buffer *buffer, struct vkd3d_glsl_generator *gen,
|
||||
enum vkd3d_shader_sysval_semantic sysval, unsigned int idx)
|
||||
{
|
||||
@@ -608,6 +652,15 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
||||
case VKD3DSIH_DCL_OUTPUT_SIV:
|
||||
case VKD3DSIH_NOP:
|
||||
break;
|
||||
+ case VKD3DSIH_DIV:
|
||||
+ shader_glsl_binop(gen, ins, "/");
|
||||
+ break;
|
||||
+ case VKD3DSIH_FRC:
|
||||
+ shader_glsl_intrinsic(gen, ins, "fract");
|
||||
+ break;
|
||||
+ case VKD3DSIH_GEO:
|
||||
+ shader_glsl_relop(gen, ins, ">=", "greaterThanEqual");
|
||||
+ break;
|
||||
case VKD3DSIH_INE:
|
||||
case VKD3DSIH_NEU:
|
||||
shader_glsl_relop(gen, ins, "!=", "notEqual");
|
||||
@@ -615,6 +668,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
||||
case VKD3DSIH_MOV:
|
||||
shader_glsl_mov(gen, ins);
|
||||
break;
|
||||
+ case VKD3DSIH_MOVC:
|
||||
+ shader_glsl_movc(gen, ins);
|
||||
+ break;
|
||||
case VKD3DSIH_MUL:
|
||||
shader_glsl_binop(gen, ins, "*");
|
||||
break;
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.c b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
|
||||
index 6323260eab7..f4401bc5d89 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
|
||||
@@ -276,6 +276,7 @@ bool hlsl_type_is_shader(const struct hlsl_type *type)
|
||||
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_RASTERIZER_STATE:
|
||||
case HLSL_CLASS_RENDER_TARGET_VIEW:
|
||||
@@ -418,6 +419,7 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
|
||||
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_PIXEL_SHADER:
|
||||
case HLSL_CLASS_RASTERIZER_STATE:
|
||||
@@ -494,6 +496,7 @@ static bool type_is_single_component(const struct hlsl_type *type)
|
||||
{
|
||||
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PIXEL_SHADER:
|
||||
case HLSL_CLASS_SCALAR:
|
||||
case HLSL_CLASS_SAMPLER:
|
||||
@@ -670,6 +673,7 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty
|
||||
break;
|
||||
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_TECHNIQUE:
|
||||
case HLSL_CLASS_VOID:
|
||||
@@ -1061,6 +1065,7 @@ unsigned int hlsl_type_component_count(const struct hlsl_type *type)
|
||||
|
||||
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PIXEL_SHADER:
|
||||
case HLSL_CLASS_RASTERIZER_STATE:
|
||||
case HLSL_CLASS_RENDER_TARGET_VIEW:
|
||||
@@ -1155,6 +1160,7 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2
|
||||
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_PIXEL_SHADER:
|
||||
case HLSL_CLASS_RASTERIZER_STATE:
|
||||
@@ -1629,6 +1635,16 @@ struct hlsl_ir_node *hlsl_new_ternary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_ex
|
||||
return hlsl_new_expr(ctx, op, operands, arg1->data_type, &arg1->loc);
|
||||
}
|
||||
|
||||
+static struct hlsl_ir_node *hlsl_new_error_expr(struct hlsl_ctx *ctx)
|
||||
+{
|
||||
+ static const struct vkd3d_shader_location loc = {.source_name = "<error>"};
|
||||
+ struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0};
|
||||
+
|
||||
+ /* Use a dummy location; we should never report any messages related to
|
||||
+ * this expression. */
|
||||
+ return hlsl_new_expr(ctx, HLSL_OP0_ERROR, operands, ctx->builtin_types.error, &loc);
|
||||
+}
|
||||
+
|
||||
struct hlsl_ir_node *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition,
|
||||
struct hlsl_block *then_block, struct hlsl_block *else_block, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
@@ -2710,6 +2726,10 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
|
||||
}
|
||||
return string;
|
||||
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
+ vkd3d_string_buffer_printf(string, "<error type>");
|
||||
+ return string;
|
||||
+
|
||||
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
@@ -3049,6 +3069,7 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op)
|
||||
{
|
||||
static const char *const op_names[] =
|
||||
{
|
||||
+ [HLSL_OP0_ERROR] = "error",
|
||||
[HLSL_OP0_VOID] = "void",
|
||||
[HLSL_OP0_RASTERIZER_SAMPLE_COUNT] = "GetRenderTargetSampleCount",
|
||||
|
||||
@@ -3990,12 +4011,12 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
|
||||
|
||||
static const char * const names[] =
|
||||
{
|
||||
- "float",
|
||||
- "half",
|
||||
- "double",
|
||||
- "int",
|
||||
- "uint",
|
||||
- "bool",
|
||||
+ [HLSL_TYPE_FLOAT] = "float",
|
||||
+ [HLSL_TYPE_HALF] = "half",
|
||||
+ [HLSL_TYPE_DOUBLE] = "double",
|
||||
+ [HLSL_TYPE_INT] = "int",
|
||||
+ [HLSL_TYPE_UINT] = "uint",
|
||||
+ [HLSL_TYPE_BOOL] = "bool",
|
||||
};
|
||||
|
||||
static const char *const variants_float[] = {"min10float", "min16float"};
|
||||
@@ -4146,6 +4167,7 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
|
||||
ctx->builtin_types.Void = hlsl_new_simple_type(ctx, "void", HLSL_CLASS_VOID);
|
||||
ctx->builtin_types.null = hlsl_new_type(ctx, "NULL", HLSL_CLASS_NULL, HLSL_TYPE_UINT, 1, 1);
|
||||
ctx->builtin_types.string = hlsl_new_simple_type(ctx, "string", HLSL_CLASS_STRING);
|
||||
+ ctx->builtin_types.error = hlsl_new_simple_type(ctx, "<error type>", HLSL_CLASS_ERROR);
|
||||
hlsl_scope_add_type(ctx->globals, ctx->builtin_types.string);
|
||||
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "DepthStencilView", HLSL_CLASS_DEPTH_STENCIL_VIEW));
|
||||
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "DepthStencilState", HLSL_CLASS_DEPTH_STENCIL_STATE));
|
||||
@@ -4248,6 +4270,7 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compil
|
||||
|
||||
case VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY:
|
||||
ctx->semantic_compat_mapping = option->value & VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES;
|
||||
+ ctx->double_as_float_alias = option->value & VKD3D_SHADER_COMPILE_OPTION_DOUBLE_AS_FLOAT_ALIAS;
|
||||
break;
|
||||
|
||||
case VKD3D_SHADER_COMPILE_OPTION_CHILD_EFFECT:
|
||||
@@ -4267,6 +4290,10 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compil
|
||||
}
|
||||
}
|
||||
|
||||
+ if (!(ctx->error_instr = hlsl_new_error_expr(ctx)))
|
||||
+ return false;
|
||||
+ hlsl_block_add_instr(&ctx->static_initializers, ctx->error_instr);
|
||||
+
|
||||
ctx->domain = VKD3D_TESSELLATOR_DOMAIN_INVALID;
|
||||
ctx->output_control_point_count = UINT_MAX;
|
||||
ctx->output_primitive = 0;
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
||||
index 20a96692a48..b8678962f67 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
||||
@@ -106,6 +106,7 @@ enum hlsl_type_class
|
||||
HLSL_CLASS_BLEND_STATE,
|
||||
HLSL_CLASS_VOID,
|
||||
HLSL_CLASS_NULL,
|
||||
+ HLSL_CLASS_ERROR,
|
||||
};
|
||||
|
||||
enum hlsl_base_type
|
||||
@@ -361,6 +362,9 @@ struct hlsl_block
|
||||
{
|
||||
/* List containing instruction nodes; linked by the hlsl_ir_node.entry fields. */
|
||||
struct list instrs;
|
||||
+ /* Instruction representing the "value" of this block, if applicable.
|
||||
+ * This may point to an instruction outside of this block! */
|
||||
+ struct hlsl_ir_node *value;
|
||||
};
|
||||
|
||||
/* A reference to an instruction node (struct hlsl_ir_node), usable as a field in other structs.
|
||||
@@ -657,6 +661,7 @@ struct hlsl_ir_switch
|
||||
|
||||
enum hlsl_ir_expr_op
|
||||
{
|
||||
+ HLSL_OP0_ERROR,
|
||||
HLSL_OP0_VOID,
|
||||
HLSL_OP0_RASTERIZER_SAMPLE_COUNT,
|
||||
|
||||
@@ -1043,8 +1048,12 @@ struct hlsl_ctx
|
||||
struct hlsl_type *string;
|
||||
struct hlsl_type *Void;
|
||||
struct hlsl_type *null;
|
||||
+ struct hlsl_type *error;
|
||||
} builtin_types;
|
||||
|
||||
+ /* Pre-allocated "error" expression. */
|
||||
+ struct hlsl_ir_node *error_instr;
|
||||
+
|
||||
/* List of the instruction nodes for initializing static variables. */
|
||||
struct hlsl_block static_initializers;
|
||||
|
||||
@@ -1091,6 +1100,7 @@ struct hlsl_ctx
|
||||
bool child_effect;
|
||||
bool include_empty_buffers;
|
||||
bool warn_implicit_truncation;
|
||||
+ bool double_as_float_alias;
|
||||
};
|
||||
|
||||
static inline bool hlsl_version_ge(const struct hlsl_ctx *ctx, unsigned int major, unsigned int minor)
|
||||
@@ -1211,16 +1221,19 @@ static inline struct hlsl_ir_stateblock_constant *hlsl_ir_stateblock_constant(co
|
||||
static inline void hlsl_block_init(struct hlsl_block *block)
|
||||
{
|
||||
list_init(&block->instrs);
|
||||
+ block->value = NULL;
|
||||
}
|
||||
|
||||
static inline void hlsl_block_add_instr(struct hlsl_block *block, struct hlsl_ir_node *instr)
|
||||
{
|
||||
list_add_tail(&block->instrs, &instr->entry);
|
||||
+ block->value = (instr->data_type ? instr : NULL);
|
||||
}
|
||||
|
||||
static inline void hlsl_block_add_block(struct hlsl_block *block, struct hlsl_block *add)
|
||||
{
|
||||
list_move_tail(&block->instrs, &add->instrs);
|
||||
+ block->value = add->value;
|
||||
}
|
||||
|
||||
static inline void hlsl_src_from_node(struct hlsl_src *src, struct hlsl_ir_node *node)
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.l b/libs/vkd3d/libs/vkd3d-shader/hlsl.l
|
||||
index b7c242661e3..97d8b13772b 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.l
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.l
|
||||
@@ -90,7 +90,6 @@ default {return KW_DEFAULT; }
|
||||
discard {return KW_DISCARD; }
|
||||
DomainShader {return KW_DOMAINSHADER; }
|
||||
do {return KW_DO; }
|
||||
-double {return KW_DOUBLE; }
|
||||
else {return KW_ELSE; }
|
||||
export {return KW_EXPORT; }
|
||||
extern {return KW_EXTERN; }
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.y b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
||||
index 67262c2ccfd..c39f2020ef7 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
||||
@@ -147,7 +147,7 @@ static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const cha
|
||||
|
||||
static struct hlsl_ir_node *node_from_block(struct hlsl_block *block)
|
||||
{
|
||||
- return LIST_ENTRY(list_tail(&block->instrs), struct hlsl_ir_node, entry);
|
||||
+ return block->value;
|
||||
}
|
||||
|
||||
static struct hlsl_block *make_empty_block(struct hlsl_ctx *ctx)
|
||||
@@ -489,9 +489,10 @@ static bool append_conditional_break(struct hlsl_ctx *ctx, struct hlsl_block *co
|
||||
check_condition_type(ctx, condition);
|
||||
|
||||
bool_type = hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL);
|
||||
- if (!(cast = hlsl_new_cast(ctx, condition, bool_type, &condition->loc)))
|
||||
+ /* We already checked for a 1-component numeric type, so
|
||||
+ * add_implicit_conversion() is equivalent to add_cast() here. */
|
||||
+ if (!(cast = add_cast(ctx, cond_block, condition, bool_type, &condition->loc)))
|
||||
return false;
|
||||
- hlsl_block_add_instr(cond_block, cast);
|
||||
|
||||
if (!(not = hlsl_new_unary_expr(ctx, HLSL_OP1_LOGIC_NOT, cast, &condition->loc)))
|
||||
return false;
|
||||
@@ -639,14 +640,14 @@ static struct hlsl_default_value evaluate_static_expression(struct hlsl_ctx *ctx
|
||||
return ret;
|
||||
hlsl_block_add_block(&expr, block);
|
||||
|
||||
- if (!add_implicit_conversion(ctx, &expr, node_from_block(&expr), dst_type, loc))
|
||||
+ if (!(node = add_implicit_conversion(ctx, &expr, node_from_block(&expr), dst_type, loc)))
|
||||
{
|
||||
hlsl_block_cleanup(&expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Wrap the node into a src to allow the reference to survive the multiple const passes. */
|
||||
- hlsl_src_from_node(&src, node_from_block(&expr));
|
||||
+ hlsl_src_from_node(&src, node);
|
||||
hlsl_run_const_passes(ctx, &expr);
|
||||
node = src.node;
|
||||
hlsl_src_remove(&src);
|
||||
@@ -1710,12 +1711,18 @@ static struct hlsl_ir_node *add_unary_arithmetic_expr(struct hlsl_ctx *ctx, stru
|
||||
{
|
||||
struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {arg};
|
||||
|
||||
+ if (arg->data_type->class == HLSL_CLASS_ERROR)
|
||||
+ return arg;
|
||||
+
|
||||
return add_expr(ctx, block, op, args, arg->data_type, loc);
|
||||
}
|
||||
|
||||
static struct hlsl_ir_node *add_unary_bitwise_expr(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
+ if (arg->data_type->class == HLSL_CLASS_ERROR)
|
||||
+ return arg;
|
||||
+
|
||||
check_integer_type(ctx, arg);
|
||||
|
||||
return add_unary_arithmetic_expr(ctx, block, op, arg, loc);
|
||||
@@ -1727,6 +1734,9 @@ static struct hlsl_ir_node *add_unary_logical_expr(struct hlsl_ctx *ctx, struct
|
||||
struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0};
|
||||
struct hlsl_type *bool_type;
|
||||
|
||||
+ if (arg->data_type->class == HLSL_CLASS_ERROR)
|
||||
+ return arg;
|
||||
+
|
||||
bool_type = hlsl_get_numeric_type(ctx, arg->data_type->class, HLSL_TYPE_BOOL,
|
||||
arg->data_type->dimx, arg->data_type->dimy);
|
||||
|
||||
@@ -1756,7 +1766,11 @@ static struct hlsl_ir_node *add_binary_arithmetic_expr(struct hlsl_ctx *ctx, str
|
||||
struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0};
|
||||
struct hlsl_type *common_type;
|
||||
|
||||
- common_type = get_common_numeric_type(ctx, arg1, arg2, loc);
|
||||
+ if (!(common_type = get_common_numeric_type(ctx, arg1, arg2, loc)))
|
||||
+ {
|
||||
+ block->value = ctx->error_instr;
|
||||
+ return block->value;
|
||||
+ }
|
||||
|
||||
if (!(args[0] = add_implicit_conversion(ctx, block, arg1, common_type, loc)))
|
||||
return NULL;
|
||||
@@ -2059,18 +2073,17 @@ static bool invert_swizzle_matrix(uint32_t *swizzle, unsigned int *writemask, un
|
||||
return true;
|
||||
}
|
||||
|
||||
-static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_node *lhs,
|
||||
+static bool add_assignment(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_node *lhs,
|
||||
enum parse_assign_op assign_op, struct hlsl_ir_node *rhs)
|
||||
{
|
||||
struct hlsl_type *lhs_type = lhs->data_type;
|
||||
- struct hlsl_ir_node *copy;
|
||||
unsigned int writemask = 0, width = 0;
|
||||
bool matrix_writemask = false;
|
||||
|
||||
if (assign_op == ASSIGN_OP_SUB)
|
||||
{
|
||||
if (!(rhs = add_unary_arithmetic_expr(ctx, block, HLSL_OP1_NEG, rhs, &rhs->loc)))
|
||||
- return NULL;
|
||||
+ return false;
|
||||
assign_op = ASSIGN_OP_ADD;
|
||||
}
|
||||
if (assign_op != ASSIGN_OP_ASSIGN)
|
||||
@@ -2079,7 +2092,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
|
||||
VKD3D_ASSERT(op);
|
||||
if (!(rhs = add_binary_expr(ctx, block, op, lhs, rhs, &rhs->loc)))
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
|
||||
if (hlsl_is_numeric_type(lhs_type))
|
||||
@@ -2089,14 +2102,14 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
}
|
||||
|
||||
if (!(rhs = add_implicit_conversion(ctx, block, rhs, lhs_type, &rhs->loc)))
|
||||
- return NULL;
|
||||
+ return false;
|
||||
|
||||
while (lhs->type != HLSL_IR_LOAD && lhs->type != HLSL_IR_INDEX)
|
||||
{
|
||||
if (lhs->type == HLSL_IR_EXPR && hlsl_ir_expr(lhs)->op == HLSL_OP1_CAST)
|
||||
{
|
||||
hlsl_fixme(ctx, &lhs->loc, "Cast on the LHS.");
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
else if (lhs->type == HLSL_IR_SWIZZLE)
|
||||
{
|
||||
@@ -2111,25 +2124,23 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
if (swizzle->val.node->type != HLSL_IR_LOAD && swizzle->val.node->type != HLSL_IR_INDEX)
|
||||
{
|
||||
hlsl_fixme(ctx, &lhs->loc, "Unhandled source of matrix swizzle.");
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
if (!invert_swizzle_matrix(&s, &writemask, &width))
|
||||
{
|
||||
hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask for matrix.");
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
matrix_writemask = true;
|
||||
}
|
||||
else if (!invert_swizzle(&s, &writemask, &width))
|
||||
{
|
||||
hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask.");
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
|
||||
if (!(new_swizzle = hlsl_new_swizzle(ctx, s, width, rhs, &swizzle->node.loc)))
|
||||
- {
|
||||
- return NULL;
|
||||
- }
|
||||
+ return false;
|
||||
hlsl_block_add_instr(block, new_swizzle);
|
||||
|
||||
lhs = swizzle->val.node;
|
||||
@@ -2138,7 +2149,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
else
|
||||
{
|
||||
hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue.");
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2153,11 +2164,11 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
if (!hlsl_index_is_resource_access(hlsl_ir_index(lhs)))
|
||||
{
|
||||
hlsl_fixme(ctx, &lhs->loc, "Non-direct structured resource store.");
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
|
||||
if (!hlsl_init_deref_from_index_chain(ctx, &resource_deref, hlsl_ir_index(lhs)->val.node))
|
||||
- return NULL;
|
||||
+ return false;
|
||||
|
||||
resource_type = hlsl_deref_get_type(ctx, &resource_deref);
|
||||
VKD3D_ASSERT(resource_type->class == HLSL_CLASS_TEXTURE || resource_type->class == HLSL_CLASS_UAV);
|
||||
@@ -2179,7 +2190,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
if (!(store = hlsl_new_resource_store(ctx, &resource_deref, coords, rhs, &lhs->loc)))
|
||||
{
|
||||
hlsl_cleanup_deref(&resource_deref);
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_cleanup_deref(&resource_deref);
|
||||
@@ -2206,13 +2217,13 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
if (!(load = hlsl_add_load_component(ctx, block, rhs, k++, &rhs->loc)))
|
||||
{
|
||||
hlsl_cleanup_deref(&deref);
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
|
||||
if (!hlsl_new_store_component(ctx, &store_block, &deref, component, load))
|
||||
{
|
||||
hlsl_cleanup_deref(&deref);
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
hlsl_block_add_block(block, &store_block);
|
||||
}
|
||||
@@ -2237,23 +2248,23 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
continue;
|
||||
|
||||
if (!(c = hlsl_new_uint_constant(ctx, i, &lhs->loc)))
|
||||
- return NULL;
|
||||
+ return false;
|
||||
hlsl_block_add_instr(block, c);
|
||||
|
||||
if (!(cell = hlsl_new_index(ctx, &row->node, c, &lhs->loc)))
|
||||
- return NULL;
|
||||
+ return false;
|
||||
hlsl_block_add_instr(block, cell);
|
||||
|
||||
if (!(load = hlsl_add_load_component(ctx, block, rhs, k++, &rhs->loc)))
|
||||
- return NULL;
|
||||
+ return false;
|
||||
|
||||
if (!hlsl_init_deref_from_index_chain(ctx, &deref, cell))
|
||||
- return NULL;
|
||||
+ return false;
|
||||
|
||||
if (!(store = hlsl_new_store_index(ctx, &deref, NULL, load, 0, &rhs->loc)))
|
||||
{
|
||||
hlsl_cleanup_deref(&deref);
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_cleanup_deref(&deref);
|
||||
@@ -2265,24 +2276,19 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
struct hlsl_deref deref;
|
||||
|
||||
if (!hlsl_init_deref_from_index_chain(ctx, &deref, lhs))
|
||||
- return NULL;
|
||||
+ return false;
|
||||
|
||||
if (!(store = hlsl_new_store_index(ctx, &deref, NULL, rhs, writemask, &rhs->loc)))
|
||||
{
|
||||
hlsl_cleanup_deref(&deref);
|
||||
- return NULL;
|
||||
+ return false;
|
||||
}
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_cleanup_deref(&deref);
|
||||
}
|
||||
|
||||
- /* Don't use the instruction itself as a source, as this makes structure
|
||||
- * splitting easier. Instead copy it here. Since we retrieve sources from
|
||||
- * the last instruction in the list, we do need to copy. */
|
||||
- if (!(copy = hlsl_new_copy(ctx, rhs)))
|
||||
- return NULL;
|
||||
- hlsl_block_add_instr(block, copy);
|
||||
- return copy;
|
||||
+ block->value = rhs;
|
||||
+ return true;
|
||||
}
|
||||
|
||||
static bool add_increment(struct hlsl_ctx *ctx, struct hlsl_block *block, bool decrement, bool post,
|
||||
@@ -5340,11 +5346,6 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
}
|
||||
else
|
||||
{
|
||||
- cond_type = hlsl_get_numeric_type(ctx, cond_type->class, HLSL_TYPE_BOOL,
|
||||
- cond_type->dimx, cond_type->dimy);
|
||||
- if (!(cond = add_implicit_conversion(ctx, block, cond, cond_type, &cond->loc)))
|
||||
- return false;
|
||||
-
|
||||
if (common_type->dimx == 1 && common_type->dimy == 1)
|
||||
{
|
||||
common_type = hlsl_get_numeric_type(ctx, cond_type->class,
|
||||
@@ -5366,6 +5367,11 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
hlsl_release_string_buffer(ctx, cond_string);
|
||||
hlsl_release_string_buffer(ctx, value_string);
|
||||
}
|
||||
+
|
||||
+ cond_type = hlsl_get_numeric_type(ctx, common_type->class, HLSL_TYPE_BOOL,
|
||||
+ common_type->dimx, common_type->dimy);
|
||||
+ if (!(cond = add_implicit_conversion(ctx, block, cond, cond_type, &cond->loc)))
|
||||
+ return false;
|
||||
}
|
||||
|
||||
if (!(first = add_implicit_conversion(ctx, block, first, common_type, &first->loc)))
|
||||
@@ -6296,7 +6302,6 @@ static bool state_block_add_entry(struct hlsl_state_block *state_block, struct h
|
||||
%token KW_DISCARD
|
||||
%token KW_DO
|
||||
%token KW_DOMAINSHADER
|
||||
-%token KW_DOUBLE
|
||||
%token KW_ELSE
|
||||
%token KW_EXPORT
|
||||
%token KW_EXTERN
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
||||
index 6cae0e3b5c9..feab6cf06c1 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
||||
@@ -1655,11 +1655,16 @@ static bool copy_propagation_transform_load(struct hlsl_ctx *ctx,
|
||||
case HLSL_CLASS_MATRIX:
|
||||
case HLSL_CLASS_ARRAY:
|
||||
case HLSL_CLASS_STRUCT:
|
||||
- case HLSL_CLASS_CONSTANT_BUFFER:
|
||||
- /* FIXME: Actually we shouldn't even get here, but we don't split
|
||||
- * matrices yet. */
|
||||
+ /* We can't handle complex types here.
|
||||
+ * They should have been already split anyway by earlier passes,
|
||||
+ * but they may not have been deleted yet. We can't rely on DCE to
|
||||
+ * solve that problem for us, since we may be called on a partial
|
||||
+ * block, but DCE deletes dead stores, so it needs to be able to
|
||||
+ * see the whole program. */
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
return false;
|
||||
|
||||
+ case HLSL_CLASS_CONSTANT_BUFFER:
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_TECHNIQUE:
|
||||
@@ -6622,7 +6627,13 @@ static bool sm1_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
return true;
|
||||
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
- hlsl_fixme(ctx, &instr->loc, "SM1 cast from double to float.");
|
||||
+ if (ctx->double_as_float_alias)
|
||||
+ {
|
||||
+ sm1_generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_MOV, 0, 0, true);
|
||||
+ return true;
|
||||
+ }
|
||||
+ hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
+ "The 'double' type is not supported for the %s profile.", ctx->profile->name);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -6660,7 +6671,22 @@ static bool sm1_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
break;
|
||||
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
- hlsl_fixme(ctx, &instr->loc, "SM1 cast to double.");
|
||||
+ switch (src_type->e.numeric.type)
|
||||
+ {
|
||||
+ case HLSL_TYPE_FLOAT:
|
||||
+ if (ctx->double_as_float_alias)
|
||||
+ {
|
||||
+ sm1_generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_MOV, 0, 0, true);
|
||||
+ return true;
|
||||
+ }
|
||||
+ hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
+ "The 'double' type is not supported for the %s profile.", ctx->profile->name);
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ hlsl_fixme(ctx, &instr->loc, "SM1 cast to double.");
|
||||
+ break;
|
||||
+ }
|
||||
break;
|
||||
|
||||
case HLSL_TYPE_BOOL:
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
index 7f1e0fea2c3..1876ad38653 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
@@ -394,6 +394,7 @@ struct vkd3d_spirv_builder
|
||||
uint32_t type_bool_id;
|
||||
uint32_t type_void_id;
|
||||
uint32_t scope_subgroup_id;
|
||||
+ uint32_t numeric_type_ids[VKD3D_SHADER_COMPONENT_TYPE_COUNT][VKD3D_VEC4_SIZE];
|
||||
|
||||
struct vkd3d_spirv_stream debug_stream; /* debug instructions */
|
||||
struct vkd3d_spirv_stream annotation_stream; /* decoration instructions */
|
||||
@@ -1902,29 +1903,37 @@ static uint32_t vkd3d_spirv_build_op_glsl_std450_nclamp(struct vkd3d_spirv_build
|
||||
static uint32_t vkd3d_spirv_get_type_id(struct vkd3d_spirv_builder *builder,
|
||||
enum vkd3d_shader_component_type component_type, unsigned int component_count)
|
||||
{
|
||||
- uint32_t scalar_id;
|
||||
+ uint32_t scalar_id, type_id;
|
||||
+
|
||||
+ VKD3D_ASSERT(component_type < VKD3D_SHADER_COMPONENT_TYPE_COUNT);
|
||||
+ VKD3D_ASSERT(1 <= component_count && component_count <= VKD3D_VEC4_SIZE);
|
||||
+
|
||||
+ if ((type_id = builder->numeric_type_ids[component_type][component_count - 1]))
|
||||
+ return type_id;
|
||||
|
||||
if (component_count == 1)
|
||||
{
|
||||
switch (component_type)
|
||||
{
|
||||
case VKD3D_SHADER_COMPONENT_VOID:
|
||||
- return vkd3d_spirv_get_op_type_void(builder);
|
||||
+ type_id = vkd3d_spirv_get_op_type_void(builder);
|
||||
break;
|
||||
case VKD3D_SHADER_COMPONENT_FLOAT:
|
||||
- return vkd3d_spirv_get_op_type_float(builder, 32);
|
||||
+ type_id = vkd3d_spirv_get_op_type_float(builder, 32);
|
||||
break;
|
||||
case VKD3D_SHADER_COMPONENT_INT:
|
||||
case VKD3D_SHADER_COMPONENT_UINT:
|
||||
- return vkd3d_spirv_get_op_type_int(builder, 32, component_type == VKD3D_SHADER_COMPONENT_INT);
|
||||
+ type_id = vkd3d_spirv_get_op_type_int(builder, 32, component_type == VKD3D_SHADER_COMPONENT_INT);
|
||||
break;
|
||||
case VKD3D_SHADER_COMPONENT_BOOL:
|
||||
- return vkd3d_spirv_get_op_type_bool(builder);
|
||||
+ type_id = vkd3d_spirv_get_op_type_bool(builder);
|
||||
break;
|
||||
case VKD3D_SHADER_COMPONENT_DOUBLE:
|
||||
- return vkd3d_spirv_get_op_type_float(builder, 64);
|
||||
+ type_id = vkd3d_spirv_get_op_type_float(builder, 64);
|
||||
+ break;
|
||||
case VKD3D_SHADER_COMPONENT_UINT64:
|
||||
- return vkd3d_spirv_get_op_type_int(builder, 64, 0);
|
||||
+ type_id = vkd3d_spirv_get_op_type_int(builder, 64, 0);
|
||||
+ break;
|
||||
default:
|
||||
FIXME("Unhandled component type %#x.\n", component_type);
|
||||
return 0;
|
||||
@@ -1934,46 +1943,21 @@ static uint32_t vkd3d_spirv_get_type_id(struct vkd3d_spirv_builder *builder,
|
||||
{
|
||||
VKD3D_ASSERT(component_type != VKD3D_SHADER_COMPONENT_VOID);
|
||||
scalar_id = vkd3d_spirv_get_type_id(builder, component_type, 1);
|
||||
- return vkd3d_spirv_get_op_type_vector(builder, scalar_id, component_count);
|
||||
+ type_id = vkd3d_spirv_get_op_type_vector(builder, scalar_id, component_count);
|
||||
}
|
||||
+
|
||||
+ builder->numeric_type_ids[component_type][component_count - 1] = type_id;
|
||||
+
|
||||
+ return type_id;
|
||||
}
|
||||
|
||||
static uint32_t vkd3d_spirv_get_type_id_for_data_type(struct vkd3d_spirv_builder *builder,
|
||||
enum vkd3d_data_type data_type, unsigned int component_count)
|
||||
{
|
||||
- uint32_t scalar_id;
|
||||
+ enum vkd3d_shader_component_type component_type;
|
||||
|
||||
- if (component_count == 1)
|
||||
- {
|
||||
- switch (data_type)
|
||||
- {
|
||||
- case VKD3D_DATA_HALF: /* Minimum precision. TODO: native 16-bit */
|
||||
- case VKD3D_DATA_FLOAT:
|
||||
- case VKD3D_DATA_SNORM:
|
||||
- case VKD3D_DATA_UNORM:
|
||||
- return vkd3d_spirv_get_op_type_float(builder, 32);
|
||||
- break;
|
||||
- case VKD3D_DATA_INT:
|
||||
- case VKD3D_DATA_UINT:
|
||||
- case VKD3D_DATA_UINT16: /* Minimum precision. TODO: native 16-bit */
|
||||
- return vkd3d_spirv_get_op_type_int(builder, 32, data_type == VKD3D_DATA_INT);
|
||||
- break;
|
||||
- case VKD3D_DATA_DOUBLE:
|
||||
- return vkd3d_spirv_get_op_type_float(builder, 64);
|
||||
- case VKD3D_DATA_UINT64:
|
||||
- return vkd3d_spirv_get_op_type_int(builder, 64, 0);
|
||||
- case VKD3D_DATA_BOOL:
|
||||
- return vkd3d_spirv_get_op_type_bool(builder);
|
||||
- default:
|
||||
- FIXME("Unhandled data type %#x.\n", data_type);
|
||||
- return 0;
|
||||
- }
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- scalar_id = vkd3d_spirv_get_type_id_for_data_type(builder, data_type, 1);
|
||||
- return vkd3d_spirv_get_op_type_vector(builder, scalar_id, component_count);
|
||||
- }
|
||||
+ component_type = vkd3d_component_type_from_data_type(data_type);
|
||||
+ return vkd3d_spirv_get_type_id(builder, component_type, component_count);
|
||||
}
|
||||
|
||||
static void vkd3d_spirv_builder_init(struct vkd3d_spirv_builder *builder, const char *entry_point)
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/tpf.c b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
index 884a2998d5b..ab9f4cf2b57 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
@@ -3236,6 +3236,7 @@ static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type)
|
||||
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||
case HLSL_CLASS_EFFECT_GROUP:
|
||||
+ case HLSL_CLASS_ERROR:
|
||||
case HLSL_CLASS_STRUCT:
|
||||
case HLSL_CLASS_PASS:
|
||||
case HLSL_CLASS_PIXEL_SHADER:
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
index 447210449da..7ac86e35227 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
@@ -59,6 +59,8 @@
|
||||
#define VKD3D_VEC4_SIZE 4
|
||||
#define VKD3D_DVEC2_SIZE 2
|
||||
|
||||
+#define VKD3D_SHADER_COMPONENT_TYPE_COUNT (VKD3D_SHADER_COMPONENT_UINT64 + 1)
|
||||
+
|
||||
enum vkd3d_shader_error
|
||||
{
|
||||
VKD3D_SHADER_ERROR_DXBC_INVALID_SIZE = 1,
|
||||
diff --git a/libs/vkd3d/libs/vkd3d/state.c b/libs/vkd3d/libs/vkd3d/state.c
|
||||
index ea7d8f040b5..fb377177403 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d/state.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d/state.c
|
||||
@@ -1107,7 +1107,9 @@ static int compare_descriptor_range(const void *a, const void *b)
|
||||
if ((ret = vkd3d_u32_compare(range_a->offset, range_b->offset)))
|
||||
return ret;
|
||||
|
||||
- return (range_a->descriptor_count == UINT_MAX) - (range_b->descriptor_count == UINT_MAX);
|
||||
+ /* Place bounded ranges after unbounded ones of equal offset,
|
||||
+ * so the bounded range can be mapped to the unbounded one. */
|
||||
+ return (range_b->descriptor_count == UINT_MAX) - (range_a->descriptor_count == UINT_MAX);
|
||||
}
|
||||
|
||||
static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_root_signature *root_signature,
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,619 +0,0 @@
|
||||
From e48d811509a661939136b1567d165fc400a38784 Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Fri, 6 Sep 2024 08:13:50 +1000
|
||||
Subject: [PATCH] Updated vkd3d to bfd1fc9cd6cf9cf4e9c23b4ffad2ba8a3282c1f9.
|
||||
|
||||
---
|
||||
libs/vkd3d/libs/vkd3d-shader/d3dbc.c | 98 +++++++++++-----------
|
||||
libs/vkd3d/libs/vkd3d-shader/ir.c | 121 ++++++++++++++++-----------
|
||||
2 files changed, 121 insertions(+), 98 deletions(-)
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
index 3b9ec98448d..de5f28c1815 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
@@ -1862,7 +1862,7 @@ void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buff
|
||||
set_u32(buffer, creator_offset, offset - ctab_start);
|
||||
|
||||
ctab_end = bytecode_align(buffer);
|
||||
- set_u32(buffer, size_offset, vkd3d_make_u32(D3DSIO_COMMENT, (ctab_end - ctab_offset) / sizeof(uint32_t)));
|
||||
+ set_u32(buffer, size_offset, vkd3d_make_u32(VKD3D_SM1_OP_COMMENT, (ctab_end - ctab_offset) / sizeof(uint32_t)));
|
||||
}
|
||||
|
||||
static uint32_t sm1_encode_register_type(enum vkd3d_shader_register_type type)
|
||||
@@ -1873,7 +1873,7 @@ static uint32_t sm1_encode_register_type(enum vkd3d_shader_register_type type)
|
||||
|
||||
struct sm1_instruction
|
||||
{
|
||||
- D3DSHADER_INSTRUCTION_OPCODE_TYPE opcode;
|
||||
+ enum vkd3d_sm1_opcode opcode;
|
||||
unsigned int flags;
|
||||
|
||||
struct sm1_dst_register
|
||||
@@ -1902,7 +1902,7 @@ static bool is_inconsequential_instr(const struct sm1_instruction *instr)
|
||||
const struct sm1_dst_register *dst = &instr->dst;
|
||||
unsigned int i;
|
||||
|
||||
- if (instr->opcode != D3DSIO_MOV)
|
||||
+ if (instr->opcode != VKD3D_SM1_OP_MOV)
|
||||
return false;
|
||||
if (dst->mod != D3DSPDM_NONE)
|
||||
return false;
|
||||
@@ -1947,7 +1947,7 @@ static void d3dbc_write_instruction(struct d3dbc_compiler *d3dbc, const struct s
|
||||
token |= VKD3D_SM1_INSTRUCTION_FLAGS_MASK & (instr->flags << VKD3D_SM1_INSTRUCTION_FLAGS_SHIFT);
|
||||
|
||||
if (version->major > 1)
|
||||
- token |= (instr->has_dst + instr->src_count) << D3DSI_INSTLENGTH_SHIFT;
|
||||
+ token |= (instr->has_dst + instr->src_count) << VKD3D_SM1_INSTRUCTION_LENGTH_SHIFT;
|
||||
put_u32(buffer, token);
|
||||
|
||||
if (instr->has_dst)
|
||||
@@ -1967,7 +1967,7 @@ static void d3dbc_write_dp2add(struct d3dbc_compiler *d3dbc, const struct hlsl_r
|
||||
{
|
||||
struct sm1_instruction instr =
|
||||
{
|
||||
- .opcode = D3DSIO_DP2ADD,
|
||||
+ .opcode = VKD3D_SM1_OP_DP2ADD,
|
||||
|
||||
.dst.type = VKD3DSPR_TEMP,
|
||||
.dst.writemask = dst->writemask,
|
||||
@@ -1989,9 +1989,9 @@ static void d3dbc_write_dp2add(struct d3dbc_compiler *d3dbc, const struct hlsl_r
|
||||
d3dbc_write_instruction(d3dbc, &instr);
|
||||
}
|
||||
|
||||
-static void d3dbc_write_ternary_op(struct d3dbc_compiler *d3dbc,
|
||||
- D3DSHADER_INSTRUCTION_OPCODE_TYPE opcode, const struct hlsl_reg *dst,
|
||||
- const struct hlsl_reg *src1, const struct hlsl_reg *src2, const struct hlsl_reg *src3)
|
||||
+static void d3dbc_write_ternary_op(struct d3dbc_compiler *d3dbc, enum vkd3d_sm1_opcode opcode,
|
||||
+ const struct hlsl_reg *dst, const struct hlsl_reg *src1,
|
||||
+ const struct hlsl_reg *src2, const struct hlsl_reg *src3)
|
||||
{
|
||||
struct sm1_instruction instr =
|
||||
{
|
||||
@@ -2020,7 +2020,7 @@ static void d3dbc_write_ternary_op(struct d3dbc_compiler *d3dbc,
|
||||
d3dbc_write_instruction(d3dbc, &instr);
|
||||
}
|
||||
|
||||
-static void d3dbc_write_binary_op(struct d3dbc_compiler *d3dbc, D3DSHADER_INSTRUCTION_OPCODE_TYPE opcode,
|
||||
+static void d3dbc_write_binary_op(struct d3dbc_compiler *d3dbc, enum vkd3d_sm1_opcode opcode,
|
||||
const struct hlsl_reg *dst, const struct hlsl_reg *src1, const struct hlsl_reg *src2)
|
||||
{
|
||||
struct sm1_instruction instr =
|
||||
@@ -2046,7 +2046,7 @@ static void d3dbc_write_binary_op(struct d3dbc_compiler *d3dbc, D3DSHADER_INSTRU
|
||||
d3dbc_write_instruction(d3dbc, &instr);
|
||||
}
|
||||
|
||||
-static void d3dbc_write_dot(struct d3dbc_compiler *d3dbc, D3DSHADER_INSTRUCTION_OPCODE_TYPE opcode,
|
||||
+static void d3dbc_write_dot(struct d3dbc_compiler *d3dbc, enum vkd3d_sm1_opcode opcode,
|
||||
const struct hlsl_reg *dst, const struct hlsl_reg *src1, const struct hlsl_reg *src2)
|
||||
{
|
||||
struct sm1_instruction instr =
|
||||
@@ -2070,7 +2070,7 @@ static void d3dbc_write_dot(struct d3dbc_compiler *d3dbc, D3DSHADER_INSTRUCTION_
|
||||
d3dbc_write_instruction(d3dbc, &instr);
|
||||
}
|
||||
|
||||
-static void d3dbc_write_unary_op(struct d3dbc_compiler *d3dbc, D3DSHADER_INSTRUCTION_OPCODE_TYPE opcode,
|
||||
+static void d3dbc_write_unary_op(struct d3dbc_compiler *d3dbc, enum vkd3d_sm1_opcode opcode,
|
||||
const struct hlsl_reg *dst, const struct hlsl_reg *src,
|
||||
D3DSHADER_PARAM_SRCMOD_TYPE src_mod, D3DSHADER_PARAM_DSTMOD_TYPE dst_mod)
|
||||
{
|
||||
@@ -2118,7 +2118,7 @@ static void d3dbc_write_cast(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_
|
||||
/* Integrals are internally represented as floats, so no change is necessary.*/
|
||||
case HLSL_TYPE_HALF:
|
||||
case HLSL_TYPE_FLOAT:
|
||||
- d3dbc_write_unary_op(d3dbc, D3DSIO_MOV, &instr->reg, &arg1->reg, 0, 0);
|
||||
+ d3dbc_write_unary_op(d3dbc, VKD3D_SM1_OP_MOV, &instr->reg, &arg1->reg, 0, 0);
|
||||
break;
|
||||
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
@@ -2142,7 +2142,7 @@ static void d3dbc_write_cast(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_
|
||||
break;
|
||||
case HLSL_TYPE_INT:
|
||||
case HLSL_TYPE_UINT:
|
||||
- d3dbc_write_unary_op(d3dbc, D3DSIO_MOV, &instr->reg, &arg1->reg, 0, 0);
|
||||
+ d3dbc_write_unary_op(d3dbc, VKD3D_SM1_OP_MOV, &instr->reg, &arg1->reg, 0, 0);
|
||||
break;
|
||||
|
||||
case HLSL_TYPE_BOOL:
|
||||
@@ -2353,7 +2353,7 @@ static void d3dbc_write_vsir_simple_instruction(struct d3dbc_compiler *d3dbc,
|
||||
return;
|
||||
}
|
||||
|
||||
- instr.opcode = (D3DSHADER_INSTRUCTION_OPCODE_TYPE)info->sm1_opcode;
|
||||
+ instr.opcode = info->sm1_opcode;
|
||||
instr.has_dst = info->dst_count;
|
||||
instr.src_count = info->src_count;
|
||||
|
||||
@@ -2413,9 +2413,9 @@ static void d3dbc_write_semantic_dcl(struct d3dbc_compiler *d3dbc,
|
||||
reg.reg = element->register_index;
|
||||
}
|
||||
|
||||
- token = D3DSIO_DCL;
|
||||
+ token = VKD3D_SM1_OP_DCL;
|
||||
if (version->major > 1)
|
||||
- token |= 2 << D3DSI_INSTLENGTH_SHIFT;
|
||||
+ token |= 2 << VKD3D_SM1_INSTRUCTION_LENGTH_SHIFT;
|
||||
put_u32(buffer, token);
|
||||
|
||||
token = (1u << 31);
|
||||
@@ -2455,7 +2455,7 @@ static void d3dbc_write_semantic_dcls(struct d3dbc_compiler *d3dbc)
|
||||
}
|
||||
|
||||
static void d3dbc_write_per_component_unary_op(struct d3dbc_compiler *d3dbc,
|
||||
- const struct hlsl_ir_node *instr, D3DSHADER_INSTRUCTION_OPCODE_TYPE opcode)
|
||||
+ const struct hlsl_ir_node *instr, enum vkd3d_sm1_opcode opcode)
|
||||
{
|
||||
struct hlsl_ir_expr *expr = hlsl_ir_expr(instr);
|
||||
struct hlsl_ir_node *arg1 = expr->operands[0].node;
|
||||
@@ -2476,7 +2476,7 @@ static void d3dbc_write_sincos(struct d3dbc_compiler *d3dbc, enum hlsl_ir_expr_o
|
||||
{
|
||||
struct sm1_instruction instr =
|
||||
{
|
||||
- .opcode = D3DSIO_SINCOS,
|
||||
+ .opcode = VKD3D_SM1_OP_SINCOS,
|
||||
|
||||
.dst.type = VKD3DSPR_TEMP,
|
||||
.dst.writemask = dst->writemask,
|
||||
@@ -2523,7 +2523,7 @@ static void d3dbc_write_expr(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_
|
||||
|
||||
if (expr->op == HLSL_OP1_REINTERPRET)
|
||||
{
|
||||
- d3dbc_write_unary_op(d3dbc, D3DSIO_MOV, &instr->reg, &arg1->reg, 0, 0);
|
||||
+ d3dbc_write_unary_op(d3dbc, VKD3D_SM1_OP_MOV, &instr->reg, &arg1->reg, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2543,39 +2543,39 @@ static void d3dbc_write_expr(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_
|
||||
switch (expr->op)
|
||||
{
|
||||
case HLSL_OP1_ABS:
|
||||
- d3dbc_write_unary_op(d3dbc, D3DSIO_ABS, &instr->reg, &arg1->reg, 0, 0);
|
||||
+ d3dbc_write_unary_op(d3dbc, VKD3D_SM1_OP_ABS, &instr->reg, &arg1->reg, 0, 0);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_DSX:
|
||||
- d3dbc_write_unary_op(d3dbc, D3DSIO_DSX, &instr->reg, &arg1->reg, 0, 0);
|
||||
+ d3dbc_write_unary_op(d3dbc, VKD3D_SM1_OP_DSX, &instr->reg, &arg1->reg, 0, 0);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_DSY:
|
||||
- d3dbc_write_unary_op(d3dbc, D3DSIO_DSY, &instr->reg, &arg1->reg, 0, 0);
|
||||
+ d3dbc_write_unary_op(d3dbc, VKD3D_SM1_OP_DSY, &instr->reg, &arg1->reg, 0, 0);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_EXP2:
|
||||
- d3dbc_write_per_component_unary_op(d3dbc, instr, D3DSIO_EXP);
|
||||
+ d3dbc_write_per_component_unary_op(d3dbc, instr, VKD3D_SM1_OP_EXP);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_LOG2:
|
||||
- d3dbc_write_per_component_unary_op(d3dbc, instr, D3DSIO_LOG);
|
||||
+ d3dbc_write_per_component_unary_op(d3dbc, instr, VKD3D_SM1_OP_LOG);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_NEG:
|
||||
- d3dbc_write_unary_op(d3dbc, D3DSIO_MOV, &instr->reg, &arg1->reg, D3DSPSM_NEG, 0);
|
||||
+ d3dbc_write_unary_op(d3dbc, VKD3D_SM1_OP_MOV, &instr->reg, &arg1->reg, D3DSPSM_NEG, 0);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_SAT:
|
||||
- d3dbc_write_unary_op(d3dbc, D3DSIO_MOV, &instr->reg, &arg1->reg, 0, D3DSPDM_SATURATE);
|
||||
+ d3dbc_write_unary_op(d3dbc, VKD3D_SM1_OP_MOV, &instr->reg, &arg1->reg, 0, D3DSPDM_SATURATE);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_RCP:
|
||||
- d3dbc_write_per_component_unary_op(d3dbc, instr, D3DSIO_RCP);
|
||||
+ d3dbc_write_per_component_unary_op(d3dbc, instr, VKD3D_SM1_OP_RCP);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_RSQ:
|
||||
- d3dbc_write_per_component_unary_op(d3dbc, instr, D3DSIO_RSQ);
|
||||
+ d3dbc_write_per_component_unary_op(d3dbc, instr, VKD3D_SM1_OP_RSQ);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_COS_REDUCED:
|
||||
@@ -2584,34 +2584,34 @@ static void d3dbc_write_expr(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_
|
||||
break;
|
||||
|
||||
case HLSL_OP2_ADD:
|
||||
- d3dbc_write_binary_op(d3dbc, D3DSIO_ADD, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ d3dbc_write_binary_op(d3dbc, VKD3D_SM1_OP_ADD, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
break;
|
||||
|
||||
case HLSL_OP2_MAX:
|
||||
- d3dbc_write_binary_op(d3dbc, D3DSIO_MAX, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ d3dbc_write_binary_op(d3dbc, VKD3D_SM1_OP_MAX, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
break;
|
||||
|
||||
case HLSL_OP2_MIN:
|
||||
- d3dbc_write_binary_op(d3dbc, D3DSIO_MIN, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ d3dbc_write_binary_op(d3dbc, VKD3D_SM1_OP_MIN, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
break;
|
||||
|
||||
case HLSL_OP2_MUL:
|
||||
- d3dbc_write_binary_op(d3dbc, D3DSIO_MUL, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ d3dbc_write_binary_op(d3dbc, VKD3D_SM1_OP_MUL, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_FRACT:
|
||||
- d3dbc_write_unary_op(d3dbc, D3DSIO_FRC, &instr->reg, &arg1->reg, D3DSPSM_NONE, 0);
|
||||
+ d3dbc_write_unary_op(d3dbc, VKD3D_SM1_OP_FRC, &instr->reg, &arg1->reg, D3DSPSM_NONE, 0);
|
||||
break;
|
||||
|
||||
case HLSL_OP2_DOT:
|
||||
switch (arg1->data_type->dimx)
|
||||
{
|
||||
case 4:
|
||||
- d3dbc_write_dot(d3dbc, D3DSIO_DP4, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ d3dbc_write_dot(d3dbc, VKD3D_SM1_OP_DP4, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
- d3dbc_write_dot(d3dbc, D3DSIO_DP3, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ d3dbc_write_dot(d3dbc, VKD3D_SM1_OP_DP3, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -2620,23 +2620,23 @@ static void d3dbc_write_expr(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_
|
||||
break;
|
||||
|
||||
case HLSL_OP2_LOGIC_AND:
|
||||
- d3dbc_write_binary_op(d3dbc, D3DSIO_MIN, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ d3dbc_write_binary_op(d3dbc, VKD3D_SM1_OP_MIN, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
break;
|
||||
|
||||
case HLSL_OP2_LOGIC_OR:
|
||||
- d3dbc_write_binary_op(d3dbc, D3DSIO_MAX, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ d3dbc_write_binary_op(d3dbc, VKD3D_SM1_OP_MAX, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
break;
|
||||
|
||||
case HLSL_OP2_SLT:
|
||||
if (version->type == VKD3D_SHADER_TYPE_PIXEL)
|
||||
hlsl_fixme(ctx, &instr->loc, "Lower SLT instructions for pixel shaders.");
|
||||
- d3dbc_write_binary_op(d3dbc, D3DSIO_SLT, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ d3dbc_write_binary_op(d3dbc, VKD3D_SM1_OP_SLT, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
break;
|
||||
|
||||
case HLSL_OP3_CMP:
|
||||
if (version->type == VKD3D_SHADER_TYPE_VERTEX)
|
||||
hlsl_fixme(ctx, &instr->loc, "Lower CMP instructions for vertex shaders.");
|
||||
- d3dbc_write_ternary_op(d3dbc, D3DSIO_CMP, &instr->reg, &arg1->reg, &arg2->reg, &arg3->reg);
|
||||
+ d3dbc_write_ternary_op(d3dbc, VKD3D_SM1_OP_CMP, &instr->reg, &arg1->reg, &arg2->reg, &arg3->reg);
|
||||
break;
|
||||
|
||||
case HLSL_OP3_DP2ADD:
|
||||
@@ -2644,7 +2644,7 @@ static void d3dbc_write_expr(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_
|
||||
break;
|
||||
|
||||
case HLSL_OP3_MAD:
|
||||
- d3dbc_write_ternary_op(d3dbc, D3DSIO_MAD, &instr->reg, &arg1->reg, &arg2->reg, &arg3->reg);
|
||||
+ d3dbc_write_ternary_op(d3dbc, VKD3D_SM1_OP_MAD, &instr->reg, &arg1->reg, &arg2->reg, &arg3->reg);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -2666,7 +2666,7 @@ static void d3dbc_write_if(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_no
|
||||
|
||||
sm1_ifc = (struct sm1_instruction)
|
||||
{
|
||||
- .opcode = D3DSIO_IFC,
|
||||
+ .opcode = VKD3D_SM1_OP_IFC,
|
||||
.flags = VKD3D_SHADER_REL_OP_NE, /* Make it a "if_ne" instruction. */
|
||||
|
||||
.srcs[0].type = VKD3DSPR_TEMP,
|
||||
@@ -2686,12 +2686,12 @@ static void d3dbc_write_if(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_no
|
||||
|
||||
if (!list_empty(&iff->else_block.instrs))
|
||||
{
|
||||
- sm1_else = (struct sm1_instruction){.opcode = D3DSIO_ELSE};
|
||||
+ sm1_else = (struct sm1_instruction){.opcode = VKD3D_SM1_OP_ELSE};
|
||||
d3dbc_write_instruction(d3dbc, &sm1_else);
|
||||
d3dbc_write_block(d3dbc, &iff->else_block);
|
||||
}
|
||||
|
||||
- sm1_endif = (struct sm1_instruction){.opcode = D3DSIO_ENDIF};
|
||||
+ sm1_endif = (struct sm1_instruction){.opcode = VKD3D_SM1_OP_ENDIF};
|
||||
d3dbc_write_instruction(d3dbc, &sm1_endif);
|
||||
}
|
||||
|
||||
@@ -2707,7 +2707,7 @@ static void d3dbc_write_jump(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_
|
||||
|
||||
struct sm1_instruction sm1_instr =
|
||||
{
|
||||
- .opcode = D3DSIO_TEXKILL,
|
||||
+ .opcode = VKD3D_SM1_OP_TEXKILL,
|
||||
|
||||
.dst.type = VKD3DSPR_TEMP,
|
||||
.dst.reg = reg->id,
|
||||
@@ -2758,21 +2758,21 @@ static void d3dbc_write_resource_load(struct d3dbc_compiler *d3dbc, const struct
|
||||
switch (load->load_type)
|
||||
{
|
||||
case HLSL_RESOURCE_SAMPLE:
|
||||
- sm1_instr.opcode = D3DSIO_TEX;
|
||||
+ sm1_instr.opcode = VKD3D_SM1_OP_TEX;
|
||||
break;
|
||||
|
||||
case HLSL_RESOURCE_SAMPLE_PROJ:
|
||||
- sm1_instr.opcode = D3DSIO_TEX;
|
||||
+ sm1_instr.opcode = VKD3D_SM1_OP_TEX;
|
||||
sm1_instr.opcode |= VKD3DSI_TEXLD_PROJECT << VKD3D_SM1_INSTRUCTION_FLAGS_SHIFT;
|
||||
break;
|
||||
|
||||
case HLSL_RESOURCE_SAMPLE_LOD_BIAS:
|
||||
- sm1_instr.opcode = D3DSIO_TEX;
|
||||
+ sm1_instr.opcode = VKD3D_SM1_OP_TEX;
|
||||
sm1_instr.opcode |= VKD3DSI_TEXLD_BIAS << VKD3D_SM1_INSTRUCTION_FLAGS_SHIFT;
|
||||
break;
|
||||
|
||||
case HLSL_RESOURCE_SAMPLE_GRAD:
|
||||
- sm1_instr.opcode = D3DSIO_TEXLDD;
|
||||
+ sm1_instr.opcode = VKD3D_SM1_OP_TEXLDD;
|
||||
|
||||
sm1_instr.srcs[2].type = VKD3DSPR_TEMP;
|
||||
sm1_instr.srcs[2].reg = ddx->reg.id;
|
||||
@@ -2889,7 +2889,7 @@ int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
d3dbc_write_semantic_dcls(&d3dbc);
|
||||
d3dbc_write_block(&d3dbc, &entry_func->body);
|
||||
|
||||
- put_u32(buffer, D3DSIO_END);
|
||||
+ put_u32(buffer, VKD3D_SM1_OP_END);
|
||||
|
||||
result = ctx->result;
|
||||
if (buffer->status)
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
index d765abc938b..a483c25f3ad 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
@@ -19,6 +19,15 @@
|
||||
#include "vkd3d_shader_private.h"
|
||||
#include "vkd3d_types.h"
|
||||
|
||||
+struct vsir_normalisation_context
|
||||
+{
|
||||
+ enum vkd3d_result result;
|
||||
+ struct vsir_program *program;
|
||||
+ uint64_t config_flags;
|
||||
+ const struct vkd3d_shader_compile_info *compile_info;
|
||||
+ struct vkd3d_shader_message_context *message_context;
|
||||
+};
|
||||
+
|
||||
static int convert_parameter_info(const struct vkd3d_shader_compile_info *compile_info,
|
||||
unsigned int *ret_count, const struct vkd3d_shader_parameter1 **ret_parameters)
|
||||
{
|
||||
@@ -442,9 +451,10 @@ static enum vkd3d_result vsir_program_lower_sm1_sincos(struct vsir_program *prog
|
||||
}
|
||||
|
||||
static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *program,
|
||||
- struct vkd3d_shader_message_context *message_context)
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
struct vkd3d_shader_instruction_array *instructions = &program->instructions;
|
||||
+ struct vkd3d_shader_message_context *message_context = ctx->message_context;
|
||||
unsigned int tmp_idx = ~0u, i;
|
||||
enum vkd3d_result ret;
|
||||
|
||||
@@ -1755,8 +1765,7 @@ static enum vkd3d_result vsir_program_normalise_io_registers(struct vsir_program
|
||||
{
|
||||
struct io_normaliser normaliser = {program->instructions};
|
||||
struct vkd3d_shader_instruction *ins;
|
||||
- bool has_control_point_phase;
|
||||
- unsigned int i, j;
|
||||
+ unsigned int i;
|
||||
|
||||
normaliser.phase = VKD3DSIH_INVALID;
|
||||
normaliser.shader_type = program->shader_version.type;
|
||||
@@ -1765,7 +1774,7 @@ static enum vkd3d_result vsir_program_normalise_io_registers(struct vsir_program
|
||||
normaliser.output_signature = &program->output_signature;
|
||||
normaliser.patch_constant_signature = &program->patch_constant_signature;
|
||||
|
||||
- for (i = 0, has_control_point_phase = false; i < program->instructions.count; ++i)
|
||||
+ for (i = 0; i < program->instructions.count; ++i)
|
||||
{
|
||||
ins = &program->instructions.elements[i];
|
||||
|
||||
@@ -1779,8 +1788,6 @@ static enum vkd3d_result vsir_program_normalise_io_registers(struct vsir_program
|
||||
vkd3d_shader_instruction_make_nop(ins);
|
||||
break;
|
||||
case VKD3DSIH_HS_CONTROL_POINT_PHASE:
|
||||
- has_control_point_phase = true;
|
||||
- /* fall through */
|
||||
case VKD3DSIH_HS_FORK_PHASE:
|
||||
case VKD3DSIH_HS_JOIN_PHASE:
|
||||
normaliser.phase = ins->opcode;
|
||||
@@ -1790,22 +1797,6 @@ static enum vkd3d_result vsir_program_normalise_io_registers(struct vsir_program
|
||||
}
|
||||
}
|
||||
|
||||
- if (normaliser.shader_type == VKD3D_SHADER_TYPE_HULL && !has_control_point_phase)
|
||||
- {
|
||||
- /* Inputs and outputs must match for the default phase, so merge ranges must match too. */
|
||||
- for (i = 0; i < MAX_REG_OUTPUT; ++i)
|
||||
- {
|
||||
- for (j = 0; j < VKD3D_VEC4_SIZE; ++j)
|
||||
- {
|
||||
- if (!normaliser.input_range_map[i][j] && normaliser.output_range_map[i][j])
|
||||
- normaliser.input_range_map[i][j] = normaliser.output_range_map[i][j];
|
||||
- else if (normaliser.input_range_map[i][j] && !normaliser.output_range_map[i][j])
|
||||
- normaliser.output_range_map[i][j] = normaliser.input_range_map[i][j];
|
||||
- else VKD3D_ASSERT(normaliser.input_range_map[i][j] == normaliser.output_range_map[i][j]);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
if (!shader_signature_merge(&program->input_signature, normaliser.input_range_map, false)
|
||||
|| !shader_signature_merge(&program->output_signature, normaliser.output_range_map, false)
|
||||
|| !shader_signature_merge(&program->patch_constant_signature, normaliser.pc_range_map, true))
|
||||
@@ -2789,8 +2780,9 @@ static enum vkd3d_result cf_flattener_iterate_instruction_array(struct cf_flatte
|
||||
}
|
||||
|
||||
static enum vkd3d_result vsir_program_flatten_control_flow_constructs(struct vsir_program *program,
|
||||
- struct vkd3d_shader_message_context *message_context)
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
+ struct vkd3d_shader_message_context *message_context = ctx->message_context;
|
||||
struct cf_flattener flattener = {.program = program};
|
||||
enum vkd3d_result result;
|
||||
|
||||
@@ -2860,7 +2852,8 @@ static bool lower_switch_to_if_ladder_add_block_mapping(struct lower_switch_to_i
|
||||
return true;
|
||||
}
|
||||
|
||||
-static enum vkd3d_result lower_switch_to_if_ladder(struct vsir_program *program)
|
||||
+static enum vkd3d_result vsir_program_lower_switch_to_selection_ladder(struct vsir_program *program,
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
unsigned int block_count = program->block_count, ssa_count = program->ssa_count, current_label = 0, if_label;
|
||||
size_t ins_capacity = 0, ins_count = 0, i, map_capacity = 0, map_count = 0;
|
||||
@@ -3050,7 +3043,8 @@ static void ssas_to_temps_block_info_cleanup(struct ssas_to_temps_block_info *bl
|
||||
vkd3d_free(block_info);
|
||||
}
|
||||
|
||||
-static enum vkd3d_result vsir_program_materialise_phi_ssas_to_temps(struct vsir_program *program)
|
||||
+static enum vkd3d_result vsir_program_materialise_phi_ssas_to_temps(struct vsir_program *program,
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
size_t ins_capacity = 0, ins_count = 0, phi_count, incoming_count, i;
|
||||
struct ssas_to_temps_block_info *info, *block_info = NULL;
|
||||
@@ -5271,8 +5265,9 @@ out:
|
||||
}
|
||||
|
||||
static enum vkd3d_result vsir_program_structurize(struct vsir_program *program,
|
||||
- struct vkd3d_shader_message_context *message_context)
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
+ struct vkd3d_shader_message_context *message_context = ctx->message_context;
|
||||
struct vsir_cfg_emit_target target = {0};
|
||||
enum vkd3d_result ret;
|
||||
size_t i;
|
||||
@@ -5451,8 +5446,9 @@ static enum vkd3d_result vsir_program_materialize_undominated_ssas_to_temps_in_f
|
||||
}
|
||||
|
||||
static enum vkd3d_result vsir_program_materialize_undominated_ssas_to_temps(struct vsir_program *program,
|
||||
- struct vkd3d_shader_message_context *message_context)
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
+ struct vkd3d_shader_message_context *message_context = ctx->message_context;
|
||||
enum vkd3d_result ret;
|
||||
size_t i;
|
||||
|
||||
@@ -5731,14 +5727,14 @@ static void VKD3D_PRINTF_FUNC(3, 4) validator_error(struct validation_context *c
|
||||
if (ctx->invalid_instruction_idx)
|
||||
{
|
||||
vkd3d_shader_error(ctx->message_context, &ctx->null_location, error, "%s", buf.buffer);
|
||||
- ERR("VSIR validation error: %s\n", buf.buffer);
|
||||
+ WARN("VSIR validation error: %s\n", buf.buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
const struct vkd3d_shader_instruction *ins = &ctx->program->instructions.elements[ctx->instruction_idx];
|
||||
vkd3d_shader_error(ctx->message_context, &ins->location, error,
|
||||
"instruction %zu: %s", ctx->instruction_idx + 1, buf.buffer);
|
||||
- ERR("VSIR validation error: instruction %zu: %s\n", ctx->instruction_idx + 1, buf.buffer);
|
||||
+ WARN("VSIR validation error: instruction %zu: %s\n", ctx->instruction_idx + 1, buf.buffer);
|
||||
}
|
||||
|
||||
vkd3d_string_buffer_cleanup(&buf);
|
||||
@@ -6243,12 +6239,13 @@ static void vsir_validate_instruction(struct validation_context *ctx)
|
||||
/* We support two different control flow types in shaders:
|
||||
* block-based, like DXIL and SPIR-V, and structured, like D3DBC
|
||||
* and TPF. The shader is detected as block-based when its first
|
||||
- * instruction, except for DCL_* and phases, is a LABEL. Currently
|
||||
- * we mandate that each shader is either purely block-based or
|
||||
+ * instruction, except for NOP, DCL_* and phases, is a LABEL.
|
||||
+ * Currently we mandate that each shader is either purely block-based or
|
||||
* purely structured. In principle we could allow structured
|
||||
* constructs in a block, provided they are confined in a single
|
||||
* block, but need for that hasn't arisen yet, so we don't. */
|
||||
- if (ctx->cf_type == CF_TYPE_UNKNOWN && !vsir_instruction_is_dcl(instruction))
|
||||
+ if (ctx->cf_type == CF_TYPE_UNKNOWN && instruction->opcode != VKD3DSIH_NOP
|
||||
+ && !vsir_instruction_is_dcl(instruction))
|
||||
{
|
||||
if (instruction->opcode == VKD3DSIH_LABEL)
|
||||
ctx->cf_type = CF_TYPE_BLOCKS;
|
||||
@@ -6610,33 +6607,59 @@ fail:
|
||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
-enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags,
|
||||
- const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
|
||||
+#define vsir_transform(ctx, step) vsir_transform_(ctx, #step, step)
|
||||
+static void vsir_transform_(
|
||||
+ struct vsir_normalisation_context *ctx, const char *step_name,
|
||||
+ enum vkd3d_result (*step)(struct vsir_program *program, struct vsir_normalisation_context *ctx))
|
||||
{
|
||||
- enum vkd3d_result result = VKD3D_OK;
|
||||
+ if (ctx->result < 0)
|
||||
+ return;
|
||||
|
||||
- if ((result = vsir_program_lower_instructions(program, message_context)) < 0)
|
||||
- return result;
|
||||
+ if ((ctx->result = step(ctx->program, ctx)) < 0)
|
||||
+ {
|
||||
+ WARN("Transformation \"%s\" failed with result %u.\n", step_name, ctx->result);
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- if (program->shader_version.major >= 6)
|
||||
+ if ((ctx->result = vsir_program_validate(ctx->program, ctx->config_flags,
|
||||
+ ctx->compile_info->source_name, ctx->message_context)) < 0)
|
||||
{
|
||||
- if ((result = vsir_program_materialise_phi_ssas_to_temps(program)) < 0)
|
||||
- return result;
|
||||
+ WARN("Validation failed with result %u after transformation \"%s\".\n", ctx->result, step_name);
|
||||
+ return;
|
||||
+ }
|
||||
+}
|
||||
|
||||
- if ((result = lower_switch_to_if_ladder(program)) < 0)
|
||||
- return result;
|
||||
+enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags,
|
||||
+ const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
|
||||
+{
|
||||
+ struct vsir_normalisation_context ctx =
|
||||
+ {
|
||||
+ .result = VKD3D_OK,
|
||||
+ .program = program,
|
||||
+ .config_flags = config_flags,
|
||||
+ .compile_info = compile_info,
|
||||
+ .message_context = message_context,
|
||||
+ };
|
||||
+ enum vkd3d_result result;
|
||||
|
||||
- if ((result = vsir_program_structurize(program, message_context)) < 0)
|
||||
- return result;
|
||||
+ vsir_transform(&ctx, vsir_program_lower_instructions);
|
||||
|
||||
- if ((result = vsir_program_flatten_control_flow_constructs(program, message_context)) < 0)
|
||||
- return result;
|
||||
+ if (program->shader_version.major >= 6)
|
||||
+ {
|
||||
+ vsir_transform(&ctx, vsir_program_materialise_phi_ssas_to_temps);
|
||||
+ vsir_transform(&ctx, vsir_program_lower_switch_to_selection_ladder);
|
||||
+ vsir_transform(&ctx, vsir_program_structurize);
|
||||
+ vsir_transform(&ctx, vsir_program_flatten_control_flow_constructs);
|
||||
+ vsir_transform(&ctx, vsir_program_materialize_undominated_ssas_to_temps);
|
||||
|
||||
- if ((result = vsir_program_materialize_undominated_ssas_to_temps(program, message_context)) < 0)
|
||||
- return result;
|
||||
+ if (ctx.result < 0)
|
||||
+ return ctx.result;
|
||||
}
|
||||
else
|
||||
{
|
||||
+ if (ctx.result < 0)
|
||||
+ return ctx.result;
|
||||
+
|
||||
if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
|
||||
{
|
||||
if ((result = vsir_program_remap_output_signature(program, compile_info, message_context)) < 0)
|
||||
@@ -6665,7 +6688,7 @@ enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t
|
||||
return result;
|
||||
|
||||
if (compile_info->target_type != VKD3D_SHADER_TARGET_GLSL
|
||||
- && (result = vsir_program_flatten_control_flow_constructs(program, message_context)) < 0)
|
||||
+ && (result = vsir_program_flatten_control_flow_constructs(program, &ctx)) < 0)
|
||||
return result;
|
||||
}
|
||||
|
||||
--
|
||||
2.45.2
|
||||
|
@ -0,0 +1,303 @@
|
||||
From 06ac76ef4dafe44bc7c05d3ccea10f773f6dfc47 Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Wed, 25 Sep 2024 07:29:36 +1000
|
||||
Subject: [PATCH] Updated vkd3d to e8b14d765dbebae32d83aa5d2a7521932d9943f9.
|
||||
|
||||
---
|
||||
libs/vkd3d/libs/vkd3d-shader/glsl.c | 38 ++++++++++++++++++++
|
||||
libs/vkd3d/libs/vkd3d-shader/ir.c | 5 +--
|
||||
libs/vkd3d/libs/vkd3d-shader/msl.c | 50 ++++++++++++++++++++++++--
|
||||
libs/vkd3d/libs/vkd3d-shader/preproc.l | 2 +-
|
||||
libs/vkd3d/libs/vkd3d-shader/spirv.c | 25 ++++---------
|
||||
libs/vkd3d/libs/vkd3d/vkd3d_main.c | 1 +
|
||||
6 files changed, 96 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
index b29f13f2b19..a8cc6d87c40 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
@@ -379,6 +379,9 @@ static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment(
|
||||
case VKD3D_DATA_FLOAT:
|
||||
close = false;
|
||||
break;
|
||||
+ case VKD3D_DATA_INT:
|
||||
+ vkd3d_string_buffer_printf(buffer, "intBitsToFloat(");
|
||||
+ break;
|
||||
case VKD3D_DATA_UINT:
|
||||
vkd3d_string_buffer_printf(buffer, "uintBitsToFloat(");
|
||||
break;
|
||||
@@ -457,6 +460,28 @@ static void shader_glsl_relop(struct vkd3d_glsl_generator *gen,
|
||||
glsl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
}
|
||||
|
||||
+static void shader_glsl_cast(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins,
|
||||
+ const char *scalar_constructor, const char *vector_constructor)
|
||||
+{
|
||||
+ unsigned int component_count;
|
||||
+ struct glsl_src src;
|
||||
+ struct glsl_dst dst;
|
||||
+ uint32_t mask;
|
||||
+
|
||||
+ mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
|
||||
+ glsl_src_init(&src, gen, &ins->src[0], mask);
|
||||
+
|
||||
+ if ((component_count = vsir_write_mask_component_count(mask)) > 1)
|
||||
+ shader_glsl_print_assignment(gen, &dst, "%s%u(%s)",
|
||||
+ vector_constructor, component_count, src.str->buffer);
|
||||
+ else
|
||||
+ shader_glsl_print_assignment(gen, &dst, "%s(%s)",
|
||||
+ scalar_constructor, src.str->buffer);
|
||||
+
|
||||
+ glsl_src_cleanup(&src, &gen->string_buffers);
|
||||
+ glsl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
+}
|
||||
+
|
||||
static void shader_glsl_mov(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
||||
{
|
||||
struct glsl_src src;
|
||||
@@ -658,6 +683,12 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
||||
case VKD3DSIH_FRC:
|
||||
shader_glsl_intrinsic(gen, ins, "fract");
|
||||
break;
|
||||
+ case VKD3DSIH_FTOI:
|
||||
+ shader_glsl_cast(gen, ins, "int", "ivec");
|
||||
+ break;
|
||||
+ case VKD3DSIH_FTOU:
|
||||
+ shader_glsl_cast(gen, ins, "uint", "uvec");
|
||||
+ break;
|
||||
case VKD3DSIH_GEO:
|
||||
shader_glsl_relop(gen, ins, ">=", "greaterThanEqual");
|
||||
break;
|
||||
@@ -665,6 +696,10 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
||||
case VKD3DSIH_NEU:
|
||||
shader_glsl_relop(gen, ins, "!=", "notEqual");
|
||||
break;
|
||||
+ case VKD3DSIH_ITOF:
|
||||
+ case VKD3DSIH_UTOF:
|
||||
+ shader_glsl_cast(gen, ins, "float", "vec");
|
||||
+ break;
|
||||
case VKD3DSIH_MOV:
|
||||
shader_glsl_mov(gen, ins);
|
||||
break;
|
||||
@@ -680,6 +715,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
||||
case VKD3DSIH_RET:
|
||||
shader_glsl_ret(gen, ins);
|
||||
break;
|
||||
+ case VKD3DSIH_ROUND_PI:
|
||||
+ shader_glsl_intrinsic(gen, ins, "ceil");
|
||||
+ break;
|
||||
default:
|
||||
shader_glsl_unhandled(gen, ins);
|
||||
break;
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
index db9992d9715..0bbe13ad7d8 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
@@ -1211,12 +1211,13 @@ static bool io_normaliser_is_in_control_point_phase(const struct io_normaliser *
|
||||
static bool shader_signature_find_element_for_reg(const struct shader_signature *signature,
|
||||
unsigned int reg_idx, unsigned int write_mask, unsigned int *element_idx)
|
||||
{
|
||||
+ const struct signature_element *e;
|
||||
unsigned int i, base_write_mask;
|
||||
|
||||
for (i = 0; i < signature->element_count; ++i)
|
||||
{
|
||||
- struct signature_element *e = &signature->elements[i];
|
||||
- if (e->register_index <= reg_idx && e->register_index + e->register_count > reg_idx
|
||||
+ e = &signature->elements[i];
|
||||
+ if (e->register_index <= reg_idx && e->register_count > reg_idx - e->register_index
|
||||
&& (e->mask & write_mask) == write_mask)
|
||||
{
|
||||
*element_idx = i;
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/msl.c b/libs/vkd3d/libs/vkd3d-shader/msl.c
|
||||
index 7d2e713cddc..6b41363d60e 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/msl.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/msl.c
|
||||
@@ -55,12 +55,44 @@ static void msl_print_indent(struct vkd3d_string_buffer *buffer, unsigned int in
|
||||
vkd3d_string_buffer_printf(buffer, "%*s", 4 * indent, "");
|
||||
}
|
||||
|
||||
+static void msl_print_register_datatype(struct vkd3d_string_buffer *buffer,
|
||||
+ struct msl_generator *gen, const struct vkd3d_shader_register *reg)
|
||||
+{
|
||||
+ vkd3d_string_buffer_printf(buffer, ".");
|
||||
+ switch (reg->data_type)
|
||||
+ {
|
||||
+ case VKD3D_DATA_FLOAT:
|
||||
+ vkd3d_string_buffer_printf(buffer, "f");
|
||||
+ break;
|
||||
+ case VKD3D_DATA_INT:
|
||||
+ vkd3d_string_buffer_printf(buffer, "i");
|
||||
+ break;
|
||||
+ case VKD3D_DATA_UINT:
|
||||
+ vkd3d_string_buffer_printf(buffer, "u");
|
||||
+ break;
|
||||
+ default:
|
||||
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled register datatype %#x.", reg->data_type);
|
||||
+ vkd3d_string_buffer_printf(buffer, "<unrecognised register datatype %#x>", reg->data_type);
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void msl_print_register_name(struct vkd3d_string_buffer *buffer,
|
||||
struct msl_generator *gen, const struct vkd3d_shader_register *reg)
|
||||
{
|
||||
- msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
- "Internal compiler error: Unhandled register type %#x.", reg->type);
|
||||
- vkd3d_string_buffer_printf(buffer, "<unrecognised register %#x>", reg->type);
|
||||
+ switch (reg->type)
|
||||
+ {
|
||||
+ case VKD3DSPR_TEMP:
|
||||
+ vkd3d_string_buffer_printf(buffer, "r[%u]", reg->idx[0].offset);
|
||||
+ msl_print_register_datatype(buffer, gen, reg);
|
||||
+ break;
|
||||
+ default:
|
||||
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled register type %#x.", reg->type);
|
||||
+ vkd3d_string_buffer_printf(buffer, "<unrecognised register %#x>", reg->type);
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
|
||||
static void msl_print_swizzle(struct vkd3d_string_buffer *buffer, uint32_t swizzle, uint32_t mask)
|
||||
@@ -221,9 +253,21 @@ static void msl_generator_generate(struct msl_generator *gen)
|
||||
|
||||
vkd3d_string_buffer_printf(gen->buffer, "/* Generated by %s. */\n\n", vkd3d_shader_get_version(NULL, NULL));
|
||||
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, "union vkd3d_vec4\n{\n");
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, " uint4 u;\n");
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, " int4 i;\n");
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, " float4 f;\n};\n\n");
|
||||
+
|
||||
vkd3d_string_buffer_printf(gen->buffer, "void shader_main()\n{\n");
|
||||
|
||||
++gen->indent;
|
||||
+
|
||||
+ if (gen->program->temp_count)
|
||||
+ {
|
||||
+ msl_print_indent(gen->buffer, gen->indent);
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, "vkd3d_vec4 r[%u];\n\n", gen->program->temp_count);
|
||||
+ }
|
||||
+
|
||||
for (i = 0; i < instructions->count; ++i)
|
||||
{
|
||||
msl_handle_instruction(gen, &instructions->elements[i]);
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/preproc.l b/libs/vkd3d/libs/vkd3d-shader/preproc.l
|
||||
index 7fc963192cf..41c21cca1f5 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/preproc.l
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/preproc.l
|
||||
@@ -67,7 +67,7 @@ static void update_location(struct preproc_ctx *ctx);
|
||||
|
||||
NEWLINE \r?\n
|
||||
WS [ \t\r]
|
||||
-IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
|
||||
+IDENTIFIER (::)?[A-Za-z_]((::)?[A-Za-z0-9_]+)*
|
||||
INT_SUFFIX [uUlL]{0,2}
|
||||
|
||||
%%
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
index 1876ad38653..0278a6ca232 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
@@ -6354,7 +6354,7 @@ static SpvImageFormat image_format_for_image_read(enum vkd3d_shader_component_ty
|
||||
static uint32_t spirv_compiler_get_image_type_id(struct spirv_compiler *compiler,
|
||||
const struct vkd3d_shader_register *reg, const struct vkd3d_shader_register_range *range,
|
||||
const struct vkd3d_spirv_resource_type *resource_type_info, enum vkd3d_shader_component_type data_type,
|
||||
- bool raw_structured, uint32_t depth)
|
||||
+ bool raw_structured)
|
||||
{
|
||||
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
||||
const struct vkd3d_shader_descriptor_info1 *d;
|
||||
@@ -6377,7 +6377,7 @@ static uint32_t spirv_compiler_get_image_type_id(struct spirv_compiler *compiler
|
||||
|
||||
sampled_type_id = vkd3d_spirv_get_type_id(builder, data_type, 1);
|
||||
return vkd3d_spirv_get_op_type_image(builder, sampled_type_id, resource_type_info->dim,
|
||||
- depth, resource_type_info->arrayed, resource_type_info->ms,
|
||||
+ 2, resource_type_info->arrayed, resource_type_info->ms,
|
||||
reg->type == VKD3DSPR_UAV ? 2 : 1, format);
|
||||
}
|
||||
|
||||
@@ -6392,18 +6392,14 @@ static void spirv_compiler_emit_combined_sampler_declarations(struct spirv_compi
|
||||
const struct vkd3d_shader_combined_resource_sampler *current;
|
||||
uint32_t image_type_id, type_id, ptr_type_id, var_id;
|
||||
enum vkd3d_shader_binding_flag resource_type_flag;
|
||||
- const struct vkd3d_shader_descriptor_info1 *d;
|
||||
struct vkd3d_symbol symbol;
|
||||
unsigned int i;
|
||||
- bool depth;
|
||||
|
||||
resource_type_flag = resource_type == VKD3D_SHADER_RESOURCE_BUFFER
|
||||
? VKD3D_SHADER_BINDING_FLAG_BUFFER : VKD3D_SHADER_BINDING_FLAG_IMAGE;
|
||||
|
||||
for (i = 0; i < shader_interface->combined_sampler_count; ++i)
|
||||
{
|
||||
- struct vkd3d_shader_register_range sampler_range;
|
||||
-
|
||||
current = &shader_interface->combined_samplers[i];
|
||||
|
||||
if (current->resource_space != resource_range->space || current->resource_index != resource_range->first)
|
||||
@@ -6425,16 +6421,8 @@ static void spirv_compiler_emit_combined_sampler_declarations(struct spirv_compi
|
||||
current->sampler_space, current->binding.count);
|
||||
}
|
||||
|
||||
- sampler_range.space = current->sampler_space;
|
||||
- sampler_range.first = current->sampler_index;
|
||||
- sampler_range.last = current->sampler_index;
|
||||
- d = spirv_compiler_get_descriptor_info(compiler,
|
||||
- VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, &sampler_range);
|
||||
- depth = current->sampler_index != VKD3D_SHADER_DUMMY_SAMPLER_INDEX
|
||||
- && (d->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE);
|
||||
-
|
||||
image_type_id = spirv_compiler_get_image_type_id(compiler, resource, resource_range,
|
||||
- resource_type_info, sampled_type, structure_stride || raw, depth);
|
||||
+ resource_type_info, sampled_type, structure_stride || raw);
|
||||
type_id = vkd3d_spirv_get_op_type_sampled_image(builder, image_type_id);
|
||||
|
||||
ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, type_id);
|
||||
@@ -6528,7 +6516,7 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
||||
else
|
||||
{
|
||||
type_id = spirv_compiler_get_image_type_id(compiler, ®, range,
|
||||
- resource_type_info, sampled_type, structure_stride || raw, 0);
|
||||
+ resource_type_info, sampled_type, structure_stride || raw);
|
||||
}
|
||||
|
||||
var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class,
|
||||
@@ -8440,11 +8428,10 @@ static void spirv_compiler_prepare_image(struct spirv_compiler *compiler,
|
||||
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
||||
uint32_t sampler_var_id, sampler_id, sampled_image_type_id;
|
||||
const struct vkd3d_symbol *symbol = NULL;
|
||||
- bool load, sampled, depth_comparison;
|
||||
+ bool load, sampled;
|
||||
|
||||
load = !(flags & VKD3D_IMAGE_FLAG_NO_LOAD);
|
||||
sampled = flags & VKD3D_IMAGE_FLAG_SAMPLED;
|
||||
- depth_comparison = flags & VKD3D_IMAGE_FLAG_DEPTH;
|
||||
|
||||
if (resource_reg->type == VKD3DSPR_RESOURCE)
|
||||
symbol = spirv_compiler_find_combined_sampler(compiler, resource_reg, sampler_reg);
|
||||
@@ -8498,7 +8485,7 @@ static void spirv_compiler_prepare_image(struct spirv_compiler *compiler,
|
||||
|
||||
image->image_type_id = spirv_compiler_get_image_type_id(compiler, resource_reg,
|
||||
&symbol->info.resource.range, image->resource_type_info,
|
||||
- image->sampled_type, image->structure_stride || image->raw, depth_comparison);
|
||||
+ image->sampled_type, image->structure_stride || image->raw);
|
||||
|
||||
if (sampled)
|
||||
{
|
||||
diff --git a/libs/vkd3d/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/libs/vkd3d/vkd3d_main.c
|
||||
index 9eccec111c7..5215cf8ef86 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d/vkd3d_main.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d/vkd3d_main.c
|
||||
@@ -415,6 +415,7 @@ HRESULT vkd3d_create_versioned_root_signature_deserializer(const void *data, SIZ
|
||||
if (FAILED(hr = d3d12_versioned_root_signature_deserializer_init(object, &dxbc)))
|
||||
{
|
||||
vkd3d_free(object);
|
||||
+ *deserializer = NULL;
|
||||
return hr;
|
||||
}
|
||||
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,485 +0,0 @@
|
||||
From 974ebb67f03cda95a36c014378acd627f913f47b Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Wed, 11 Sep 2024 07:14:31 +1000
|
||||
Subject: [PATCH] Updated vkd3d to 3b4e0ce8e94cd4091b9f2fe80d86588b64c88111.
|
||||
|
||||
---
|
||||
libs/vkd3d/libs/vkd3d-shader/d3dbc.c | 10 ++-
|
||||
libs/vkd3d/libs/vkd3d-shader/dxil.c | 2 +-
|
||||
libs/vkd3d/libs/vkd3d-shader/fx.c | 8 ++-
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl.y | 15 ++++
|
||||
libs/vkd3d/libs/vkd3d-shader/ir.c | 69 ++++++++++---------
|
||||
libs/vkd3d/libs/vkd3d-shader/tpf.c | 19 +++++
|
||||
.../libs/vkd3d-shader/vkd3d_shader_private.h | 4 +-
|
||||
libs/vkd3d/libs/vkd3d/command.c | 20 ++++--
|
||||
libs/vkd3d/libs/vkd3d/state.c | 2 +-
|
||||
libs/vkd3d/libs/vkd3d/vkd3d_private.h | 1 -
|
||||
10 files changed, 100 insertions(+), 50 deletions(-)
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
index de5f28c1815..a41182e1f4a 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
@@ -1481,10 +1481,8 @@ struct d3dbc_compiler
|
||||
|
||||
static uint32_t sm1_version(enum vkd3d_shader_type type, unsigned int major, unsigned int minor)
|
||||
{
|
||||
- if (type == VKD3D_SHADER_TYPE_VERTEX)
|
||||
- return D3DVS_VERSION(major, minor);
|
||||
- else
|
||||
- return D3DPS_VERSION(major, minor);
|
||||
+ return vkd3d_make_u32(vkd3d_make_u16(minor, major),
|
||||
+ type == VKD3D_SHADER_TYPE_VERTEX ? VKD3D_SM1_VS : VKD3D_SM1_PS);
|
||||
}
|
||||
|
||||
D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type)
|
||||
@@ -1867,8 +1865,8 @@ void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buff
|
||||
|
||||
static uint32_t sm1_encode_register_type(enum vkd3d_shader_register_type type)
|
||||
{
|
||||
- return ((type << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK)
|
||||
- | ((type << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2);
|
||||
+ return ((type << VKD3D_SM1_REGISTER_TYPE_SHIFT) & VKD3D_SM1_REGISTER_TYPE_MASK)
|
||||
+ | ((type << VKD3D_SM1_REGISTER_TYPE_SHIFT2) & VKD3D_SM1_REGISTER_TYPE_MASK2);
|
||||
}
|
||||
|
||||
struct sm1_instruction
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/dxil.c b/libs/vkd3d/libs/vkd3d-shader/dxil.c
|
||||
index 4a17c62292b..1c62a305d30 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/dxil.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/dxil.c
|
||||
@@ -3888,7 +3888,7 @@ static void sm6_parser_init_signature(struct sm6_parser *sm6, const struct shade
|
||||
if (is_control_point)
|
||||
{
|
||||
if (reg_type == VKD3DSPR_OUTPUT)
|
||||
- param->reg.idx[count].rel_addr = instruction_array_create_outpointid_param(&sm6->p.program->instructions);
|
||||
+ param->reg.idx[count].rel_addr = vsir_program_create_outpointid_param(sm6->p.program);
|
||||
param->reg.idx[count++].offset = 0;
|
||||
}
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/fx.c b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
||||
index e3ab71fb386..2c2e486aa0e 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/fx.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
||||
@@ -38,6 +38,7 @@ struct type_entry
|
||||
struct list entry;
|
||||
const char *name;
|
||||
uint32_t elements_count;
|
||||
+ uint32_t modifiers;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
@@ -278,9 +279,9 @@ static void write_fx_4_state_block(struct hlsl_ir_var *var, unsigned int block_i
|
||||
|
||||
static uint32_t write_type(const struct hlsl_type *type, struct fx_write_context *fx)
|
||||
{
|
||||
+ unsigned int elements_count, modifiers;
|
||||
const struct hlsl_type *element_type;
|
||||
struct type_entry *type_entry;
|
||||
- unsigned int elements_count;
|
||||
const char *name;
|
||||
|
||||
VKD3D_ASSERT(fx->ctx->profile->major_version >= 4);
|
||||
@@ -297,6 +298,7 @@ static uint32_t write_type(const struct hlsl_type *type, struct fx_write_context
|
||||
}
|
||||
|
||||
name = get_fx_4_type_name(element_type);
|
||||
+ modifiers = element_type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(type_entry, &fx->types, struct type_entry, entry)
|
||||
{
|
||||
@@ -306,6 +308,9 @@ static uint32_t write_type(const struct hlsl_type *type, struct fx_write_context
|
||||
if (type_entry->elements_count != elements_count)
|
||||
continue;
|
||||
|
||||
+ if (type_entry->modifiers != modifiers)
|
||||
+ continue;
|
||||
+
|
||||
return type_entry->offset;
|
||||
}
|
||||
|
||||
@@ -315,6 +320,7 @@ static uint32_t write_type(const struct hlsl_type *type, struct fx_write_context
|
||||
type_entry->offset = write_fx_4_type(type, fx);
|
||||
type_entry->name = name;
|
||||
type_entry->elements_count = elements_count;
|
||||
+ type_entry->modifiers = modifiers;
|
||||
|
||||
list_add_tail(&fx->types, &type_entry->entry);
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.y b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
||||
index 816d992afa8..38642025b52 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
||||
@@ -4152,6 +4152,20 @@ static bool intrinsic_log2(struct hlsl_ctx *ctx,
|
||||
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_LOG2, arg, loc);
|
||||
}
|
||||
|
||||
+static bool intrinsic_mad(struct hlsl_ctx *ctx,
|
||||
+ const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
+{
|
||||
+ struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0};
|
||||
+
|
||||
+ if (!elementwise_intrinsic_convert_args(ctx, params, loc))
|
||||
+ return false;
|
||||
+
|
||||
+ args[0] = params->args[0];
|
||||
+ args[1] = params->args[1];
|
||||
+ args[2] = params->args[2];
|
||||
+ return add_expr(ctx, params->instrs, HLSL_OP3_MAD, args, args[0]->data_type, loc);
|
||||
+}
|
||||
+
|
||||
static bool intrinsic_max(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
@@ -5053,6 +5067,7 @@ intrinsic_functions[] =
|
||||
{"log", 1, true, intrinsic_log},
|
||||
{"log10", 1, true, intrinsic_log10},
|
||||
{"log2", 1, true, intrinsic_log2},
|
||||
+ {"mad", 3, true, intrinsic_mad},
|
||||
{"max", 2, true, intrinsic_max},
|
||||
{"min", 2, true, intrinsic_min},
|
||||
{"mul", 2, true, intrinsic_mul},
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
index a483c25f3ad..68f2e2f795e 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
@@ -551,9 +551,11 @@ static const struct vkd3d_shader_varying_map *find_varying_map(
|
||||
}
|
||||
|
||||
static enum vkd3d_result vsir_program_remap_output_signature(struct vsir_program *program,
|
||||
- const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
- const struct vkd3d_shader_location location = {.source_name = compile_info->source_name};
|
||||
+ const struct vkd3d_shader_location location = {.source_name = ctx->compile_info->source_name};
|
||||
+ struct vkd3d_shader_message_context *message_context = ctx->message_context;
|
||||
+ const struct vkd3d_shader_compile_info *compile_info = ctx->compile_info;
|
||||
struct shader_signature *signature = &program->output_signature;
|
||||
const struct vkd3d_shader_varying_map_info *varying_map;
|
||||
unsigned int i;
|
||||
@@ -862,9 +864,10 @@ static bool vsir_instruction_init_label(struct vkd3d_shader_instruction *ins,
|
||||
return true;
|
||||
}
|
||||
|
||||
-static enum vkd3d_result instruction_array_flatten_hull_shader_phases(struct vkd3d_shader_instruction_array *src_instructions)
|
||||
+static enum vkd3d_result vsir_program_flatten_hull_shader_phases(struct vsir_program *program,
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
- struct hull_flattener flattener = {*src_instructions};
|
||||
+ struct hull_flattener flattener = {program->instructions};
|
||||
struct vkd3d_shader_instruction_array *instructions;
|
||||
struct shader_phase_location_array locations;
|
||||
enum vkd3d_result result = VKD3D_OK;
|
||||
@@ -886,7 +889,7 @@ static enum vkd3d_result instruction_array_flatten_hull_shader_phases(struct vkd
|
||||
vsir_instruction_init(&instructions->elements[instructions->count++], &flattener.last_ret_location, VKD3DSIH_RET);
|
||||
}
|
||||
|
||||
- *src_instructions = flattener.instructions;
|
||||
+ program->instructions = flattener.instructions;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -902,9 +905,9 @@ static bool control_point_normaliser_is_in_control_point_phase(const struct cont
|
||||
return normaliser->phase == VKD3DSIH_HS_CONTROL_POINT_PHASE;
|
||||
}
|
||||
|
||||
-struct vkd3d_shader_src_param *instruction_array_create_outpointid_param(
|
||||
- struct vkd3d_shader_instruction_array *instructions)
|
||||
+struct vkd3d_shader_src_param *vsir_program_create_outpointid_param(struct vsir_program *program)
|
||||
{
|
||||
+ struct vkd3d_shader_instruction_array *instructions = &program->instructions;
|
||||
struct vkd3d_shader_src_param *rel_addr;
|
||||
|
||||
if (instructions->outpointid_param)
|
||||
@@ -1001,7 +1004,7 @@ static enum vkd3d_result control_point_normaliser_emit_hs_input(struct control_p
|
||||
}
|
||||
|
||||
static enum vkd3d_result instruction_array_normalise_hull_shader_control_point_io(
|
||||
- struct vkd3d_shader_instruction_array *src_instructions, const struct shader_signature *input_signature)
|
||||
+ struct vsir_program *program, struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
struct vkd3d_shader_instruction_array *instructions;
|
||||
struct control_point_normaliser normaliser;
|
||||
@@ -1011,12 +1014,12 @@ static enum vkd3d_result instruction_array_normalise_hull_shader_control_point_i
|
||||
enum vkd3d_result ret;
|
||||
unsigned int i, j;
|
||||
|
||||
- if (!(normaliser.outpointid_param = instruction_array_create_outpointid_param(src_instructions)))
|
||||
+ if (!(normaliser.outpointid_param = vsir_program_create_outpointid_param(program)))
|
||||
{
|
||||
ERR("Failed to allocate src param.\n");
|
||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
- normaliser.instructions = *src_instructions;
|
||||
+ normaliser.instructions = program->instructions;
|
||||
instructions = &normaliser.instructions;
|
||||
normaliser.phase = VKD3DSIH_INVALID;
|
||||
|
||||
@@ -1053,22 +1056,22 @@ static enum vkd3d_result instruction_array_normalise_hull_shader_control_point_i
|
||||
input_control_point_count = ins->declaration.count;
|
||||
break;
|
||||
case VKD3DSIH_HS_CONTROL_POINT_PHASE:
|
||||
- *src_instructions = normaliser.instructions;
|
||||
+ program->instructions = normaliser.instructions;
|
||||
return VKD3D_OK;
|
||||
case VKD3DSIH_HS_FORK_PHASE:
|
||||
case VKD3DSIH_HS_JOIN_PHASE:
|
||||
/* ins may be relocated if the instruction array expands. */
|
||||
location = ins->location;
|
||||
- ret = control_point_normaliser_emit_hs_input(&normaliser, input_signature,
|
||||
+ ret = control_point_normaliser_emit_hs_input(&normaliser, &program->input_signature,
|
||||
input_control_point_count, i, &location);
|
||||
- *src_instructions = normaliser.instructions;
|
||||
+ program->instructions = normaliser.instructions;
|
||||
return ret;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- *src_instructions = normaliser.instructions;
|
||||
+ program->instructions = normaliser.instructions;
|
||||
return VKD3D_OK;
|
||||
}
|
||||
|
||||
@@ -1398,6 +1401,8 @@ static bool shader_signature_merge(struct shader_signature *s, uint8_t range_map
|
||||
else
|
||||
e->interpolation_mode = f->interpolation_mode;
|
||||
}
|
||||
+
|
||||
+ vkd3d_free((void *)f->semantic_name);
|
||||
}
|
||||
}
|
||||
element_count = new_count;
|
||||
@@ -1425,6 +1430,12 @@ static bool shader_signature_merge(struct shader_signature *s, uint8_t range_map
|
||||
TRACE("Merging %s, base reg %u, count %u.\n", e->semantic_name, e->register_index, register_count);
|
||||
e->register_count = register_count;
|
||||
e->mask = signature_element_range_expand_mask(e, register_count, range_map);
|
||||
+
|
||||
+ for (j = 1; j < register_count; ++j)
|
||||
+ {
|
||||
+ f = &elements[i + j];
|
||||
+ vkd3d_free((void *)f->semantic_name);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
element_count = new_count;
|
||||
@@ -1761,8 +1772,9 @@ static bool use_flat_interpolation(const struct vsir_program *program,
|
||||
}
|
||||
|
||||
static enum vkd3d_result vsir_program_normalise_io_registers(struct vsir_program *program,
|
||||
- struct vkd3d_shader_message_context *message_context)
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
+ struct vkd3d_shader_message_context *message_context = ctx->message_context;
|
||||
struct io_normaliser normaliser = {program->instructions};
|
||||
struct vkd3d_shader_instruction *ins;
|
||||
unsigned int i;
|
||||
@@ -1909,7 +1921,8 @@ static void shader_register_normalise_flat_constants(struct vkd3d_shader_src_par
|
||||
param->reg.idx_count = 3;
|
||||
}
|
||||
|
||||
-static enum vkd3d_result instruction_array_normalise_flat_constants(struct vsir_program *program)
|
||||
+static enum vkd3d_result vsir_program_normalise_flat_constants(struct vsir_program *program,
|
||||
+ struct vsir_normalisation_context *ctx)
|
||||
{
|
||||
struct flat_constants_normaliser normaliser = {0};
|
||||
unsigned int i, j;
|
||||
@@ -6657,30 +6670,20 @@ enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t
|
||||
}
|
||||
else
|
||||
{
|
||||
- if (ctx.result < 0)
|
||||
- return ctx.result;
|
||||
-
|
||||
if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
|
||||
- {
|
||||
- if ((result = vsir_program_remap_output_signature(program, compile_info, message_context)) < 0)
|
||||
- return result;
|
||||
- }
|
||||
+ vsir_transform(&ctx, vsir_program_remap_output_signature);
|
||||
|
||||
if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL)
|
||||
{
|
||||
- if ((result = instruction_array_flatten_hull_shader_phases(&program->instructions)) < 0)
|
||||
- return result;
|
||||
-
|
||||
- if ((result = instruction_array_normalise_hull_shader_control_point_io(&program->instructions,
|
||||
- &program->input_signature)) < 0)
|
||||
- return result;
|
||||
+ vsir_transform(&ctx, vsir_program_flatten_hull_shader_phases);
|
||||
+ vsir_transform(&ctx, instruction_array_normalise_hull_shader_control_point_io);
|
||||
}
|
||||
|
||||
- if ((result = vsir_program_normalise_io_registers(program, message_context)) < 0)
|
||||
- return result;
|
||||
+ vsir_transform(&ctx, vsir_program_normalise_io_registers);
|
||||
+ vsir_transform(&ctx, vsir_program_normalise_flat_constants);
|
||||
|
||||
- if ((result = instruction_array_normalise_flat_constants(program)) < 0)
|
||||
- return result;
|
||||
+ if (ctx.result < 0)
|
||||
+ return ctx.result;
|
||||
|
||||
remove_dead_code(program);
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/tpf.c b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
index c61086419a6..b76a596bb60 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
@@ -2814,6 +2814,7 @@ bool sysval_semantic_from_hlsl(enum vkd3d_shader_sysval_semantic *semantic,
|
||||
{"sv_isfrontface", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_IS_FRONT_FACE},
|
||||
{"sv_rendertargetarrayindex", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_RENDER_TARGET_ARRAY_INDEX},
|
||||
{"sv_viewportarrayindex", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_VIEWPORT_ARRAY_INDEX},
|
||||
+ {"sv_sampleindex", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_SAMPLE_INDEX},
|
||||
|
||||
{"color", true, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_TARGET},
|
||||
{"depth", true, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_DEPTH},
|
||||
@@ -4461,6 +4462,7 @@ static void write_sm4_dcl_semantic(const struct tpf_writer *tpf, const struct hl
|
||||
case VKD3D_SHADER_SV_INSTANCE_ID:
|
||||
case VKD3D_SHADER_SV_PRIMITIVE_ID:
|
||||
case VKD3D_SHADER_SV_VERTEX_ID:
|
||||
+ case VKD3D_SHADER_SV_SAMPLE_INDEX:
|
||||
instr.opcode = (profile->type == VKD3D_SHADER_TYPE_PIXEL)
|
||||
? VKD3D_SM4_OP_DCL_INPUT_PS_SGV : VKD3D_SM4_OP_DCL_INPUT_SGV;
|
||||
break;
|
||||
@@ -5578,6 +5580,23 @@ static void write_sm4_expr(const struct tpf_writer *tpf, const struct hlsl_ir_ex
|
||||
write_sm4_ternary_op(tpf, VKD3D_SM4_OP_MOVC, &expr->node, arg1, arg2, arg3);
|
||||
break;
|
||||
|
||||
+ case HLSL_OP3_MAD:
|
||||
+ switch (dst_type->e.numeric.type)
|
||||
+ {
|
||||
+ case HLSL_TYPE_FLOAT:
|
||||
+ write_sm4_ternary_op(tpf, VKD3D_SM4_OP_MAD, &expr->node, arg1, arg2, arg3);
|
||||
+ break;
|
||||
+
|
||||
+ case HLSL_TYPE_INT:
|
||||
+ case HLSL_TYPE_UINT:
|
||||
+ write_sm4_ternary_op(tpf, VKD3D_SM4_OP_IMAD, &expr->node, arg1, arg2, arg3);
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ hlsl_fixme(tpf->ctx, &expr->node.loc, "SM4 %s negation expression.", dst_type_string->buffer);
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
default:
|
||||
hlsl_fixme(tpf->ctx, &expr->node.loc, "SM4 %s expression.", debug_hlsl_expr_op(expr->op));
|
||||
}
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
index 327461371a4..ffec48daa17 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
@@ -1354,8 +1354,6 @@ bool shader_instruction_array_add_icb(struct vkd3d_shader_instruction_array *ins
|
||||
struct vkd3d_shader_immediate_constant_buffer *icb);
|
||||
bool shader_instruction_array_clone_instruction(struct vkd3d_shader_instruction_array *instructions,
|
||||
unsigned int dst, unsigned int src);
|
||||
-struct vkd3d_shader_src_param *instruction_array_create_outpointid_param(
|
||||
- struct vkd3d_shader_instruction_array *instructions);
|
||||
void shader_instruction_array_destroy(struct vkd3d_shader_instruction_array *instructions);
|
||||
|
||||
enum vkd3d_shader_config_flags
|
||||
@@ -1399,6 +1397,8 @@ enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t
|
||||
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context);
|
||||
enum vkd3d_result vsir_program_validate(struct vsir_program *program, uint64_t config_flags,
|
||||
const char *source_name, struct vkd3d_shader_message_context *message_context);
|
||||
+struct vkd3d_shader_src_param *vsir_program_create_outpointid_param(
|
||||
+ struct vsir_program *program);
|
||||
bool vsir_instruction_init_with_params(struct vsir_program *program,
|
||||
struct vkd3d_shader_instruction *ins, const struct vkd3d_shader_location *location,
|
||||
enum vkd3d_shader_opcode opcode, unsigned int dst_count, unsigned int src_count);
|
||||
diff --git a/libs/vkd3d/libs/vkd3d/command.c b/libs/vkd3d/libs/vkd3d/command.c
|
||||
index dcc7690876f..188162f9e6e 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d/command.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d/command.c
|
||||
@@ -3078,7 +3078,7 @@ done:
|
||||
vkd3d_free(vk_descriptor_writes);
|
||||
}
|
||||
|
||||
-static void d3d12_command_list_update_descriptors(struct d3d12_command_list *list,
|
||||
+static void d3d12_command_list_update_virtual_descriptors(struct d3d12_command_list *list,
|
||||
enum vkd3d_pipeline_bind_point bind_point)
|
||||
{
|
||||
struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
|
||||
@@ -3210,6 +3210,9 @@ static void command_list_flush_vk_heap_updates(struct d3d12_command_list *list)
|
||||
|
||||
static void command_list_add_descriptor_heap(struct d3d12_command_list *list, struct d3d12_descriptor_heap *heap)
|
||||
{
|
||||
+ if (!list->device->use_vk_heaps)
|
||||
+ return;
|
||||
+
|
||||
if (!contains_heap(list->descriptor_heaps, list->descriptor_heap_count, heap))
|
||||
{
|
||||
if (list->descriptor_heap_count == ARRAY_SIZE(list->descriptor_heaps))
|
||||
@@ -3296,6 +3299,15 @@ static void d3d12_command_list_update_heap_descriptors(struct d3d12_command_list
|
||||
d3d12_command_list_bind_descriptor_heap(list, bind_point, sampler_heap);
|
||||
}
|
||||
|
||||
+static void d3d12_command_list_update_descriptors(struct d3d12_command_list *list,
|
||||
+ enum vkd3d_pipeline_bind_point bind_point)
|
||||
+{
|
||||
+ if (list->device->use_vk_heaps)
|
||||
+ d3d12_command_list_update_heap_descriptors(list, bind_point);
|
||||
+ else
|
||||
+ d3d12_command_list_update_virtual_descriptors(list, bind_point);
|
||||
+}
|
||||
+
|
||||
static bool d3d12_command_list_update_compute_state(struct d3d12_command_list *list)
|
||||
{
|
||||
d3d12_command_list_end_current_render_pass(list);
|
||||
@@ -3303,7 +3315,7 @@ static bool d3d12_command_list_update_compute_state(struct d3d12_command_list *l
|
||||
if (!d3d12_command_list_update_compute_pipeline(list))
|
||||
return false;
|
||||
|
||||
- list->update_descriptors(list, VKD3D_PIPELINE_BIND_POINT_COMPUTE);
|
||||
+ d3d12_command_list_update_descriptors(list, VKD3D_PIPELINE_BIND_POINT_COMPUTE);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -3320,7 +3332,7 @@ static bool d3d12_command_list_begin_render_pass(struct d3d12_command_list *list
|
||||
if (!d3d12_command_list_update_current_framebuffer(list))
|
||||
return false;
|
||||
|
||||
- list->update_descriptors(list, VKD3D_PIPELINE_BIND_POINT_GRAPHICS);
|
||||
+ d3d12_command_list_update_descriptors(list, VKD3D_PIPELINE_BIND_POINT_GRAPHICS);
|
||||
|
||||
if (list->current_render_pass != VK_NULL_HANDLE)
|
||||
return true;
|
||||
@@ -6189,8 +6201,6 @@ static HRESULT d3d12_command_list_init(struct d3d12_command_list *list, struct d
|
||||
|
||||
list->allocator = allocator;
|
||||
|
||||
- list->update_descriptors = device->use_vk_heaps ? d3d12_command_list_update_heap_descriptors
|
||||
- : d3d12_command_list_update_descriptors;
|
||||
list->descriptor_heap_count = 0;
|
||||
|
||||
if (SUCCEEDED(hr = d3d12_command_allocator_allocate_command_buffer(allocator, list)))
|
||||
diff --git a/libs/vkd3d/libs/vkd3d/state.c b/libs/vkd3d/libs/vkd3d/state.c
|
||||
index 682d488faa8..bc887fa2f33 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d/state.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d/state.c
|
||||
@@ -738,7 +738,7 @@ static bool vkd3d_validate_descriptor_set_count(struct d3d12_device *device, uns
|
||||
if (set_count > max_count)
|
||||
{
|
||||
/* NOTE: If maxBoundDescriptorSets is < 9, try VKD3D_CONFIG=virtual_heaps */
|
||||
- ERR("Required descriptor set count exceeds maximum allowed count of %u.\n", max_count);
|
||||
+ WARN("Required descriptor set count exceeds maximum allowed count of %u.\n", max_count);
|
||||
return false;
|
||||
}
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/libs/vkd3d/vkd3d_private.h
|
||||
index ba4e2e8488d..729b1baee18 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d/vkd3d_private.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d/vkd3d_private.h
|
||||
@@ -1271,7 +1271,6 @@ struct d3d12_command_list
|
||||
VkBuffer so_counter_buffers[D3D12_SO_BUFFER_SLOT_COUNT];
|
||||
VkDeviceSize so_counter_buffer_offsets[D3D12_SO_BUFFER_SLOT_COUNT];
|
||||
|
||||
- void (*update_descriptors)(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point);
|
||||
struct d3d12_descriptor_heap *descriptor_heaps[64];
|
||||
unsigned int descriptor_heap_count;
|
||||
|
||||
--
|
||||
2.45.2
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,820 +0,0 @@
|
||||
From 72a24faa48be8d8a3b396a94fb8e028b7eaf6898 Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Fri, 20 Sep 2024 07:31:45 +1000
|
||||
Subject: [PATCH] Updated vkd3d to 32ced3bd8f52e19d184c8191f420dcb7badbbad2.
|
||||
|
||||
---
|
||||
libs/vkd3d/libs/vkd3d-shader/d3dbc.c | 35 +-
|
||||
libs/vkd3d/libs/vkd3d-shader/glsl.c | 334 +++++++++++++++++-
|
||||
libs/vkd3d/libs/vkd3d-shader/msl.c | 146 ++++++++
|
||||
libs/vkd3d/libs/vkd3d-shader/tpf.c | 18 +-
|
||||
.../libs/vkd3d-shader/vkd3d_shader_main.c | 3 +-
|
||||
.../libs/vkd3d-shader/vkd3d_shader_private.h | 6 +-
|
||||
6 files changed, 506 insertions(+), 36 deletions(-)
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
index 9c7be1f08bb..10f2e5e5e6d 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
@@ -104,6 +104,19 @@ enum vkd3d_sm1_resource_type
|
||||
VKD3D_SM1_RESOURCE_TEXTURE_3D = 0x4,
|
||||
};
|
||||
|
||||
+enum vkd3d_sm1_misc_register
|
||||
+{
|
||||
+ VKD3D_SM1_MISC_POSITION = 0x0,
|
||||
+ VKD3D_SM1_MISC_FACE = 0x1,
|
||||
+};
|
||||
+
|
||||
+enum vkd3d_sm1_rastout_register
|
||||
+{
|
||||
+ VKD3D_SM1_RASTOUT_POSITION = 0x0,
|
||||
+ VKD3D_SM1_RASTOUT_FOG = 0x1,
|
||||
+ VKD3D_SM1_RASTOUT_POINT_SIZE = 0x2,
|
||||
+};
|
||||
+
|
||||
enum vkd3d_sm1_opcode
|
||||
{
|
||||
VKD3D_SM1_OP_NOP = 0x00,
|
||||
@@ -1385,22 +1398,22 @@ bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version,
|
||||
{"depth", true, VKD3D_SHADER_TYPE_PIXEL, 3, VKD3DSPR_DEPTHOUT},
|
||||
{"sv_depth", true, VKD3D_SHADER_TYPE_PIXEL, 3, VKD3DSPR_DEPTHOUT},
|
||||
{"sv_target", true, VKD3D_SHADER_TYPE_PIXEL, 3, VKD3DSPR_COLOROUT},
|
||||
- {"sv_position", false, VKD3D_SHADER_TYPE_PIXEL, 3, VKD3DSPR_MISCTYPE, D3DSMO_POSITION},
|
||||
- {"vface", false, VKD3D_SHADER_TYPE_PIXEL, 3, VKD3DSPR_MISCTYPE, D3DSMO_FACE},
|
||||
- {"vpos", false, VKD3D_SHADER_TYPE_PIXEL, 3, VKD3DSPR_MISCTYPE, D3DSMO_POSITION},
|
||||
+ {"sv_position", false, VKD3D_SHADER_TYPE_PIXEL, 3, VKD3DSPR_MISCTYPE, VKD3D_SM1_MISC_POSITION},
|
||||
+ {"vface", false, VKD3D_SHADER_TYPE_PIXEL, 3, VKD3DSPR_MISCTYPE, VKD3D_SM1_MISC_FACE},
|
||||
+ {"vpos", false, VKD3D_SHADER_TYPE_PIXEL, 3, VKD3DSPR_MISCTYPE, VKD3D_SM1_MISC_POSITION},
|
||||
|
||||
{"color", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_ATTROUT},
|
||||
- {"fog", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_RASTOUT, D3DSRO_FOG},
|
||||
- {"position", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_RASTOUT, D3DSRO_POSITION},
|
||||
- {"psize", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_RASTOUT, D3DSRO_POINT_SIZE},
|
||||
- {"sv_position", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_RASTOUT, D3DSRO_POSITION},
|
||||
+ {"fog", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_RASTOUT, VKD3D_SM1_RASTOUT_FOG},
|
||||
+ {"position", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_RASTOUT, VKD3D_SM1_RASTOUT_POSITION},
|
||||
+ {"psize", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_RASTOUT, VKD3D_SM1_RASTOUT_POINT_SIZE},
|
||||
+ {"sv_position", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_RASTOUT, VKD3D_SM1_RASTOUT_POSITION},
|
||||
{"texcoord", true, VKD3D_SHADER_TYPE_VERTEX, 1, VKD3DSPR_TEXCRDOUT},
|
||||
|
||||
{"color", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_ATTROUT},
|
||||
- {"fog", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_RASTOUT, D3DSRO_FOG},
|
||||
- {"position", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_RASTOUT, D3DSRO_POSITION},
|
||||
- {"psize", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_RASTOUT, D3DSRO_POINT_SIZE},
|
||||
- {"sv_position", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_RASTOUT, D3DSRO_POSITION},
|
||||
+ {"fog", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_RASTOUT, VKD3D_SM1_RASTOUT_FOG},
|
||||
+ {"position", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_RASTOUT, VKD3D_SM1_RASTOUT_POSITION},
|
||||
+ {"psize", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_RASTOUT, VKD3D_SM1_RASTOUT_POINT_SIZE},
|
||||
+ {"sv_position", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_RASTOUT, VKD3D_SM1_RASTOUT_POSITION},
|
||||
{"texcoord", true, VKD3D_SHADER_TYPE_VERTEX, 2, VKD3DSPR_TEXCRDOUT},
|
||||
};
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
index f8fec6ac2bc..ac101d44214 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
@@ -48,6 +48,10 @@ struct vkd3d_glsl_generator
|
||||
} limits;
|
||||
bool interstage_input;
|
||||
bool interstage_output;
|
||||
+
|
||||
+ const struct vkd3d_shader_interface_info *interface_info;
|
||||
+ const struct vkd3d_shader_descriptor_offset_info *offset_info;
|
||||
+ const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info;
|
||||
};
|
||||
|
||||
static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_glsl_compiler_error(
|
||||
@@ -133,6 +137,40 @@ static void shader_glsl_print_register_name(struct vkd3d_string_buffer *buffer,
|
||||
vkd3d_string_buffer_printf(buffer, "%s_out[%u]", gen->prefix, reg->idx[0].offset);
|
||||
break;
|
||||
|
||||
+ case VKD3DSPR_IMMCONST:
|
||||
+ switch (reg->dimension)
|
||||
+ {
|
||||
+ case VSIR_DIMENSION_SCALAR:
|
||||
+ vkd3d_string_buffer_printf(buffer, "%#xu", reg->u.immconst_u32[0]);
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ vkd3d_string_buffer_printf(buffer, "<unhandled_dimension %#x>", reg->dimension);
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled dimension %#x.", reg->dimension);
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
+ case VKD3DSPR_CONSTBUFFER:
|
||||
+ if (reg->idx_count != 3)
|
||||
+ {
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled constant buffer register index count %u.", reg->idx_count);
|
||||
+ vkd3d_string_buffer_printf(buffer, "<unhandled register %#x>", reg->type);
|
||||
+ break;
|
||||
+ }
|
||||
+ if (reg->idx[0].rel_addr || reg->idx[2].rel_addr)
|
||||
+ {
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled constant buffer register indirect addressing.");
|
||||
+ vkd3d_string_buffer_printf(buffer, "<unhandled register %#x>", reg->type);
|
||||
+ break;
|
||||
+ }
|
||||
+ vkd3d_string_buffer_printf(buffer, "%s_cb_%u[%u]",
|
||||
+ gen->prefix, reg->idx[0].offset, reg->idx[2].offset);
|
||||
+ break;
|
||||
+
|
||||
default:
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
"Internal compiler error: Unhandled register type %#x.", reg->type);
|
||||
@@ -172,23 +210,86 @@ static void glsl_src_cleanup(struct glsl_src *src, struct vkd3d_string_buffer_ca
|
||||
vkd3d_string_buffer_release(cache, src->str);
|
||||
}
|
||||
|
||||
+static void shader_glsl_print_bitcast(struct vkd3d_string_buffer *dst, struct vkd3d_glsl_generator *gen,
|
||||
+ const char *src, enum vkd3d_data_type dst_data_type, enum vkd3d_data_type src_data_type)
|
||||
+{
|
||||
+ if (dst_data_type == VKD3D_DATA_UNORM || dst_data_type == VKD3D_DATA_SNORM)
|
||||
+ dst_data_type = VKD3D_DATA_FLOAT;
|
||||
+ if (src_data_type == VKD3D_DATA_UNORM || src_data_type == VKD3D_DATA_SNORM)
|
||||
+ src_data_type = VKD3D_DATA_FLOAT;
|
||||
+
|
||||
+ if (dst_data_type == src_data_type)
|
||||
+ {
|
||||
+ vkd3d_string_buffer_printf(dst, "%s", src);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (src_data_type == VKD3D_DATA_FLOAT && dst_data_type == VKD3D_DATA_UINT)
|
||||
+ {
|
||||
+ vkd3d_string_buffer_printf(dst, "floatBitsToUint(%s)", src);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (src_data_type == VKD3D_DATA_UINT && dst_data_type == VKD3D_DATA_FLOAT)
|
||||
+ {
|
||||
+ vkd3d_string_buffer_printf(dst, "uintBitsToFloat(%s)", src);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled bitcast from %#x to %#x.",
|
||||
+ src_data_type, dst_data_type);
|
||||
+ vkd3d_string_buffer_printf(dst, "%s", src);
|
||||
+}
|
||||
+
|
||||
static void glsl_src_init(struct glsl_src *glsl_src, struct vkd3d_glsl_generator *gen,
|
||||
const struct vkd3d_shader_src_param *vsir_src, uint32_t mask)
|
||||
{
|
||||
const struct vkd3d_shader_register *reg = &vsir_src->reg;
|
||||
+ struct vkd3d_string_buffer *register_name, *str;
|
||||
+ enum vkd3d_data_type src_data_type;
|
||||
|
||||
glsl_src->str = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
+ register_name = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
|
||||
if (reg->non_uniform)
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
"Internal compiler error: Unhandled 'non-uniform' modifier.");
|
||||
- if (vsir_src->modifiers)
|
||||
- vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
- "Internal compiler error: Unhandled source modifier(s) %#x.", vsir_src->modifiers);
|
||||
|
||||
- shader_glsl_print_register_name(glsl_src->str, gen, reg);
|
||||
+ if (reg->type == VKD3DSPR_IMMCONST)
|
||||
+ src_data_type = VKD3D_DATA_UINT;
|
||||
+ else
|
||||
+ src_data_type = VKD3D_DATA_FLOAT;
|
||||
+
|
||||
+ shader_glsl_print_register_name(register_name, gen, reg);
|
||||
+
|
||||
+ if (!vsir_src->modifiers)
|
||||
+ str = glsl_src->str;
|
||||
+ else
|
||||
+ str = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
+
|
||||
+ shader_glsl_print_bitcast(str, gen, register_name->buffer, reg->data_type, src_data_type);
|
||||
if (reg->dimension == VSIR_DIMENSION_VEC4)
|
||||
- shader_glsl_print_swizzle(glsl_src->str, vsir_src->swizzle, mask);
|
||||
+ shader_glsl_print_swizzle(str, vsir_src->swizzle, mask);
|
||||
+
|
||||
+ switch (vsir_src->modifiers)
|
||||
+ {
|
||||
+ case VKD3DSPSM_NONE:
|
||||
+ break;
|
||||
+ case VKD3DSPSM_ABS:
|
||||
+ vkd3d_string_buffer_printf(glsl_src->str, "abs(%s)", str->buffer);
|
||||
+ break;
|
||||
+ default:
|
||||
+ vkd3d_string_buffer_printf(glsl_src->str, "<unhandled modifier %#x>(%s)",
|
||||
+ vsir_src->modifiers, str->buffer);
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled source modifier(s) %#x.", vsir_src->modifiers);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (str != glsl_src->str)
|
||||
+ vkd3d_string_buffer_release(&gen->string_buffers, str);
|
||||
+ vkd3d_string_buffer_release(&gen->string_buffers, register_name);
|
||||
}
|
||||
|
||||
static void glsl_dst_cleanup(struct glsl_dst *dst, struct vkd3d_string_buffer_cache *cache)
|
||||
@@ -222,6 +323,9 @@ static uint32_t glsl_dst_init(struct glsl_dst *glsl_dst, struct vkd3d_glsl_gener
|
||||
static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment(
|
||||
struct vkd3d_glsl_generator *gen, struct glsl_dst *dst, const char *format, ...)
|
||||
{
|
||||
+ const struct vkd3d_shader_register *dst_reg = &dst->vsir->reg;
|
||||
+ struct vkd3d_string_buffer *buffer = gen->buffer;
|
||||
+ bool close = true;
|
||||
va_list args;
|
||||
|
||||
if (dst->vsir->shift)
|
||||
@@ -231,14 +335,28 @@ static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment(
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
"Internal compiler error: Unhandled destination modifier(s) %#x.", dst->vsir->modifiers);
|
||||
|
||||
- shader_glsl_print_indent(gen->buffer, gen->indent);
|
||||
- vkd3d_string_buffer_printf(gen->buffer, "%s%s = ", dst->register_name->buffer, dst->mask->buffer);
|
||||
+ shader_glsl_print_indent(buffer, gen->indent);
|
||||
+ vkd3d_string_buffer_printf(buffer, "%s%s = ", dst->register_name->buffer, dst->mask->buffer);
|
||||
+
|
||||
+ switch (dst_reg->data_type)
|
||||
+ {
|
||||
+ default:
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled destination register data type %#x.", dst_reg->data_type);
|
||||
+ /* fall through */
|
||||
+ case VKD3D_DATA_FLOAT:
|
||||
+ close = false;
|
||||
+ break;
|
||||
+ case VKD3D_DATA_UINT:
|
||||
+ vkd3d_string_buffer_printf(buffer, "uintBitsToFloat(");
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
va_start(args, format);
|
||||
- vkd3d_string_buffer_vprintf(gen->buffer, format, args);
|
||||
+ vkd3d_string_buffer_vprintf(buffer, format, args);
|
||||
va_end(args);
|
||||
|
||||
- vkd3d_string_buffer_printf(gen->buffer, ";\n");
|
||||
+ vkd3d_string_buffer_printf(buffer, "%s;\n", close ? ")" : "");
|
||||
}
|
||||
|
||||
static void shader_glsl_unhandled(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
||||
@@ -249,6 +367,24 @@ static void shader_glsl_unhandled(struct vkd3d_glsl_generator *gen, const struct
|
||||
"Internal compiler error: Unhandled instruction %#x.", ins->opcode);
|
||||
}
|
||||
|
||||
+static void shader_glsl_binop(struct vkd3d_glsl_generator *gen,
|
||||
+ const struct vkd3d_shader_instruction *ins, const char *op)
|
||||
+{
|
||||
+ struct glsl_src src[2];
|
||||
+ struct glsl_dst dst;
|
||||
+ uint32_t mask;
|
||||
+
|
||||
+ mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
|
||||
+ glsl_src_init(&src[0], gen, &ins->src[0], mask);
|
||||
+ glsl_src_init(&src[1], gen, &ins->src[1], mask);
|
||||
+
|
||||
+ shader_glsl_print_assignment(gen, &dst, "%s %s %s", src[0].str->buffer, op, src[1].str->buffer);
|
||||
+
|
||||
+ glsl_src_cleanup(&src[1], &gen->string_buffers);
|
||||
+ glsl_src_cleanup(&src[0], &gen->string_buffers);
|
||||
+ glsl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
+}
|
||||
+
|
||||
static void shader_glsl_mov(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
||||
{
|
||||
struct glsl_src src;
|
||||
@@ -267,11 +403,12 @@ static void shader_glsl_mov(struct vkd3d_glsl_generator *gen, const struct vkd3d
|
||||
static void shader_glsl_print_sysval_name(struct vkd3d_string_buffer *buffer, struct vkd3d_glsl_generator *gen,
|
||||
enum vkd3d_shader_sysval_semantic sysval, unsigned int idx)
|
||||
{
|
||||
+ const struct vkd3d_shader_version *version = &gen->program->shader_version;
|
||||
+
|
||||
switch (sysval)
|
||||
{
|
||||
case VKD3D_SHADER_SV_POSITION:
|
||||
- if (gen->program->shader_version.type == VKD3D_SHADER_TYPE_PIXEL
|
||||
- || gen->program->shader_version.type == VKD3D_SHADER_TYPE_COMPUTE)
|
||||
+ if (version->type == VKD3D_SHADER_TYPE_PIXEL || version->type == VKD3D_SHADER_TYPE_COMPUTE)
|
||||
{
|
||||
vkd3d_string_buffer_printf(buffer, "<unhandled sysval %#x>", sysval);
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
@@ -286,6 +423,13 @@ static void shader_glsl_print_sysval_name(struct vkd3d_string_buffer *buffer, st
|
||||
}
|
||||
break;
|
||||
|
||||
+ case VKD3D_SHADER_SV_TARGET:
|
||||
+ if (version->type != VKD3D_SHADER_TYPE_PIXEL)
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled SV_TARGET in shader type #%x.", version->type);
|
||||
+ vkd3d_string_buffer_printf(buffer, "shader_out_%u", idx);
|
||||
+ break;
|
||||
+
|
||||
default:
|
||||
vkd3d_string_buffer_printf(buffer, "<unhandled sysval %#x>", sysval);
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
@@ -400,6 +544,12 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
||||
|
||||
switch (ins->opcode)
|
||||
{
|
||||
+ case VKD3DSIH_ADD:
|
||||
+ shader_glsl_binop(gen, ins, "+");
|
||||
+ break;
|
||||
+ case VKD3DSIH_AND:
|
||||
+ shader_glsl_binop(gen, ins, "&");
|
||||
+ break;
|
||||
case VKD3DSIH_DCL_INPUT:
|
||||
case VKD3DSIH_DCL_OUTPUT:
|
||||
case VKD3DSIH_DCL_OUTPUT_SIV:
|
||||
@@ -417,6 +567,151 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
||||
}
|
||||
}
|
||||
|
||||
+static bool shader_glsl_check_shader_visibility(const struct vkd3d_glsl_generator *gen,
|
||||
+ enum vkd3d_shader_visibility visibility)
|
||||
+{
|
||||
+ enum vkd3d_shader_type t = gen->program->shader_version.type;
|
||||
+
|
||||
+ switch (visibility)
|
||||
+ {
|
||||
+ case VKD3D_SHADER_VISIBILITY_ALL:
|
||||
+ return true;
|
||||
+ case VKD3D_SHADER_VISIBILITY_VERTEX:
|
||||
+ return t == VKD3D_SHADER_TYPE_VERTEX;
|
||||
+ case VKD3D_SHADER_VISIBILITY_HULL:
|
||||
+ return t == VKD3D_SHADER_TYPE_HULL;
|
||||
+ case VKD3D_SHADER_VISIBILITY_DOMAIN:
|
||||
+ return t == VKD3D_SHADER_TYPE_DOMAIN;
|
||||
+ case VKD3D_SHADER_VISIBILITY_GEOMETRY:
|
||||
+ return t == VKD3D_SHADER_TYPE_GEOMETRY;
|
||||
+ case VKD3D_SHADER_VISIBILITY_PIXEL:
|
||||
+ return t == VKD3D_SHADER_TYPE_PIXEL;
|
||||
+ case VKD3D_SHADER_VISIBILITY_COMPUTE:
|
||||
+ return t == VKD3D_SHADER_TYPE_COMPUTE;
|
||||
+ default:
|
||||
+ WARN("Invalid shader visibility %#x.\n", visibility);
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static bool shader_glsl_get_cbv_binding(const struct vkd3d_glsl_generator *gen,
|
||||
+ unsigned int register_space, unsigned int register_idx, unsigned int *binding_idx)
|
||||
+{
|
||||
+ const struct vkd3d_shader_interface_info *interface_info = gen->interface_info;
|
||||
+ const struct vkd3d_shader_resource_binding *binding;
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ if (!interface_info)
|
||||
+ return false;
|
||||
+
|
||||
+ for (i = 0; i < interface_info->binding_count; ++i)
|
||||
+ {
|
||||
+ binding = &interface_info->bindings[i];
|
||||
+
|
||||
+ if (binding->type != VKD3D_SHADER_DESCRIPTOR_TYPE_CBV)
|
||||
+ continue;
|
||||
+ if (binding->register_space != register_space)
|
||||
+ continue;
|
||||
+ if (binding->register_index != register_idx)
|
||||
+ continue;
|
||||
+ if (!shader_glsl_check_shader_visibility(gen, binding->shader_visibility))
|
||||
+ continue;
|
||||
+ if (!(binding->flags & VKD3D_SHADER_BINDING_FLAG_BUFFER))
|
||||
+ continue;
|
||||
+ *binding_idx = i;
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static void shader_glsl_generate_cbv_declaration(struct vkd3d_glsl_generator *gen,
|
||||
+ const struct vkd3d_shader_descriptor_info1 *cbv)
|
||||
+{
|
||||
+ const struct vkd3d_shader_descriptor_binding *binding;
|
||||
+ const struct vkd3d_shader_descriptor_offset *offset;
|
||||
+ struct vkd3d_string_buffer *buffer = gen->buffer;
|
||||
+ const char *prefix = gen->prefix;
|
||||
+ unsigned int binding_idx;
|
||||
+ size_t size;
|
||||
+
|
||||
+ if (cbv->count != 1)
|
||||
+ {
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_BINDING_NOT_FOUND,
|
||||
+ "Constant buffer %u has unsupported descriptor array size %u.", cbv->register_id, cbv->count);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (!shader_glsl_get_cbv_binding(gen, cbv->register_space, cbv->register_index, &binding_idx))
|
||||
+ {
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_BINDING_NOT_FOUND,
|
||||
+ "No descriptor binding specified for constant buffer %u.", cbv->register_id);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ binding = &gen->interface_info->bindings[binding_idx].binding;
|
||||
+
|
||||
+ if (binding->set != 0)
|
||||
+ {
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_BINDING_NOT_FOUND,
|
||||
+ "Unsupported binding set %u specified for constant buffer %u.", binding->set, cbv->register_id);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (binding->count != 1)
|
||||
+ {
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_BINDING_NOT_FOUND,
|
||||
+ "Unsupported binding count %u specified for constant buffer %u.", binding->count, cbv->register_id);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (gen->offset_info && gen->offset_info->binding_offsets)
|
||||
+ {
|
||||
+ offset = &gen->offset_info->binding_offsets[binding_idx];
|
||||
+ if (offset->static_offset || offset->dynamic_offset_index != ~0u)
|
||||
+ {
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled descriptor offset specified for constant buffer %u.",
|
||||
+ cbv->register_id);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ size = align(cbv->buffer_size, VKD3D_VEC4_SIZE * sizeof(uint32_t));
|
||||
+ size /= VKD3D_VEC4_SIZE * sizeof(uint32_t);
|
||||
+
|
||||
+ vkd3d_string_buffer_printf(buffer,
|
||||
+ "layout(std140, binding = %u) uniform block_%s_cb_%u { vec4 %s_cb_%u[%zu]; };\n",
|
||||
+ binding->binding, prefix, cbv->register_id, prefix, cbv->register_id, size);
|
||||
+}
|
||||
+
|
||||
+static void shader_glsl_generate_descriptor_declarations(struct vkd3d_glsl_generator *gen)
|
||||
+{
|
||||
+ const struct vkd3d_shader_scan_descriptor_info1 *info = gen->descriptor_info;
|
||||
+ const struct vkd3d_shader_descriptor_info1 *descriptor;
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ for (i = 0; i < info->descriptor_count; ++i)
|
||||
+ {
|
||||
+ descriptor = &info->descriptors[i];
|
||||
+
|
||||
+ switch (descriptor->type)
|
||||
+ {
|
||||
+ case VKD3D_SHADER_DESCRIPTOR_TYPE_CBV:
|
||||
+ shader_glsl_generate_cbv_declaration(gen, descriptor);
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, "/* <unhandled descriptor type %#x> */\n", descriptor->type);
|
||||
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled descriptor type %#x.", descriptor->type);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (info->descriptor_count)
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, "\n");
|
||||
+}
|
||||
+
|
||||
static void shader_glsl_generate_interface_block(struct vkd3d_string_buffer *buffer,
|
||||
const char *type, unsigned int count)
|
||||
{
|
||||
@@ -545,6 +840,7 @@ static void shader_glsl_generate_declarations(struct vkd3d_glsl_generator *gen)
|
||||
const struct vsir_program *program = gen->program;
|
||||
struct vkd3d_string_buffer *buffer = gen->buffer;
|
||||
|
||||
+ shader_glsl_generate_descriptor_declarations(gen);
|
||||
shader_glsl_generate_input_declarations(gen);
|
||||
shader_glsl_generate_output_declarations(gen);
|
||||
|
||||
@@ -634,7 +930,9 @@ static void shader_glsl_init_limits(struct vkd3d_glsl_generator *gen, const stru
|
||||
}
|
||||
|
||||
static void vkd3d_glsl_generator_init(struct vkd3d_glsl_generator *gen,
|
||||
- struct vsir_program *program, struct vkd3d_shader_message_context *message_context)
|
||||
+ struct vsir_program *program, const struct vkd3d_shader_compile_info *compile_info,
|
||||
+ const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
||||
+ struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
enum vkd3d_shader_type type = program->shader_version.type;
|
||||
|
||||
@@ -642,6 +940,7 @@ static void vkd3d_glsl_generator_init(struct vkd3d_glsl_generator *gen,
|
||||
gen->program = program;
|
||||
vkd3d_string_buffer_cache_init(&gen->string_buffers);
|
||||
gen->buffer = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
+ gen->location.source_name = compile_info->source_name;
|
||||
gen->message_context = message_context;
|
||||
if (!(gen->prefix = shader_glsl_get_prefix(type)))
|
||||
{
|
||||
@@ -652,11 +951,16 @@ static void vkd3d_glsl_generator_init(struct vkd3d_glsl_generator *gen,
|
||||
shader_glsl_init_limits(gen, &program->shader_version);
|
||||
gen->interstage_input = type != VKD3D_SHADER_TYPE_VERTEX;
|
||||
gen->interstage_output = type != VKD3D_SHADER_TYPE_PIXEL;
|
||||
+
|
||||
+ gen->interface_info = vkd3d_find_struct(compile_info->next, INTERFACE_INFO);
|
||||
+ gen->offset_info = vkd3d_find_struct(compile_info->next, DESCRIPTOR_OFFSET_INFO);
|
||||
+ gen->descriptor_info = descriptor_info;
|
||||
}
|
||||
|
||||
int glsl_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
- const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
|
||||
- struct vkd3d_shader_message_context *message_context)
|
||||
+ const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
||||
+ const struct vkd3d_shader_compile_info *compile_info,
|
||||
+ struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
struct vkd3d_glsl_generator generator;
|
||||
int ret;
|
||||
@@ -664,7 +968,7 @@ int glsl_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
if ((ret = vsir_program_transform(program, config_flags, compile_info, message_context)) < 0)
|
||||
return ret;
|
||||
|
||||
- vkd3d_glsl_generator_init(&generator, program, message_context);
|
||||
+ vkd3d_glsl_generator_init(&generator, program, compile_info, descriptor_info, message_context);
|
||||
ret = vkd3d_glsl_generator_generate(&generator, out);
|
||||
vkd3d_glsl_generator_cleanup(&generator);
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/msl.c b/libs/vkd3d/libs/vkd3d-shader/msl.c
|
||||
index 2923494feed..7d2e713cddc 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/msl.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/msl.c
|
||||
@@ -18,6 +18,18 @@
|
||||
|
||||
#include "vkd3d_shader_private.h"
|
||||
|
||||
+struct msl_src
|
||||
+{
|
||||
+ struct vkd3d_string_buffer *str;
|
||||
+};
|
||||
+
|
||||
+struct msl_dst
|
||||
+{
|
||||
+ const struct vkd3d_shader_dst_param *vsir;
|
||||
+ struct vkd3d_string_buffer *register_name;
|
||||
+ struct vkd3d_string_buffer *mask;
|
||||
+};
|
||||
+
|
||||
struct msl_generator
|
||||
{
|
||||
struct vsir_program *program;
|
||||
@@ -43,6 +55,113 @@ static void msl_print_indent(struct vkd3d_string_buffer *buffer, unsigned int in
|
||||
vkd3d_string_buffer_printf(buffer, "%*s", 4 * indent, "");
|
||||
}
|
||||
|
||||
+static void msl_print_register_name(struct vkd3d_string_buffer *buffer,
|
||||
+ struct msl_generator *gen, const struct vkd3d_shader_register *reg)
|
||||
+{
|
||||
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled register type %#x.", reg->type);
|
||||
+ vkd3d_string_buffer_printf(buffer, "<unrecognised register %#x>", reg->type);
|
||||
+}
|
||||
+
|
||||
+static void msl_print_swizzle(struct vkd3d_string_buffer *buffer, uint32_t swizzle, uint32_t mask)
|
||||
+{
|
||||
+ const char swizzle_chars[] = "xyzw";
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ vkd3d_string_buffer_printf(buffer, ".");
|
||||
+ for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
|
||||
+ {
|
||||
+ if (mask & (VKD3DSP_WRITEMASK_0 << i))
|
||||
+ vkd3d_string_buffer_printf(buffer, "%c", swizzle_chars[vsir_swizzle_get_component(swizzle, i)]);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void msl_print_write_mask(struct vkd3d_string_buffer *buffer, uint32_t write_mask)
|
||||
+{
|
||||
+ vkd3d_string_buffer_printf(buffer, ".");
|
||||
+ if (write_mask & VKD3DSP_WRITEMASK_0)
|
||||
+ vkd3d_string_buffer_printf(buffer, "x");
|
||||
+ if (write_mask & VKD3DSP_WRITEMASK_1)
|
||||
+ vkd3d_string_buffer_printf(buffer, "y");
|
||||
+ if (write_mask & VKD3DSP_WRITEMASK_2)
|
||||
+ vkd3d_string_buffer_printf(buffer, "z");
|
||||
+ if (write_mask & VKD3DSP_WRITEMASK_3)
|
||||
+ vkd3d_string_buffer_printf(buffer, "w");
|
||||
+}
|
||||
+
|
||||
+static void msl_src_cleanup(struct msl_src *src, struct vkd3d_string_buffer_cache *cache)
|
||||
+{
|
||||
+ vkd3d_string_buffer_release(cache, src->str);
|
||||
+}
|
||||
+
|
||||
+static void msl_src_init(struct msl_src *msl_src, struct msl_generator *gen,
|
||||
+ const struct vkd3d_shader_src_param *vsir_src, uint32_t mask)
|
||||
+{
|
||||
+ const struct vkd3d_shader_register *reg = &vsir_src->reg;
|
||||
+
|
||||
+ msl_src->str = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
+
|
||||
+ if (reg->non_uniform)
|
||||
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled 'non-uniform' modifier.");
|
||||
+ if (vsir_src->modifiers)
|
||||
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled source modifier(s) %#x.", vsir_src->modifiers);
|
||||
+
|
||||
+ msl_print_register_name(msl_src->str, gen, reg);
|
||||
+ if (reg->dimension == VSIR_DIMENSION_VEC4)
|
||||
+ msl_print_swizzle(msl_src->str, vsir_src->swizzle, mask);
|
||||
+}
|
||||
+
|
||||
+static void msl_dst_cleanup(struct msl_dst *dst, struct vkd3d_string_buffer_cache *cache)
|
||||
+{
|
||||
+ vkd3d_string_buffer_release(cache, dst->mask);
|
||||
+ vkd3d_string_buffer_release(cache, dst->register_name);
|
||||
+}
|
||||
+
|
||||
+static uint32_t msl_dst_init(struct msl_dst *msl_dst, struct msl_generator *gen,
|
||||
+ const struct vkd3d_shader_instruction *ins, const struct vkd3d_shader_dst_param *vsir_dst)
|
||||
+{
|
||||
+ uint32_t write_mask = vsir_dst->write_mask;
|
||||
+
|
||||
+ if (ins->flags & VKD3DSI_PRECISE_XYZW)
|
||||
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled 'precise' modifier.");
|
||||
+ if (vsir_dst->reg.non_uniform)
|
||||
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled 'non-uniform' modifier.");
|
||||
+
|
||||
+ msl_dst->vsir = vsir_dst;
|
||||
+ msl_dst->register_name = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
+ msl_dst->mask = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
+
|
||||
+ msl_print_register_name(msl_dst->register_name, gen, &vsir_dst->reg);
|
||||
+ msl_print_write_mask(msl_dst->mask, write_mask);
|
||||
+
|
||||
+ return write_mask;
|
||||
+}
|
||||
+
|
||||
+static void VKD3D_PRINTF_FUNC(3, 4) msl_print_assignment(
|
||||
+ struct msl_generator *gen, struct msl_dst *dst, const char *format, ...)
|
||||
+{
|
||||
+ va_list args;
|
||||
+
|
||||
+ if (dst->vsir->shift)
|
||||
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled destination shift %#x.", dst->vsir->shift);
|
||||
+ if (dst->vsir->modifiers)
|
||||
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
+ "Internal compiler error: Unhandled destination modifier(s) %#x.", dst->vsir->modifiers);
|
||||
+
|
||||
+ msl_print_indent(gen->buffer, gen->indent);
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, "%s%s = ", dst->register_name->buffer, dst->mask->buffer);
|
||||
+
|
||||
+ va_start(args, format);
|
||||
+ vkd3d_string_buffer_vprintf(gen->buffer, format, args);
|
||||
+ va_end(args);
|
||||
+
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, ";\n");
|
||||
+}
|
||||
|
||||
static void msl_unhandled(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
||||
{
|
||||
@@ -52,6 +171,27 @@ static void msl_unhandled(struct msl_generator *gen, const struct vkd3d_shader_i
|
||||
"Internal compiler error: Unhandled instruction %#x.", ins->opcode);
|
||||
}
|
||||
|
||||
+static void msl_mov(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
||||
+{
|
||||
+ struct msl_src src;
|
||||
+ struct msl_dst dst;
|
||||
+ uint32_t mask;
|
||||
+
|
||||
+ mask = msl_dst_init(&dst, gen, ins, &ins->dst[0]);
|
||||
+ msl_src_init(&src, gen, &ins->src[0], mask);
|
||||
+
|
||||
+ msl_print_assignment(gen, &dst, "%s", src.str->buffer);
|
||||
+
|
||||
+ msl_src_cleanup(&src, &gen->string_buffers);
|
||||
+ msl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
+}
|
||||
+
|
||||
+static void msl_ret(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
||||
+{
|
||||
+ msl_print_indent(gen->buffer, gen->indent);
|
||||
+ vkd3d_string_buffer_printf(gen->buffer, "return;\n");
|
||||
+}
|
||||
+
|
||||
static void msl_handle_instruction(struct msl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
||||
{
|
||||
gen->location = ins->location;
|
||||
@@ -60,6 +200,12 @@ static void msl_handle_instruction(struct msl_generator *gen, const struct vkd3d
|
||||
{
|
||||
case VKD3DSIH_NOP:
|
||||
break;
|
||||
+ case VKD3DSIH_MOV:
|
||||
+ msl_mov(gen, ins);
|
||||
+ break;
|
||||
+ case VKD3DSIH_RET:
|
||||
+ msl_ret(gen, ins);
|
||||
+ break;
|
||||
default:
|
||||
msl_unhandled(gen, ins);
|
||||
break;
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/tpf.c b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
index 48efe1e2d72..cbf28f5ec50 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
@@ -645,6 +645,9 @@ enum vkd3d_sm4_stat_field
|
||||
VKD3D_STAT_TESS_PARTITIONING,
|
||||
VKD3D_STAT_TESS_OUTPUT_PRIMITIVE,
|
||||
VKD3D_STAT_TESS_CONTROL_POINT_COUNT,
|
||||
+ VKD3D_STAT_BARRIER,
|
||||
+ VKD3D_STAT_LOD,
|
||||
+ VKD3D_STAT_GATHER,
|
||||
VKD3D_STAT_COUNT,
|
||||
};
|
||||
|
||||
@@ -1793,17 +1796,16 @@ static void init_sm4_lookup_tables(struct vkd3d_sm4_lookup_tables *lookup)
|
||||
{VKD3D_SM4_OP_SAMPLE_LOD, VKD3D_STAT_SAMPLE},
|
||||
{VKD3D_SM5_OP_SAMPLE_LOD_S, VKD3D_STAT_SAMPLE},
|
||||
{VKD3D_SM5_OP_SAMPLE_CL_S, VKD3D_STAT_SAMPLE},
|
||||
- {VKD3D_SM4_OP_GATHER4, VKD3D_STAT_SAMPLE},
|
||||
- {VKD3D_SM5_OP_GATHER4_PO, VKD3D_STAT_SAMPLE},
|
||||
{VKD3D_SM4_OP_SAMPLE_C, VKD3D_STAT_SAMPLE_C},
|
||||
{VKD3D_SM4_OP_SAMPLE_C_LZ, VKD3D_STAT_SAMPLE_C},
|
||||
{VKD3D_SM5_OP_SAMPLE_C_LZ_S, VKD3D_STAT_SAMPLE_C},
|
||||
{VKD3D_SM5_OP_SAMPLE_C_CL_S, VKD3D_STAT_SAMPLE_C},
|
||||
- {VKD3D_SM5_OP_GATHER4_C, VKD3D_STAT_SAMPLE_C},
|
||||
- {VKD3D_SM5_OP_GATHER4_PO_C, VKD3D_STAT_SAMPLE_C},
|
||||
{VKD3D_SM4_OP_SAMPLE_GRAD, VKD3D_STAT_SAMPLE_GRAD},
|
||||
{VKD3D_SM5_OP_SAMPLE_GRAD_CL_S, VKD3D_STAT_SAMPLE_GRAD},
|
||||
{VKD3D_SM4_OP_SAMPLE_B, VKD3D_STAT_SAMPLE_BIAS},
|
||||
+ {VKD3D_SM4_OP_GATHER4, VKD3D_STAT_GATHER},
|
||||
+ {VKD3D_SM5_OP_GATHER4_PO, VKD3D_STAT_GATHER},
|
||||
+ {VKD3D_SM4_OP_LOD, VKD3D_STAT_LOD},
|
||||
|
||||
{VKD3D_SM4_OP_LD, VKD3D_STAT_LOAD},
|
||||
{VKD3D_SM4_OP_LD2DMS, VKD3D_STAT_LOAD},
|
||||
@@ -1857,6 +1859,8 @@ static void init_sm4_lookup_tables(struct vkd3d_sm4_lookup_tables *lookup)
|
||||
{VKD3D_SM5_OP_DCL_TESSELLATOR_OUTPUT_PRIMITIVE, VKD3D_STAT_TESS_OUTPUT_PRIMITIVE},
|
||||
{VKD3D_SM5_OP_DCL_INPUT_CONTROL_POINT_COUNT, VKD3D_STAT_TESS_CONTROL_POINT_COUNT},
|
||||
{VKD3D_SM5_OP_DCL_OUTPUT_CONTROL_POINT_COUNT, VKD3D_STAT_TESS_CONTROL_POINT_COUNT},
|
||||
+
|
||||
+ {VKD3D_SM5_OP_SYNC, VKD3D_STAT_BARRIER},
|
||||
};
|
||||
|
||||
memset(lookup, 0, sizeof(*lookup));
|
||||
@@ -6433,8 +6437,8 @@ static void write_sm4_stat(struct hlsl_ctx *ctx, const struct sm4_stat *stat, st
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_DCL_INPUT_PRIMITIVE]);
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_DCL_OUTPUT_TOPOLOGY]);
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_DCL_VERTICES_OUT]);
|
||||
- put_u32(&buffer, 0); /* Unknown */
|
||||
- put_u32(&buffer, 0); /* Unknown */
|
||||
+ put_u32(&buffer, stat->fields[VKD3D_STAT_GATHER]);
|
||||
+ put_u32(&buffer, stat->fields[VKD3D_STAT_LOD]);
|
||||
put_u32(&buffer, 0); /* Sample frequency */
|
||||
|
||||
if (hlsl_version_ge(ctx, 5, 0))
|
||||
@@ -6444,7 +6448,7 @@ static void write_sm4_stat(struct hlsl_ctx *ctx, const struct sm4_stat *stat, st
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_TESS_OUTPUT_PRIMITIVE]);
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_TESS_PARTITIONING]);
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_TESS_DOMAIN]);
|
||||
- put_u32(&buffer, 0); /* Barrier instructions */
|
||||
+ put_u32(&buffer, stat->fields[VKD3D_STAT_BARRIER]);
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_ATOMIC]);
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_STORE]);
|
||||
}
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
||||
index ee98a504a5b..fc217860403 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
||||
@@ -1635,7 +1635,8 @@ int vsir_program_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
case VKD3D_SHADER_TARGET_GLSL:
|
||||
if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
|
||||
return ret;
|
||||
- ret = glsl_compile(program, config_flags, compile_info, out, message_context);
|
||||
+ ret = glsl_compile(program, config_flags, &scan_descriptor_info,
|
||||
+ compile_info, out, message_context);
|
||||
vkd3d_shader_free_scan_descriptor_info1(&scan_descriptor_info);
|
||||
break;
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
index 8146a393a4c..a5d869172d3 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
@@ -168,6 +168,7 @@ enum vkd3d_shader_error
|
||||
VKD3D_SHADER_WARNING_HLSL_IGNORED_DEFAULT_VALUE = 5306,
|
||||
|
||||
VKD3D_SHADER_ERROR_GLSL_INTERNAL = 6000,
|
||||
+ VKD3D_SHADER_ERROR_GLSL_BINDING_NOT_FOUND = 6001,
|
||||
|
||||
VKD3D_SHADER_ERROR_D3DBC_UNEXPECTED_EOF = 7000,
|
||||
VKD3D_SHADER_ERROR_D3DBC_INVALID_VERSION_TOKEN = 7001,
|
||||
@@ -1593,8 +1594,9 @@ int shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
|
||||
struct vkd3d_shader_message_context *message_context, struct shader_signature *signature);
|
||||
|
||||
int glsl_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
- const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out,
|
||||
- struct vkd3d_shader_message_context *message_context);
|
||||
+ const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
|
||||
+ const struct vkd3d_shader_compile_info *compile_info,
|
||||
+ struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
||||
|
||||
#define SPIRV_MAX_SRC_COUNT 6
|
||||
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,520 +0,0 @@
|
||||
From 50e1fdcf167b4e3a8284fe5ac5c797cc780adb73 Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Sat, 21 Sep 2024 09:40:50 +1000
|
||||
Subject: [PATCH] Updated vkd3d to 2ac7f650a196e47a18ea1957eac5953255cf424d.
|
||||
|
||||
---
|
||||
libs/vkd3d/libs/vkd3d-shader/glsl.c | 79 +++++++++++--
|
||||
libs/vkd3d/libs/vkd3d-shader/ir.c | 32 +++--
|
||||
libs/vkd3d/libs/vkd3d-shader/spirv.c | 30 ++---
|
||||
libs/vkd3d/libs/vkd3d-shader/tpf.c | 110 ++++++++++++------
|
||||
.../libs/vkd3d-shader/vkd3d_shader_private.h | 1 +
|
||||
libs/vkd3d/libs/vkd3d/utils.c | 3 +-
|
||||
6 files changed, 182 insertions(+), 73 deletions(-)
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
index ac101d44214..dd1c121d5a8 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
@@ -144,6 +144,12 @@ static void shader_glsl_print_register_name(struct vkd3d_string_buffer *buffer,
|
||||
vkd3d_string_buffer_printf(buffer, "%#xu", reg->u.immconst_u32[0]);
|
||||
break;
|
||||
|
||||
+ case VSIR_DIMENSION_VEC4:
|
||||
+ vkd3d_string_buffer_printf(buffer, "uvec4(%#xu, %#xu, %#xu, %#xu)",
|
||||
+ reg->u.immconst_u32[0], reg->u.immconst_u32[1],
|
||||
+ reg->u.immconst_u32[2], reg->u.immconst_u32[3]);
|
||||
+ break;
|
||||
+
|
||||
default:
|
||||
vkd3d_string_buffer_printf(buffer, "<unhandled_dimension %#x>", reg->dimension);
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
@@ -211,7 +217,7 @@ static void glsl_src_cleanup(struct glsl_src *src, struct vkd3d_string_buffer_ca
|
||||
}
|
||||
|
||||
static void shader_glsl_print_bitcast(struct vkd3d_string_buffer *dst, struct vkd3d_glsl_generator *gen,
|
||||
- const char *src, enum vkd3d_data_type dst_data_type, enum vkd3d_data_type src_data_type)
|
||||
+ const char *src, enum vkd3d_data_type dst_data_type, enum vkd3d_data_type src_data_type, unsigned int size)
|
||||
{
|
||||
if (dst_data_type == VKD3D_DATA_UNORM || dst_data_type == VKD3D_DATA_SNORM)
|
||||
dst_data_type = VKD3D_DATA_FLOAT;
|
||||
@@ -224,16 +230,37 @@ static void shader_glsl_print_bitcast(struct vkd3d_string_buffer *dst, struct vk
|
||||
return;
|
||||
}
|
||||
|
||||
- if (src_data_type == VKD3D_DATA_FLOAT && dst_data_type == VKD3D_DATA_UINT)
|
||||
+ if (src_data_type == VKD3D_DATA_FLOAT)
|
||||
{
|
||||
- vkd3d_string_buffer_printf(dst, "floatBitsToUint(%s)", src);
|
||||
- return;
|
||||
+ switch (dst_data_type)
|
||||
+ {
|
||||
+ case VKD3D_DATA_INT:
|
||||
+ vkd3d_string_buffer_printf(dst, "floatBitsToInt(%s)", src);
|
||||
+ return;
|
||||
+ case VKD3D_DATA_UINT:
|
||||
+ vkd3d_string_buffer_printf(dst, "floatBitsToUint(%s)", src);
|
||||
+ return;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
|
||||
- if (src_data_type == VKD3D_DATA_UINT && dst_data_type == VKD3D_DATA_FLOAT)
|
||||
+ if (src_data_type == VKD3D_DATA_UINT)
|
||||
{
|
||||
- vkd3d_string_buffer_printf(dst, "uintBitsToFloat(%s)", src);
|
||||
- return;
|
||||
+ switch (dst_data_type)
|
||||
+ {
|
||||
+ case VKD3D_DATA_FLOAT:
|
||||
+ vkd3d_string_buffer_printf(dst, "uintBitsToFloat(%s)", src);
|
||||
+ return;
|
||||
+ case VKD3D_DATA_INT:
|
||||
+ if (size == 1)
|
||||
+ vkd3d_string_buffer_printf(dst, "int(%s)", src);
|
||||
+ else
|
||||
+ vkd3d_string_buffer_printf(dst, "ivec%u(%s)", size, src);
|
||||
+ return;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
@@ -248,6 +275,7 @@ static void glsl_src_init(struct glsl_src *glsl_src, struct vkd3d_glsl_generator
|
||||
const struct vkd3d_shader_register *reg = &vsir_src->reg;
|
||||
struct vkd3d_string_buffer *register_name, *str;
|
||||
enum vkd3d_data_type src_data_type;
|
||||
+ unsigned int size;
|
||||
|
||||
glsl_src->str = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
register_name = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
@@ -268,7 +296,8 @@ static void glsl_src_init(struct glsl_src *glsl_src, struct vkd3d_glsl_generator
|
||||
else
|
||||
str = vkd3d_string_buffer_get(&gen->string_buffers);
|
||||
|
||||
- shader_glsl_print_bitcast(str, gen, register_name->buffer, reg->data_type, src_data_type);
|
||||
+ size = reg->dimension == VSIR_DIMENSION_VEC4 ? 4 : 1;
|
||||
+ shader_glsl_print_bitcast(str, gen, register_name->buffer, reg->data_type, src_data_type, size);
|
||||
if (reg->dimension == VSIR_DIMENSION_VEC4)
|
||||
shader_glsl_print_swizzle(str, vsir_src->swizzle, mask);
|
||||
|
||||
@@ -385,6 +414,30 @@ static void shader_glsl_binop(struct vkd3d_glsl_generator *gen,
|
||||
glsl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
}
|
||||
|
||||
+static void shader_glsl_relop(struct vkd3d_glsl_generator *gen,
|
||||
+ const struct vkd3d_shader_instruction *ins, const char *scalar_op, const char *vector_op)
|
||||
+{
|
||||
+ unsigned int mask_size;
|
||||
+ struct glsl_src src[2];
|
||||
+ struct glsl_dst dst;
|
||||
+ uint32_t mask;
|
||||
+
|
||||
+ mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
|
||||
+ glsl_src_init(&src[0], gen, &ins->src[0], mask);
|
||||
+ glsl_src_init(&src[1], gen, &ins->src[1], mask);
|
||||
+
|
||||
+ if ((mask_size = vsir_write_mask_component_count(mask)) > 1)
|
||||
+ shader_glsl_print_assignment(gen, &dst, "uvec%u(%s(%s, %s)) * 0xffffffffu",
|
||||
+ mask_size, vector_op, src[0].str->buffer, src[1].str->buffer);
|
||||
+ else
|
||||
+ shader_glsl_print_assignment(gen, &dst, "%s %s %s ? 0xffffffffu : 0u",
|
||||
+ src[0].str->buffer, scalar_op, src[1].str->buffer);
|
||||
+
|
||||
+ glsl_src_cleanup(&src[1], &gen->string_buffers);
|
||||
+ glsl_src_cleanup(&src[0], &gen->string_buffers);
|
||||
+ glsl_dst_cleanup(&dst, &gen->string_buffers);
|
||||
+}
|
||||
+
|
||||
static void shader_glsl_mov(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
||||
{
|
||||
struct glsl_src src;
|
||||
@@ -555,9 +608,19 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
||||
case VKD3DSIH_DCL_OUTPUT_SIV:
|
||||
case VKD3DSIH_NOP:
|
||||
break;
|
||||
+ case VKD3DSIH_INE:
|
||||
+ case VKD3DSIH_NEU:
|
||||
+ shader_glsl_relop(gen, ins, "!=", "notEqual");
|
||||
+ break;
|
||||
case VKD3DSIH_MOV:
|
||||
shader_glsl_mov(gen, ins);
|
||||
break;
|
||||
+ case VKD3DSIH_MUL:
|
||||
+ shader_glsl_binop(gen, ins, "*");
|
||||
+ break;
|
||||
+ case VKD3DSIH_OR:
|
||||
+ shader_glsl_binop(gen, ins, "|");
|
||||
+ break;
|
||||
case VKD3DSIH_RET:
|
||||
shader_glsl_ret(gen, ins);
|
||||
break;
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
index 9e06b94e2eb..db9992d9715 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
@@ -1208,8 +1208,8 @@ static bool io_normaliser_is_in_control_point_phase(const struct io_normaliser *
|
||||
return normaliser->phase == VKD3DSIH_HS_CONTROL_POINT_PHASE;
|
||||
}
|
||||
|
||||
-static unsigned int shader_signature_find_element_for_reg(const struct shader_signature *signature,
|
||||
- unsigned int reg_idx, unsigned int write_mask)
|
||||
+static bool shader_signature_find_element_for_reg(const struct shader_signature *signature,
|
||||
+ unsigned int reg_idx, unsigned int write_mask, unsigned int *element_idx)
|
||||
{
|
||||
unsigned int i, base_write_mask;
|
||||
|
||||
@@ -1219,7 +1219,8 @@ static unsigned int shader_signature_find_element_for_reg(const struct shader_si
|
||||
if (e->register_index <= reg_idx && e->register_index + e->register_count > reg_idx
|
||||
&& (e->mask & write_mask) == write_mask)
|
||||
{
|
||||
- return i;
|
||||
+ *element_idx = i;
|
||||
+ return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1229,15 +1230,20 @@ static unsigned int shader_signature_find_element_for_reg(const struct shader_si
|
||||
reg_idx, write_mask);
|
||||
base_write_mask = 1u << vsir_write_mask_get_component_idx(write_mask);
|
||||
if (base_write_mask != write_mask)
|
||||
- return shader_signature_find_element_for_reg(signature, reg_idx, base_write_mask);
|
||||
+ return shader_signature_find_element_for_reg(signature, reg_idx, base_write_mask, element_idx);
|
||||
|
||||
- vkd3d_unreachable();
|
||||
+ return false;
|
||||
}
|
||||
|
||||
struct signature_element *vsir_signature_find_element_for_reg(const struct shader_signature *signature,
|
||||
unsigned int reg_idx, unsigned int write_mask)
|
||||
{
|
||||
- return &signature->elements[shader_signature_find_element_for_reg(signature, reg_idx, write_mask)];
|
||||
+ unsigned int element_idx;
|
||||
+
|
||||
+ if (shader_signature_find_element_for_reg(signature, reg_idx, write_mask, &element_idx))
|
||||
+ return &signature->elements[element_idx];
|
||||
+
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
static unsigned int range_map_get_register_count(uint8_t range_map[][VKD3D_VEC4_SIZE],
|
||||
@@ -1291,9 +1297,10 @@ static void io_normaliser_add_index_range(struct io_normaliser *normaliser,
|
||||
{
|
||||
const struct vkd3d_shader_index_range *range = &ins->declaration.index_range;
|
||||
const struct vkd3d_shader_register *reg = &range->dst.reg;
|
||||
- unsigned int reg_idx, write_mask, element_idx;
|
||||
const struct shader_signature *signature;
|
||||
uint8_t (*range_map)[VKD3D_VEC4_SIZE];
|
||||
+ struct signature_element *element;
|
||||
+ unsigned int reg_idx, write_mask;
|
||||
|
||||
switch (reg->type)
|
||||
{
|
||||
@@ -1325,9 +1332,8 @@ static void io_normaliser_add_index_range(struct io_normaliser *normaliser,
|
||||
|
||||
reg_idx = reg->idx[reg->idx_count - 1].offset;
|
||||
write_mask = range->dst.write_mask;
|
||||
- element_idx = shader_signature_find_element_for_reg(signature, reg_idx, write_mask);
|
||||
- range_map_set_register_range(range_map, reg_idx, range->register_count,
|
||||
- signature->elements[element_idx].mask, true);
|
||||
+ element = vsir_signature_find_element_for_reg(signature, reg_idx, write_mask);
|
||||
+ range_map_set_register_range(range_map, reg_idx, range->register_count, element->mask, true);
|
||||
}
|
||||
|
||||
static int signature_element_mask_compare(const void *a, const void *b)
|
||||
@@ -1648,7 +1654,8 @@ static bool shader_dst_param_io_normalise(struct vkd3d_shader_dst_param *dst_par
|
||||
|
||||
id_idx = reg->idx_count - 1;
|
||||
write_mask = dst_param->write_mask;
|
||||
- element_idx = shader_signature_find_element_for_reg(signature, reg_idx, write_mask);
|
||||
+ if (!shader_signature_find_element_for_reg(signature, reg_idx, write_mask, &element_idx))
|
||||
+ vkd3d_unreachable();
|
||||
e = &signature->elements[element_idx];
|
||||
|
||||
dst_param->write_mask >>= vsir_write_mask_get_component_idx(e->mask);
|
||||
@@ -1771,7 +1778,8 @@ static void shader_src_param_io_normalise(struct vkd3d_shader_src_param *src_par
|
||||
|
||||
id_idx = reg->idx_count - 1;
|
||||
write_mask = VKD3DSP_WRITEMASK_0 << vsir_swizzle_get_component(src_param->swizzle, 0);
|
||||
- element_idx = shader_signature_find_element_for_reg(signature, reg_idx, write_mask);
|
||||
+ if (!shader_signature_find_element_for_reg(signature, reg_idx, write_mask, &element_idx))
|
||||
+ vkd3d_unreachable();
|
||||
|
||||
e = &signature->elements[element_idx];
|
||||
if ((e->register_count > 1 || vsir_sysval_semantic_is_tess_factor(e->sysval_semantic)))
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
index a3e121f8687..7f1e0fea2c3 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
@@ -299,6 +299,16 @@ static void vkd3d_spirv_stream_free(struct vkd3d_spirv_stream *stream)
|
||||
vkd3d_spirv_stream_clear(stream);
|
||||
}
|
||||
|
||||
+static void vkd3d_shader_code_from_spirv_stream(struct vkd3d_shader_code *code, struct vkd3d_spirv_stream *stream)
|
||||
+{
|
||||
+ code->code = stream->words;
|
||||
+ code->size = stream->word_count * sizeof(*stream->words);
|
||||
+
|
||||
+ stream->words = NULL;
|
||||
+ stream->capacity = 0;
|
||||
+ stream->word_count = 0;
|
||||
+}
|
||||
+
|
||||
static size_t vkd3d_spirv_stream_current_location(struct vkd3d_spirv_stream *stream)
|
||||
{
|
||||
return stream->word_count;
|
||||
@@ -2018,9 +2028,7 @@ static bool vkd3d_spirv_compile_module(struct vkd3d_spirv_builder *builder,
|
||||
{
|
||||
uint64_t capability_mask = builder->capability_mask;
|
||||
struct vkd3d_spirv_stream stream;
|
||||
- uint32_t *code;
|
||||
unsigned int i;
|
||||
- size_t size;
|
||||
|
||||
vkd3d_spirv_stream_init(&stream);
|
||||
|
||||
@@ -2075,26 +2083,20 @@ static bool vkd3d_spirv_compile_module(struct vkd3d_spirv_builder *builder,
|
||||
if (builder->invocation_count)
|
||||
vkd3d_spirv_build_op_execution_mode(&builder->execution_mode_stream,
|
||||
builder->main_function_id, SpvExecutionModeInvocations, &builder->invocation_count, 1);
|
||||
- vkd3d_spirv_stream_append(&stream, &builder->execution_mode_stream);
|
||||
-
|
||||
- vkd3d_spirv_stream_append(&stream, &builder->debug_stream);
|
||||
- vkd3d_spirv_stream_append(&stream, &builder->annotation_stream);
|
||||
- vkd3d_spirv_stream_append(&stream, &builder->global_stream);
|
||||
- vkd3d_spirv_stream_append(&stream, &builder->function_stream);
|
||||
|
||||
- if (!(code = vkd3d_calloc(stream.word_count, sizeof(*code))))
|
||||
+ if (!vkd3d_spirv_stream_append(&stream, &builder->execution_mode_stream)
|
||||
+ || !vkd3d_spirv_stream_append(&stream, &builder->debug_stream)
|
||||
+ || !vkd3d_spirv_stream_append(&stream, &builder->annotation_stream)
|
||||
+ || !vkd3d_spirv_stream_append(&stream, &builder->global_stream)
|
||||
+ || !vkd3d_spirv_stream_append(&stream, &builder->function_stream))
|
||||
{
|
||||
vkd3d_spirv_stream_free(&stream);
|
||||
return false;
|
||||
}
|
||||
|
||||
- size = stream.word_count * sizeof(*code);
|
||||
- memcpy(code, stream.words, size);
|
||||
+ vkd3d_shader_code_from_spirv_stream(spirv, &stream);
|
||||
vkd3d_spirv_stream_free(&stream);
|
||||
|
||||
- spirv->code = code;
|
||||
- spirv->size = size;
|
||||
-
|
||||
return true;
|
||||
}
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/tpf.c b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
index cbf28f5ec50..884a2998d5b 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
||||
@@ -648,6 +648,7 @@ enum vkd3d_sm4_stat_field
|
||||
VKD3D_STAT_BARRIER,
|
||||
VKD3D_STAT_LOD,
|
||||
VKD3D_STAT_GATHER,
|
||||
+ VKD3D_STAT_TEMPS,
|
||||
VKD3D_STAT_COUNT,
|
||||
};
|
||||
|
||||
@@ -1157,7 +1158,18 @@ static void shader_sm4_read_dcl_input_ps(struct vkd3d_shader_instruction *ins, u
|
||||
struct signature_element *e = vsir_signature_find_element_for_reg(
|
||||
&priv->p.program->input_signature, dst->reg.idx[dst->reg.idx_count - 1].offset, dst->write_mask);
|
||||
|
||||
- e->interpolation_mode = ins->flags;
|
||||
+ if (!e)
|
||||
+ {
|
||||
+ WARN("No matching signature element for input register %u with mask %#x.\n",
|
||||
+ dst->reg.idx[dst->reg.idx_count - 1].offset, dst->write_mask);
|
||||
+ vkd3d_shader_parser_error(&priv->p, VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_DCL,
|
||||
+ "No matching signature element for input register %u with mask %#x.\n",
|
||||
+ dst->reg.idx[dst->reg.idx_count - 1].offset, dst->write_mask);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ e->interpolation_mode = ins->flags;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1172,7 +1184,18 @@ static void shader_sm4_read_dcl_input_ps_siv(struct vkd3d_shader_instruction *in
|
||||
struct signature_element *e = vsir_signature_find_element_for_reg(
|
||||
&priv->p.program->input_signature, dst->reg.idx[dst->reg.idx_count - 1].offset, dst->write_mask);
|
||||
|
||||
- e->interpolation_mode = ins->flags;
|
||||
+ if (!e)
|
||||
+ {
|
||||
+ WARN("No matching signature element for input register %u with mask %#x.\n",
|
||||
+ dst->reg.idx[dst->reg.idx_count - 1].offset, dst->write_mask);
|
||||
+ vkd3d_shader_parser_error(&priv->p, VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_DCL,
|
||||
+ "No matching signature element for input register %u with mask %#x.\n",
|
||||
+ dst->reg.idx[dst->reg.idx_count - 1].offset, dst->write_mask);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ e->interpolation_mode = ins->flags;
|
||||
+ }
|
||||
}
|
||||
ins->declaration.register_semantic.sysval_semantic = *tokens;
|
||||
}
|
||||
@@ -1861,6 +1884,8 @@ static void init_sm4_lookup_tables(struct vkd3d_sm4_lookup_tables *lookup)
|
||||
{VKD3D_SM5_OP_DCL_OUTPUT_CONTROL_POINT_COUNT, VKD3D_STAT_TESS_CONTROL_POINT_COUNT},
|
||||
|
||||
{VKD3D_SM5_OP_SYNC, VKD3D_STAT_BARRIER},
|
||||
+
|
||||
+ {VKD3D_SM4_OP_DCL_TEMPS, VKD3D_STAT_TEMPS},
|
||||
};
|
||||
|
||||
memset(lookup, 0, sizeof(*lookup));
|
||||
@@ -4403,44 +4428,11 @@ static void sm4_write_src_register(const struct tpf_writer *tpf, const struct vk
|
||||
}
|
||||
}
|
||||
|
||||
-static void write_sm4_instruction(const struct tpf_writer *tpf, const struct sm4_instruction *instr)
|
||||
+static void sm4_update_stat_counters(const struct tpf_writer *tpf, const struct sm4_instruction *instr)
|
||||
{
|
||||
enum vkd3d_shader_type shader_type = tpf->ctx->profile->type;
|
||||
- uint32_t token = instr->opcode | instr->extra_bits, opcode;
|
||||
- struct vkd3d_bytecode_buffer *buffer = tpf->buffer;
|
||||
enum vkd3d_sm4_stat_field stat_field;
|
||||
- unsigned int size, i, j;
|
||||
- size_t token_position;
|
||||
-
|
||||
- if (instr->modifier_count > 0)
|
||||
- token |= VKD3D_SM4_INSTRUCTION_MODIFIER;
|
||||
-
|
||||
- token_position = put_u32(buffer, 0);
|
||||
-
|
||||
- for (i = 0; i < instr->modifier_count; ++i)
|
||||
- {
|
||||
- uint32_t modifier_token = sm4_encode_instruction_modifier(&instr->modifiers[i]);
|
||||
-
|
||||
- if (instr->modifier_count > i + 1)
|
||||
- modifier_token |= VKD3D_SM4_INSTRUCTION_MODIFIER;
|
||||
- put_u32(buffer, modifier_token);
|
||||
- }
|
||||
-
|
||||
- for (i = 0; i < instr->dst_count; ++i)
|
||||
- sm4_write_dst_register(tpf, &instr->dsts[i]);
|
||||
-
|
||||
- for (i = 0; i < instr->src_count; ++i)
|
||||
- sm4_write_src_register(tpf, &instr->srcs[i]);
|
||||
-
|
||||
- if (instr->byte_stride)
|
||||
- put_u32(buffer, instr->byte_stride);
|
||||
-
|
||||
- for (j = 0; j < instr->idx_count; ++j)
|
||||
- put_u32(buffer, instr->idx[j]);
|
||||
-
|
||||
- size = (bytecode_get_size(buffer) - token_position) / sizeof(uint32_t);
|
||||
- token |= (size << VKD3D_SM4_INSTRUCTION_LENGTH_SHIFT);
|
||||
- set_u32(buffer, token_position, token);
|
||||
+ uint32_t opcode;
|
||||
|
||||
++tpf->stat->fields[VKD3D_STAT_INSTR_COUNT];
|
||||
|
||||
@@ -4449,6 +4441,9 @@ static void write_sm4_instruction(const struct tpf_writer *tpf, const struct sm4
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
+ case VKD3D_SM4_OP_DCL_TEMPS:
|
||||
+ tpf->stat->fields[stat_field] = max(tpf->stat->fields[stat_field], instr->idx[0]);
|
||||
+ break;
|
||||
case VKD3D_SM4_OP_DCL_OUTPUT_TOPOLOGY:
|
||||
case VKD3D_SM4_OP_DCL_INPUT_PRIMITIVE:
|
||||
tpf->stat->fields[stat_field] = (instr->opcode & VKD3D_SM4_PRIMITIVE_TYPE_MASK)
|
||||
@@ -4476,7 +4471,46 @@ static void write_sm4_instruction(const struct tpf_writer *tpf, const struct sm4
|
||||
default:
|
||||
++tpf->stat->fields[stat_field];
|
||||
}
|
||||
+}
|
||||
+
|
||||
+static void write_sm4_instruction(const struct tpf_writer *tpf, const struct sm4_instruction *instr)
|
||||
+{
|
||||
+ uint32_t token = instr->opcode | instr->extra_bits;
|
||||
+ struct vkd3d_bytecode_buffer *buffer = tpf->buffer;
|
||||
+ unsigned int size, i, j;
|
||||
+ size_t token_position;
|
||||
+
|
||||
+ if (instr->modifier_count > 0)
|
||||
+ token |= VKD3D_SM4_INSTRUCTION_MODIFIER;
|
||||
+
|
||||
+ token_position = put_u32(buffer, 0);
|
||||
+
|
||||
+ for (i = 0; i < instr->modifier_count; ++i)
|
||||
+ {
|
||||
+ uint32_t modifier_token = sm4_encode_instruction_modifier(&instr->modifiers[i]);
|
||||
+
|
||||
+ if (instr->modifier_count > i + 1)
|
||||
+ modifier_token |= VKD3D_SM4_INSTRUCTION_MODIFIER;
|
||||
+ put_u32(buffer, modifier_token);
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < instr->dst_count; ++i)
|
||||
+ sm4_write_dst_register(tpf, &instr->dsts[i]);
|
||||
+
|
||||
+ for (i = 0; i < instr->src_count; ++i)
|
||||
+ sm4_write_src_register(tpf, &instr->srcs[i]);
|
||||
+
|
||||
+ if (instr->byte_stride)
|
||||
+ put_u32(buffer, instr->byte_stride);
|
||||
+
|
||||
+ for (j = 0; j < instr->idx_count; ++j)
|
||||
+ put_u32(buffer, instr->idx[j]);
|
||||
+
|
||||
+ size = (bytecode_get_size(buffer) - token_position) / sizeof(uint32_t);
|
||||
+ token |= (size << VKD3D_SM4_INSTRUCTION_LENGTH_SHIFT);
|
||||
+ set_u32(buffer, token_position, token);
|
||||
|
||||
+ sm4_update_stat_counters(tpf, instr);
|
||||
}
|
||||
|
||||
static bool encode_texel_offset_as_aoffimmi(struct sm4_instruction *instr,
|
||||
@@ -6412,7 +6446,7 @@ static void write_sm4_stat(struct hlsl_ctx *ctx, const struct sm4_stat *stat, st
|
||||
struct vkd3d_bytecode_buffer buffer = {0};
|
||||
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_INSTR_COUNT]);
|
||||
- put_u32(&buffer, 0); /* Temp count */
|
||||
+ put_u32(&buffer, stat->fields[VKD3D_STAT_TEMPS]);
|
||||
put_u32(&buffer, 0); /* Def count */
|
||||
put_u32(&buffer, 0); /* DCL count */
|
||||
put_u32(&buffer, stat->fields[VKD3D_STAT_FLOAT]);
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
index a5d869172d3..447210449da 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
@@ -80,6 +80,7 @@ enum vkd3d_shader_error
|
||||
VKD3D_SHADER_ERROR_TPF_INVALID_CASE_VALUE = 1007,
|
||||
VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_DIMENSION = 1008,
|
||||
VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_SWIZZLE = 1009,
|
||||
+ VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_DCL = 1010,
|
||||
|
||||
VKD3D_SHADER_WARNING_TPF_MASK_NOT_CONTIGUOUS = 1300,
|
||||
VKD3D_SHADER_WARNING_TPF_UNHANDLED_INDEX_RANGE_MASK = 1301,
|
||||
diff --git a/libs/vkd3d/libs/vkd3d/utils.c b/libs/vkd3d/libs/vkd3d/utils.c
|
||||
index 831dc07af56..839bb173854 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d/utils.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d/utils.c
|
||||
@@ -703,7 +703,7 @@ const char *debug_vk_extent_3d(VkExtent3D extent)
|
||||
|
||||
const char *debug_vk_queue_flags(VkQueueFlags flags)
|
||||
{
|
||||
- char buffer[159];
|
||||
+ char buffer[191];
|
||||
|
||||
buffer[0] = '\0';
|
||||
#define FLAG_TO_STR(f) if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }
|
||||
@@ -715,6 +715,7 @@ const char *debug_vk_queue_flags(VkQueueFlags flags)
|
||||
#undef FLAG_TO_STR
|
||||
#define FLAG_TO_STR(f, n) if (flags & f) { strcat(buffer, " | "#n); flags &= ~f; }
|
||||
FLAG_TO_STR(0x20, VK_QUEUE_VIDEO_DECODE_BIT_KHR)
|
||||
+ FLAG_TO_STR(0x40, VK_QUEUE_VIDEO_ENCODE_BIT_KHR)
|
||||
#undef FLAG_TO_STR
|
||||
if (flags)
|
||||
FIXME("Unrecognized flag(s) %#x.\n", flags);
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,7 +0,0 @@
|
||||
#Update vkd3d to the latest to allow testing before it's
|
||||
# finally be integrated into wine.
|
||||
# Bugs for this patchset should be filled in the usually place against vkd3d
|
||||
|
||||
# Games used for testing
|
||||
# Stranded Alien Dawn - Requires dxvk
|
||||
# DOOM Eternal
|
Loading…
Reference in New Issue
Block a user