vkd3d-shader/hlsl: Implement typed UAV loads.

This commit is contained in:
Zebediah Figura 2021-08-15 12:05:54 -05:00 committed by Alexandre Julliard
parent 12e397de9a
commit 0a2aaa690e
Notes: Alexandre Julliard 2022-10-31 22:39:35 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/36
2 changed files with 24 additions and 9 deletions

View File

@ -786,7 +786,8 @@ static bool add_array_load(struct hlsl_ctx *ctx, struct list *instrs, struct hls
const struct hlsl_type *expr_type = array->data_type, *index_type = index->data_type;
struct hlsl_ir_expr *cast;
if (expr_type->type == HLSL_CLASS_OBJECT && expr_type->base_type == HLSL_TYPE_TEXTURE
if (expr_type->type == HLSL_CLASS_OBJECT
&& (expr_type->base_type == HLSL_TYPE_TEXTURE || expr_type->base_type == HLSL_TYPE_UAV)
&& expr_type->sampler_dim != HLSL_SAMPLER_DIM_GENERIC)
{
struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_LOAD};

View File

@ -855,6 +855,16 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct sm4_register *r
reg->idx_count = 1;
*writemask = VKD3DSP_WRITEMASK_ALL;
}
else if (data_type->type == HLSL_CLASS_OBJECT && data_type->base_type == HLSL_TYPE_UAV)
{
reg->type = VKD3D_SM5_RT_UAV;
reg->dim = VKD3D_SM4_DIMENSION_VEC4;
if (swizzle_type)
*swizzle_type = VKD3D_SM4_SWIZZLE_VEC4;
reg->idx[0] = var->reg.id;
reg->idx_count = 1;
*writemask = VKD3DSP_WRITEMASK_ALL;
}
else if (data_type->type == HLSL_CLASS_OBJECT && data_type->base_type == HLSL_TYPE_SAMPLER)
{
reg->type = VKD3D_SM4_RT_SAMPLER;
@ -1397,17 +1407,20 @@ static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf
const struct hlsl_type *resource_type, const struct hlsl_ir_node *dst,
const struct hlsl_deref *resource, const struct hlsl_ir_node *coords)
{
bool uav = (resource_type->base_type == HLSL_TYPE_UAV);
struct sm4_instruction instr;
unsigned int dim_count;
memset(&instr, 0, sizeof(instr));
instr.opcode = VKD3D_SM4_OP_LD;
instr.opcode = uav ? VKD3D_SM5_OP_LD_UAV_TYPED : VKD3D_SM4_OP_LD;
sm4_dst_from_node(&instr.dsts[0], dst);
instr.dst_count = 1;
sm4_src_from_node(&instr.srcs[0], coords, VKD3DSP_WRITEMASK_ALL);
if (!uav)
{
/* Mipmap level is in the last component in the IR, but needs to be in the W
* component in the instruction. */
dim_count = hlsl_sampler_dim_count(resource_type->sampler_dim);
@ -1415,6 +1428,7 @@ static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf
instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, X, X, Y), 4);
if (dim_count == 2)
instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, Y, X, Z), 4);
}
sm4_src_from_deref(ctx, &instr.srcs[1], resource, resource_type, instr.dsts[0].writemask);