vkd3d-shader/hlsl: Improve UAV format type checking for buffer types.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2023-05-04 01:25:24 +02:00 committed by Alexandre Julliard
parent cff22ecde8
commit cf8cacd336
Notes: Alexandre Julliard 2023-05-22 23:19:48 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/193
5 changed files with 340 additions and 7 deletions

View File

@ -173,9 +173,11 @@ vkd3d_shader_tests = \
tests/texture-load-offset.shader_test \
tests/texture-load-typed.shader_test \
tests/trigonometry.shader_test \
tests/uav.shader_test \
tests/uav-load.shader_test \
tests/uav-out-param.shader_test \
tests/uav-rwbuffer.shader_test \
tests/uav-rwstructuredbuffer.shader_test \
tests/uav-rwtexture.shader_test \
tests/writemask-assignop-0.shader_test \
tests/writemask-assignop-1.shader_test \
tests/writemask-assignop-2.shader_test \

View File

@ -5097,16 +5097,42 @@ type_no_void:
}
| uav_type '<' type '>'
{
if ($3->class > HLSL_CLASS_VECTOR)
{
struct vkd3d_string_buffer *string;
struct vkd3d_string_buffer *string = hlsl_type_to_string(ctx, $3);
string = hlsl_type_to_string(ctx, $3);
if (!type_contains_only_numerics($3))
{
if (string)
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"UAV data type %s is not scalar or vector.", string->buffer);
hlsl_release_string_buffer(ctx, string);
"UAV type %s is not numeric.", string->buffer);
}
switch ($1)
{
case HLSL_SAMPLER_DIM_BUFFER:
case HLSL_SAMPLER_DIM_1D:
case HLSL_SAMPLER_DIM_2D:
case HLSL_SAMPLER_DIM_3D:
if ($3->class == HLSL_CLASS_ARRAY)
{
if (string)
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"This type of UAV does not support array type.");
}
else if (hlsl_type_component_count($3) > 4)
{
if (string)
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"UAV data type %s size exceeds maximum size.", string->buffer);
}
break;
case HLSL_SAMPLER_DIM_STRUCTURED_BUFFER:
break;
default:
vkd3d_unreachable();
}
hlsl_release_string_buffer(ctx, string);
$$ = hlsl_new_uav_type(ctx, $1, $3);
}
| TYPE_IDENTIFIER

View File

@ -0,0 +1,80 @@
[require]
shader model >= 5.0
[pixel shader]
struct s
{
float3 a;
};
RWBuffer<float4> u : register(u2);
RWBuffer<float> u1;
RWBuffer<float2x2> u2;
RWBuffer<struct s> u3;
float4 main() : sv_target1
{
u[0] = float4(11.1, 12.2, 13.3, 14.4);
return 0;
}
% Type size is too wide
[pixel shader fail]
struct s
{
float3 a;
float2 b;
};
RWBuffer<struct s> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail todo]
RWBuffer<double3> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader]
RWBuffer<double2> u;
float4 main() : sv_target1
{
return 0;
}
% Array type
[pixel shader fail]
typedef float arr[2];
RWBuffer<arr> u;
float4 main() : sv_target1
{
return 0;
}
% Object types
[pixel shader fail]
RWBuffer<Texture2D> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail]
struct s
{
Texture2D t;
};
RWBuffer<struct s> u;
float4 main() : sv_target1
{
return 0;
}

View File

@ -0,0 +1,57 @@
[require]
shader model >= 5.0
[pixel shader todo]
struct s
{
float3 a;
};
struct s2
{
float4x4 f1, f2, f3;
};
RWStructuredBuffer<float4> u : register(u2);
RWStructuredBuffer<float> u1;
RWStructuredBuffer<float2x2> u2;
RWStructuredBuffer<struct s> u3;
RWStructuredBuffer<float4x4> u4;
RWStructuredBuffer<struct s2> u5;
float4 main() : sv_target1
{
u[0] = float4(11.1, 12.2, 13.3, 14.4);
return 0;
}
% Array type
[pixel shader]
typedef float arr[2];
RWStructuredBuffer<arr> u;
float4 main() : sv_target1
{
return 0;
}
% Object types
[pixel shader fail]
RWStructuredBuffer<Texture2D> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail]
struct s
{
Texture2D t;
};
RWStructuredBuffer<struct s> u;
float4 main() : sv_target1
{
return 0;
}

View File

@ -161,3 +161,171 @@ float4 main() : sv_target1
draw quad
probe uav 2 (0, 0) rgba (1.1, 1.2, 1.3, 1.4)
probe uav 3 (0, 0) rgba (2.1, 2.2, 2.3, 2.4)
% RWTexture1D types
[pixel shader]
struct s
{
float3 a;
};
RWTexture1D<float4> u : register(u2);
RWTexture1D<float> u1;
RWTexture1D<float2x2> u2;
RWTexture1D<struct s> u3;
float4 main() : sv_target1
{
u[0] = float4(11.1, 12.2, 13.3, 14.4);
return 0;
}
% RWTexture2D types
[pixel shader]
struct s
{
float3 a;
};
RWTexture2D<float4> u : register(u2);
RWTexture2D<float> u1;
RWTexture2D<float2x2> u2;
RWTexture2D<struct s> u3;
float4 main() : sv_target1
{
u[int2(0, 0)] = float4(11.1, 12.2, 13.3, 14.4);
return 0;
}
% RWTexture3D types
[pixel shader]
struct s
{
float3 a;
};
RWTexture3D<float4> u : register(u2);
RWTexture3D<float> u1;
RWTexture3D<float2x2> u2;
RWTexture3D<struct s> u3;
float4 main() : sv_target1
{
u[int3(0, 0, 0)] = float4(11.1, 12.2, 13.3, 14.4);
return 0;
}
% Type is too wide
[pixel shader fail]
struct s
{
float3 a;
float2 b;
};
RWTexture1D<struct s> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail]
struct s
{
float3 a;
float2 b;
};
RWTexture2D<struct s> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail]
struct s
{
float3 a;
float2 b;
};
RWTexture3D<struct s> u;
float4 main() : sv_target1
{
return 0;
}
% Array type
[pixel shader fail]
typedef float arr[2];
RWTexture1D<arr> u;
float4 main() : sv_target1
{
return 0;
}
% Object types
[pixel shader fail]
RWTexture1D<Texture2D> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail]
RWTexture2D<Texture2D> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail]
RWTexture3D<Texture2D> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail]
struct s
{
Texture2D t;
};
RWTexture1D<struct s> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail]
struct s
{
Texture2D t;
};
RWTexture2D<struct s> u;
float4 main() : sv_target1
{
return 0;
}
[pixel shader fail]
struct s
{
Texture2D t;
};
RWTexture3D<struct s> u;
float4 main() : sv_target1
{
return 0;
}