2025-06-13 08:26:56 +10:00
|
|
|
From 1bb8646ffba747c1dd8fe298e6b9e98595d28198 Mon Sep 17 00:00:00 2001
|
2025-06-06 07:11:56 +10:00
|
|
|
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
|
|
|
Date: Tue, 3 Jun 2025 07:40:14 +1000
|
|
|
|
Subject: [PATCH] Updated vkd3d to 2b257caea94fce2a5ef58dd303de9d73563b9126.
|
|
|
|
|
|
|
|
---
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/d3d_asm.c | 8 +-
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/d3dbc.c | 8 +-
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/dxil.c | 227 +++++++++---------
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/fx.c | 139 +++++------
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/glsl.c | 8 +-
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/hlsl.h | 1 +
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 180 +++++++++++---
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/ir.c | 9 +-
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/msl.c | 10 +-
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/spirv.c | 51 ----
|
|
|
|
libs/vkd3d/libs/vkd3d-shader/tpf.c | 29 ++-
|
|
|
|
.../libs/vkd3d-shader/vkd3d_shader_main.c | 3 +-
|
|
|
|
.../libs/vkd3d-shader/vkd3d_shader_private.h | 12 +-
|
|
|
|
13 files changed, 385 insertions(+), 300 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c
|
|
|
|
index dc1678795e8..db60883f2a3 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c
|
|
|
|
@@ -298,14 +298,16 @@ static const char * const shader_opcode_names[] =
|
|
|
|
[VKD3DSIH_SWITCH_MONOLITHIC ] = "switch",
|
|
|
|
[VKD3DSIH_SYNC ] = "sync",
|
|
|
|
[VKD3DSIH_TAN ] = "tan",
|
|
|
|
- [VKD3DSIH_TEX ] = "texld",
|
|
|
|
+ [VKD3DSIH_TEX ] = "tex",
|
|
|
|
[VKD3DSIH_TEXBEM ] = "texbem",
|
|
|
|
[VKD3DSIH_TEXBEML ] = "texbeml",
|
|
|
|
- [VKD3DSIH_TEXCOORD ] = "texcrd",
|
|
|
|
+ [VKD3DSIH_TEXCOORD ] = "texcoord",
|
|
|
|
+ [VKD3DSIH_TEXCRD ] = "texcrd",
|
|
|
|
[VKD3DSIH_TEXDEPTH ] = "texdepth",
|
|
|
|
[VKD3DSIH_TEXDP3 ] = "texdp3",
|
|
|
|
[VKD3DSIH_TEXDP3TEX ] = "texdp3tex",
|
|
|
|
[VKD3DSIH_TEXKILL ] = "texkill",
|
|
|
|
+ [VKD3DSIH_TEXLD ] = "texld",
|
|
|
|
[VKD3DSIH_TEXLDD ] = "texldd",
|
|
|
|
[VKD3DSIH_TEXLDL ] = "texldl",
|
|
|
|
[VKD3DSIH_TEXM3x2DEPTH ] = "texm3x2depth",
|
|
|
|
@@ -1706,7 +1708,7 @@ static void shader_dump_instruction_flags(struct vkd3d_d3d_asm_compiler *compile
|
|
|
|
shader_dump_sync_flags(compiler, ins->flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
- case VKD3DSIH_TEX:
|
|
|
|
+ case VKD3DSIH_TEXLD:
|
|
|
|
if (vkd3d_shader_ver_ge(&compiler->shader_version, 2, 0))
|
|
|
|
{
|
|
|
|
if (ins->flags & VKD3DSI_TEXLD_PROJECT)
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
|
|
|
index 57d874efe37..05f46e264b9 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
|
|
|
@@ -382,11 +382,11 @@ static const struct vkd3d_sm1_opcode_info ps_opcode_table[] =
|
|
|
|
{VKD3D_SM1_OP_LABEL, 0, 1, VKD3DSIH_LABEL, {2, 1}},
|
|
|
|
/* Texture */
|
|
|
|
{VKD3D_SM1_OP_TEXCOORD, 1, 0, VKD3DSIH_TEXCOORD, {0, 0}, {1, 3}},
|
|
|
|
- {VKD3D_SM1_OP_TEXCOORD, 1, 1, VKD3DSIH_TEXCOORD, {1, 4}, {1, 4}},
|
|
|
|
+ {VKD3D_SM1_OP_TEXCOORD, 1, 1, VKD3DSIH_TEXCRD, {1, 4}, {1, 4}},
|
|
|
|
{VKD3D_SM1_OP_TEXKILL, 1, 0, VKD3DSIH_TEXKILL, {1, 0}},
|
|
|
|
{VKD3D_SM1_OP_TEX, 1, 0, VKD3DSIH_TEX, {0, 0}, {1, 3}},
|
|
|
|
- {VKD3D_SM1_OP_TEX, 1, 1, VKD3DSIH_TEX, {1, 4}, {1, 4}},
|
|
|
|
- {VKD3D_SM1_OP_TEX, 1, 2, VKD3DSIH_TEX, {2, 0}},
|
|
|
|
+ {VKD3D_SM1_OP_TEX, 1, 1, VKD3DSIH_TEXLD, {1, 4}, {1, 4}},
|
|
|
|
+ {VKD3D_SM1_OP_TEX, 1, 2, VKD3DSIH_TEXLD, {2, 0}},
|
|
|
|
{VKD3D_SM1_OP_TEXBEM, 1, 1, VKD3DSIH_TEXBEM, {0, 0}, {1, 3}},
|
|
|
|
{VKD3D_SM1_OP_TEXBEML, 1, 1, VKD3DSIH_TEXBEML, {1, 0}, {1, 3}},
|
|
|
|
{VKD3D_SM1_OP_TEXREG2AR, 1, 1, VKD3DSIH_TEXREG2AR, {1, 0}, {1, 3}},
|
|
|
|
@@ -2014,7 +2014,7 @@ static void d3dbc_write_vsir_instruction(struct d3dbc_compiler *d3dbc, const str
|
|
|
|
case VKD3DSIH_MUL:
|
|
|
|
case VKD3DSIH_SINCOS:
|
|
|
|
case VKD3DSIH_SLT:
|
|
|
|
- case VKD3DSIH_TEX:
|
|
|
|
+ case VKD3DSIH_TEXLD:
|
|
|
|
case VKD3DSIH_TEXLDD:
|
|
|
|
d3dbc_write_instruction(d3dbc, ins);
|
|
|
|
break;
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/dxil.c b/libs/vkd3d/libs/vkd3d-shader/dxil.c
|
|
|
|
index 9a4d194586b..c85b644df15 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/dxil.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/dxil.c
|
|
|
|
@@ -651,6 +651,7 @@ enum sm6_value_type
|
|
|
|
VALUE_TYPE_ICB,
|
|
|
|
VALUE_TYPE_IDXTEMP,
|
|
|
|
VALUE_TYPE_GROUPSHAREDMEM,
|
|
|
|
+ VALUE_TYPE_CONSTANT,
|
|
|
|
VALUE_TYPE_UNDEFINED,
|
|
|
|
VALUE_TYPE_INVALID,
|
|
|
|
};
|
|
|
|
@@ -699,6 +700,11 @@ struct sm6_groupsharedmem_data
|
|
|
|
struct sm6_index index;
|
|
|
|
};
|
|
|
|
|
|
|
|
+struct sm6_constant_data
|
|
|
|
+{
|
|
|
|
+ union vsir_immediate_constant immconst;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
struct sm6_value
|
|
|
|
{
|
|
|
|
const struct sm6_type *type;
|
|
|
|
@@ -714,6 +720,7 @@ struct sm6_value
|
|
|
|
struct sm6_icb_data icb;
|
|
|
|
struct sm6_idxtemp_data idxtemp;
|
|
|
|
struct sm6_groupsharedmem_data groupsharedmem;
|
|
|
|
+ struct sm6_constant_data constant;
|
|
|
|
} u;
|
|
|
|
struct vkd3d_shader_register reg;
|
|
|
|
};
|
|
|
|
@@ -2019,11 +2026,6 @@ static inline bool sm6_type_is_handle(const struct sm6_type *type)
|
|
|
|
return sm6_type_is_struct(type) && !strcmp(type->u.struc->name, "dx.types.Handle");
|
|
|
|
}
|
|
|
|
|
|
|
|
-static inline const struct sm6_type *sm6_type_get_element_type(const struct sm6_type *type)
|
|
|
|
-{
|
|
|
|
- return (type->class == TYPE_CLASS_ARRAY || type->class == TYPE_CLASS_VECTOR) ? type->u.array.elem_type : type;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static const struct sm6_type *sm6_type_get_pointer_to_type(const struct sm6_type *type,
|
|
|
|
enum bitcode_address_space addr_space, struct sm6_parser *sm6)
|
|
|
|
{
|
|
|
|
@@ -2278,6 +2280,7 @@ static inline bool sm6_value_is_register(const struct sm6_value *value)
|
|
|
|
case VALUE_TYPE_ICB:
|
|
|
|
case VALUE_TYPE_IDXTEMP:
|
|
|
|
case VALUE_TYPE_GROUPSHAREDMEM:
|
|
|
|
+ case VALUE_TYPE_CONSTANT:
|
|
|
|
case VALUE_TYPE_UNDEFINED:
|
|
|
|
case VALUE_TYPE_INVALID:
|
|
|
|
return true;
|
|
|
|
@@ -2329,7 +2332,16 @@ static bool sm6_value_is_ssa(const struct sm6_value *value)
|
|
|
|
|
|
|
|
static bool sm6_value_is_numeric_array(const struct sm6_value *value)
|
|
|
|
{
|
|
|
|
- return sm6_value_is_register(value) && register_is_numeric_array(&value->reg);
|
|
|
|
+ switch (value->value_type)
|
|
|
|
+ {
|
|
|
|
+ case VALUE_TYPE_ICB:
|
|
|
|
+ case VALUE_TYPE_IDXTEMP:
|
|
|
|
+ case VALUE_TYPE_GROUPSHAREDMEM:
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int sm6_value_get_constant_uint(const struct sm6_value *value)
|
|
|
|
@@ -2448,9 +2460,11 @@ static void register_index_address_init(struct vkd3d_shader_register_index *idx,
|
|
|
|
static void sm6_register_from_value(struct vkd3d_shader_register *reg, const struct sm6_value *value,
|
|
|
|
struct sm6_parser *sm6)
|
|
|
|
{
|
|
|
|
+ const struct sm6_type *scalar_type;
|
|
|
|
enum vkd3d_data_type data_type;
|
|
|
|
|
|
|
|
- data_type = vkd3d_data_type_from_sm6_type(sm6_type_get_scalar_type(value->type, 0));
|
|
|
|
+ scalar_type = sm6_type_get_scalar_type(value->type, 0);
|
|
|
|
+ data_type = vkd3d_data_type_from_sm6_type(scalar_type);
|
|
|
|
|
|
|
|
switch (value->value_type)
|
|
|
|
{
|
|
|
|
@@ -2484,6 +2498,12 @@ static void sm6_register_from_value(struct vkd3d_shader_register *reg, const str
|
|
|
|
reg->idx[1].is_in_bounds = value->u.groupsharedmem.index.is_in_bounds;
|
|
|
|
break;
|
|
|
|
|
|
|
|
+ case VALUE_TYPE_CONSTANT:
|
|
|
|
+ vsir_register_init(reg, scalar_type->u.width == 64 ? VKD3DSPR_IMMCONST64 : VKD3DSPR_IMMCONST,
|
|
|
|
+ data_type, 0);
|
|
|
|
+ reg->u = value->u.constant.immconst;
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
case VALUE_TYPE_UNDEFINED:
|
|
|
|
case VALUE_TYPE_INVALID:
|
|
|
|
vsir_register_init(reg, VKD3DSPR_UNDEF, data_type, 0);
|
|
|
|
@@ -2657,19 +2677,17 @@ static void instruction_dst_param_init_ssa_vector(struct vkd3d_shader_instructio
|
|
|
|
sm6_register_from_value(¶m->reg, dst, sm6);
|
|
|
|
}
|
|
|
|
|
|
|
|
-static bool instruction_dst_param_init_temp_vector(struct vkd3d_shader_instruction *ins, struct sm6_parser *sm6)
|
|
|
|
+static bool instruction_dst_param_init_uint_temp_vector(struct vkd3d_shader_instruction *ins, struct sm6_parser *sm6)
|
|
|
|
{
|
|
|
|
- struct sm6_value *dst = sm6_parser_get_current_value(sm6);
|
|
|
|
struct vkd3d_shader_dst_param *param;
|
|
|
|
|
|
|
|
if (!(param = instruction_dst_params_alloc(ins, 1, sm6)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
- vsir_dst_param_init(param, VKD3DSPR_TEMP, vkd3d_data_type_from_sm6_type(sm6_type_get_scalar_type(dst->type, 0)), 1);
|
|
|
|
+ vsir_dst_param_init(param, VKD3DSPR_TEMP, VKD3D_DATA_UINT, 1);
|
|
|
|
param->write_mask = VKD3DSP_WRITEMASK_ALL;
|
|
|
|
param->reg.idx[0].offset = 0;
|
|
|
|
param->reg.dimension = VSIR_DIMENSION_VEC4;
|
|
|
|
- dst->reg = param->reg;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
@@ -3040,30 +3058,6 @@ static inline uint64_t decode_rotated_signed_value(uint64_t value)
|
|
|
|
return value << 63;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static float bitcast_uint_to_float(unsigned int value)
|
|
|
|
-{
|
|
|
|
- union
|
|
|
|
- {
|
|
|
|
- uint32_t uint32_value;
|
|
|
|
- float float_value;
|
|
|
|
- } u;
|
|
|
|
-
|
|
|
|
- u.uint32_value = value;
|
|
|
|
- return u.float_value;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static inline double bitcast_uint64_to_double(uint64_t value)
|
|
|
|
-{
|
|
|
|
- union
|
|
|
|
- {
|
|
|
|
- uint64_t uint64_value;
|
|
|
|
- double double_value;
|
|
|
|
- } u;
|
|
|
|
-
|
|
|
|
- u.uint64_value = value;
|
|
|
|
- return u.double_value;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static float register_get_float_value(const struct vkd3d_shader_register *reg)
|
|
|
|
{
|
|
|
|
if (!register_is_constant(reg) || !data_type_is_floating_point(reg->data_type))
|
|
|
|
@@ -3075,10 +3069,10 @@ static float register_get_float_value(const struct vkd3d_shader_register *reg)
|
|
|
|
if (reg->type == VKD3DSPR_IMMCONST64)
|
|
|
|
{
|
|
|
|
WARN("Truncating double to float.\n");
|
|
|
|
- return bitcast_uint64_to_double(reg->u.immconst_u64[0]);
|
|
|
|
+ return reg->u.immconst_f64[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
- return bitcast_uint_to_float(reg->u.immconst_u32[0]);
|
|
|
|
+ return reg->u.immconst_f32[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum vkd3d_result value_allocate_constant_array(struct sm6_value *dst, const struct sm6_type *type,
|
|
|
|
@@ -3298,10 +3292,8 @@ static enum vkd3d_result sm6_parser_init_constexpr_gep(struct sm6_parser *sm6, c
|
|
|
|
|
|
|
|
static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const struct dxil_block *block)
|
|
|
|
{
|
|
|
|
- enum vkd3d_shader_register_type reg_type = VKD3DSPR_INVALID;
|
|
|
|
- const struct sm6_type *type, *elem_type, *ptr_type;
|
|
|
|
+ const struct sm6_type *type, *ptr_type;
|
|
|
|
size_t i, base_value_idx, value_idx;
|
|
|
|
- enum vkd3d_data_type reg_data_type;
|
|
|
|
const struct dxil_record *record;
|
|
|
|
const struct sm6_value *src;
|
|
|
|
enum vkd3d_result ret;
|
|
|
|
@@ -3322,18 +3314,6 @@ static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const
|
|
|
|
if (!(type = sm6_parser_get_type(sm6, record->operands[0])))
|
|
|
|
return VKD3D_ERROR_INVALID_SHADER;
|
|
|
|
|
|
|
|
- elem_type = sm6_type_get_element_type(type);
|
|
|
|
- if (sm6_type_is_numeric(elem_type))
|
|
|
|
- {
|
|
|
|
- reg_data_type = vkd3d_data_type_from_sm6_type(elem_type);
|
|
|
|
- reg_type = elem_type->u.width > 32 ? VKD3DSPR_IMMCONST64 : VKD3DSPR_IMMCONST;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- reg_data_type = VKD3D_DATA_UNUSED;
|
|
|
|
- reg_type = VKD3DSPR_INVALID;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (i == block->record_count - 1)
|
|
|
|
WARN("Unused SETTYPE record.\n");
|
|
|
|
|
|
|
|
@@ -3348,19 +3328,22 @@ static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const
|
|
|
|
|
|
|
|
dst = sm6_parser_get_current_value(sm6);
|
|
|
|
dst->type = type;
|
|
|
|
- dst->value_type = VALUE_TYPE_REG;
|
|
|
|
dst->is_back_ref = true;
|
|
|
|
- vsir_register_init(&dst->reg, reg_type, reg_data_type, 0);
|
|
|
|
|
|
|
|
switch (record->code)
|
|
|
|
{
|
|
|
|
case CST_CODE_NULL:
|
|
|
|
- if (sm6_type_is_array(type)
|
|
|
|
- && (ret = value_allocate_constant_array(dst, type, NULL, sm6)) < 0)
|
|
|
|
+ if (sm6_type_is_array(type))
|
|
|
|
{
|
|
|
|
- return ret;
|
|
|
|
+ if ((ret = value_allocate_constant_array(dst, type, NULL, sm6)) < 0)
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ dst->value_type = VALUE_TYPE_CONSTANT;
|
|
|
|
+ memset(&dst->u.constant, 0, sizeof(dst->u.constant));
|
|
|
|
+ sm6_register_from_value(&dst->reg, dst, sm6);
|
|
|
|
}
|
|
|
|
- /* For non-aggregates, register constant data is already zero-filled. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CST_CODE_INTEGER:
|
|
|
|
@@ -3373,11 +3356,15 @@ static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const
|
|
|
|
return VKD3D_ERROR_INVALID_SHADER;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ dst->value_type = VALUE_TYPE_CONSTANT;
|
|
|
|
+
|
|
|
|
value = decode_rotated_signed_value(record->operands[0]);
|
|
|
|
if (type->u.width <= 32)
|
|
|
|
- dst->reg.u.immconst_u32[0] = value & ((1ull << type->u.width) - 1);
|
|
|
|
+ dst->u.constant.immconst.immconst_u32[0] = value & ((1ull << type->u.width) - 1);
|
|
|
|
else
|
|
|
|
- dst->reg.u.immconst_u64[0] = value;
|
|
|
|
+ dst->u.constant.immconst.immconst_u64[0] = value;
|
|
|
|
+
|
|
|
|
+ sm6_register_from_value(&dst->reg, dst, sm6);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
@@ -3391,14 +3378,15 @@ static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const
|
|
|
|
return VKD3D_ERROR_INVALID_SHADER;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (type->u.width == 16)
|
|
|
|
- dst->reg.u.immconst_u32[0] = record->operands[0];
|
|
|
|
- else if (type->u.width == 32)
|
|
|
|
- dst->reg.u.immconst_f32[0] = bitcast_uint_to_float(record->operands[0]);
|
|
|
|
- else if (type->u.width == 64)
|
|
|
|
- dst->reg.u.immconst_f64[0] = bitcast_uint64_to_double(record->operands[0]);
|
|
|
|
+ dst->value_type = VALUE_TYPE_CONSTANT;
|
|
|
|
+
|
|
|
|
+ value = record->operands[0];
|
|
|
|
+ if (type->u.width <= 32)
|
|
|
|
+ dst->u.constant.immconst.immconst_u32[0] = value & ((1ull << type->u.width) - 1);
|
|
|
|
else
|
|
|
|
- vkd3d_unreachable();
|
|
|
|
+ dst->u.constant.immconst.immconst_u64[0] = value;
|
|
|
|
+
|
|
|
|
+ sm6_register_from_value(&dst->reg, dst, sm6);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
@@ -3424,6 +3412,48 @@ static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const
|
|
|
|
return ret;
|
|
|
|
break;
|
|
|
|
|
|
|
|
+ case CST_CODE_CE_CAST:
|
|
|
|
+ /* Resolve later in case forward refs exist. */
|
|
|
|
+ dst->type = type;
|
|
|
|
+ dst->value_type = VALUE_TYPE_INVALID;
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case CST_CODE_UNDEF:
|
|
|
|
+ dxil_record_validate_operand_max_count(record, 0, sm6);
|
|
|
|
+ dst->value_type = VALUE_TYPE_UNDEFINED;
|
|
|
|
+ sm6_register_from_value(&dst->reg, dst, sm6);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND,
|
|
|
|
+ "Constant code %u is unhandled.", record->code);
|
|
|
|
+ dst->value_type = VALUE_TYPE_INVALID;
|
|
|
|
+ sm6_register_from_value(&dst->reg, dst, sm6);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (record->attachment)
|
|
|
|
+ vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_IGNORING_ATTACHMENT,
|
|
|
|
+ "Ignoring a metadata attachment for a constant.");
|
|
|
|
+
|
|
|
|
+ ++sm6->value_count;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ value_idx = base_value_idx;
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < block->record_count; ++i)
|
|
|
|
+ {
|
|
|
|
+ sm6->p.location.column = i;
|
|
|
|
+ record = block->records[i];
|
|
|
|
+
|
|
|
|
+ switch (record->code)
|
|
|
|
+ {
|
|
|
|
+ case CST_CODE_SETTYPE:
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
case CST_CODE_CE_CAST:
|
|
|
|
if (!dxil_record_validate_operand_count(record, 3, 3, sm6))
|
|
|
|
return VKD3D_ERROR_INVALID_SHADER;
|
|
|
|
@@ -3460,59 +3490,28 @@ static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const
|
|
|
|
return VKD3D_ERROR_INVALID_SHADER;
|
|
|
|
}
|
|
|
|
|
|
|
|
- /* Resolve later in case forward refs exist. */
|
|
|
|
- dst->type = type;
|
|
|
|
- dst->reg.type = VKD3DSPR_COUNT;
|
|
|
|
- dst->reg.idx[0].offset = value;
|
|
|
|
- break;
|
|
|
|
+ dst = &sm6->values[value_idx];
|
|
|
|
+ src = &sm6->values[value];
|
|
|
|
|
|
|
|
- case CST_CODE_UNDEF:
|
|
|
|
- dxil_record_validate_operand_max_count(record, 0, sm6);
|
|
|
|
- dst->value_type = VALUE_TYPE_UNDEFINED;
|
|
|
|
- sm6_register_from_value(&dst->reg, dst, sm6);
|
|
|
|
- break;
|
|
|
|
+ if (!sm6_value_is_numeric_array(src))
|
|
|
|
+ {
|
|
|
|
+ vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND,
|
|
|
|
+ "Constexpr cast source value is not a global array element.");
|
|
|
|
+ return VKD3D_ERROR_INVALID_SHADER;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ type = dst->type;
|
|
|
|
+ *dst = *src;
|
|
|
|
+ dst->type = type;
|
|
|
|
|
|
|
|
- default:
|
|
|
|
- FIXME("Unhandled constant code %u.\n", record->code);
|
|
|
|
- vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND,
|
|
|
|
- "Constant code %u is unhandled.", record->code);
|
|
|
|
- dst->value_type = VALUE_TYPE_INVALID;
|
|
|
|
sm6_register_from_value(&dst->reg, dst, sm6);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (record->attachment)
|
|
|
|
- {
|
|
|
|
- WARN("Ignoring metadata attachment.\n");
|
|
|
|
- vkd3d_shader_parser_warning(&sm6->p, VKD3D_SHADER_WARNING_DXIL_IGNORING_ATTACHMENT,
|
|
|
|
- "Ignoring a metadata attachment for a constant.");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ++sm6->value_count;
|
|
|
|
+ ++value_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
- /* Resolve cast forward refs. */
|
|
|
|
- for (i = base_value_idx; i < sm6->value_count; ++i)
|
|
|
|
- {
|
|
|
|
- dst = &sm6->values[i];
|
|
|
|
- if (dst->reg.type != VKD3DSPR_COUNT)
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- type = dst->type;
|
|
|
|
-
|
|
|
|
- src = &sm6->values[dst->reg.idx[0].offset];
|
|
|
|
- if (!sm6_value_is_numeric_array(src))
|
|
|
|
- {
|
|
|
|
- WARN("Value is not an array.\n");
|
|
|
|
- vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_INVALID_OPERAND,
|
|
|
|
- "Constexpr cast source value is not a global array element.");
|
|
|
|
- return VKD3D_ERROR_INVALID_SHADER;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- *dst = *src;
|
|
|
|
- dst->type = type;
|
|
|
|
- dst->reg.data_type = vkd3d_data_type_from_sm6_type(type->u.pointer.type);
|
|
|
|
- }
|
|
|
|
+ VKD3D_ASSERT(value_idx == sm6->value_count);
|
|
|
|
|
|
|
|
return VKD3D_OK;
|
|
|
|
}
|
|
|
|
@@ -5427,7 +5426,7 @@ static void sm6_parser_emit_dx_get_dimensions(struct sm6_parser *sm6, enum dx_in
|
|
|
|
|
|
|
|
if (resource_kind_is_multisampled(resource_kind))
|
|
|
|
{
|
|
|
|
- instruction_dst_param_init_temp_vector(ins++, sm6);
|
|
|
|
+ instruction_dst_param_init_uint_temp_vector(ins++, sm6);
|
|
|
|
state->temp_idx = 1;
|
|
|
|
|
|
|
|
/* DXIL does not have an intrinsic for sample info, and resinfo is expected to return
|
|
|
|
@@ -5440,7 +5439,7 @@ static void sm6_parser_emit_dx_get_dimensions(struct sm6_parser *sm6, enum dx_in
|
|
|
|
src_param_init_vector_from_handle(sm6, &src_params[0], &resource->u.handle);
|
|
|
|
src_params[0].swizzle = VKD3D_SHADER_SWIZZLE(X, X, X, X);
|
|
|
|
|
|
|
|
- if (!instruction_dst_param_init_temp_vector(ins, sm6))
|
|
|
|
+ if (!instruction_dst_param_init_uint_temp_vector(ins, sm6))
|
|
|
|
return;
|
|
|
|
dst = ins->dst;
|
|
|
|
dst->write_mask = VKD3DSP_WRITEMASK_3;
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/fx.c b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
|
|
|
index 1d5f95fa988..90da8048b8e 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/fx.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
|
|
|
@@ -873,7 +873,7 @@ fx_2_states[] =
|
|
|
|
{ "AdaptiveTess_Y", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 84 },
|
|
|
|
{ "AdaptiveTess_Z", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 85 },
|
|
|
|
{ "AdaptiveTess_W", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 86 },
|
|
|
|
- { "EnableAdaptiveTesselation", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 87 },
|
|
|
|
+ { "EnableAdaptiveTessellation",HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 87 },
|
|
|
|
{ "TwoSidedStencilMode", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 88 },
|
|
|
|
{ "StencilFail", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 89, fx_2_stencilcaps_values },
|
|
|
|
{ "StencilZFail", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 90, fx_2_stencilcaps_values },
|
|
|
|
@@ -904,17 +904,17 @@ fx_2_states[] =
|
|
|
|
{ "BumpEnvMat01", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 8, 113 },
|
|
|
|
{ "BumpEnvMat10", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 8, 114 },
|
|
|
|
{ "BumpEnvMat11", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 8, 115 },
|
|
|
|
- { "TextCoordIndex", HLSL_CLASS_SCALAR, FX_UINT, 1, 8, 116 },
|
|
|
|
+ { "TexCoordIndex", HLSL_CLASS_SCALAR, FX_UINT, 1, 8, 116 },
|
|
|
|
{ "BumpEnvLScale", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 8, 117 },
|
|
|
|
{ "BumpEnvLOffset", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 8, 118 },
|
|
|
|
{ "TextureTransformFlags", HLSL_CLASS_SCALAR, FX_UINT, 1, 8, 119, fx_2_texturetransform_values },
|
|
|
|
{ "Constant", HLSL_CLASS_SCALAR, FX_UINT, 1, 8, 120 },
|
|
|
|
- { "NPatchMode", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 121 },
|
|
|
|
+ { "PatchSegments", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 121 },
|
|
|
|
{ "FVF", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 122 },
|
|
|
|
|
|
|
|
{ "ProjectionTransform", HLSL_CLASS_MATRIX, FX_FLOAT, 4, 1, 123 },
|
|
|
|
{ "ViewTransform", HLSL_CLASS_MATRIX, FX_FLOAT, 4, 1, 124 },
|
|
|
|
- { "WorldTransform", HLSL_CLASS_MATRIX, FX_FLOAT, 4, 1, 125 },
|
|
|
|
+ { "WorldTransform", HLSL_CLASS_MATRIX, FX_FLOAT, 4, 256, 125 },
|
|
|
|
{ "TextureTransform", HLSL_CLASS_MATRIX, FX_FLOAT, 4, 8, 126 },
|
|
|
|
|
|
|
|
{ "MaterialAmbient", HLSL_CLASS_VECTOR, FX_FLOAT, 4, 1, 127 },
|
|
|
|
@@ -923,55 +923,55 @@ fx_2_states[] =
|
|
|
|
{ "MaterialEmissive", HLSL_CLASS_VECTOR, FX_FLOAT, 4, 1, 130 },
|
|
|
|
{ "MaterialPower", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 131 },
|
|
|
|
|
|
|
|
- { "LightType", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 132, fx_2_lighttype_values },
|
|
|
|
- { "LightDiffuse", HLSL_CLASS_VECTOR, FX_FLOAT, 4, 1, 133 },
|
|
|
|
- { "LightSpecular", HLSL_CLASS_VECTOR, FX_FLOAT, 4, 1, 134 },
|
|
|
|
- { "LightAmbient", HLSL_CLASS_VECTOR, FX_FLOAT, 4, 1, 135 },
|
|
|
|
- { "LightPosition", HLSL_CLASS_VECTOR, FX_FLOAT, 3, 1, 136 },
|
|
|
|
- { "LightDirection", HLSL_CLASS_VECTOR, FX_FLOAT, 3, 1, 137 },
|
|
|
|
- { "LightRange", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 138 },
|
|
|
|
- { "LightFalloff", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 139 },
|
|
|
|
- { "LightAttenuation0", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 140 },
|
|
|
|
- { "LightAttenuation1", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 141 },
|
|
|
|
- { "LightAttenuation2", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 142 },
|
|
|
|
- { "LightTheta", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 143 },
|
|
|
|
- { "LightPhi", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 1, 144 },
|
|
|
|
- { "LightEnable", HLSL_CLASS_SCALAR, FX_FLOAT, 1, 8, 145 },
|
|
|
|
+ { "LightType", HLSL_CLASS_SCALAR, FX_UINT, 1, ~0u, 132, fx_2_lighttype_values },
|
|
|
|
+ { "LightDiffuse", HLSL_CLASS_VECTOR, FX_FLOAT, 4, ~0u, 133 },
|
|
|
|
+ { "LightSpecular", HLSL_CLASS_VECTOR, FX_FLOAT, 4, ~0u, 134 },
|
|
|
|
+ { "LightAmbient", HLSL_CLASS_VECTOR, FX_FLOAT, 4, ~0u, 135 },
|
|
|
|
+ { "LightPosition", HLSL_CLASS_VECTOR, FX_FLOAT, 3, ~0u, 136 },
|
|
|
|
+ { "LightDirection", HLSL_CLASS_VECTOR, FX_FLOAT, 3, ~0u, 137 },
|
|
|
|
+ { "LightRange", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 138 },
|
|
|
|
+ { "LightFalloff", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 139 },
|
|
|
|
+ { "LightAttenuation0", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 140 },
|
|
|
|
+ { "LightAttenuation1", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 141 },
|
|
|
|
+ { "LightAttenuation2", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 142 },
|
|
|
|
+ { "LightTheta", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 143 },
|
|
|
|
+ { "LightPhi", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 144 },
|
|
|
|
+ { "LightEnable", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 145 },
|
|
|
|
|
|
|
|
{ "VertexShader", HLSL_CLASS_SCALAR, FX_VERTEXSHADER, 1, 1, 146 },
|
|
|
|
{ "PixelShader", HLSL_CLASS_SCALAR, FX_PIXELSHADER, 1, 1, 147 },
|
|
|
|
|
|
|
|
- { "VertexShaderConstantF", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 148 },
|
|
|
|
- { "VertexShaderConstantB", HLSL_CLASS_SCALAR, FX_BOOL, 1, ~0u-1, 149 },
|
|
|
|
- { "VertexShaderConstantI", HLSL_CLASS_SCALAR, FX_UINT, 1, ~0u-1, 150 },
|
|
|
|
- { "VertexShaderConstant", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 151 },
|
|
|
|
- { "VertexShaderConstant1", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 152 },
|
|
|
|
- { "VertexShaderConstant2", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 153 },
|
|
|
|
- { "VertexShaderConstant3", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 154 },
|
|
|
|
- { "VertexShaderConstant4", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 155 },
|
|
|
|
-
|
|
|
|
- { "PixelShaderConstantF", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 156 },
|
|
|
|
- { "PixelShaderConstantB", HLSL_CLASS_SCALAR, FX_BOOL, 1, ~0u-1, 157 },
|
|
|
|
- { "PixelShaderConstantI", HLSL_CLASS_SCALAR, FX_UINT, 1, ~0u-1, 158 },
|
|
|
|
- { "PixelShaderConstant", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 159 },
|
|
|
|
- { "PixelShaderConstant1", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 160 },
|
|
|
|
- { "PixelShaderConstant2", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 161 },
|
|
|
|
- { "PixelShaderConstant3", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 162 },
|
|
|
|
- { "PixelShaderConstant4", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u-1, 163 },
|
|
|
|
-
|
|
|
|
- { "Texture", HLSL_CLASS_SCALAR, FX_TEXTURE, 1, 1, 164 },
|
|
|
|
- { "AddressU", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 165, fx_2_address_values },
|
|
|
|
- { "AddressV", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 166, fx_2_address_values },
|
|
|
|
- { "AddressW", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 167, fx_2_address_values },
|
|
|
|
- { "BorderColor", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 168 },
|
|
|
|
- { "MagFilter", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 169, fx_2_filter_values },
|
|
|
|
- { "MinFilter", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 170, fx_2_filter_values },
|
|
|
|
- { "MipFilter", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 171, fx_2_filter_values },
|
|
|
|
- { "MipMapLodBias", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 172 },
|
|
|
|
- { "MaxMipLevel", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 173 },
|
|
|
|
- { "MaxAnisotropy", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 174 },
|
|
|
|
- { "SRBTexture", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 175 },
|
|
|
|
- { "ElementIndex", HLSL_CLASS_SCALAR, FX_UINT, 1, 1, 176 },
|
|
|
|
+ { "VertexShaderConstantF", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 148 },
|
|
|
|
+ { "VertexShaderConstantB", HLSL_CLASS_SCALAR, FX_BOOL, 1, ~0u, 149 },
|
|
|
|
+ { "VertexShaderConstantI", HLSL_CLASS_SCALAR, FX_UINT, 1, ~0u, 150 },
|
|
|
|
+ { "VertexShaderConstant", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 151 },
|
|
|
|
+ { "VertexShaderConstant1", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 152 },
|
|
|
|
+ { "VertexShaderConstant2", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 153 },
|
|
|
|
+ { "VertexShaderConstant3", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 154 },
|
|
|
|
+ { "VertexShaderConstant4", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 155 },
|
|
|
|
+
|
|
|
|
+ { "PixelShaderConstantF", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 156 },
|
|
|
|
+ { "PixelShaderConstantB", HLSL_CLASS_SCALAR, FX_BOOL, 1, ~0u, 157 },
|
|
|
|
+ { "PixelShaderConstantI", HLSL_CLASS_SCALAR, FX_UINT, 1, ~0u, 158 },
|
|
|
|
+ { "PixelShaderConstant", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 159 },
|
|
|
|
+ { "PixelShaderConstant1", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 160 },
|
|
|
|
+ { "PixelShaderConstant2", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 161 },
|
|
|
|
+ { "PixelShaderConstant3", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 162 },
|
|
|
|
+ { "PixelShaderConstant4", HLSL_CLASS_SCALAR, FX_FLOAT, 1, ~0u, 163 },
|
|
|
|
+
|
|
|
|
+ { "Texture", HLSL_CLASS_SCALAR, FX_TEXTURE, 1, 261, 164 },
|
|
|
|
+ { "AddressU", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 165, fx_2_address_values },
|
|
|
|
+ { "AddressV", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 166, fx_2_address_values },
|
|
|
|
+ { "AddressW", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 167, fx_2_address_values },
|
|
|
|
+ { "BorderColor", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 168 },
|
|
|
|
+ { "MagFilter", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 169, fx_2_filter_values },
|
|
|
|
+ { "MinFilter", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 170, fx_2_filter_values },
|
|
|
|
+ { "MipFilter", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 171, fx_2_filter_values },
|
|
|
|
+ { "MipMapLodBias", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 172 },
|
|
|
|
+ { "MaxMipLevel", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 173 },
|
|
|
|
+ { "MaxAnisotropy", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 174 },
|
|
|
|
+ { "SRGBTexture", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 175 },
|
|
|
|
+ { "ElementIndex", HLSL_CLASS_SCALAR, FX_UINT, 1, 261, 176 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static void write_fx_2_pass(struct hlsl_ir_var *var, struct fx_write_context *fx)
|
|
|
|
@@ -994,16 +994,6 @@ static void write_fx_2_pass(struct hlsl_ir_var *var, struct fx_write_context *fx
|
|
|
|
fx->shader_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static uint32_t get_fx_4_type_size(const struct hlsl_type *type)
|
|
|
|
-{
|
|
|
|
- uint32_t elements_count;
|
|
|
|
-
|
|
|
|
- elements_count = hlsl_get_multiarray_size(type);
|
|
|
|
- type = hlsl_get_multiarray_element_type(type);
|
|
|
|
-
|
|
|
|
- return type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float) * elements_count;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
enum fx_4_type_constants
|
|
|
|
{
|
|
|
|
/* Numeric types encoding */
|
|
|
|
@@ -1021,6 +1011,9 @@ enum fx_4_type_constants
|
|
|
|
FX_4_NUMERIC_COLUMNS_SHIFT = 11,
|
|
|
|
FX_4_NUMERIC_COLUMN_MAJOR_MASK = 0x4000,
|
|
|
|
|
|
|
|
+ /* Variable flags */
|
|
|
|
+ FX_4_HAS_EXPLICIT_BIND_POINT = 0x4,
|
|
|
|
+
|
|
|
|
/* Object types */
|
|
|
|
FX_4_OBJECT_TYPE_STRING = 0x1,
|
|
|
|
FX_4_OBJECT_TYPE_BLEND_STATE = 0x2,
|
|
|
|
@@ -2140,13 +2133,9 @@ static void write_fx_4_numeric_variable(struct hlsl_ir_var *var, bool shared, st
|
|
|
|
struct vkd3d_bytecode_buffer *buffer = &fx->structured;
|
|
|
|
uint32_t name_offset, type_offset, value_offset;
|
|
|
|
uint32_t semantic_offset, flags = 0;
|
|
|
|
- enum fx_4_numeric_variable_flags
|
|
|
|
- {
|
|
|
|
- HAS_EXPLICIT_BIND_POINT = 0x4,
|
|
|
|
- };
|
|
|
|
|
|
|
|
if (var->has_explicit_bind_point)
|
|
|
|
- flags |= HAS_EXPLICIT_BIND_POINT;
|
|
|
|
+ flags |= FX_4_HAS_EXPLICIT_BIND_POINT;
|
|
|
|
|
|
|
|
type_offset = write_type(var->data_type, fx);
|
|
|
|
name_offset = write_string(var->name, fx);
|
|
|
|
@@ -3295,6 +3284,8 @@ static void write_fx_4_buffer(struct hlsl_buffer *b, struct fx_write_context *fx
|
|
|
|
size = 0;
|
|
|
|
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
|
|
|
{
|
|
|
|
+ uint32_t unpacked_size;
|
|
|
|
+
|
|
|
|
if (!is_numeric_fx_4_type(var->data_type))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
@@ -3302,7 +3293,9 @@ static void write_fx_4_buffer(struct hlsl_buffer *b, struct fx_write_context *fx
|
|
|
|
continue;
|
|
|
|
|
|
|
|
write_fx_4_numeric_variable(var, shared, fx);
|
|
|
|
- size = max(size, get_fx_4_type_size(var->data_type) + var->buffer_offset * 4);
|
|
|
|
+
|
|
|
|
+ unpacked_size = var->data_type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float);
|
|
|
|
+ size = max(size, unpacked_size + var->buffer_offset * 4);
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3969,7 +3962,7 @@ static void fx_parse_fx_2_assignment(struct fx_parser *parser, const struct fx_a
|
|
|
|
}
|
|
|
|
vkd3d_string_buffer_printf(&parser->buffer, " = ");
|
|
|
|
|
|
|
|
- if (state && state->type == FX_UINT)
|
|
|
|
+ if (state && state->type == FX_UINT && state->values)
|
|
|
|
{
|
|
|
|
const struct rhs_named_value *ptr = state->values;
|
|
|
|
uint32_t value;
|
|
|
|
@@ -3993,13 +3986,14 @@ static void fx_parse_fx_2_assignment(struct fx_parser *parser, const struct fx_a
|
|
|
|
}
|
|
|
|
else if (state)
|
|
|
|
{
|
|
|
|
- if (state->type == FX_UINT || state->type == FX_FLOAT)
|
|
|
|
+ if (state->type == FX_UINT || state->type == FX_FLOAT || state->type == FX_BOOL)
|
|
|
|
{
|
|
|
|
- uint32_t offset = entry->type;
|
|
|
|
+ uint32_t offset = entry->type, base_type;
|
|
|
|
unsigned int size;
|
|
|
|
|
|
|
|
size = fx_get_fx_2_type_size(parser, &offset);
|
|
|
|
- parse_fx_2_numeric_value(parser, entry->value, size, entry->type);
|
|
|
|
+ fx_parser_read_unstructured(parser, &base_type, entry->type, sizeof(base_type));
|
|
|
|
+ parse_fx_2_numeric_value(parser, entry->value, size, base_type);
|
|
|
|
}
|
|
|
|
else if (state->type == FX_VERTEXSHADER || state->type == FX_PIXELSHADER)
|
|
|
|
{
|
|
|
|
@@ -4540,6 +4534,11 @@ static void fx_parse_fx_4_numeric_variables(struct fx_parser *parser, uint32_t c
|
|
|
|
semantic = fx_4_get_string(parser, var.semantic);
|
|
|
|
vkd3d_string_buffer_printf(&parser->buffer, " : %s", semantic);
|
|
|
|
}
|
|
|
|
+ if (var.flags & FX_4_HAS_EXPLICIT_BIND_POINT)
|
|
|
|
+ {
|
|
|
|
+ vkd3d_string_buffer_printf(&parser->buffer, " : packoffset(c%u.%c)",
|
|
|
|
+ var.offset / 16, "xyzw"[(var.offset % 16) / 4]);
|
|
|
|
+ }
|
|
|
|
fx_parse_fx_4_annotations(parser);
|
|
|
|
|
|
|
|
if (var.value)
|
|
|
|
@@ -4575,6 +4574,8 @@ static void fx_parse_buffers(struct fx_parser *parser)
|
|
|
|
name = fx_4_get_string(parser, buffer.name);
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(&parser->buffer, "cbuffer %s", name);
|
|
|
|
+ if (buffer.bind_point != ~0u)
|
|
|
|
+ vkd3d_string_buffer_printf(&parser->buffer, " : register(b%u)", buffer.bind_point);
|
|
|
|
fx_parse_fx_4_annotations(parser);
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(&parser->buffer, "\n{\n");
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
|
|
|
index e4497b9ac5b..0a91024a8d1 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
|
|
|
@@ -421,6 +421,9 @@ static void shader_glsl_print_src(struct vkd3d_string_buffer *buffer, struct vkd
|
|
|
|
case VKD3DSPSM_ABS:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "abs(%s)", str->buffer);
|
|
|
|
break;
|
|
|
|
+ case VKD3DSPSM_ABSNEG:
|
|
|
|
+ vkd3d_string_buffer_printf(buffer, "-abs(%s)", str->buffer);
|
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "<unhandled modifier %#x>(%s)",
|
|
|
|
vsir_src->modifiers, str->buffer);
|
|
|
|
@@ -495,6 +498,9 @@ static void VKD3D_PRINTF_FUNC(4, 0) shader_glsl_vprint_assignment(struct vkd3d_g
|
|
|
|
uint32_t modifiers = dst->vsir->modifiers;
|
|
|
|
bool close = true;
|
|
|
|
|
|
|
|
+ /* It is always legitimate to ignore _pp. */
|
|
|
|
+ modifiers &= ~VKD3DSPDM_PARTIALPRECISION;
|
|
|
|
+
|
|
|
|
if (dst->vsir->shift)
|
|
|
|
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
|
|
|
"Internal compiler error: Unhandled destination shift %#x.", dst->vsir->shift);
|
|
|
|
@@ -2313,7 +2319,7 @@ static void shader_glsl_handle_global_flags(struct vkd3d_string_buffer *buffer,
|
|
|
|
flags &= ~VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (flags)
|
|
|
|
+ if (flags & ~VKD3DSGF_REFACTORING_ALLOWED)
|
|
|
|
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
|
|
|
"Internal compiler error: Unhandled global flags %#"PRIx64".", (uint64_t)flags);
|
|
|
|
}
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
|
|
|
index 58f579cd9f9..63c9733ec7b 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
|
|
|
@@ -245,6 +245,7 @@ struct hlsl_semantic
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
uint32_t index;
|
|
|
|
+ uint32_t stream_index;
|
|
|
|
|
|
|
|
/* Name exactly as it appears in the sources. */
|
|
|
|
const char *raw_name;
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
|
|
|
index e9d3d2ec8dd..d4cd338f15a 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
|
|
|
@@ -288,7 +288,8 @@ static bool types_are_semantic_equivalent(struct hlsl_ctx *ctx, const struct hls
|
|
|
|
|
|
|
|
static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *func,
|
|
|
|
struct hlsl_ir_var *var, struct hlsl_type *type, uint32_t modifiers, struct hlsl_semantic *semantic,
|
|
|
|
- uint32_t index, bool output, bool force_align, bool create, const struct vkd3d_shader_location *loc)
|
|
|
|
+ uint32_t index, uint32_t stream_index, bool output, bool force_align, bool create,
|
|
|
|
+ const struct vkd3d_shader_location *loc)
|
|
|
|
{
|
|
|
|
struct hlsl_semantic new_semantic;
|
|
|
|
struct hlsl_ir_var *ext_var;
|
|
|
|
@@ -300,7 +301,12 @@ static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir
|
|
|
|
else
|
|
|
|
prefix = output ? "output" : "input";
|
|
|
|
|
|
|
|
- if (!(new_name = hlsl_sprintf_alloc(ctx, "<%s-%s%u>", prefix, semantic->name, index)))
|
|
|
|
+ if (stream_index)
|
|
|
|
+ new_name = hlsl_sprintf_alloc(ctx, "<%s-m%u:%s%u>", prefix, stream_index, semantic->name, index);
|
|
|
|
+ else
|
|
|
|
+ new_name = hlsl_sprintf_alloc(ctx, "<%s-%s%u>", prefix, semantic->name, index);
|
|
|
|
+
|
|
|
|
+ if (!new_name)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(ext_var, &func->extern_vars, struct hlsl_ir_var, extern_entry)
|
|
|
|
@@ -353,6 +359,7 @@ static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
new_semantic.index = index;
|
|
|
|
+ new_semantic.stream_index = stream_index;
|
|
|
|
if (!(ext_var = hlsl_new_var(ctx, new_name, type, loc, &new_semantic, modifiers, NULL)))
|
|
|
|
{
|
|
|
|
vkd3d_free(new_name);
|
|
|
|
@@ -435,7 +442,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_dec
|
|
|
|
prim_type_src->modifiers = var->data_type->modifiers & HLSL_PRIMITIVE_MODIFIERS_MASK;
|
|
|
|
|
|
|
|
if (!(input = add_semantic_var(ctx, func, var, prim_type_src,
|
|
|
|
- modifiers, semantic, semantic_index + i, false, force_align, true, loc)))
|
|
|
|
+ modifiers, semantic, semantic_index + i, 0, false, force_align, true, loc)))
|
|
|
|
return;
|
|
|
|
hlsl_init_simple_deref_from_var(&prim_deref, input);
|
|
|
|
|
|
|
|
@@ -448,7 +455,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_dec
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(input = add_semantic_var(ctx, func, var, vector_type_src,
|
|
|
|
- modifiers, semantic, semantic_index + i, false, force_align, true, loc)))
|
|
|
|
+ modifiers, semantic, semantic_index + i, 0, false, force_align, true, loc)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(load = hlsl_new_var_load(ctx, input, &var->loc)))
|
|
|
|
@@ -558,7 +565,7 @@ static void prepend_input_var_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function
|
|
|
|
|
|
|
|
static void append_output_copy(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
|
|
|
struct hlsl_ir_function_decl *func, struct hlsl_ir_load *rhs, uint32_t modifiers,
|
|
|
|
- struct hlsl_semantic *semantic, uint32_t semantic_index, bool force_align, bool create)
|
|
|
|
+ struct hlsl_semantic *semantic, uint32_t semantic_index, uint32_t stream_index, bool force_align, bool create)
|
|
|
|
{
|
|
|
|
struct hlsl_type *type = rhs->node.data_type, *vector_type;
|
|
|
|
struct vkd3d_shader_location *loc = &rhs->node.loc;
|
|
|
|
@@ -588,7 +595,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
|
|
|
struct hlsl_ir_node *load;
|
|
|
|
|
|
|
|
if (!(output = add_semantic_var(ctx, func, var, vector_type,
|
|
|
|
- modifiers, semantic, semantic_index + i, true, force_align, create, loc)))
|
|
|
|
+ modifiers, semantic, semantic_index + i, stream_index, true, force_align, create, loc)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (type->class == HLSL_CLASS_MATRIX)
|
|
|
|
@@ -609,7 +616,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
|
|
|
|
|
|
|
static void append_output_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
|
|
|
struct hlsl_ir_function_decl *func, const struct hlsl_type *type, struct hlsl_ir_load *rhs, uint32_t modifiers,
|
|
|
|
- struct hlsl_semantic *semantic, uint32_t semantic_index, bool force_align, bool create)
|
|
|
|
+ struct hlsl_semantic *semantic, uint32_t semantic_index, uint32_t stream_index, bool force_align, bool create)
|
|
|
|
{
|
|
|
|
struct vkd3d_shader_location *loc = &rhs->node.loc;
|
|
|
|
struct hlsl_ir_var *var = rhs->src.var;
|
|
|
|
@@ -654,12 +661,13 @@ static void append_output_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_block *
|
|
|
|
hlsl_block_add_instr(block, &element_load->node);
|
|
|
|
|
|
|
|
append_output_copy_recurse(ctx, block, func, element_type, element_load, element_modifiers, semantic,
|
|
|
|
- elem_semantic_index, force_align, create);
|
|
|
|
+ elem_semantic_index, stream_index, force_align, create);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
- append_output_copy(ctx, block, func, rhs, modifiers, semantic, semantic_index, force_align, create);
|
|
|
|
+ append_output_copy(ctx, block, func, rhs, modifiers, semantic,
|
|
|
|
+ semantic_index, stream_index, force_align, create);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -676,7 +684,7 @@ static void append_output_var_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function
|
|
|
|
hlsl_block_add_instr(&func->body, &load->node);
|
|
|
|
|
|
|
|
append_output_copy_recurse(ctx, &func->body, func, var->data_type, load, var->storage_modifiers,
|
|
|
|
- &var->semantic, var->semantic.index, false, true);
|
|
|
|
+ &var->semantic, var->semantic.index, 0, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hlsl_transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *),
|
|
|
|
@@ -3360,7 +3368,7 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
|
|
|
|
struct stream_append_ctx
|
|
|
|
{
|
|
|
|
struct hlsl_ir_function_decl *func;
|
|
|
|
- bool created;
|
|
|
|
+ bool created[VKD3D_MAX_STREAM_COUNT];
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool lower_stream_appends(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
|
|
|
@@ -3371,6 +3379,7 @@ static bool lower_stream_appends(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
|
|
|
|
const struct hlsl_type *type;
|
|
|
|
struct hlsl_ir_var *var;
|
|
|
|
struct hlsl_block block;
|
|
|
|
+ uint32_t stream_index;
|
|
|
|
|
|
|
|
if (instr->type != HLSL_IR_RESOURCE_STORE)
|
|
|
|
return false;
|
|
|
|
@@ -3390,18 +3399,17 @@ static bool lower_stream_appends(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
|
|
|
|
}
|
|
|
|
|
|
|
|
VKD3D_ASSERT(var->regs[HLSL_REGSET_STREAM_OUTPUTS].allocated);
|
|
|
|
+ stream_index = var->regs[HLSL_REGSET_STREAM_OUTPUTS].index;
|
|
|
|
|
|
|
|
- if (var->regs[HLSL_REGSET_STREAM_OUTPUTS].index)
|
|
|
|
- {
|
|
|
|
- hlsl_fixme(ctx, &instr->loc, "Append to an output stream with a nonzero stream index.");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
+ VKD3D_ASSERT(stream_index < ARRAY_SIZE(append_ctx->created));
|
|
|
|
|
|
|
|
hlsl_block_init(&block);
|
|
|
|
|
|
|
|
- append_output_copy_recurse(ctx, &block, append_ctx->func, type->e.so.type, hlsl_ir_load(rhs), var->storage_modifiers,
|
|
|
|
- &var->semantic, var->semantic.index, false, !append_ctx->created);
|
|
|
|
- append_ctx->created = true;
|
|
|
|
+ append_output_copy_recurse(ctx, &block, append_ctx->func, type->e.so.type, hlsl_ir_load(rhs),
|
|
|
|
+ var->storage_modifiers, &var->semantic, var->semantic.index,
|
|
|
|
+ var->regs[HLSL_REGSET_STREAM_OUTPUTS].index, false, !append_ctx->created[stream_index]);
|
|
|
|
+
|
|
|
|
+ append_ctx->created[stream_index] = true;
|
|
|
|
|
|
|
|
list_move_before(&instr->entry, &block.instrs);
|
|
|
|
hlsl_src_remove(&store->value);
|
|
|
|
@@ -6456,6 +6464,8 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
|
|
|
|
|
|
|
|
if ((!output && !var->last_read) || (output && !var->first_write))
|
|
|
|
return;
|
|
|
|
+
|
|
|
|
+ optimize = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
@@ -6518,8 +6528,8 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
|
|
|
|
static void allocate_semantic_registers(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func,
|
|
|
|
uint32_t *output_reg_count)
|
|
|
|
{
|
|
|
|
+ struct register_allocator input_allocator = {0}, output_allocators[VKD3D_MAX_STREAM_COUNT] = {{0}};
|
|
|
|
struct register_allocator in_prim_allocator = {0}, patch_constant_out_patch_allocator = {0};
|
|
|
|
- struct register_allocator input_allocator = {0}, output_allocator = {0};
|
|
|
|
bool is_vertex_shader = ctx->profile->type == VKD3D_SHADER_TYPE_VERTEX;
|
|
|
|
bool is_pixel_shader = ctx->profile->type == VKD3D_SHADER_TYPE_PIXEL;
|
|
|
|
struct hlsl_ir_var *var;
|
|
|
|
@@ -6527,7 +6537,8 @@ static void allocate_semantic_registers(struct hlsl_ctx *ctx, struct hlsl_ir_fun
|
|
|
|
in_prim_allocator.prioritize_smaller_writemasks = true;
|
|
|
|
patch_constant_out_patch_allocator.prioritize_smaller_writemasks = true;
|
|
|
|
input_allocator.prioritize_smaller_writemasks = true;
|
|
|
|
- output_allocator.prioritize_smaller_writemasks = true;
|
|
|
|
+ for (unsigned int i = 0; i < ARRAY_SIZE(output_allocators); ++i)
|
|
|
|
+ output_allocators[i].prioritize_smaller_writemasks = true;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(var, &entry_func->extern_vars, struct hlsl_ir_var, extern_entry)
|
|
|
|
{
|
|
|
|
@@ -6550,15 +6561,22 @@ static void allocate_semantic_registers(struct hlsl_ctx *ctx, struct hlsl_ir_fun
|
|
|
|
}
|
|
|
|
|
|
|
|
if (var->is_output_semantic)
|
|
|
|
- allocate_semantic_register(ctx, var, &output_allocator, true, !is_pixel_shader);
|
|
|
|
+ {
|
|
|
|
+ VKD3D_ASSERT(var->semantic.stream_index < ARRAY_SIZE(output_allocators));
|
|
|
|
+ allocate_semantic_register(ctx, var, &output_allocators[var->semantic.stream_index],
|
|
|
|
+ true, !is_pixel_shader);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
- *output_reg_count = output_allocator.reg_count;
|
|
|
|
+ *output_reg_count = output_allocators[0].reg_count;
|
|
|
|
+ for (unsigned int i = 1; i < ARRAY_SIZE(output_allocators); ++i)
|
|
|
|
+ *output_reg_count = max(*output_reg_count, output_allocators[i].reg_count);
|
|
|
|
|
|
|
|
vkd3d_free(in_prim_allocator.allocations);
|
|
|
|
vkd3d_free(patch_constant_out_patch_allocator.allocations);
|
|
|
|
vkd3d_free(input_allocator.allocations);
|
|
|
|
- vkd3d_free(output_allocator.allocations);
|
|
|
|
+ for (unsigned int i = 0; i < ARRAY_SIZE(output_allocators); ++i)
|
|
|
|
+ vkd3d_free(output_allocators[i].allocations);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct hlsl_buffer *get_reserved_buffer(struct hlsl_ctx *ctx,
|
|
|
|
@@ -8018,6 +8036,7 @@ static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_prog
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
element->semantic_index = var->semantic.index;
|
|
|
|
+ element->stream_index = var->semantic.stream_index;
|
|
|
|
element->sysval_semantic = sysval;
|
|
|
|
element->component_type = component_type;
|
|
|
|
element->register_index = register_index;
|
|
|
|
@@ -8485,6 +8504,14 @@ static bool sm4_generate_vsir_reg_from_deref(struct hlsl_ctx *ctx, struct vsir_p
|
|
|
|
VKD3D_ASSERT(regset == HLSL_REGSET_SAMPLERS);
|
|
|
|
*writemask = VKD3DSP_WRITEMASK_ALL;
|
|
|
|
}
|
|
|
|
+ else if (regset == HLSL_REGSET_STREAM_OUTPUTS)
|
|
|
|
+ {
|
|
|
|
+ reg->type = VKD3DSPR_STREAM;
|
|
|
|
+ reg->dimension = VSIR_DIMENSION_NONE;
|
|
|
|
+ reg->idx[0].offset = var->regs[HLSL_REGSET_STREAM_OUTPUTS].index;
|
|
|
|
+ reg->idx_count = 1;
|
|
|
|
+ *writemask = VKD3DSP_WRITEMASK_ALL;
|
|
|
|
+ }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned int offset = deref->const_offset + var->buffer_offset;
|
|
|
|
@@ -9279,16 +9306,16 @@ static void sm1_generate_vsir_instr_resource_load(struct hlsl_ctx *ctx,
|
|
|
|
switch (load->load_type)
|
|
|
|
{
|
|
|
|
case HLSL_RESOURCE_SAMPLE:
|
|
|
|
- opcode = VKD3DSIH_TEX;
|
|
|
|
+ opcode = VKD3DSIH_TEXLD;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HLSL_RESOURCE_SAMPLE_PROJ:
|
|
|
|
- opcode = VKD3DSIH_TEX;
|
|
|
|
+ opcode = VKD3DSIH_TEXLD;
|
|
|
|
flags |= VKD3DSI_TEXLD_PROJECT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HLSL_RESOURCE_SAMPLE_LOD_BIAS:
|
|
|
|
- opcode = VKD3DSIH_TEX;
|
|
|
|
+ opcode = VKD3DSIH_TEXLD;
|
|
|
|
flags |= VKD3DSI_TEXLD_BIAS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
@@ -9922,6 +9949,57 @@ static void sm1_generate_ctab(struct hlsl_ctx *ctx, struct vkd3d_shader_code *ct
|
|
|
|
ctab->size = buffer.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static enum vkd3d_shader_input_sysval_semantic vkd3d_siv_from_sysval_indexed(enum vkd3d_shader_sysval_semantic sysval,
|
|
|
|
+ unsigned int index)
|
|
|
|
+{
|
|
|
|
+ switch (sysval)
|
|
|
|
+ {
|
|
|
|
+ case VKD3D_SHADER_SV_COVERAGE:
|
|
|
|
+ case VKD3D_SHADER_SV_DEPTH:
|
|
|
|
+ case VKD3D_SHADER_SV_DEPTH_GREATER_EQUAL:
|
|
|
|
+ case VKD3D_SHADER_SV_DEPTH_LESS_EQUAL:
|
|
|
|
+ case VKD3D_SHADER_SV_NONE:
|
|
|
|
+ case VKD3D_SHADER_SV_STENCIL_REF:
|
|
|
|
+ case VKD3D_SHADER_SV_TARGET:
|
|
|
|
+ return VKD3D_SIV_NONE;
|
|
|
|
+ case VKD3D_SHADER_SV_POSITION:
|
|
|
|
+ return VKD3D_SIV_POSITION;
|
|
|
|
+ case VKD3D_SHADER_SV_CLIP_DISTANCE:
|
|
|
|
+ return VKD3D_SIV_CLIP_DISTANCE;
|
|
|
|
+ case VKD3D_SHADER_SV_CULL_DISTANCE:
|
|
|
|
+ return VKD3D_SIV_CULL_DISTANCE;
|
|
|
|
+ case VKD3D_SHADER_SV_INSTANCE_ID:
|
|
|
|
+ return VKD3D_SIV_INSTANCE_ID;
|
|
|
|
+ case VKD3D_SHADER_SV_IS_FRONT_FACE:
|
|
|
|
+ return VKD3D_SIV_IS_FRONT_FACE;
|
|
|
|
+ case VKD3D_SHADER_SV_PRIMITIVE_ID:
|
|
|
|
+ return VKD3D_SIV_PRIMITIVE_ID;
|
|
|
|
+ case VKD3D_SHADER_SV_RENDER_TARGET_ARRAY_INDEX:
|
|
|
|
+ return VKD3D_SIV_RENDER_TARGET_ARRAY_INDEX;
|
|
|
|
+ case VKD3D_SHADER_SV_SAMPLE_INDEX:
|
|
|
|
+ return VKD3D_SIV_SAMPLE_INDEX;
|
|
|
|
+ case VKD3D_SHADER_SV_TESS_FACTOR_QUADEDGE:
|
|
|
|
+ return VKD3D_SIV_QUAD_U0_TESS_FACTOR + index;
|
|
|
|
+ case VKD3D_SHADER_SV_TESS_FACTOR_QUADINT:
|
|
|
|
+ return VKD3D_SIV_QUAD_U_INNER_TESS_FACTOR + index;
|
|
|
|
+ case VKD3D_SHADER_SV_TESS_FACTOR_TRIEDGE:
|
|
|
|
+ return VKD3D_SIV_TRIANGLE_U_TESS_FACTOR + index;
|
|
|
|
+ case VKD3D_SHADER_SV_TESS_FACTOR_TRIINT:
|
|
|
|
+ return VKD3D_SIV_TRIANGLE_INNER_TESS_FACTOR;
|
|
|
|
+ case VKD3D_SHADER_SV_TESS_FACTOR_LINEDET:
|
|
|
|
+ return VKD3D_SIV_LINE_DETAIL_TESS_FACTOR;
|
|
|
|
+ case VKD3D_SHADER_SV_TESS_FACTOR_LINEDEN:
|
|
|
|
+ return VKD3D_SIV_LINE_DENSITY_TESS_FACTOR;
|
|
|
|
+ case VKD3D_SHADER_SV_VERTEX_ID:
|
|
|
|
+ return VKD3D_SIV_VERTEX_ID;
|
|
|
|
+ case VKD3D_SHADER_SV_VIEWPORT_ARRAY_INDEX:
|
|
|
|
+ return VKD3D_SIV_VIEWPORT_ARRAY_INDEX;
|
|
|
|
+ default:
|
|
|
|
+ FIXME("Unhandled sysval %#x, index %u.\n", sysval, index);
|
|
|
|
+ return VKD3D_SIV_NONE;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static void sm4_generate_vsir_instr_dcl_semantic(struct hlsl_ctx *ctx, struct vsir_program *program,
|
|
|
|
const struct hlsl_ir_var *var, struct hlsl_block *block, const struct vkd3d_shader_location *loc)
|
|
|
|
{
|
|
|
|
@@ -10835,20 +10913,27 @@ static bool sm4_generate_vsir_instr_resource_store(struct hlsl_ctx *ctx,
|
|
|
|
|
|
|
|
if (store->store_type != HLSL_RESOURCE_STORE)
|
|
|
|
{
|
|
|
|
- enum vkd3d_shader_opcode opcode = store->store_type == HLSL_RESOURCE_STREAM_APPEND
|
|
|
|
- ? VKD3DSIH_EMIT : VKD3DSIH_CUT;
|
|
|
|
+ enum vkd3d_shader_opcode opcode;
|
|
|
|
|
|
|
|
VKD3D_ASSERT(!store->value.node && !store->coords.node);
|
|
|
|
VKD3D_ASSERT(store->resource.var->regs[HLSL_REGSET_STREAM_OUTPUTS].allocated);
|
|
|
|
|
|
|
|
- if (store->resource.var->regs[HLSL_REGSET_STREAM_OUTPUTS].index)
|
|
|
|
+ if (hlsl_version_lt(ctx, 5, 0))
|
|
|
|
{
|
|
|
|
- hlsl_fixme(ctx, &instr->loc, "Stream output operation with a nonzero stream index.");
|
|
|
|
- return false;
|
|
|
|
+ opcode = store->store_type == HLSL_RESOURCE_STREAM_APPEND ? VKD3DSIH_EMIT : VKD3DSIH_CUT;
|
|
|
|
+ ins = generate_vsir_add_program_instruction(ctx, program, &store->node.loc, opcode, 0, 0);
|
|
|
|
+ return !!ins;
|
|
|
|
}
|
|
|
|
|
|
|
|
- ins = generate_vsir_add_program_instruction(ctx, program, &store->node.loc, opcode, 0, 0);
|
|
|
|
- return !!ins;
|
|
|
|
+ opcode = store->store_type == HLSL_RESOURCE_STREAM_APPEND ? VKD3DSIH_EMIT_STREAM : VKD3DSIH_CUT_STREAM;
|
|
|
|
+ if (!(ins = generate_vsir_add_program_instruction(ctx, program, &store->node.loc, opcode, 0, 1)))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ if (!sm4_generate_vsir_init_src_param_from_deref(ctx, program, &ins->src[0],
|
|
|
|
+ &store->resource, VKD3DSP_WRITEMASK_ALL, &instr->loc))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!store->resource.var->is_uniform)
|
|
|
|
@@ -12130,6 +12215,22 @@ static void sm4_generate_vsir_add_dcl_texture(struct hlsl_ctx *ctx,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void sm4_generate_vsir_add_dcl_stream(struct hlsl_ctx *ctx,
|
|
|
|
+ struct vsir_program *program, const struct hlsl_ir_var *var)
|
|
|
|
+{
|
|
|
|
+ struct vkd3d_shader_instruction *ins;
|
|
|
|
+
|
|
|
|
+ if (!(ins = generate_vsir_add_program_instruction(ctx, program, &var->loc, VKD3DSIH_DCL_STREAM, 0, 1)))
|
|
|
|
+ {
|
|
|
|
+ ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ vsir_src_param_init(&ins->src[0], VKD3DSPR_STREAM, VKD3D_DATA_OPAQUE, 1);
|
|
|
|
+ ins->src[0].reg.dimension = VSIR_DIMENSION_NONE;
|
|
|
|
+ ins->src[0].reg.idx[0].offset = var->regs[HLSL_REGSET_STREAM_OUTPUTS].index;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* OBJECTIVE: Translate all the information from ctx and entry_func to the
|
|
|
|
* vsir_program, so it can be used as input to tpf_compile() without relying
|
|
|
|
* on ctx and entry_func. */
|
|
|
|
@@ -12204,6 +12305,17 @@ static void sm4_generate_vsir(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
|
|
|
|
}
|
|
|
|
sm4_free_extern_resources(extern_resources, extern_resources_count);
|
|
|
|
|
|
|
|
+ if (version.type == VKD3D_SHADER_TYPE_GEOMETRY && version.major >= 5)
|
|
|
|
+ {
|
|
|
|
+ const struct hlsl_ir_var *var;
|
|
|
|
+
|
|
|
|
+ LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
|
|
|
+ {
|
|
|
|
+ if (var->bind_count[HLSL_REGSET_STREAM_OUTPUTS])
|
|
|
|
+ sm4_generate_vsir_add_dcl_stream(ctx, program, var);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (version.type == VKD3D_SHADER_TYPE_HULL)
|
|
|
|
generate_vsir_add_program_instruction(ctx, program,
|
|
|
|
&ctx->patch_constant_func->loc, VKD3DSIH_HS_CONTROL_POINT_PHASE, 0, 0);
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
|
|
|
index a6f17d4a834..4abf6a65dbb 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
|
|
|
@@ -823,7 +823,7 @@ static enum vkd3d_result vsir_program_lower_texldp(struct vsir_program *program,
|
|
|
|
div_ins->src[1] = tex->src[0];
|
|
|
|
div_ins->src[1].swizzle = vkd3d_shader_create_swizzle(w_comp, w_comp, w_comp, w_comp);
|
|
|
|
|
|
|
|
- if (!vsir_instruction_init_with_params(program, tex_ins, location, VKD3DSIH_TEX, 1, 2))
|
|
|
|
+ if (!vsir_instruction_init_with_params(program, tex_ins, location, VKD3DSIH_TEXLD, 1, 2))
|
|
|
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
tex_ins->dst[0] = tex->dst[0];
|
|
|
|
@@ -838,7 +838,7 @@ static enum vkd3d_result vsir_program_lower_texldp(struct vsir_program *program,
|
|
|
|
return VKD3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static enum vkd3d_result vsir_program_lower_tex(struct vsir_program *program,
|
|
|
|
+static enum vkd3d_result vsir_program_lower_texld(struct vsir_program *program,
|
|
|
|
struct vkd3d_shader_instruction *tex, struct vkd3d_shader_message_context *message_context)
|
|
|
|
{
|
|
|
|
unsigned int idx = tex->src[1].reg.idx[0].offset;
|
|
|
|
@@ -1041,7 +1041,7 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr
|
|
|
|
return ret;
|
|
|
|
break;
|
|
|
|
|
|
|
|
- case VKD3DSIH_TEX:
|
|
|
|
+ case VKD3DSIH_TEXLD:
|
|
|
|
if (ins->flags == VKD3DSI_TEXLD_PROJECT)
|
|
|
|
{
|
|
|
|
if ((ret = vsir_program_lower_texldp(program, ins, &tmp_idx)) < 0)
|
|
|
|
@@ -1049,7 +1049,7 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
- if ((ret = vsir_program_lower_tex(program, ins, message_context)) < 0)
|
|
|
|
+ if ((ret = vsir_program_lower_texld(program, ins, message_context)) < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
@@ -1062,6 +1062,7 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr
|
|
|
|
case VKD3DSIH_TEXBEM:
|
|
|
|
case VKD3DSIH_TEXBEML:
|
|
|
|
case VKD3DSIH_TEXCOORD:
|
|
|
|
+ case VKD3DSIH_TEXCRD:
|
|
|
|
case VKD3DSIH_TEXDEPTH:
|
|
|
|
case VKD3DSIH_TEXDP3:
|
|
|
|
case VKD3DSIH_TEXDP3TEX:
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/msl.c b/libs/vkd3d/libs/vkd3d-shader/msl.c
|
|
|
|
index 4f37468af86..d354c7efcb1 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/msl.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/msl.c
|
|
|
|
@@ -488,6 +488,9 @@ static void msl_print_src_with_type(struct vkd3d_string_buffer *buffer, struct m
|
|
|
|
case VKD3DSPSM_ABS:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "abs(%s)", str->buffer);
|
|
|
|
break;
|
|
|
|
+ case VKD3DSPSM_ABSNEG:
|
|
|
|
+ vkd3d_string_buffer_printf(buffer, "-abs(%s)", str->buffer);
|
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
vkd3d_string_buffer_printf(buffer, "<unhandled modifier %#x>(%s)",
|
|
|
|
vsir_src->modifiers, str->buffer);
|
|
|
|
@@ -545,6 +548,9 @@ static void VKD3D_PRINTF_FUNC(3, 4) msl_print_assignment(
|
|
|
|
uint32_t modifiers = dst->vsir->modifiers;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
+ /* It is always legitimate to ignore _pp. */
|
|
|
|
+ modifiers &= ~VKD3DSPDM_PARTIALPRECISION;
|
|
|
|
+
|
|
|
|
if (dst->vsir->shift)
|
|
|
|
msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
|
|
|
"Internal compiler error: Unhandled destination shift %#x.", dst->vsir->shift);
|
|
|
|
@@ -1353,7 +1359,7 @@ static int msl_generator_generate(struct msl_generator *gen, struct vkd3d_shader
|
|
|
|
vkd3d_string_buffer_printf(gen->buffer, "#include <metal_texture>\n\n");
|
|
|
|
vkd3d_string_buffer_printf(gen->buffer, "using namespace metal;\n\n");
|
|
|
|
|
|
|
|
- if (gen->program->global_flags)
|
|
|
|
+ if (gen->program->global_flags & ~VKD3DSGF_REFACTORING_ALLOWED)
|
|
|
|
msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
|
|
|
"Internal compiler error: Unhandled global flags %#"PRIx64".", (uint64_t)gen->program->global_flags);
|
|
|
|
|
|
|
|
@@ -1388,7 +1394,7 @@ static int msl_generator_generate(struct msl_generator *gen, struct vkd3d_shader
|
|
|
|
msl_generate_output_struct_declarations(gen);
|
|
|
|
|
|
|
|
vkd3d_string_buffer_printf(gen->buffer,
|
|
|
|
- "void %s_main(thread vkd3d_vec4 *v, "
|
|
|
|
+ "static void %s_main(thread vkd3d_vec4 *v, "
|
|
|
|
"thread vkd3d_vec4 *o",
|
|
|
|
gen->prefix);
|
|
|
|
if (gen->write_depth)
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
|
|
index a6f34703c2d..3e58718afa1 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
|
|
@@ -847,57 +847,6 @@ static void vkd3d_spirv_dump(const struct vkd3d_shader_code *spirv, enum vkd3d_s
|
|
|
|
vkd3d_shader_message_context_cleanup(&message_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
-enum vkd3d_shader_input_sysval_semantic vkd3d_siv_from_sysval_indexed(enum vkd3d_shader_sysval_semantic sysval,
|
|
|
|
- unsigned int index)
|
|
|
|
-{
|
|
|
|
- switch (sysval)
|
|
|
|
- {
|
|
|
|
- case VKD3D_SHADER_SV_COVERAGE:
|
|
|
|
- case VKD3D_SHADER_SV_DEPTH:
|
|
|
|
- case VKD3D_SHADER_SV_DEPTH_GREATER_EQUAL:
|
|
|
|
- case VKD3D_SHADER_SV_DEPTH_LESS_EQUAL:
|
|
|
|
- case VKD3D_SHADER_SV_NONE:
|
|
|
|
- case VKD3D_SHADER_SV_STENCIL_REF:
|
|
|
|
- case VKD3D_SHADER_SV_TARGET:
|
|
|
|
- return VKD3D_SIV_NONE;
|
|
|
|
- case VKD3D_SHADER_SV_POSITION:
|
|
|
|
- return VKD3D_SIV_POSITION;
|
|
|
|
- case VKD3D_SHADER_SV_CLIP_DISTANCE:
|
|
|
|
- return VKD3D_SIV_CLIP_DISTANCE;
|
|
|
|
- case VKD3D_SHADER_SV_CULL_DISTANCE:
|
|
|
|
- return VKD3D_SIV_CULL_DISTANCE;
|
|
|
|
- case VKD3D_SHADER_SV_INSTANCE_ID:
|
|
|
|
- return VKD3D_SIV_INSTANCE_ID;
|
|
|
|
- case VKD3D_SHADER_SV_IS_FRONT_FACE:
|
|
|
|
- return VKD3D_SIV_IS_FRONT_FACE;
|
|
|
|
- case VKD3D_SHADER_SV_PRIMITIVE_ID:
|
|
|
|
- return VKD3D_SIV_PRIMITIVE_ID;
|
|
|
|
- case VKD3D_SHADER_SV_RENDER_TARGET_ARRAY_INDEX:
|
|
|
|
- return VKD3D_SIV_RENDER_TARGET_ARRAY_INDEX;
|
|
|
|
- case VKD3D_SHADER_SV_SAMPLE_INDEX:
|
|
|
|
- return VKD3D_SIV_SAMPLE_INDEX;
|
|
|
|
- case VKD3D_SHADER_SV_TESS_FACTOR_QUADEDGE:
|
|
|
|
- return VKD3D_SIV_QUAD_U0_TESS_FACTOR + index;
|
|
|
|
- case VKD3D_SHADER_SV_TESS_FACTOR_QUADINT:
|
|
|
|
- return VKD3D_SIV_QUAD_U_INNER_TESS_FACTOR + index;
|
|
|
|
- case VKD3D_SHADER_SV_TESS_FACTOR_TRIEDGE:
|
|
|
|
- return VKD3D_SIV_TRIANGLE_U_TESS_FACTOR + index;
|
|
|
|
- case VKD3D_SHADER_SV_TESS_FACTOR_TRIINT:
|
|
|
|
- return VKD3D_SIV_TRIANGLE_INNER_TESS_FACTOR;
|
|
|
|
- case VKD3D_SHADER_SV_TESS_FACTOR_LINEDET:
|
|
|
|
- return VKD3D_SIV_LINE_DETAIL_TESS_FACTOR;
|
|
|
|
- case VKD3D_SHADER_SV_TESS_FACTOR_LINEDEN:
|
|
|
|
- return VKD3D_SIV_LINE_DENSITY_TESS_FACTOR;
|
|
|
|
- case VKD3D_SHADER_SV_VERTEX_ID:
|
|
|
|
- return VKD3D_SIV_VERTEX_ID;
|
|
|
|
- case VKD3D_SHADER_SV_VIEWPORT_ARRAY_INDEX:
|
|
|
|
- return VKD3D_SIV_VIEWPORT_ARRAY_INDEX;
|
|
|
|
- default:
|
|
|
|
- FIXME("Unhandled sysval %#x, index %u.\n", sysval, index);
|
|
|
|
- return VKD3D_SIV_NONE;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
struct vkd3d_spirv_stream
|
|
|
|
{
|
|
|
|
uint32_t *words;
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/tpf.c b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
|
|
|
index 6042a76c3c4..08bdc3e645a 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
|
|
|
@@ -3261,6 +3261,8 @@ static int signature_element_pointer_compare(const void *x, const void *y)
|
|
|
|
const struct signature_element *f = *(const struct signature_element **)y;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
+ if ((ret = vkd3d_u32_compare(e->stream_index, f->stream_index)))
|
|
|
|
+ return ret;
|
|
|
|
if ((ret = vkd3d_u32_compare(e->register_index, f->register_index)))
|
|
|
|
return ret;
|
|
|
|
return vkd3d_u32_compare(e->mask, f->mask);
|
|
|
|
@@ -3269,12 +3271,17 @@ static int signature_element_pointer_compare(const void *x, const void *y)
|
|
|
|
static void tpf_write_signature(struct tpf_compiler *tpf, const struct shader_signature *signature, uint32_t tag)
|
|
|
|
{
|
|
|
|
bool has_minimum_precision = tpf->program->global_flags & VKD3DSGF_ENABLE_MINIMUM_PRECISION;
|
|
|
|
- bool output = tag == TAG_OSGN || (tag == TAG_PCSG
|
|
|
|
- && tpf->program->shader_version.type == VKD3D_SHADER_TYPE_HULL);
|
|
|
|
+ const struct vkd3d_shader_version *version = &tpf->program->shader_version;
|
|
|
|
const struct signature_element **sorted_elements;
|
|
|
|
struct vkd3d_bytecode_buffer buffer = {0};
|
|
|
|
+ bool has_stream_index, output;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
+ output = tag == TAG_OSGN || (tag == TAG_PCSG && version->type == VKD3D_SHADER_TYPE_HULL);
|
|
|
|
+ if (output && version->type == VKD3D_SHADER_TYPE_GEOMETRY && version->major >= 5)
|
|
|
|
+ tag = TAG_OSG5;
|
|
|
|
+ has_stream_index = tag == TAG_OSG5 || has_minimum_precision;
|
|
|
|
+
|
|
|
|
put_u32(&buffer, signature->element_count);
|
|
|
|
put_u32(&buffer, 8); /* unknown */
|
|
|
|
|
|
|
|
@@ -3297,8 +3304,8 @@ static void tpf_write_signature(struct tpf_compiler *tpf, const struct shader_si
|
|
|
|
if (sysval >= VKD3D_SHADER_SV_TARGET)
|
|
|
|
sysval = VKD3D_SHADER_SV_NONE;
|
|
|
|
|
|
|
|
- if (has_minimum_precision)
|
|
|
|
- put_u32(&buffer, 0); /* FIXME: stream index */
|
|
|
|
+ if (has_stream_index)
|
|
|
|
+ put_u32(&buffer, element->stream_index);
|
|
|
|
put_u32(&buffer, 0); /* name */
|
|
|
|
put_u32(&buffer, element->semantic_index);
|
|
|
|
put_u32(&buffer, sysval);
|
|
|
|
@@ -3312,13 +3319,16 @@ static void tpf_write_signature(struct tpf_compiler *tpf, const struct shader_si
|
|
|
|
for (i = 0; i < signature->element_count; ++i)
|
|
|
|
{
|
|
|
|
const struct signature_element *element = sorted_elements[i];
|
|
|
|
+ size_t name_index = 2 + i * 6;
|
|
|
|
size_t string_offset;
|
|
|
|
|
|
|
|
- string_offset = put_string(&buffer, element->semantic_name);
|
|
|
|
+ if (has_stream_index)
|
|
|
|
+ name_index += i + 1;
|
|
|
|
if (has_minimum_precision)
|
|
|
|
- set_u32(&buffer, (2 + i * 8 + 1) * sizeof(uint32_t), string_offset);
|
|
|
|
- else
|
|
|
|
- set_u32(&buffer, (2 + i * 6) * sizeof(uint32_t), string_offset);
|
|
|
|
+ name_index += i;
|
|
|
|
+
|
|
|
|
+ string_offset = put_string(&buffer, element->semantic_name);
|
|
|
|
+ set_u32(&buffer, name_index * sizeof(uint32_t), string_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_minimum_precision)
|
|
|
|
@@ -4176,6 +4186,8 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
|
|
|
|
case VKD3DSIH_CASE:
|
|
|
|
case VKD3DSIH_CONTINUE:
|
|
|
|
case VKD3DSIH_CUT:
|
|
|
|
+ case VKD3DSIH_CUT_STREAM:
|
|
|
|
+ case VKD3DSIH_DCL_STREAM:
|
|
|
|
case VKD3DSIH_DEFAULT:
|
|
|
|
case VKD3DSIH_DISCARD:
|
|
|
|
case VKD3DSIH_DIV:
|
|
|
|
@@ -4190,6 +4202,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
|
|
|
|
case VKD3DSIH_DSY_FINE:
|
|
|
|
case VKD3DSIH_ELSE:
|
|
|
|
case VKD3DSIH_EMIT:
|
|
|
|
+ case VKD3DSIH_EMIT_STREAM:
|
|
|
|
case VKD3DSIH_ENDIF:
|
|
|
|
case VKD3DSIH_ENDLOOP:
|
|
|
|
case VKD3DSIH_ENDSWITCH:
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
|
|
|
index 4f625e3fae5..783f4e6134c 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
|
|
|
@@ -1436,13 +1436,14 @@ static int vkd3d_shader_scan_instruction(struct vkd3d_shader_scan_context *conte
|
|
|
|
if (context->cf_info_count)
|
|
|
|
context->cf_info[context->cf_info_count - 1].inside_block = false;
|
|
|
|
break;
|
|
|
|
- case VKD3DSIH_TEX:
|
|
|
|
+ case VKD3DSIH_TEXLD:
|
|
|
|
if (context->version->major == 1)
|
|
|
|
sampler_reg = &instruction->dst[0].reg;
|
|
|
|
else
|
|
|
|
sampler_reg = &instruction->src[1].reg;
|
|
|
|
vkd3d_shader_scan_combined_sampler_usage(context, sampler_reg, sampler_reg);
|
|
|
|
break;
|
|
|
|
+ case VKD3DSIH_TEX:
|
|
|
|
case VKD3DSIH_TEXBEM:
|
|
|
|
case VKD3DSIH_TEXBEML:
|
|
|
|
case VKD3DSIH_TEXDP3TEX:
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
|
|
|
index d4d76266df2..5dd00f00fe8 100644
|
|
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
|
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
|
|
|
@@ -552,10 +552,12 @@ enum vkd3d_shader_opcode
|
|
|
|
VKD3DSIH_TEXBEM,
|
|
|
|
VKD3DSIH_TEXBEML,
|
|
|
|
VKD3DSIH_TEXCOORD,
|
|
|
|
+ VKD3DSIH_TEXCRD,
|
|
|
|
VKD3DSIH_TEXDEPTH,
|
|
|
|
VKD3DSIH_TEXDP3,
|
|
|
|
VKD3DSIH_TEXDP3TEX,
|
|
|
|
VKD3DSIH_TEXKILL,
|
|
|
|
+ VKD3DSIH_TEXLD,
|
|
|
|
VKD3DSIH_TEXLDD,
|
|
|
|
VKD3DSIH_TEXLDL,
|
|
|
|
VKD3DSIH_TEXM3x2DEPTH,
|
|
|
|
@@ -966,7 +968,7 @@ struct vkd3d_shader_register
|
|
|
|
enum vsir_dimension dimension;
|
|
|
|
/* known address alignment for optimisation, or zero */
|
|
|
|
unsigned int alignment;
|
|
|
|
- union
|
|
|
|
+ union vsir_immediate_constant
|
|
|
|
{
|
|
|
|
uint32_t immconst_u32[VKD3D_VEC4_SIZE];
|
|
|
|
float immconst_f32[VKD3D_VEC4_SIZE];
|
|
|
|
@@ -1781,14 +1783,6 @@ static inline bool component_type_is_64_bit(enum vkd3d_shader_component_type com
|
|
|
|
return component_type == VKD3D_SHADER_COMPONENT_DOUBLE || component_type == VKD3D_SHADER_COMPONENT_UINT64;
|
|
|
|
}
|
|
|
|
|
|
|
|
-enum vkd3d_shader_input_sysval_semantic vkd3d_siv_from_sysval_indexed(enum vkd3d_shader_sysval_semantic sysval,
|
|
|
|
- unsigned int index);
|
|
|
|
-
|
|
|
|
-static inline enum vkd3d_shader_input_sysval_semantic vkd3d_siv_from_sysval(enum vkd3d_shader_sysval_semantic sysval)
|
|
|
|
-{
|
|
|
|
- return vkd3d_siv_from_sysval_indexed(sysval, 0);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static inline unsigned int vsir_write_mask_get_component_idx(uint32_t write_mask)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
--
|
|
|
|
2.47.2
|
|
|
|
|