diff --git a/patches/vkd3d-latest/0001-Updated-vkd3d-to-39391230d27d58f4e7e8786ba32a0ca133b.patch b/patches/vkd3d-latest/0001-Updated-vkd3d-to-39391230d27d58f4e7e8786ba32a0ca133b.patch index 2c458a5d..14b6924c 100644 --- a/patches/vkd3d-latest/0001-Updated-vkd3d-to-39391230d27d58f4e7e8786ba32a0ca133b.patch +++ b/patches/vkd3d-latest/0001-Updated-vkd3d-to-39391230d27d58f4e7e8786ba32a0ca133b.patch @@ -1,4 +1,4 @@ -From 9aac32c0e09bb62200f552d7971b932f12ef8f4c Mon Sep 17 00:00:00 2001 +From e3af0db8f4cb14ce0592fdbb9b3a2ec314daf7ef Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Mon, 26 May 2025 07:03:34 +1000 Subject: [PATCH] Updated vkd3d to 39391230d27d58f4e7e8786ba32a0ca133b28fc0. diff --git a/patches/vkd3d-latest/0002-Updated-vkd3d-to-74ebd4621f3177f45ce22512019ee968ec4.patch b/patches/vkd3d-latest/0002-Updated-vkd3d-to-74ebd4621f3177f45ce22512019ee968ec4.patch index fa786b1f..3799bcef 100644 --- a/patches/vkd3d-latest/0002-Updated-vkd3d-to-74ebd4621f3177f45ce22512019ee968ec4.patch +++ b/patches/vkd3d-latest/0002-Updated-vkd3d-to-74ebd4621f3177f45ce22512019ee968ec4.patch @@ -1,4 +1,4 @@ -From 1d274d4a0da9ef10f377394b92fd871904d4319f Mon Sep 17 00:00:00 2001 +From 82311f84ad8344655c3649f05d002092fb88df6b Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 5 Nov 2025 10:32:36 +1100 Subject: [PATCH] Updated vkd3d to 74ebd4621f3177f45ce22512019ee968ec400f4d. diff --git a/patches/vkd3d-latest/0003-Updated-vkd3d-to-1569bb3fb8c745d895ad555da1de5e6a2a8.patch b/patches/vkd3d-latest/0003-Updated-vkd3d-to-1569bb3fb8c745d895ad555da1de5e6a2a8.patch new file mode 100644 index 00000000..1b57e040 --- /dev/null +++ b/patches/vkd3d-latest/0003-Updated-vkd3d-to-1569bb3fb8c745d895ad555da1de5e6a2a8.patch @@ -0,0 +1,643 @@ +From 96fcc9490766c82944e09eb5d549386679236bd9 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Tue, 11 Nov 2025 08:00:39 +1100 +Subject: [PATCH] Updated vkd3d to 1569bb3fb8c745d895ad555da1de5e6a2a846218. + +--- + libs/vkd3d/libs/vkd3d-shader/fx.c | 2 +- + libs/vkd3d/libs/vkd3d-shader/hlsl.h | 5 +- + libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 189 ++++++++---------- + .../libs/vkd3d-shader/hlsl_constant_ops.c | 45 ++--- + libs/vkd3d/libs/vkd3d-shader/ir.c | 11 +- + 5 files changed, 115 insertions(+), 137 deletions(-) + +diff --git a/libs/vkd3d/libs/vkd3d-shader/fx.c b/libs/vkd3d/libs/vkd3d-shader/fx.c +index a14346a45d2..4848c531ced 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/fx.c ++++ b/libs/vkd3d/libs/vkd3d-shader/fx.c +@@ -1607,7 +1607,7 @@ static void write_fx_2_type_iter(const struct hlsl_type *type, const char *name, + } + + buffer = &fx->unstructured; +- offset = put_u32(buffer, hlsl_sm1_base_type(type, ctx->is_combined_sampler)); ++ offset = put_u32(buffer, hlsl_sm1_base_type(type, ctx->is_combined_sampler, HLSL_SAMPLER_DIM_GENERIC)); + put_u32(buffer, get_fx_2_type_class(type)); + *ctx->names++ = put_u32(buffer, 0); + *ctx->semantics++ = put_u32(buffer, 0); +diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h +index 87cfaf83f76..0202d71cc23 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h ++++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h +@@ -1844,18 +1844,19 @@ unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl + struct hlsl_reg hlsl_reg_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref); + + bool hlsl_copy_propagation_execute(struct hlsl_ctx *ctx, struct hlsl_block *block); ++struct hlsl_ir_node *hlsl_fold_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block); + struct hlsl_ir_node *hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, + struct hlsl_ir_node *instr, struct hlsl_block *block); + struct hlsl_ir_node *hlsl_fold_constant_identities(struct hlsl_ctx *ctx, + struct hlsl_ir_node *instr, struct hlsl_block *block); +-bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context); + struct hlsl_ir_node *hlsl_fold_constant_swizzles(struct hlsl_ctx *ctx, + struct hlsl_ir_node *instr, struct hlsl_block *block); + bool hlsl_transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *), + struct hlsl_block *block, void *context); + + D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type); +-D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type, bool is_combined_sampler); ++D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type, ++ bool is_combined_sampler, enum hlsl_sampler_dim sampler_dim); + + struct extern_resource + { +diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c +index 6fe29e5bfed..8bb23e0690d 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c ++++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c +@@ -938,7 +938,8 @@ static bool call_replace_func(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, + if ((replacement = func(ctx, instr, &block))) + { + list_move_before(&instr->entry, &block.instrs); +- hlsl_replace_node(instr, replacement); ++ if (replacement != instr) ++ hlsl_replace_node(instr, replacement); + return true; + } + else +@@ -955,7 +956,10 @@ static bool call_replace_func(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, + * + * New instructions should be added to "block", and the replacement instruction + * should be returned. If the instruction should be left alone, NULL should be +- * returned instead. */ ++ * returned instead. ++ * ++ * It is legal to return the same instruction from the replace function, in ++ * which case replace_ir() returns true but hlsl_replace_node() is skipped. */ + static bool replace_ir(struct hlsl_ctx *ctx, PFN_replace_func func, struct hlsl_block *block) + { + return hlsl_transform_ir(ctx, call_replace_func, block, func); +@@ -4095,7 +4099,6 @@ static bool lower_conditional_block_stores(struct hlsl_ctx *ctx, struct hlsl_ir_ + static bool lower_conditional_block_discard_nz(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, + struct hlsl_ir_node *cond, bool is_then) + { +- struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0}; + struct hlsl_ir_node *discard_cond, *new_cond = NULL; + struct hlsl_ir_jump *jump; + struct hlsl_block block; +@@ -4118,12 +4121,8 @@ static bool lower_conditional_block_discard_nz(struct hlsl_ctx *ctx, struct hlsl + cond = hlsl_block_add_unary_expr(ctx, &block, HLSL_OP1_LOGIC_NOT, cond, &instr->loc); + discard_cond = hlsl_block_add_cast(ctx, &block, discard_cond, cond->data_type, &instr->loc); + +- operands[0] = cond; +- operands[1] = discard_cond; +- + /* discard_nz (cond && discard_cond) */ +- new_cond = hlsl_block_add_expr(ctx, &block, HLSL_OP2_LOGIC_AND, operands, +- hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), &jump->node.loc); ++ new_cond = hlsl_block_add_binary_expr(ctx, &block, HLSL_OP2_LOGIC_AND, cond, discard_cond); + + list_move_before(&jump->node.entry, &block.instrs); + hlsl_src_remove(&jump->condition); +@@ -5250,49 +5249,37 @@ static struct hlsl_ir_node *lower_ternary(struct hlsl_ctx *ctx, struct hlsl_ir_n + return hlsl_block_add_expr(ctx, block, HLSL_OP3_CMP, operands, first->data_type, &instr->loc); + } + +-static bool lower_resource_load_bias(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) ++static struct hlsl_ir_node *lower_resource_load_bias(struct hlsl_ctx *ctx, ++ struct hlsl_ir_node *instr, struct hlsl_block *block) + { +- struct hlsl_ir_node *swizzle, *store; ++ struct hlsl_ir_node *swizzle, *tmp_load; + struct hlsl_ir_resource_load *load; +- struct hlsl_ir_load *tmp_load; + struct hlsl_ir_var *tmp_var; +- struct hlsl_deref deref; + + if (instr->type != HLSL_IR_RESOURCE_LOAD) +- return false; ++ return NULL; + load = hlsl_ir_resource_load(instr); + if (load->load_type != HLSL_RESOURCE_SAMPLE_LOD + && load->load_type != HLSL_RESOURCE_SAMPLE_LOD_BIAS) +- return false; ++ return NULL; + + if (!load->lod.node) +- return false; ++ return NULL; + + if (!(tmp_var = hlsl_new_synthetic_var(ctx, "coords-with-lod", + hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, 4), &instr->loc))) +- return false; +- +- if (!(swizzle = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, X, X, X), 4, load->lod.node, &load->lod.node->loc))) +- return false; +- list_add_before(&instr->entry, &swizzle->entry); +- +- if (!(store = hlsl_new_simple_store(ctx, tmp_var, swizzle))) +- return false; +- list_add_before(&instr->entry, &store->entry); ++ return NULL; + +- hlsl_init_simple_deref_from_var(&deref, tmp_var); +- if (!(store = hlsl_new_store_index(ctx, &deref, NULL, load->coords.node, 0, &instr->loc))) +- return false; +- list_add_before(&instr->entry, &store->entry); ++ swizzle = hlsl_block_add_swizzle(ctx, block, HLSL_SWIZZLE(X, X, X, X), 4, load->lod.node, &load->lod.node->loc); ++ hlsl_block_add_simple_store(ctx, block, tmp_var, swizzle); ++ hlsl_block_add_simple_store(ctx, block, tmp_var, load->coords.node); + +- if (!(tmp_load = hlsl_new_var_load(ctx, tmp_var, &instr->loc))) +- return false; +- list_add_before(&instr->entry, &tmp_load->node.entry); ++ tmp_load = hlsl_block_add_simple_load(ctx, block, tmp_var, &instr->loc); + + hlsl_src_remove(&load->coords); +- hlsl_src_from_node(&load->coords, &tmp_load->node); ++ hlsl_src_from_node(&load->coords, tmp_load); + hlsl_src_remove(&load->lod); +- return true; ++ return &load->node; + } + + static struct hlsl_ir_node *lower_comparison_operators(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, +@@ -5746,34 +5733,29 @@ static bool lower_discard_neg(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, + return true; + } + +-static bool lower_discard_nz(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) ++static struct hlsl_ir_node *lower_discard_nz(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block) + { + struct hlsl_ir_node *cond, *cond_cast, *abs, *neg; + struct hlsl_type *float_type; + struct hlsl_ir_jump *jump; +- struct hlsl_block block; + + if (instr->type != HLSL_IR_JUMP) +- return false; ++ return NULL; + jump = hlsl_ir_jump(instr); + if (jump->type != HLSL_IR_JUMP_DISCARD_NZ) +- return false; ++ return NULL; + + cond = jump->condition.node; + float_type = hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, cond->data_type->e.numeric.dimx); + +- hlsl_block_init(&block); +- +- cond_cast = hlsl_block_add_cast(ctx, &block, cond, float_type, &instr->loc); +- abs = hlsl_block_add_unary_expr(ctx, &block, HLSL_OP1_ABS, cond_cast, &instr->loc); +- neg = hlsl_block_add_unary_expr(ctx, &block, HLSL_OP1_NEG, abs, &instr->loc); ++ cond_cast = hlsl_block_add_cast(ctx, block, cond, float_type, &instr->loc); ++ abs = hlsl_block_add_unary_expr(ctx, block, HLSL_OP1_ABS, cond_cast, &instr->loc); ++ neg = hlsl_block_add_unary_expr(ctx, block, HLSL_OP1_NEG, abs, &instr->loc); + +- list_move_tail(&instr->entry, &block.instrs); + hlsl_src_remove(&jump->condition); + hlsl_src_from_node(&jump->condition, neg); + jump->type = HLSL_IR_JUMP_DISCARD_NEG; +- +- return true; ++ return &jump->node; + } + + static bool cast_discard_neg_conditions_to_vec4(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +@@ -8551,96 +8533,74 @@ static enum hlsl_ir_expr_op invert_comparison_op(enum hlsl_ir_expr_op op) + } + } + +-static bool fold_unary_identities(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) ++static struct hlsl_ir_node *fold_unary_identities(struct hlsl_ctx *ctx, ++ struct hlsl_ir_node *instr, struct hlsl_block *block) + { +- struct hlsl_ir_node *res = NULL; + struct hlsl_ir_expr *expr, *x; + + if (instr->type != HLSL_IR_EXPR) +- return false; ++ return NULL; + + if (instr->data_type->class > HLSL_CLASS_VECTOR) +- return false; ++ return NULL; + + expr = hlsl_ir_expr(instr); + if (!expr->operands[0].node) +- return false; ++ return NULL; + + if (expr->operands[0].node->type != HLSL_IR_EXPR) +- return false; ++ return NULL; + x = hlsl_ir_expr(expr->operands[0].node); + + switch (expr->op) + { + case HLSL_OP1_ABS: ++ /* ||x|| -> |x| */ + if (x->op == HLSL_OP1_ABS) +- { +- /* ||x|| -> |x| */ +- hlsl_replace_node(instr, &x->node); +- return true; +- } ++ return &x->node; + ++ /* |-x| -> |x| */ + if (x->op == HLSL_OP1_NEG) + { +- /* |-x| -> |x| */ + hlsl_src_remove(&expr->operands[0]); + hlsl_src_from_node(&expr->operands[0], x->operands[0].node); +- return true; ++ return &expr->node; + } + break; + + case HLSL_OP1_BIT_NOT: ++ /* ~(~x) -> x */ + if (x->op == HLSL_OP1_BIT_NOT) +- { +- /* ~(~x) -> x */ +- hlsl_replace_node(instr, x->operands[0].node); +- return true; +- } ++ return x->operands[0].node; + break; + + case HLSL_OP1_CEIL: + case HLSL_OP1_FLOOR: ++ /* f(g(x)) -> g(x), where f(), g() are floor() or ceil() functions. */ + if (x->op == HLSL_OP1_CEIL || x->op == HLSL_OP1_FLOOR) +- { +- /* f(g(x)) -> g(x), where f(), g() are floor() or ceil() functions. */ +- hlsl_replace_node(instr, &x->node); +- return true; +- } ++ return &x->node; + break; + + case HLSL_OP1_NEG: ++ /* -(-x) -> x */ + if (x->op == HLSL_OP1_NEG) +- { +- /* -(-x) -> x */ +- hlsl_replace_node(instr, x->operands[0].node); +- return true; +- } ++ return x->operands[0].node; + break; + + case HLSL_OP1_LOGIC_NOT: ++ /* !!x -> x */ + if (x->op == HLSL_OP1_LOGIC_NOT) +- { +- /* !!x -> x */ +- hlsl_replace_node(instr, x->operands[0].node); +- return true; +- } ++ return x->operands[0].node; + + if (hlsl_is_comparison_op(x->op) + && hlsl_base_type_is_integer(x->operands[0].node->data_type->e.numeric.type) + && hlsl_base_type_is_integer(x->operands[1].node->data_type->e.numeric.type)) + { + struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {x->operands[0].node, x->operands[1].node}; +- struct hlsl_block block; +- +- hlsl_block_init(&block); + + /* !(x == y) -> x != y, !(x < y) -> x >= y, etc. */ +- res = hlsl_block_add_expr(ctx, &block, invert_comparison_op(x->op), ++ return hlsl_block_add_expr(ctx, block, invert_comparison_op(x->op), + operands, instr->data_type, &instr->loc); +- +- list_move_before(&instr->entry, &block.instrs); +- hlsl_replace_node(instr, res); +- return true; + } + + break; +@@ -8649,7 +8609,7 @@ static bool fold_unary_identities(struct hlsl_ctx *ctx, struct hlsl_ir_node *ins + break; + } + +- return false; ++ return NULL; + } + + static bool nodes_are_equivalent(const struct hlsl_ir_node *c1, const struct hlsl_ir_node *c2) +@@ -8784,8 +8744,8 @@ static bool simplify_exprs(struct hlsl_ctx *ctx, struct hlsl_block *block) + do + { + progress = replace_ir(ctx, hlsl_fold_constant_exprs, block); +- progress |= hlsl_transform_ir(ctx, hlsl_normalize_binary_exprs, block, NULL); +- progress |= hlsl_transform_ir(ctx, fold_unary_identities, block, NULL); ++ progress |= replace_ir(ctx, hlsl_fold_binary_exprs, block); ++ progress |= replace_ir(ctx, fold_unary_identities, block); + progress |= replace_ir(ctx, fold_conditional_identities, block); + progress |= replace_ir(ctx, hlsl_fold_constant_identities, block); + progress |= replace_ir(ctx, hlsl_fold_constant_swizzles, block); +@@ -10053,7 +10013,7 @@ static void sm1_generate_vsir_init_dst_param_from_deref(struct hlsl_ctx *ctx, + else + writemask = (1u << deref->var->data_type->e.numeric.dimx) - 1; + +- if (version.type == VKD3D_SHADER_TYPE_PIXEL && (!ascii_strcasecmp(semantic_name, "PSIZE") ++ if (version.type == VKD3D_SHADER_TYPE_VERTEX && (!ascii_strcasecmp(semantic_name, "PSIZE") + || (!ascii_strcasecmp(semantic_name, "FOG") && version.major < 3))) + { + /* These are always 1-component, but for some reason are written +@@ -10525,7 +10485,8 @@ D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type) + vkd3d_unreachable(); + } + +-D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type, bool is_combined_sampler) ++D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type, ++ bool is_combined_sampler, enum hlsl_sampler_dim sampler_dim) + { + enum hlsl_type_class class = type->class; + +@@ -10564,7 +10525,7 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type, bool is_comb + break; + + case HLSL_CLASS_SAMPLER: +- switch (type->sampler_dim) ++ switch (sampler_dim) + { + case HLSL_SAMPLER_DIM_1D: + return D3DXPT_SAMPLER1D; +@@ -10602,7 +10563,7 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type, bool is_comb + break; + + case HLSL_CLASS_ARRAY: +- return hlsl_sm1_base_type(type->e.array.type, is_combined_sampler); ++ return hlsl_sm1_base_type(type->e.array.type, is_combined_sampler, sampler_dim); + + case HLSL_CLASS_STRUCT: + return D3DXPT_VOID; +@@ -10640,15 +10601,19 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type, bool is_comb + vkd3d_unreachable(); + } + +-static void write_sm1_type(struct vkd3d_bytecode_buffer *buffer, +- struct hlsl_type *type, bool is_combined_sampler, unsigned int ctab_start) ++static void write_sm1_type(struct vkd3d_bytecode_buffer *buffer, struct hlsl_type *type, ++ bool is_combined_sampler, enum hlsl_sampler_dim sampler_dim, unsigned int ctab_start) + { + const struct hlsl_type *array_type = hlsl_get_multiarray_element_type(type); + unsigned int array_size = hlsl_get_multiarray_size(type); + struct hlsl_struct_field *field; + size_t i; + +- if (type->bytecode_offset) ++ /* Native deduplicates types, but emits the correct dimension for generic ++ * samplers. Apparently it deals with this by never deduplicating any ++ * sampler types. This is not very efficient, but we may as well do the ++ * same. */ ++ if (type->bytecode_offset && array_type->class != HLSL_CLASS_SAMPLER) + return; + + if (array_type->class == HLSL_CLASS_STRUCT) +@@ -10660,7 +10625,7 @@ static void write_sm1_type(struct vkd3d_bytecode_buffer *buffer, + { + field = &array_type->e.record.fields[i]; + field->name_bytecode_offset = put_string(buffer, field->name); +- write_sm1_type(buffer, field->type, false, ctab_start); ++ write_sm1_type(buffer, field->type, false, HLSL_SAMPLER_DIM_GENERIC, ctab_start); + } + + fields_offset = bytecode_align(buffer) - ctab_start; +@@ -10680,9 +10645,11 @@ static void write_sm1_type(struct vkd3d_bytecode_buffer *buffer, + else + { + type->bytecode_offset = put_u32(buffer, +- vkd3d_make_u32(hlsl_sm1_class(type), hlsl_sm1_base_type(array_type, is_combined_sampler))); ++ vkd3d_make_u32(hlsl_sm1_class(type), hlsl_sm1_base_type(array_type, is_combined_sampler, sampler_dim))); + if (hlsl_is_numeric_type(array_type)) + put_u32(buffer, vkd3d_make_u32(array_type->e.numeric.dimy, array_type->e.numeric.dimx)); ++ else if (is_combined_sampler) ++ put_u32(buffer, vkd3d_make_u32(1, 4)); + else + put_u32(buffer, vkd3d_make_u32(1, 1)); + put_u32(buffer, vkd3d_make_u32(array_size, 0)); +@@ -10736,7 +10703,9 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe + + ++uniform_count; + +- if (var->is_param && var->is_uniform) ++ /* Not var->is_uniform. The $ prefix is only added if the variable ++ * is actually declared with a 'uniform' modifier. */ ++ if (var->is_param && (var->storage_modifiers & HLSL_STORAGE_UNIFORM)) + { + char *new_name; + +@@ -10793,17 +10762,33 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe + { + for (r = 0; r <= HLSL_REGSET_LAST; ++r) + { ++ enum hlsl_sampler_dim sampler_dim = HLSL_SAMPLER_DIM_GENERIC; + size_t var_offset, name_offset; + + if (var->semantic.name || !var->regs[r].allocated || !var->last_read) + continue; + ++ /* Arrays can be used with multiple different dimensions. ++ * The dimension written into the CTAB is the dimension of the ++ * first usage, which is not really that sensible... */ ++ if (r == HLSL_REGSET_SAMPLERS) ++ { ++ for (unsigned int i = 0; i < var->bind_count[r]; ++i) ++ { ++ if (var->objects_usage[r][i].sampler_dim != HLSL_SAMPLER_DIM_GENERIC) ++ { ++ sampler_dim = var->objects_usage[r][i].sampler_dim; ++ break; ++ } ++ } ++ } ++ + var_offset = vars_start + (uniform_count * 5 * sizeof(uint32_t)); + + name_offset = put_string(buffer, var->name); + set_u32(buffer, var_offset, name_offset - ctab_start); + +- write_sm1_type(buffer, var->data_type, var->is_combined_sampler, ctab_start); ++ write_sm1_type(buffer, var->data_type, var->is_combined_sampler, sampler_dim, ctab_start); + set_u32(buffer, var_offset + 3 * sizeof(uint32_t), var->data_type->bytecode_offset - ctab_start); + + if (var->default_values) +@@ -15101,8 +15086,8 @@ static void process_entry_function(struct hlsl_ctx *ctx, struct list *semantic_v + } + else + { +- hlsl_transform_ir(ctx, lower_discard_nz, body, NULL); +- hlsl_transform_ir(ctx, lower_resource_load_bias, body, NULL); ++ replace_ir(ctx, lower_discard_nz, body); ++ replace_ir(ctx, lower_resource_load_bias, body); + } + + compute_liveness(ctx, body); +diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_constant_ops.c +index 1c44e5fa37a..627418165bc 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_constant_ops.c ++++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_constant_ops.c +@@ -1818,26 +1818,23 @@ static struct hlsl_ir_node *collect_exprs(struct hlsl_ctx *ctx, struct hlsl_bloc + return hlsl_block_add_expr(ctx, block, opl, operands, instr->data_type, &instr->loc); + } + +-bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) ++struct hlsl_ir_node *hlsl_fold_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block) + { + struct hlsl_ir_node *arg1, *arg2, *tmp; + struct hlsl_ir_expr *expr; + enum hlsl_base_type type; + enum hlsl_ir_expr_op op; +- struct hlsl_block block; + bool progress = false; + + if (instr->type != HLSL_IR_EXPR) +- return false; ++ return NULL; + expr = hlsl_ir_expr(instr); + + if (instr->data_type->class > HLSL_CLASS_VECTOR) +- return false; ++ return NULL; + + if (expr->operands[2].node) +- return false; +- +- hlsl_block_init(&block); ++ return NULL; + + arg1 = expr->operands[0].node; + arg2 = expr->operands[1].node; +@@ -1845,15 +1842,11 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst + op = expr->op; + + if (!arg1 || !arg2) +- return false; ++ return NULL; + +- if ((tmp = collect_exprs(ctx, &block, instr, op, arg1, arg2))) +- { +- /* (x OPL a) OPR (x OPL b) -> x OPL (a OPR b) */ +- list_move_before(&instr->entry, &block.instrs); +- hlsl_replace_node(instr, tmp); +- return true; +- } ++ /* (x OPL a) OPR (x OPL b) -> x OPL (a OPR b) */ ++ if ((tmp = collect_exprs(ctx, block, instr, op, arg1, arg2))) ++ return tmp; + + if (is_op_commutative(op) && arg1->type == HLSL_IR_CONSTANT && arg2->type != HLSL_IR_CONSTANT) + { +@@ -1876,13 +1869,13 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst + { + /* (x OP a) OP b -> x OP (a OP b) */ + arg1 = e1->operands[0].node; +- arg2 = hlsl_block_add_binary_expr(ctx, &block, op, e1->operands[1].node, arg2); ++ arg2 = hlsl_block_add_binary_expr(ctx, block, op, e1->operands[1].node, arg2); + progress = true; + } + else if (is_op_commutative(op)) + { + /* (x OP a) OP y -> (x OP y) OP a */ +- arg1 = hlsl_block_add_binary_expr(ctx, &block, op, e1->operands[0].node, arg2); ++ arg1 = hlsl_block_add_binary_expr(ctx, block, op, e1->operands[0].node, arg2); + arg2 = e1->operands[1].node; + progress = true; + } +@@ -1892,13 +1885,13 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst + && e2->operands[0].node->type != HLSL_IR_CONSTANT && e2->operands[1].node->type == HLSL_IR_CONSTANT) + { + /* x OP (y OP a) -> (x OP y) OP a */ +- arg1 = hlsl_block_add_binary_expr(ctx, &block, op, arg1, e2->operands[0].node); ++ arg1 = hlsl_block_add_binary_expr(ctx, block, op, arg1, e2->operands[0].node); + arg2 = e2->operands[1].node; + progress = true; + } + + if (!progress && e1 && e1->op == op +- && (tmp = collect_exprs(ctx, &block, instr, op, e1->operands[1].node, arg2))) ++ && (tmp = collect_exprs(ctx, block, instr, op, e1->operands[1].node, arg2))) + { + /* (y OPR (x OPL a)) OPR (x OPL b) -> y OPR (x OPL (a OPR b)) */ + arg1 = e1->operands[0].node; +@@ -1907,7 +1900,7 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst + } + + if (!progress && is_op_commutative(op) && e1 && e1->op == op +- && (tmp = collect_exprs(ctx, &block, instr, op, e1->operands[0].node, arg2))) ++ && (tmp = collect_exprs(ctx, block, instr, op, e1->operands[0].node, arg2))) + { + /* ((x OPL a) OPR y) OPR (x OPL b) -> (x OPL (a OPR b)) OPR y */ + arg1 = tmp; +@@ -1916,7 +1909,7 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst + } + + if (!progress && e2 && e2->op == op +- && (tmp = collect_exprs(ctx, &block, instr, op, arg1, e2->operands[0].node))) ++ && (tmp = collect_exprs(ctx, block, instr, op, arg1, e2->operands[0].node))) + { + /* (x OPL a) OPR ((x OPL b) OPR y) -> (x OPL (a OPR b)) OPR y */ + arg1 = tmp; +@@ -1925,7 +1918,7 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst + } + + if (!progress && is_op_commutative(op) && e2 && e2->op == op +- && (tmp = collect_exprs(ctx, &block, instr, op, arg1, e2->operands[1].node))) ++ && (tmp = collect_exprs(ctx, block, instr, op, arg1, e2->operands[1].node))) + { + /* (x OPL a) OPR (y OPR (x OPL b)) -> (x OPL (a OPR b)) OPR y */ + arg1 = tmp; +@@ -1937,15 +1930,11 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst + if (progress) + { + struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {arg1, arg2}; +- struct hlsl_ir_node *res; +- +- res = hlsl_block_add_expr(ctx, &block, op, operands, instr->data_type, &instr->loc); + +- list_move_before(&instr->entry, &block.instrs); +- hlsl_replace_node(instr, res); ++ return hlsl_block_add_expr(ctx, block, op, operands, instr->data_type, &instr->loc); + } + +- return progress; ++ return NULL; + } + + struct hlsl_ir_node *hlsl_fold_constant_swizzles(struct hlsl_ctx *ctx, +diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c +index 5b1d0449a64..6a1c5303eb4 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/ir.c ++++ b/libs/vkd3d/libs/vkd3d-shader/ir.c +@@ -3846,16 +3846,19 @@ static bool shader_dst_param_io_normalise(struct vkd3d_shader_dst_param *dst_par + break; + + case VKD3DSPR_RASTOUT: ++ /* Fog and point size are scalar, but fxc/d3dcompiler emits a full ++ * write mask when writing to them. */ ++ if (reg->idx[0].offset > 0) ++ { ++ write_mask = VKD3DSP_WRITEMASK_0; ++ dst_param->write_mask = write_mask; ++ } + /* Leave point size as a system value for the backends to consume. */ + if (reg->idx[0].offset == VSIR_RASTOUT_POINT_SIZE) + return true; + reg_idx = SM1_RASTOUT_REGISTER_OFFSET + reg->idx[0].offset; + signature = normaliser->output_signature; + reg->type = VKD3DSPR_OUTPUT; +- /* Fog and point size are scalar, but fxc/d3dcompiler emits a full +- * write mask when writing to them. */ +- if (reg->idx[0].offset > 0) +- write_mask = VKD3DSP_WRITEMASK_0; + break; + + default: +-- +2.51.0 + diff --git a/patches/vkd3d-latest/0004-Updated-vkd3d-to-7f377879fc526dfb69966ed1672d3036e80.patch b/patches/vkd3d-latest/0004-Updated-vkd3d-to-7f377879fc526dfb69966ed1672d3036e80.patch new file mode 100644 index 00000000..5357b663 --- /dev/null +++ b/patches/vkd3d-latest/0004-Updated-vkd3d-to-7f377879fc526dfb69966ed1672d3036e80.patch @@ -0,0 +1,338 @@ +From 1c19b515adc2181cff5be945b742fbd357330bbe Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Fri, 14 Nov 2025 08:07:32 +1100 +Subject: [PATCH] Updated vkd3d to 7f377879fc526dfb69966ed1672d3036e807235c. + +--- + libs/vkd3d/include/private/vkd3d_common.h | 20 +++++++----- + libs/vkd3d/libs/vkd3d-common/debug.c | 9 +++--- + libs/vkd3d/libs/vkd3d-shader/d3d_asm.c | 31 ++++++++++++++++++- + libs/vkd3d/libs/vkd3d-shader/dxil.c | 13 +++++--- + libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 8 +++-- + libs/vkd3d/libs/vkd3d-shader/spirv.c | 13 +++++--- + .../libs/vkd3d-shader/vkd3d_shader_main.c | 4 +-- + .../libs/vkd3d-shader/vkd3d_shader_private.h | 1 + + .../vkd3d/libs/vkd3d-utils/vkd3d_utils_main.c | 2 -- + libs/vkd3d/libs/vkd3d/vkd3d_main.c | 2 -- + 10 files changed, 71 insertions(+), 32 deletions(-) + +diff --git a/libs/vkd3d/include/private/vkd3d_common.h b/libs/vkd3d/include/private/vkd3d_common.h +index c2e957a2fea..56f8ad4ee25 100644 +--- a/libs/vkd3d/include/private/vkd3d_common.h ++++ b/libs/vkd3d/include/private/vkd3d_common.h +@@ -19,6 +19,11 @@ + #ifndef __VKD3D_COMMON_H + #define __VKD3D_COMMON_H + ++#ifndef VKD3D_DEBUG_ENV ++#define VKD3D_DEBUG_ENV VKD3D_DEBUG ++#endif ++#define VKD3D_DEBUG_ENV_NAME VKD3D_EXPAND_AND_STRINGIFY(VKD3D_DEBUG_ENV) ++ + #include "config.h" + #define WIN32_LEAN_AND_MEAN + #include "windows.h" +@@ -149,9 +154,10 @@ enum vkd3d_dbg_level + VKD3D_DBG_LEVEL_TRACE, + }; + +-enum vkd3d_dbg_level vkd3d_dbg_get_level(void); ++enum vkd3d_dbg_level vkd3d_dbg_get_level(const char *vkd3d_dbg_env_name); + +-void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4); ++void vkd3d_dbg_printf(const char *vkd3d_dbg_env_name, enum vkd3d_dbg_level level, ++ const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5); + void vkd3d_dbg_set_log_callback(PFN_vkd3d_log callback); + + const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2); +@@ -174,7 +180,7 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size); + VKD3D_DBG_PRINTF_##level + + #define VKD3D_DBG_PRINTF(...) \ +- vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0) ++ vkd3d_dbg_printf(VKD3D_DEBUG_ENV_NAME, vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0) + + #define VKD3D_DBG_PRINTF_TRACE(...) VKD3D_DBG_PRINTF(__VA_ARGS__) + #define VKD3D_DBG_PRINTF_WARN(...) VKD3D_DBG_PRINTF(__VA_ARGS__) +@@ -183,7 +189,7 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size); + + #ifdef VKD3D_ABORT_ON_ERR + #define VKD3D_DBG_PRINTF_ERR(...) \ +- vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); \ ++ vkd3d_dbg_printf(VKD3D_DEBUG_ENV_NAME, vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); \ + abort(); \ + } while (0) + #else +@@ -217,19 +223,17 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size); + #endif + + #ifndef TRACE_ON +-#define TRACE_ON() (vkd3d_dbg_get_level() == VKD3D_DBG_LEVEL_TRACE) ++#define TRACE_ON() (vkd3d_dbg_get_level(VKD3D_DEBUG_ENV_NAME) == VKD3D_DBG_LEVEL_TRACE) + #endif + + #ifndef WARN_ON +-#define WARN_ON() (vkd3d_dbg_get_level() >= VKD3D_DBG_LEVEL_WARN) ++#define WARN_ON() (vkd3d_dbg_get_level(VKD3D_DEBUG_ENV_NAME) >= VKD3D_DBG_LEVEL_WARN) + #endif + + #ifndef FIXME_ONCE + #define FIXME_ONCE VKD3D_DBG_LOG_ONCE(FIXME, WARN) + #endif + +-#define VKD3D_DEBUG_ENV_NAME(name) const char *const vkd3d_dbg_env_name = name +- + static inline const char *debugstr_guid(const GUID *guid) + { + if (!guid) +diff --git a/libs/vkd3d/libs/vkd3d-common/debug.c b/libs/vkd3d/libs/vkd3d-common/debug.c +index 32862024b90..b5d74ca3dc7 100644 +--- a/libs/vkd3d/libs/vkd3d-common/debug.c ++++ b/libs/vkd3d/libs/vkd3d-common/debug.c +@@ -40,8 +40,6 @@ + #define VKD3D_DEBUG_BUFFER_COUNT 64 + #define VKD3D_DEBUG_BUFFER_SIZE 512 + +-extern const char *const vkd3d_dbg_env_name; +- + static const char *const debug_level_names[] = + { + [VKD3D_DBG_LEVEL_NONE ] = "none", +@@ -52,7 +50,7 @@ static const char *const debug_level_names[] = + [VKD3D_DBG_LEVEL_TRACE] = "trace", + }; + +-enum vkd3d_dbg_level vkd3d_dbg_get_level(void) ++enum vkd3d_dbg_level vkd3d_dbg_get_level(const char *vkd3d_dbg_env_name) + { + static unsigned int level = ~0u; + const char *vkd3d_debug; +@@ -108,11 +106,12 @@ static uint64_t get_pthread_threadid(void) + } + #endif + +-void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) ++void vkd3d_dbg_printf(const char *vkd3d_dbg_env_name, ++ enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) + { + va_list args; + +- if (vkd3d_dbg_get_level() < level) ++ if (vkd3d_dbg_get_level(vkd3d_dbg_env_name) < level) + return; + + #ifdef _WIN32 +diff --git a/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c +index 4573cb67fb5..b316f6c8830 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c ++++ b/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c +@@ -398,12 +398,41 @@ static void shader_dump_resource_data_type(struct vkd3d_d3d_asm_compiler *compil + { + int i; + ++ /* We want the D3D names here, not the vsir ones. */ ++ static const char * const names[] = ++ { ++ [VSIR_DATA_BOOL ] = "bool", ++ [VSIR_DATA_F16 ] = "half", ++ [VSIR_DATA_F32 ] = "float", ++ [VSIR_DATA_F64 ] = "double", ++ [VSIR_DATA_I8 ] = "int8", ++ [VSIR_DATA_I16 ] = "int16", ++ [VSIR_DATA_I32 ] = "int", ++ [VSIR_DATA_I64 ] = "int64", ++ [VSIR_DATA_U8 ] = "uint8", ++ [VSIR_DATA_U16 ] = "uint16", ++ [VSIR_DATA_U32 ] = "uint", ++ [VSIR_DATA_U64 ] = "uint64", ++ [VSIR_DATA_SNORM ] = "snorm", ++ [VSIR_DATA_UNORM ] = "unorm", ++ [VSIR_DATA_OPAQUE ] = "opaque", ++ [VSIR_DATA_MIXED ] = "mixed", ++ [VSIR_DATA_CONTINUED] = "", ++ [VSIR_DATA_UNUSED ] = "", ++ }; ++ + vkd3d_string_buffer_printf(&compiler->buffer, "("); + + for (i = 0; i < 4; i++) + { ++ size_t t = type[i]; ++ + vkd3d_string_buffer_printf(&compiler->buffer, "%s", i == 0 ? "" : ","); +- shader_print_data_type(compiler, type[i]); ++ if (t < ARRAY_SIZE(names) && names[t]) ++ vkd3d_string_buffer_printf(&compiler->buffer, "%s", names[t]); ++ else ++ vkd3d_string_buffer_printf(&compiler->buffer, "%s%s", ++ compiler->colours.error, t, compiler->colours.reset); + } + + vkd3d_string_buffer_printf(&compiler->buffer, ")"); +diff --git a/libs/vkd3d/libs/vkd3d-shader/dxil.c b/libs/vkd3d/libs/vkd3d-shader/dxil.c +index 8d803b91f7a..9f25ae8334b 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/dxil.c ++++ b/libs/vkd3d/libs/vkd3d-shader/dxil.c +@@ -6142,11 +6142,14 @@ static unsigned int sm6_value_get_texel_offset(const struct sm6_value *value, st + } + + static void instruction_set_texel_offset(struct vkd3d_shader_instruction *ins, +- const struct sm6_value **operands, struct sm6_parser *sm6) ++ const struct sm6_value **operands, unsigned int count, struct sm6_parser *sm6) + { + ins->texel_offset.u = sm6_value_get_texel_offset(operands[0], sm6); + ins->texel_offset.v = sm6_value_get_texel_offset(operands[1], sm6); +- ins->texel_offset.w = sm6_value_get_texel_offset(operands[2], sm6); ++ if (count == 3) ++ ins->texel_offset.w = sm6_value_get_texel_offset(operands[2], sm6); ++ else ++ ins->texel_offset.w = 0; + } + + static void sm6_parser_emit_dx_sample(struct sm6_parser *sm6, enum dx_intrinsic_opcode op, +@@ -6228,7 +6231,7 @@ static void sm6_parser_emit_dx_sample(struct sm6_parser *sm6, enum dx_intrinsic_ + src_param_init_vector_from_reg(&src_params[0], &coord); + src_param_init_vector_from_handle(sm6, &src_params[1], &resource->u.handle); + src_param_init_vector_from_handle(sm6, &src_params[2], &sampler->u.handle); +- instruction_set_texel_offset(ins, &operands[6], sm6); ++ instruction_set_texel_offset(ins, &operands[6], 3, sm6); + + instruction_dst_param_init_ssa_vector(ins, component_count, sm6); + } +@@ -6402,7 +6405,7 @@ static void sm6_parser_emit_dx_texture_gather(struct sm6_parser *sm6, enum dx_in + if (extended_offset) + src_param_init_vector_from_reg(&src_params[1], &offset); + else +- instruction_set_texel_offset(ins, &operands[6], sm6); ++ instruction_set_texel_offset(ins, &operands[6], 2, sm6); + src_param_init_vector_from_handle(sm6, &src_params[1 + extended_offset], &resource->u.handle); + src_param_init_vector_from_handle(sm6, &src_params[2 + extended_offset], &sampler->u.handle); + /* Swizzle stored in the sampler parameter is the scalar component index to be gathered. */ +@@ -6448,7 +6451,7 @@ static void sm6_parser_emit_dx_texture_load(struct sm6_parser *sm6, enum dx_intr + ins = state->ins; + instruction_init_with_resource(ins, is_uav ? VSIR_OP_LD_UAV_TYPED + : is_multisample ? VSIR_OP_LD2DMS : VSIR_OP_LD, resource, sm6); +- instruction_set_texel_offset(ins, &operands[5], sm6); ++ instruction_set_texel_offset(ins, &operands[5], 3, sm6); + + for (i = 0; i < VKD3D_VEC4_SIZE; ++i) + ins->resource_data_type[i] = resource->u.handle.d->resource_data_type; +diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c +index 8bb23e0690d..f1368b151aa 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c ++++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c +@@ -5490,10 +5490,14 @@ static struct hlsl_ir_node *lower_casts_to_bool(struct hlsl_ctx *ctx, + struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_block *instrs, + struct hlsl_ir_node *condition, struct hlsl_ir_node *if_true, struct hlsl_ir_node *if_false) + { ++ struct hlsl_type *false_type = if_false->data_type; + struct hlsl_type *cond_type = condition->data_type; + struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS]; ++ struct hlsl_type *true_type = if_true->data_type; + +- VKD3D_ASSERT(hlsl_types_are_equal(if_true->data_type, if_false->data_type)); ++ VKD3D_ASSERT(hlsl_types_are_equal(true_type, false_type) ++ || (hlsl_is_vec1(true_type) && hlsl_is_vec1(false_type) ++ && true_type->e.numeric.type == false_type->e.numeric.type)); + + if (cond_type->e.numeric.type != HLSL_TYPE_BOOL) + { +@@ -5505,7 +5509,7 @@ struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_bloc + operands[0] = condition; + operands[1] = if_true; + operands[2] = if_false; +- return hlsl_block_add_expr(ctx, instrs, HLSL_OP3_TERNARY, operands, if_true->data_type, &condition->loc); ++ return hlsl_block_add_expr(ctx, instrs, HLSL_OP3_TERNARY, operands, true_type, &condition->loc); + } + + static struct hlsl_ir_node *lower_int_division_sm4(struct hlsl_ctx *ctx, +diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c +index 3950021a2ef..87ec827b420 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c ++++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c +@@ -6668,13 +6668,18 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler, + /* Push constant buffers are handled in + * spirv_compiler_emit_push_constant_buffers(). + */ +- push_cb->reg = reg; +- push_cb->size = size; + if (size_in_bytes > push_cb->pc.size) + { +- WARN("Constant buffer size %u exceeds push constant size %u.\n", +- size_in_bytes, push_cb->pc.size); ++ spirv_compiler_warning(compiler, VKD3D_SHADER_WARNING_SPV_INVALID_SIZE, ++ "Constant buffer cb%u, space %u, has size %u which exceeds the push constant size %u.", ++ push_cb->pc.register_index, push_cb->pc.register_space, size_in_bytes, push_cb->pc.size); ++ size_in_bytes = push_cb->pc.size; ++ size = align(size_in_bytes, VKD3D_VEC4_SIZE * sizeof(uint32_t)); ++ size /= VKD3D_VEC4_SIZE * sizeof(uint32_t); + } ++ ++ push_cb->reg = reg; ++ push_cb->size = size; + return; + } + +diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c +index c0faa30f14a..ee113f57736 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c ++++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c +@@ -23,8 +23,6 @@ + #include + #include + +-/* VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); */ +- + static inline int char_to_int(char c) + { + if ('0' <= c && c <= '9') +@@ -268,7 +266,7 @@ void vkd3d_shader_trace_text_(const char *text, size_t size, const char *functio + q = end; + else + ++q; +- vkd3d_dbg_printf(VKD3D_DBG_LEVEL_TRACE, function, "%.*s", (int)(q - p), p); ++ vkd3d_dbg_printf(VKD3D_DEBUG_ENV_NAME, VKD3D_DBG_LEVEL_TRACE, function, "%.*s", (int)(q - p), p); + } + } + +diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h +index 763a4906919..97fe5238046 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h ++++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h +@@ -110,6 +110,7 @@ enum vkd3d_shader_error + VKD3D_SHADER_WARNING_SPV_INVALID_SWIZZLE = 2300, + VKD3D_SHADER_WARNING_SPV_INVALID_UAV_FLAGS = 2301, + VKD3D_SHADER_WARNING_SPV_IGNORING_FLAG = 2302, ++ VKD3D_SHADER_WARNING_SPV_INVALID_SIZE = 2303, + + VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY = 3000, + VKD3D_SHADER_ERROR_RS_INVALID_VERSION = 3001, +diff --git a/libs/vkd3d/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d/libs/vkd3d-utils/vkd3d_utils_main.c +index fea8c2440d1..6e90b48e877 100644 +--- a/libs/vkd3d/libs/vkd3d-utils/vkd3d_utils_main.c ++++ b/libs/vkd3d/libs/vkd3d-utils/vkd3d_utils_main.c +@@ -19,8 +19,6 @@ + #include "vkd3d_utils_private.h" + #undef D3D12CreateDevice + +-/* VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); */ +- + static const char *debug_d3d_blob_part(D3D_BLOB_PART part) + { + switch (part) +diff --git a/libs/vkd3d/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/libs/vkd3d/vkd3d_main.c +index 5215cf8ef86..4c58f0a1787 100644 +--- a/libs/vkd3d/libs/vkd3d/vkd3d_main.c ++++ b/libs/vkd3d/libs/vkd3d/vkd3d_main.c +@@ -18,8 +18,6 @@ + + #include "vkd3d_private.h" + +-VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); +- + HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info, + REFIID iid, void **device) + { +-- +2.51.0 +