Updated vkd3d-latest patchset

This commit is contained in:
Alistair Leslie-Hughes 2024-10-15 09:23:52 +11:00
parent 683813d151
commit 81492f7156
10 changed files with 10167 additions and 6044 deletions

View File

@ -1,949 +0,0 @@
From 1b1edbf05da10281bbb9b0ef228752ec9c21ab28 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

View File

@ -0,0 +1,386 @@
From b7ab480481541737db8e9b5514bc0e52309211c9 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Thu, 10 Oct 2024 07:16:15 +1100
Subject: [PATCH] Updated vkd3d to 9cb4207c92ec3ee05fce15580c89f2e5146354db.
---
libs/vkd3d/libs/vkd3d-shader/dxil.c | 15 +++
libs/vkd3d/libs/vkd3d-shader/glsl.c | 101 ++++++++++++++++--
libs/vkd3d/libs/vkd3d-shader/ir.c | 40 +++++++
libs/vkd3d/libs/vkd3d-shader/spirv.c | 24 ++---
libs/vkd3d/libs/vkd3d-shader/tpf.c | 15 +++
.../libs/vkd3d-shader/vkd3d_shader_main.c | 2 +
.../libs/vkd3d-shader/vkd3d_shader_private.h | 1 +
7 files changed, 173 insertions(+), 25 deletions(-)
diff --git a/libs/vkd3d/libs/vkd3d-shader/dxil.c b/libs/vkd3d/libs/vkd3d-shader/dxil.c
index c66b059325a..5db9d6da063 100644
--- a/libs/vkd3d/libs/vkd3d-shader/dxil.c
+++ b/libs/vkd3d/libs/vkd3d-shader/dxil.c
@@ -10315,6 +10315,21 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, struct vsir_pro
sm6->ptr = &sm6->start[1];
sm6->bitpos = 2;
+ switch (program->shader_version.type)
+ {
+ case VKD3D_SHADER_TYPE_HULL:
+ case VKD3D_SHADER_TYPE_DOMAIN:
+ break;
+
+ default:
+ if (program->patch_constant_signature.element_count != 0)
+ {
+ WARN("The patch constant signature only makes sense for Hull and Domain Shaders, ignoring it.\n");
+ shader_signature_cleanup(&program->patch_constant_signature);
+ }
+ break;
+ }
+
input_signature = &program->input_signature;
output_signature = &program->output_signature;
patch_constant_signature = &program->patch_constant_signature;
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
index 4dc95899a11..91ee355ed39 100644
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
@@ -651,6 +651,20 @@ static void shader_glsl_cast(struct vkd3d_glsl_generator *gen, const struct vkd3
glsl_dst_cleanup(&dst, &gen->string_buffers);
}
+static void shader_glsl_end_block(struct vkd3d_glsl_generator *gen)
+{
+ --gen->indent;
+ shader_glsl_print_indent(gen->buffer, gen->indent);
+ vkd3d_string_buffer_printf(gen->buffer, "}\n");
+}
+
+static void shader_glsl_begin_block(struct vkd3d_glsl_generator *gen)
+{
+ shader_glsl_print_indent(gen->buffer, gen->indent);
+ vkd3d_string_buffer_printf(gen->buffer, "{\n");
+ ++gen->indent;
+}
+
static void shader_glsl_if(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
{
const char *condition;
@@ -664,23 +678,65 @@ static void shader_glsl_if(struct vkd3d_glsl_generator *gen, const struct vkd3d_
glsl_src_cleanup(&src, &gen->string_buffers);
- shader_glsl_print_indent(gen->buffer, gen->indent);
- vkd3d_string_buffer_printf(gen->buffer, "{\n");
- ++gen->indent;
+ shader_glsl_begin_block(gen);
}
static void shader_glsl_else(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
{
- unsigned int i = 4 * (gen->indent - 1);
+ shader_glsl_end_block(gen);
+ shader_glsl_print_indent(gen->buffer, gen->indent);
+ vkd3d_string_buffer_printf(gen->buffer, "else\n");
+ shader_glsl_begin_block(gen);
+}
- vkd3d_string_buffer_printf(gen->buffer, "%*s}\n%*selse\n%*s{\n", i, "", i, "", i, "");
+static void shader_glsl_loop(struct vkd3d_glsl_generator *gen)
+{
+ shader_glsl_print_indent(gen->buffer, gen->indent);
+ vkd3d_string_buffer_printf(gen->buffer, "for (;;)\n");
+ shader_glsl_begin_block(gen);
}
-static void shader_glsl_endif(struct vkd3d_glsl_generator *gen)
+static void shader_glsl_break(struct vkd3d_glsl_generator *gen)
{
- --gen->indent;
shader_glsl_print_indent(gen->buffer, gen->indent);
- vkd3d_string_buffer_printf(gen->buffer, "}\n");
+ vkd3d_string_buffer_printf(gen->buffer, "break;\n");
+}
+
+static void shader_glsl_continue(struct vkd3d_glsl_generator *gen)
+{
+ shader_glsl_print_indent(gen->buffer, gen->indent);
+ vkd3d_string_buffer_printf(gen->buffer, "continue;\n");
+}
+
+static void shader_glsl_switch(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
+{
+ struct glsl_src src;
+
+ glsl_src_init(&src, gen, &ins->src[0], VKD3DSP_WRITEMASK_0);
+
+ shader_glsl_print_indent(gen->buffer, gen->indent);
+ vkd3d_string_buffer_printf(gen->buffer, "switch (%s)\n", src.str->buffer);
+ shader_glsl_begin_block(gen);
+
+ glsl_src_cleanup(&src, &gen->string_buffers);
+}
+
+static void shader_glsl_case(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
+{
+ struct glsl_src src;
+
+ glsl_src_init(&src, gen, &ins->src[0], VKD3DSP_WRITEMASK_0);
+
+ shader_glsl_print_indent(gen->buffer, gen->indent);
+ vkd3d_string_buffer_printf(gen->buffer, "case %s:\n", src.str->buffer);
+
+ glsl_src_cleanup(&src, &gen->string_buffers);
+}
+
+static void shader_glsl_default(struct vkd3d_glsl_generator *gen)
+{
+ shader_glsl_print_indent(gen->buffer, gen->indent);
+ vkd3d_string_buffer_printf(gen->buffer, "default:\n");
}
static void shader_glsl_ld(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
@@ -1013,6 +1069,9 @@ static void shader_glsl_shader_prologue(struct vkd3d_glsl_generator *gen)
case VKD3D_SHADER_COMPONENT_UINT:
vkd3d_string_buffer_printf(buffer, " = uintBitsToFloat(shader_in_%u)", i);
break;
+ case VKD3D_SHADER_COMPONENT_INT:
+ vkd3d_string_buffer_printf(buffer, " = intBitsToFloat(shader_in_%u)", i);
+ break;
default:
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
"Internal compiler error: Unhandled input component type %#x.", e->component_type);
@@ -1127,6 +1186,15 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_AND:
shader_glsl_binop(gen, ins, "&");
break;
+ case VKD3DSIH_BREAK:
+ shader_glsl_break(gen);
+ break;
+ case VKD3DSIH_CASE:
+ shader_glsl_case(gen, ins);
+ break;
+ case VKD3DSIH_CONTINUE:
+ shader_glsl_continue(gen);
+ break;
case VKD3DSIH_DCL_INDEXABLE_TEMP:
shader_glsl_dcl_indexable_temp(gen, ins);
break;
@@ -1138,6 +1206,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_DCL_OUTPUT_SIV:
case VKD3DSIH_NOP:
break;
+ case VKD3DSIH_DEFAULT:
+ shader_glsl_default(gen);
+ break;
case VKD3DSIH_DIV:
shader_glsl_binop(gen, ins, "/");
break;
@@ -1154,7 +1225,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
shader_glsl_else(gen, ins);
break;
case VKD3DSIH_ENDIF:
- shader_glsl_endif(gen);
+ case VKD3DSIH_ENDLOOP:
+ case VKD3DSIH_ENDSWITCH:
+ shader_glsl_end_block(gen);
break;
case VKD3DSIH_EQO:
case VKD3DSIH_IEQ:
@@ -1184,6 +1257,7 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
break;
case VKD3DSIH_ILT:
case VKD3DSIH_LTO:
+ case VKD3DSIH_ULT:
shader_glsl_relop(gen, ins, "<", "lessThan");
break;
case VKD3DSIH_IMAX:
@@ -1220,6 +1294,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_LOG:
shader_glsl_intrinsic(gen, ins, "log2");
break;
+ case VKD3DSIH_LOOP:
+ shader_glsl_loop(gen);
+ break;
case VKD3DSIH_MOV:
shader_glsl_mov(gen, ins);
break;
@@ -1259,6 +1336,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_SQRT:
shader_glsl_intrinsic(gen, ins, "sqrt");
break;
+ case VKD3DSIH_SWITCH:
+ shader_glsl_switch(gen, ins);
+ break;
default:
shader_glsl_unhandled(gen, ins);
break;
@@ -1663,6 +1743,9 @@ static void shader_glsl_generate_input_declarations(struct vkd3d_glsl_generator
case VKD3D_SHADER_COMPONENT_UINT:
vkd3d_string_buffer_printf(buffer, "uvec4");
break;
+ case VKD3D_SHADER_COMPONENT_INT:
+ vkd3d_string_buffer_printf(buffer, "ivec4");
+ break;
case VKD3D_SHADER_COMPONENT_FLOAT:
vkd3d_string_buffer_printf(buffer, "vec4");
break;
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
index 14cf23e8d1a..affbae3ea4e 100644
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
@@ -6505,6 +6505,30 @@ static bool vsir_validate_src_max_count(struct validation_context *ctx,
return true;
}
+static void vsir_validate_signature_element(struct validation_context *ctx,
+ const struct shader_signature *signature, const char *signature_type,
+ unsigned int idx)
+{
+ const struct signature_element *element = &signature->elements[idx];
+
+ if (element->register_count == 0)
+ validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_SIGNATURE,
+ "element %u of %s signature: Invalid zero register count.", idx, signature_type);
+
+ if (element->mask == 0 || (element->mask & ~0xf))
+ validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_SIGNATURE,
+ "element %u of %s signature: Invalid mask %#x.", idx, signature_type, element->mask);
+}
+
+static void vsir_validate_signature(struct validation_context *ctx,
+ const struct shader_signature *signature, const char *signature_type)
+{
+ unsigned int i;
+
+ for (i = 0; i < signature->element_count; ++i)
+ vsir_validate_signature_element(ctx, signature, signature_type, i);
+}
+
static const char *name_from_cf_type(enum vsir_control_flow_type type)
{
switch (type)
@@ -7042,6 +7066,22 @@ enum vkd3d_result vsir_program_validate(struct vsir_program *program, uint64_t c
if (!(config_flags & VKD3D_SHADER_CONFIG_FLAG_FORCE_VALIDATION))
return VKD3D_OK;
+ switch (program->shader_version.type)
+ {
+ case VKD3D_SHADER_TYPE_HULL:
+ case VKD3D_SHADER_TYPE_DOMAIN:
+ break;
+
+ default:
+ if (program->patch_constant_signature.element_count != 0)
+ validator_error(&ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_SIGNATURE,
+ "Patch constant signature is only valid for hull and domain shaders.");
+ }
+
+ vsir_validate_signature(&ctx, &program->input_signature, "input");
+ vsir_validate_signature(&ctx, &program->output_signature, "output");
+ vsir_validate_signature(&ctx, &program->patch_constant_signature, "patch constant");
+
if (!(ctx.temps = vkd3d_calloc(ctx.program->temp_count, sizeof(*ctx.temps))))
goto fail;
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
index cb610c929b6..692432d5513 100644
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
@@ -3267,18 +3267,6 @@ static void spirv_compiler_emit_register_debug_name(struct vkd3d_spirv_builder *
vkd3d_spirv_build_op_name(builder, id, "%s", debug_name);
}
-static uint32_t spirv_compiler_emit_variable(struct spirv_compiler *compiler,
- struct vkd3d_spirv_stream *stream, SpvStorageClass storage_class,
- enum vkd3d_shader_component_type component_type, unsigned int component_count)
-{
- struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
- uint32_t type_id, ptr_type_id;
-
- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count);
- ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, type_id);
- return vkd3d_spirv_build_op_variable(builder, stream, ptr_type_id, storage_class, 0);
-}
-
static uint32_t spirv_compiler_emit_array_variable(struct spirv_compiler *compiler,
struct vkd3d_spirv_stream *stream, SpvStorageClass storage_class,
enum vkd3d_shader_component_type component_type, unsigned int component_count,
@@ -3288,10 +3276,6 @@ static uint32_t spirv_compiler_emit_array_variable(struct spirv_compiler *compil
uint32_t type_id, length_id, ptr_type_id;
unsigned int i;
- if (!length_count)
- return spirv_compiler_emit_variable(compiler,
- stream, storage_class, component_type, component_count);
-
type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count);
for (i = 0; i < length_count; ++i)
{
@@ -3305,6 +3289,14 @@ static uint32_t spirv_compiler_emit_array_variable(struct spirv_compiler *compil
return vkd3d_spirv_build_op_variable(builder, stream, ptr_type_id, storage_class, 0);
}
+static uint32_t spirv_compiler_emit_variable(struct spirv_compiler *compiler,
+ struct vkd3d_spirv_stream *stream, SpvStorageClass storage_class,
+ enum vkd3d_shader_component_type component_type, unsigned int component_count)
+{
+ return spirv_compiler_emit_array_variable(compiler, stream, storage_class,
+ component_type, component_count, NULL, 0);
+}
+
static const struct vkd3d_spec_constant_info
{
enum vkd3d_shader_parameter_name name;
diff --git a/libs/vkd3d/libs/vkd3d-shader/tpf.c b/libs/vkd3d/libs/vkd3d-shader/tpf.c
index 75bdb06fe0e..f79e97e92d4 100644
--- a/libs/vkd3d/libs/vkd3d-shader/tpf.c
+++ b/libs/vkd3d/libs/vkd3d-shader/tpf.c
@@ -2914,6 +2914,21 @@ int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t con
if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL)
uninvert_used_masks(&program->patch_constant_signature);
+ switch (program->shader_version.type)
+ {
+ case VKD3D_SHADER_TYPE_HULL:
+ case VKD3D_SHADER_TYPE_DOMAIN:
+ break;
+
+ default:
+ if (program->patch_constant_signature.element_count != 0)
+ {
+ WARN("The patch constant signature only makes sense for Hull and Domain Shaders, ignoring it.\n");
+ shader_signature_cleanup(&program->patch_constant_signature);
+ }
+ break;
+ }
+
if (!shader_sm4_parser_validate_signature(&sm4, &program->input_signature,
sm4.input_register_masks, "Input")
|| !shader_sm4_parser_validate_signature(&sm4, &program->output_signature,
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
index 9b320106340..f84ac551272 100644
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
@@ -1846,6 +1846,8 @@ void shader_signature_cleanup(struct shader_signature *signature)
}
vkd3d_free(signature->elements);
signature->elements = NULL;
+ signature->elements_capacity = 0;
+ signature->element_count = 0;
}
int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
index 1a42f385fc0..41b879af4b4 100644
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
@@ -245,6 +245,7 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_VSIR_INVALID_GS = 9019,
VKD3D_SHADER_ERROR_VSIR_INVALID_PARAMETER = 9020,
VKD3D_SHADER_ERROR_VSIR_MISSING_SEMANTIC = 9021,
+ VKD3D_SHADER_ERROR_VSIR_INVALID_SIGNATURE = 9022,
VKD3D_SHADER_WARNING_VSIR_DYNAMIC_DESCRIPTOR_ARRAY = 9300,
--
2.45.2

View File

@ -1,303 +0,0 @@
From 3bca6a7e645ca8f48f2ec73a13b63a412cb7f2be 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, &reg, 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

View File

@ -1,893 +0,0 @@
From baf455d7ecc67cac7c6c450535226f67d3af6c21 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Sat, 5 Oct 2024 11:26:42 +1000
Subject: [PATCH] Updated vkd3d to 25232f2b2b35bcf1c265bc380c31cd1d32e4f4a6.
---
libs/vkd3d/libs/vkd3d-shader/dxil.c | 7 +-
libs/vkd3d/libs/vkd3d-shader/glsl.c | 474 +++++++++++++++++-
libs/vkd3d/libs/vkd3d-shader/hlsl.c | 4 +-
libs/vkd3d/libs/vkd3d-shader/hlsl.y | 42 +-
libs/vkd3d/libs/vkd3d-shader/ir.c | 36 ++
.../libs/vkd3d-shader/vkd3d_shader_main.c | 7 +-
.../libs/vkd3d-shader/vkd3d_shader_private.h | 2 +
7 files changed, 553 insertions(+), 19 deletions(-)
diff --git a/libs/vkd3d/libs/vkd3d-shader/dxil.c b/libs/vkd3d/libs/vkd3d-shader/dxil.c
index 165ab222fca..d4296ef4bc5 100644
--- a/libs/vkd3d/libs/vkd3d-shader/dxil.c
+++ b/libs/vkd3d/libs/vkd3d-shader/dxil.c
@@ -4864,8 +4864,10 @@ static void sm6_parser_emit_dx_cbuffer_load(struct sm6_parser *sm6, enum dx_intr
if (!(src_param = instruction_src_params_alloc(ins, 1, sm6)))
return;
src_param_init_vector_from_reg(src_param, &buffer->u.handle.reg);
+ /* Differently from other descriptors, constant buffers require an
+ * additional index, used to index within the constant buffer itself. */
+ src_param->reg.idx_count = 3;
register_index_address_init(&src_param->reg.idx[2], operands[1], sm6);
- VKD3D_ASSERT(src_param->reg.idx_count == 3);
type = sm6_type_get_scalar_type(dst->type, 0);
VKD3D_ASSERT(type);
@@ -4964,8 +4966,7 @@ static void sm6_parser_emit_dx_create_handle(struct sm6_parser *sm6, enum dx_int
dst->u.handle.d = d;
reg = &dst->u.handle.reg;
- /* Set idx_count to 3 for use with load/store instructions. */
- vsir_register_init(reg, d->reg_type, d->reg_data_type, 3);
+ vsir_register_init(reg, d->reg_type, d->reg_data_type, 2);
reg->dimension = VSIR_DIMENSION_VEC4;
reg->idx[0].offset = id;
register_index_address_init(&reg->idx[1], operands[2], sm6);
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
index e2bcca56f05..c2fb58c55e6 100644
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
@@ -18,6 +18,13 @@
#include "vkd3d_shader_private.h"
+struct glsl_resource_type_info
+{
+ size_t coord_size;
+ bool shadow;
+ const char *sampler_type;
+};
+
struct glsl_src
{
struct vkd3d_string_buffer *str;
@@ -52,6 +59,7 @@ struct vkd3d_glsl_generator
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;
+ const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info;
};
static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_glsl_compiler_error(
@@ -87,11 +95,81 @@ static const char *shader_glsl_get_prefix(enum vkd3d_shader_type type)
}
}
+static const struct glsl_resource_type_info *shader_glsl_get_resource_type_info(enum vkd3d_shader_resource_type t)
+{
+ static const struct glsl_resource_type_info info[] =
+ {
+ {0, 0, "samplerNone"}, /* VKD3D_SHADER_RESOURCE_NONE */
+ {1, 0, "samplerBuffer"}, /* VKD3D_SHADER_RESOURCE_BUFFER */
+ {1, 1, "sampler1D"}, /* VKD3D_SHADER_RESOURCE_TEXTURE_1D */
+ {2, 1, "sampler2D"}, /* VKD3D_SHADER_RESOURCE_TEXTURE_2D */
+ {2, 0, "sampler2DMS"}, /* VKD3D_SHADER_RESOURCE_TEXTURE_2DMS */
+ {3, 0, "sampler3D"}, /* VKD3D_SHADER_RESOURCE_TEXTURE_3D */
+ {3, 1, "samplerCube"}, /* VKD3D_SHADER_RESOURCE_TEXTURE_CUBE */
+ {2, 1, "sampler1DArray"}, /* VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY */
+ {3, 1, "sampler2DArray"}, /* VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY */
+ {3, 0, "sampler2DMSArray"}, /* VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY */
+ {4, 1, "samplerCubeArray"}, /* VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY */
+ };
+
+ if (!t || t >= ARRAY_SIZE(info))
+ return NULL;
+
+ return &info[t];
+}
+
+static const struct vkd3d_shader_descriptor_info1 *shader_glsl_get_descriptor(struct vkd3d_glsl_generator *gen,
+ enum vkd3d_shader_descriptor_type type, unsigned int idx, unsigned int space)
+{
+ const struct vkd3d_shader_scan_descriptor_info1 *info = gen->descriptor_info;
+
+ for (unsigned int i = 0; i < info->descriptor_count; ++i)
+ {
+ const struct vkd3d_shader_descriptor_info1 *d = &info->descriptors[i];
+
+ if (d->type == type && d->register_space == space && d->register_index == idx)
+ return d;
+ }
+
+ return NULL;
+}
+
+static const struct vkd3d_shader_descriptor_info1 *shader_glsl_get_descriptor_by_id(
+ struct vkd3d_glsl_generator *gen, enum vkd3d_shader_descriptor_type type, unsigned int id)
+{
+ const struct vkd3d_shader_scan_descriptor_info1 *info = gen->descriptor_info;
+
+ for (unsigned int i = 0; i < info->descriptor_count; ++i)
+ {
+ const struct vkd3d_shader_descriptor_info1 *d = &info->descriptors[i];
+
+ if (d->type == type && d->register_id == id)
+ return d;
+ }
+
+ return NULL;
+}
+
static void shader_glsl_print_indent(struct vkd3d_string_buffer *buffer, unsigned int indent)
{
vkd3d_string_buffer_printf(buffer, "%*s", 4 * indent, "");
}
+static void shader_glsl_print_combined_sampler_name(struct vkd3d_string_buffer *buffer,
+ struct vkd3d_glsl_generator *gen, unsigned int resource_index,
+ unsigned int resource_space, unsigned int sampler_index, unsigned int sampler_space)
+{
+ vkd3d_string_buffer_printf(buffer, "%s_t_%u", gen->prefix, resource_index);
+ if (resource_space)
+ vkd3d_string_buffer_printf(buffer, "_%u", resource_space);
+ if (sampler_index != VKD3D_SHADER_DUMMY_SAMPLER_INDEX)
+ {
+ vkd3d_string_buffer_printf(buffer, "_s_%u", sampler_index);
+ if (sampler_space)
+ vkd3d_string_buffer_printf(buffer, "_%u", sampler_space);
+ }
+}
+
static void shader_glsl_print_register_name(struct vkd3d_string_buffer *buffer,
struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_register *reg)
{
@@ -360,14 +438,12 @@ static uint32_t glsl_dst_init(struct glsl_dst *glsl_dst, struct vkd3d_glsl_gener
return write_mask;
}
-static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment(
- struct vkd3d_glsl_generator *gen, struct glsl_dst *dst, const char *format, ...)
+static void VKD3D_PRINTF_FUNC(4, 0) shader_glsl_vprint_assignment(struct vkd3d_glsl_generator *gen,
+ struct glsl_dst *dst, enum vkd3d_data_type data_type, const char *format, va_list args)
{
- const struct vkd3d_shader_register *dst_reg = &dst->vsir->reg;
struct vkd3d_string_buffer *buffer = gen->buffer;
uint32_t modifiers = dst->vsir->modifiers;
bool close = true;
- va_list args;
if (dst->vsir->shift)
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
@@ -381,11 +457,11 @@ static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment(
if (modifiers & VKD3DSPDM_SATURATE)
vkd3d_string_buffer_printf(buffer, "clamp(");
- switch (dst_reg->data_type)
+ switch (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);
+ "Internal compiler error: Unhandled destination register data type %#x.", data_type);
/* fall through */
case VKD3D_DATA_FLOAT:
close = false;
@@ -398,9 +474,7 @@ static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment(
break;
}
- va_start(args, format);
vkd3d_string_buffer_vprintf(buffer, format, args);
- va_end(args);
if (close)
vkd3d_string_buffer_printf(buffer, ")");
@@ -409,6 +483,26 @@ static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment(
vkd3d_string_buffer_printf(buffer, ";\n");
}
+static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment(
+ struct vkd3d_glsl_generator *gen, struct glsl_dst *dst, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ shader_glsl_vprint_assignment(gen, dst, dst->vsir->reg.data_type, format, args);
+ va_end(args);
+}
+
+static void VKD3D_PRINTF_FUNC(4, 5) shader_glsl_print_assignment_ext(struct vkd3d_glsl_generator *gen,
+ struct glsl_dst *dst, enum vkd3d_data_type data_type, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ shader_glsl_vprint_assignment(gen, dst, data_type, format, args);
+ va_end(args);
+}
+
static void shader_glsl_unhandled(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
{
shader_glsl_print_indent(gen->buffer, gen->indent);
@@ -561,6 +655,159 @@ static void shader_glsl_endif(struct vkd3d_glsl_generator *gen)
vkd3d_string_buffer_printf(gen->buffer, "}\n");
}
+static void shader_glsl_ld(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
+{
+ const struct glsl_resource_type_info *resource_type_info;
+ unsigned int resource_id, resource_idx, resource_space;
+ const struct vkd3d_shader_descriptor_info1 *d;
+ enum vkd3d_shader_component_type sampled_type;
+ enum vkd3d_shader_resource_type resource_type;
+ struct vkd3d_string_buffer *fetch;
+ enum vkd3d_data_type data_type;
+ struct glsl_src coord, lod;
+ struct glsl_dst dst;
+ uint32_t coord_mask;
+
+ if (vkd3d_shader_instruction_has_texel_offset(ins))
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Unhandled texel fetch offset.");
+
+ if (ins->src[1].reg.idx[0].rel_addr || ins->src[1].reg.idx[1].rel_addr)
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_UNSUPPORTED,
+ "Descriptor indexing is not supported.");
+
+ resource_id = ins->src[1].reg.idx[0].offset;
+ resource_idx = ins->src[1].reg.idx[1].offset;
+ if ((d = shader_glsl_get_descriptor_by_id(gen, VKD3D_SHADER_DESCRIPTOR_TYPE_SRV, resource_id)))
+ {
+ resource_type = d->resource_type;
+ resource_space = d->register_space;
+ sampled_type = vkd3d_component_type_from_resource_data_type(d->resource_data_type);
+ data_type = vkd3d_data_type_from_component_type(sampled_type);
+ }
+ else
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Undeclared resource descriptor %u.", resource_id);
+ resource_space = 0;
+ resource_type = VKD3D_SHADER_RESOURCE_TEXTURE_2D;
+ data_type = VKD3D_DATA_FLOAT;
+ }
+
+ if ((resource_type_info = shader_glsl_get_resource_type_info(resource_type)))
+ {
+ coord_mask = vkd3d_write_mask_from_component_count(resource_type_info->coord_size);
+ }
+ else
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Unhandled resource type %#x.", resource_type);
+ coord_mask = vkd3d_write_mask_from_component_count(2);
+ }
+
+ glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
+ glsl_src_init(&coord, gen, &ins->src[0], coord_mask);
+ glsl_src_init(&lod, gen, &ins->src[0], VKD3DSP_WRITEMASK_3);
+ fetch = vkd3d_string_buffer_get(&gen->string_buffers);
+
+ vkd3d_string_buffer_printf(fetch, "texelFetch(");
+ shader_glsl_print_combined_sampler_name(fetch, gen, resource_idx,
+ resource_space, VKD3D_SHADER_DUMMY_SAMPLER_INDEX, 0);
+ vkd3d_string_buffer_printf(fetch, ", %s", coord.str->buffer);
+ if (resource_type != VKD3D_SHADER_RESOURCE_BUFFER)
+ vkd3d_string_buffer_printf(fetch, ", %s", lod.str->buffer);
+ vkd3d_string_buffer_printf(fetch, ")");
+ shader_glsl_print_swizzle(fetch, ins->src[1].swizzle, ins->dst[0].write_mask);
+
+ shader_glsl_print_assignment_ext(gen, &dst, data_type, "%s", fetch->buffer);
+
+ vkd3d_string_buffer_release(&gen->string_buffers, fetch);
+ glsl_src_cleanup(&lod, &gen->string_buffers);
+ glsl_src_cleanup(&coord, &gen->string_buffers);
+ glsl_dst_cleanup(&dst, &gen->string_buffers);
+}
+
+static void shader_glsl_sample(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
+{
+ const struct glsl_resource_type_info *resource_type_info;
+ unsigned int resource_id, resource_idx, resource_space;
+ unsigned int sampler_id, sampler_idx, sampler_space;
+ const struct vkd3d_shader_descriptor_info1 *d;
+ enum vkd3d_shader_component_type sampled_type;
+ enum vkd3d_shader_resource_type resource_type;
+ struct vkd3d_string_buffer *sample;
+ enum vkd3d_data_type data_type;
+ struct glsl_src coord;
+ struct glsl_dst dst;
+ uint32_t coord_mask;
+
+ if (vkd3d_shader_instruction_has_texel_offset(ins))
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Unhandled texel sample offset.");
+
+ if (ins->src[1].reg.idx[0].rel_addr || ins->src[1].reg.idx[1].rel_addr
+ || ins->src[2].reg.idx[0].rel_addr || ins->src[2].reg.idx[1].rel_addr)
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_UNSUPPORTED,
+ "Descriptor indexing is not supported.");
+
+ resource_id = ins->src[1].reg.idx[0].offset;
+ resource_idx = ins->src[1].reg.idx[1].offset;
+ if ((d = shader_glsl_get_descriptor_by_id(gen, VKD3D_SHADER_DESCRIPTOR_TYPE_SRV, resource_id)))
+ {
+ resource_type = d->resource_type;
+ resource_space = d->register_space;
+ sampled_type = vkd3d_component_type_from_resource_data_type(d->resource_data_type);
+ data_type = vkd3d_data_type_from_component_type(sampled_type);
+ }
+ else
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Undeclared resource descriptor %u.", resource_id);
+ resource_space = 0;
+ resource_type = VKD3D_SHADER_RESOURCE_TEXTURE_2D;
+ data_type = VKD3D_DATA_FLOAT;
+ }
+
+ if ((resource_type_info = shader_glsl_get_resource_type_info(resource_type)))
+ {
+ coord_mask = vkd3d_write_mask_from_component_count(resource_type_info->coord_size);
+ }
+ else
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Unhandled resource type %#x.", resource_type);
+ coord_mask = vkd3d_write_mask_from_component_count(2);
+ }
+
+ sampler_id = ins->src[2].reg.idx[0].offset;
+ sampler_idx = ins->src[2].reg.idx[1].offset;
+ if ((d = shader_glsl_get_descriptor_by_id(gen, VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, sampler_id)))
+ {
+ sampler_space = d->register_space;
+ }
+ else
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Undeclared sampler descriptor %u.", sampler_id);
+ sampler_space = 0;
+ }
+
+ glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
+ glsl_src_init(&coord, gen, &ins->src[0], coord_mask);
+ sample = vkd3d_string_buffer_get(&gen->string_buffers);
+
+ vkd3d_string_buffer_printf(sample, "texture(");
+ shader_glsl_print_combined_sampler_name(sample, gen, resource_idx, resource_space, sampler_idx, sampler_space);
+ vkd3d_string_buffer_printf(sample, ", %s)", coord.str->buffer);
+ shader_glsl_print_swizzle(sample, ins->src[1].swizzle, ins->dst[0].write_mask);
+
+ shader_glsl_print_assignment_ext(gen, &dst, data_type, "%s", sample->buffer);
+
+ vkd3d_string_buffer_release(&gen->string_buffers, sample);
+ glsl_src_cleanup(&coord, &gen->string_buffers);
+ glsl_dst_cleanup(&dst, &gen->string_buffers);
+}
+
static void shader_glsl_unary_op(struct vkd3d_glsl_generator *gen,
const struct vkd3d_shader_instruction *ins, const char *op)
{
@@ -617,6 +864,37 @@ static void shader_glsl_movc(struct vkd3d_glsl_generator *gen, const struct vkd3
glsl_dst_cleanup(&dst, &gen->string_buffers);
}
+static void shader_glsl_mul_extended(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
+{
+ struct glsl_src src[2];
+ struct glsl_dst dst;
+ uint32_t mask;
+
+ if (ins->dst[0].reg.type != VKD3DSPR_NULL)
+ {
+ /* FIXME: imulExtended()/umulExtended() from ARB_gpu_shader5/GLSL 4.00+. */
+ mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
+ shader_glsl_print_assignment(gen, &dst, "<unhandled 64-bit multiplication>");
+ glsl_dst_cleanup(&dst, &gen->string_buffers);
+
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Unhandled 64-bit integer multiplication.");
+ }
+
+ if (ins->dst[1].reg.type != VKD3DSPR_NULL)
+ {
+ mask = glsl_dst_init(&dst, gen, ins, &ins->dst[1]);
+ 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", src[0].str->buffer, 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_print_sysval_name(struct vkd3d_string_buffer *buffer, struct vkd3d_glsl_generator *gen,
enum vkd3d_shader_sysval_semantic sysval, unsigned int idx)
{
@@ -817,6 +1095,7 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
shader_glsl_cast(gen, ins, "uint", "uvec");
break;
case VKD3DSIH_GEO:
+ case VKD3DSIH_IGE:
shader_glsl_relop(gen, ins, ">=", "greaterThanEqual");
break;
case VKD3DSIH_IF:
@@ -825,6 +1104,13 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_MAD:
shader_glsl_intrinsic(gen, ins, "fma");
break;
+ case VKD3DSIH_ILT:
+ case VKD3DSIH_LTO:
+ shader_glsl_relop(gen, ins, "<", "lessThan");
+ break;
+ case VKD3DSIH_IMUL:
+ shader_glsl_mul_extended(gen, ins);
+ break;
case VKD3DSIH_ISHL:
shader_glsl_binop(gen, ins, "<<");
break;
@@ -832,9 +1118,6 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_USHR:
shader_glsl_binop(gen, ins, ">>");
break;
- case VKD3DSIH_LTO:
- shader_glsl_relop(gen, ins, "<", "lessThan");
- break;
case VKD3DSIH_MAX:
shader_glsl_intrinsic(gen, ins, "max");
break;
@@ -849,6 +1132,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_UTOF:
shader_glsl_cast(gen, ins, "float", "vec");
break;
+ case VKD3DSIH_LD:
+ shader_glsl_ld(gen, ins);
+ break;
case VKD3DSIH_LOG:
shader_glsl_intrinsic(gen, ins, "log2");
break;
@@ -885,6 +1171,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
case VKD3DSIH_RSQ:
shader_glsl_intrinsic(gen, ins, "inversesqrt");
break;
+ case VKD3DSIH_SAMPLE:
+ shader_glsl_sample(gen, ins);
+ break;
case VKD3DSIH_SQRT:
shader_glsl_intrinsic(gen, ins, "sqrt");
break;
@@ -1012,8 +1301,156 @@ static void shader_glsl_generate_cbv_declaration(struct vkd3d_glsl_generator *ge
binding->binding, prefix, cbv->register_id, prefix, cbv->register_id, size);
}
+static bool shader_glsl_get_combined_sampler_binding(const struct vkd3d_glsl_generator *gen,
+ const struct vkd3d_shader_combined_resource_sampler_info *crs,
+ enum vkd3d_shader_resource_type resource_type, unsigned int *binding_idx)
+{
+ const struct vkd3d_shader_interface_info *interface_info = gen->interface_info;
+ const struct vkd3d_shader_combined_resource_sampler *s;
+ enum vkd3d_shader_binding_flag resource_type_flag;
+ unsigned int i;
+
+ if (!interface_info)
+ return false;
+
+ resource_type_flag = resource_type == VKD3D_SHADER_RESOURCE_BUFFER
+ ? VKD3D_SHADER_BINDING_FLAG_BUFFER : VKD3D_SHADER_BINDING_FLAG_IMAGE;
+
+ for (i = 0; i < interface_info->combined_sampler_count; ++i)
+ {
+ s = &interface_info->combined_samplers[i];
+
+ if (s->resource_space != crs->resource_space)
+ continue;
+ if (s->resource_index != crs->resource_index)
+ continue;
+ if (crs->sampler_index != VKD3D_SHADER_DUMMY_SAMPLER_INDEX)
+ {
+ if (s->sampler_space != crs->sampler_space)
+ continue;
+ if (s->sampler_index != crs->sampler_index)
+ continue;
+ }
+ if (!shader_glsl_check_shader_visibility(gen, s->shader_visibility))
+ continue;
+ if (!(s->flags & resource_type_flag))
+ continue;
+ *binding_idx = i;
+ return true;
+ }
+
+ return false;
+}
+
+static void shader_glsl_generate_sampler_declaration(struct vkd3d_glsl_generator *gen,
+ const struct vkd3d_shader_combined_resource_sampler_info *crs)
+{
+ const struct vkd3d_shader_descriptor_info1 *sampler, *srv;
+ const struct glsl_resource_type_info *resource_type_info;
+ const struct vkd3d_shader_descriptor_binding *binding;
+ struct vkd3d_string_buffer *buffer = gen->buffer;
+ enum vkd3d_shader_component_type component_type;
+ const char *sampler_type, *sampler_type_prefix;
+ unsigned int binding_idx;
+ bool shadow = false;
+
+ if (crs->sampler_index != VKD3D_SHADER_DUMMY_SAMPLER_INDEX)
+ {
+ if (!(sampler = shader_glsl_get_descriptor(gen, VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER,
+ crs->sampler_index, crs->sampler_space)))
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: No descriptor found for sampler %u, space %u.",
+ crs->sampler_index, crs->sampler_space);
+ return;
+ }
+ shadow = sampler->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE;
+ }
+
+ if (!(srv = shader_glsl_get_descriptor(gen, VKD3D_SHADER_DESCRIPTOR_TYPE_SRV,
+ crs->resource_index, crs->resource_space)))
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: No descriptor found for resource %u, space %u.",
+ crs->resource_index, crs->resource_space);
+ return;
+ }
+
+ if ((resource_type_info = shader_glsl_get_resource_type_info(srv->resource_type)))
+ {
+ sampler_type = resource_type_info->sampler_type;
+ if (shadow && !resource_type_info->shadow)
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_UNSUPPORTED,
+ "Comparison samplers are not supported with resource type %#x.", srv->resource_type);
+ }
+ else
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Unhandled resource type %#x for combined resource/sampler "
+ "for resource %u, space %u and sampler %u, space %u.", srv->resource_type,
+ crs->resource_index, crs->resource_space, crs->sampler_index, crs->sampler_space);
+ sampler_type = "<unhandled sampler type>";
+ }
+
+ switch ((component_type = vkd3d_component_type_from_resource_data_type(srv->resource_data_type)))
+ {
+ case VKD3D_SHADER_COMPONENT_UINT:
+ sampler_type_prefix = "u";
+ break;
+ case VKD3D_SHADER_COMPONENT_INT:
+ sampler_type_prefix = "i";
+ break;
+ case VKD3D_SHADER_COMPONENT_FLOAT:
+ sampler_type_prefix = "";
+ break;
+ default:
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
+ "Internal compiler error: Unhandled component type %#x for combined resource/sampler "
+ "for resource %u, space %u and sampler %u, space %u.", component_type,
+ crs->resource_index, crs->resource_space, crs->sampler_index, crs->sampler_space);
+ sampler_type_prefix = "";
+ break;
+ }
+
+ if (!shader_glsl_get_combined_sampler_binding(gen, crs, srv->resource_type, &binding_idx))
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_BINDING_NOT_FOUND,
+ "No descriptor binding specified for combined resource/sampler "
+ "for resource %u, space %u and sampler %u, space %u.",
+ crs->resource_index, crs->resource_space, crs->sampler_index, crs->sampler_space);
+ return;
+ }
+
+ binding = &gen->interface_info->combined_samplers[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 combined resource/sampler "
+ "for resource %u, space %u and sampler %u, space %u.", binding->set,
+ crs->resource_index, crs->resource_space, crs->sampler_index, crs->sampler_space);
+ return;
+ }
+
+ if (binding->count != 1)
+ {
+ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_BINDING_NOT_FOUND,
+ "Unsupported binding count %u specified for combined resource/sampler "
+ "for resource %u, space %u and sampler %u, space %u.", binding->count,
+ crs->resource_index, crs->resource_space, crs->sampler_index, crs->sampler_space);
+ return;
+ }
+
+ vkd3d_string_buffer_printf(buffer, "layout(binding = %u) uniform %s%s%s ",
+ binding->binding, sampler_type_prefix, sampler_type, shadow ? "Shadow" : "");
+ shader_glsl_print_combined_sampler_name(buffer, gen, crs->resource_index,
+ crs->resource_space, crs->sampler_index, crs->sampler_space);
+ vkd3d_string_buffer_printf(buffer, ";\n");
+}
+
static void shader_glsl_generate_descriptor_declarations(struct vkd3d_glsl_generator *gen)
{
+ const struct vkd3d_shader_scan_combined_resource_sampler_info *sampler_info = gen->combined_sampler_info;
const struct vkd3d_shader_scan_descriptor_info1 *info = gen->descriptor_info;
const struct vkd3d_shader_descriptor_info1 *descriptor;
unsigned int i;
@@ -1024,6 +1461,11 @@ static void shader_glsl_generate_descriptor_declarations(struct vkd3d_glsl_gener
switch (descriptor->type)
{
+ case VKD3D_SHADER_DESCRIPTOR_TYPE_SRV:
+ case VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER:
+ /* GLSL uses combined resource/sampler descriptors.*/
+ break;
+
case VKD3D_SHADER_DESCRIPTOR_TYPE_CBV:
shader_glsl_generate_cbv_declaration(gen, descriptor);
break;
@@ -1035,6 +1477,10 @@ static void shader_glsl_generate_descriptor_declarations(struct vkd3d_glsl_gener
break;
}
}
+ for (i = 0; i < sampler_info->combined_sampler_count; ++i)
+ {
+ shader_glsl_generate_sampler_declaration(gen, &sampler_info->combined_samplers[i]);
+ }
if (info->descriptor_count)
vkd3d_string_buffer_printf(gen->buffer, "\n");
}
@@ -1259,6 +1705,7 @@ 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, const struct vkd3d_shader_compile_info *compile_info,
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
+ const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
struct vkd3d_shader_message_context *message_context)
{
enum vkd3d_shader_type type = program->shader_version.type;
@@ -1282,10 +1729,12 @@ static void vkd3d_glsl_generator_init(struct vkd3d_glsl_generator *gen,
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;
+ gen->combined_sampler_info = combined_sampler_info;
}
int glsl_compile(struct vsir_program *program, uint64_t config_flags,
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
+ const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
{
@@ -1295,7 +1744,8 @@ 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, compile_info, descriptor_info, message_context);
+ vkd3d_glsl_generator_init(&generator, program, compile_info,
+ descriptor_info, combined_sampler_info, message_context);
ret = vkd3d_glsl_generator_generate(&generator, out);
vkd3d_glsl_generator_cleanup(&generator);
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.c b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
index ce3dd91f04f..9ace1930c1b 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
@@ -4408,8 +4408,6 @@ static void hlsl_ctx_cleanup(struct hlsl_ctx *ctx)
struct hlsl_type *type, *next_type;
unsigned int i;
- hlsl_block_cleanup(&ctx->static_initializers);
-
for (i = 0; i < ctx->source_files_count; ++i)
vkd3d_free((void *)ctx->source_files[i]);
vkd3d_free(ctx->source_files);
@@ -4417,6 +4415,8 @@ static void hlsl_ctx_cleanup(struct hlsl_ctx *ctx)
rb_destroy(&ctx->functions, free_function_rb, NULL);
+ hlsl_block_cleanup(&ctx->static_initializers);
+
/* State blocks must be free before the variables, because they contain instructions that may
* refer to them. */
LIST_FOR_EACH_ENTRY_SAFE(scope, next_scope, &ctx->scopes, struct hlsl_scope, entry)
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.y b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
index b4d9f0988b0..ef37eb75f03 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
@@ -1972,6 +1972,12 @@ static struct hlsl_block *add_binary_expr_merge(struct hlsl_ctx *ctx, struct hls
hlsl_block_add_block(block1, block2);
destroy_block(block2);
+ if (arg1->data_type->class == HLSL_CLASS_ERROR || arg2->data_type->class == HLSL_CLASS_ERROR)
+ {
+ block1->value = ctx->error_instr;
+ return block1;
+ }
+
if (add_binary_expr(ctx, block1, op, arg1, arg2, loc) == NULL)
return NULL;
@@ -2085,6 +2091,12 @@ static bool add_assignment(struct hlsl_ctx *ctx, struct hlsl_block *block, struc
unsigned int writemask = 0, width = 0;
bool matrix_writemask = false;
+ if (lhs->data_type->class == HLSL_CLASS_ERROR || rhs->data_type->class == HLSL_CLASS_ERROR)
+ {
+ block->value = ctx->error_instr;
+ return true;
+ }
+
if (assign_op == ASSIGN_OP_SUB)
{
if (!(rhs = add_unary_arithmetic_expr(ctx, block, HLSL_OP1_NEG, rhs, &rhs->loc)))
@@ -5141,6 +5153,15 @@ static struct hlsl_block *add_call(struct hlsl_ctx *ctx, const char *name,
struct intrinsic_function *intrinsic;
struct hlsl_ir_function_decl *decl;
+ for (unsigned int i = 0; i < args->args_count; ++i)
+ {
+ if (args->args[i]->data_type->class == HLSL_CLASS_ERROR)
+ {
+ args->instrs->value = ctx->error_instr;
+ return args->instrs;
+ }
+ }
+
if ((decl = find_function_call(ctx, name, args, false, loc)))
{
if (!add_user_call(ctx, decl, args, false, loc))
@@ -6071,6 +6092,21 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct hlsl_block *block, stru
const struct hlsl_type *object_type = object->data_type;
const struct method_function *method;
+ if (object_type->class == HLSL_CLASS_ERROR)
+ {
+ block->value = ctx->error_instr;
+ return true;
+ }
+
+ for (unsigned int i = 0; i < params->args_count; ++i)
+ {
+ if (params->args[i]->data_type->class == HLSL_CLASS_ERROR)
+ {
+ block->value = ctx->error_instr;
+ return true;
+ }
+ }
+
if (object_type->class != HLSL_CLASS_TEXTURE || object_type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC)
{
struct vkd3d_string_buffer *string;
@@ -8682,7 +8718,11 @@ primary_expr:
else
{
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Identifier \"%s\" is not declared.", $1);
- YYABORT;
+ vkd3d_free($1);
+
+ if (!($$ = make_empty_block(ctx)))
+ YYABORT;
+ $$->value = ctx->error_instr;
}
}
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
index 2fe5472167f..6a74e2eb8de 100644
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
@@ -6186,6 +6186,18 @@ static void vsir_validate_register(struct validation_context *ctx,
if (reg->dimension == VSIR_DIMENSION_SCALAR)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION,
"Invalid dimension SCALAR for a SAMPLER register.");
+
+ if (reg->idx_count != 2)
+ {
+ validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
+ "Invalid index count %u for a SAMPLER register.",
+ reg->idx_count);
+ break;
+ }
+
+ if (reg->idx[0].rel_addr)
+ validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX,
+ "Non-NULL relative address for the descriptor index of a SAMPLER register.");
break;
case VKD3DSPR_RESOURCE:
@@ -6203,6 +6215,18 @@ static void vsir_validate_register(struct validation_context *ctx,
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION,
"Invalid dimension %#x for a RESOURCE register.",
reg->dimension);
+
+ if (reg->idx_count != 2)
+ {
+ validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
+ "Invalid index count %u for a RESOURCE register.",
+ reg->idx_count);
+ break;
+ }
+
+ if (reg->idx[0].rel_addr)
+ validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX,
+ "Non-NULL relative address for the descriptor index of a RESOURCE register.");
break;
case VKD3DSPR_UAV:
@@ -6221,6 +6245,18 @@ static void vsir_validate_register(struct validation_context *ctx,
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION,
"Invalid dimension %#x for a UAV register.",
reg->dimension);
+
+ if (reg->idx_count != 2)
+ {
+ validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
+ "Invalid index count %u for a UAV register.",
+ reg->idx_count);
+ break;
+ }
+
+ if (reg->idx[0].rel_addr)
+ validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX,
+ "Non-NULL relative address for the descriptor index of a UAV register.");
break;
case VKD3DSPR_DEPTHOUT:
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
index fc217860403..ee8a633431a 100644
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
@@ -1620,6 +1620,7 @@ int vsir_program_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)
{
+ struct vkd3d_shader_scan_combined_resource_sampler_info combined_sampler_info;
struct vkd3d_shader_scan_descriptor_info1 scan_descriptor_info;
struct vkd3d_shader_compile_info scan_info;
int ret;
@@ -1633,10 +1634,14 @@ int vsir_program_compile(struct vsir_program *program, uint64_t config_flags,
break;
case VKD3D_SHADER_TARGET_GLSL:
+ combined_sampler_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_COMBINED_RESOURCE_SAMPLER_INFO;
+ combined_sampler_info.next = scan_info.next;
+ scan_info.next = &combined_sampler_info;
if ((ret = vsir_program_scan(program, &scan_info, message_context, &scan_descriptor_info)) < 0)
return ret;
ret = glsl_compile(program, config_flags, &scan_descriptor_info,
- compile_info, out, message_context);
+ &combined_sampler_info, compile_info, out, message_context);
+ vkd3d_shader_free_scan_combined_resource_sampler_info(&combined_sampler_info);
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 d9d5b4a405e..eab164cc848 100644
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
@@ -173,6 +173,7 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_GLSL_INTERNAL = 6000,
VKD3D_SHADER_ERROR_GLSL_BINDING_NOT_FOUND = 6001,
+ VKD3D_SHADER_ERROR_GLSL_UNSUPPORTED = 6002,
VKD3D_SHADER_ERROR_D3DBC_UNEXPECTED_EOF = 7000,
VKD3D_SHADER_ERROR_D3DBC_INVALID_VERSION_TOKEN = 7001,
@@ -1599,6 +1600,7 @@ int shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
int glsl_compile(struct vsir_program *program, uint64_t config_flags,
const struct vkd3d_shader_scan_descriptor_info1 *descriptor_info,
+ const struct vkd3d_shader_scan_combined_resource_sampler_info *combined_sampler_info,
const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
--
2.45.2