mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Implement typed UAV loads.
This commit is contained in:
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
@ -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;
|
const struct hlsl_type *expr_type = array->data_type, *index_type = index->data_type;
|
||||||
struct hlsl_ir_expr *cast;
|
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)
|
&& expr_type->sampler_dim != HLSL_SAMPLER_DIM_GENERIC)
|
||||||
{
|
{
|
||||||
struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_LOAD};
|
struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_LOAD};
|
||||||
|
@ -855,6 +855,16 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct sm4_register *r
|
|||||||
reg->idx_count = 1;
|
reg->idx_count = 1;
|
||||||
*writemask = VKD3DSP_WRITEMASK_ALL;
|
*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)
|
else if (data_type->type == HLSL_CLASS_OBJECT && data_type->base_type == HLSL_TYPE_SAMPLER)
|
||||||
{
|
{
|
||||||
reg->type = VKD3D_SM4_RT_SAMPLER;
|
reg->type = VKD3D_SM4_RT_SAMPLER;
|
||||||
@ -1397,24 +1407,28 @@ 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_type *resource_type, const struct hlsl_ir_node *dst,
|
||||||
const struct hlsl_deref *resource, const struct hlsl_ir_node *coords)
|
const struct hlsl_deref *resource, const struct hlsl_ir_node *coords)
|
||||||
{
|
{
|
||||||
|
bool uav = (resource_type->base_type == HLSL_TYPE_UAV);
|
||||||
struct sm4_instruction instr;
|
struct sm4_instruction instr;
|
||||||
unsigned int dim_count;
|
unsigned int dim_count;
|
||||||
|
|
||||||
memset(&instr, 0, sizeof(instr));
|
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);
|
sm4_dst_from_node(&instr.dsts[0], dst);
|
||||||
instr.dst_count = 1;
|
instr.dst_count = 1;
|
||||||
|
|
||||||
sm4_src_from_node(&instr.srcs[0], coords, VKD3DSP_WRITEMASK_ALL);
|
sm4_src_from_node(&instr.srcs[0], coords, VKD3DSP_WRITEMASK_ALL);
|
||||||
|
|
||||||
/* Mipmap level is in the last component in the IR, but needs to be in the W
|
if (!uav)
|
||||||
* component in the instruction. */
|
{
|
||||||
dim_count = hlsl_sampler_dim_count(resource_type->sampler_dim);
|
/* Mipmap level is in the last component in the IR, but needs to be in the W
|
||||||
if (dim_count == 1)
|
* component in the instruction. */
|
||||||
instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, X, X, Y), 4);
|
dim_count = hlsl_sampler_dim_count(resource_type->sampler_dim);
|
||||||
if (dim_count == 2)
|
if (dim_count == 1)
|
||||||
instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, Y, X, Z), 4);
|
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);
|
sm4_src_from_deref(ctx, &instr.srcs[1], resource, resource_type, instr.dsts[0].writemask);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user