mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-12-15 08:03:30 -08:00
tests: Add bump mapping tests.
This commit is contained in:
committed by
Henri Verbeet
parent
6b5fe9daaf
commit
6633c220b7
Notes:
Henri Verbeet
2025-10-27 19:10:04 +01:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1793
106
tests/hlsl/bump.shader_test
Normal file
106
tests/hlsl/bump.shader_test
Normal file
@@ -0,0 +1,106 @@
|
||||
% Tests for 1.x bump environment mapping instructions.
|
||||
|
||||
% The main function of texbem/texbeml is to slightly perturb the texture
|
||||
% coordinates. We could in theory test the perturbed texture coordinates simply
|
||||
% by setting up a linear filter between two pixels and testing what value is
|
||||
% returned, but unfortunately linear filtering doesn't actually have arbitrary
|
||||
% precision between two given pixels, and in practice the precision can be low.
|
||||
% Instead we'll need to use a large source texture. Since we can't feasibly
|
||||
% specify that much data by hand, we set up an initial rendering pass to fill
|
||||
% the source texture with the right values.
|
||||
|
||||
[require]
|
||||
shader model < 3.0
|
||||
|
||||
[rtv 0]
|
||||
format r32g32b32a32-float
|
||||
size (2d, 1000, 1000)
|
||||
|
||||
[sampler 0]
|
||||
filter point point point
|
||||
address clamp clamp clamp
|
||||
|
||||
[sampler 1]
|
||||
filter linear linear linear
|
||||
address clamp clamp clamp
|
||||
|
||||
[srv 0]
|
||||
size (2d, 2, 1)
|
||||
0.1 0.2 0.3 0.4 0.4 0.3 0.2 0.1
|
||||
|
||||
[srv 1]
|
||||
size (2d, 1000, 1000)
|
||||
|
||||
[vertex shader]
|
||||
void main(inout float4 pos : position, out float4 tex : texcoord)
|
||||
{
|
||||
tex = (pos + 1) / 2;
|
||||
}
|
||||
|
||||
[pixel shader]
|
||||
float4 main(float4 tex : texcoord) : color
|
||||
{
|
||||
/* Compensate for the pixel center. */
|
||||
tex.x += (0.5 / 1000.0);
|
||||
tex.y -= (0.5 / 1000.0);
|
||||
return float4(tex.yx, 1.0 - tex.xy);
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
copy rtv 0 srv 1
|
||||
|
||||
[vertex shader]
|
||||
void main(inout float4 pos : position, out float4 tex0 : texcoord, out float4 tex1 : texcoord1)
|
||||
{
|
||||
tex0 = (pos + 1) / 2;
|
||||
tex1 = float4(0.2, 0.3, 0.4, 0.5);
|
||||
}
|
||||
|
||||
[pixel shader d3dbc-hex]
|
||||
% TODO: Convert to assembly.
|
||||
ffff0101 % ps_1_1
|
||||
00000042 b00f0000 % tex t0
|
||||
00000043 b00f0001 b0e40000 % texbem t1, t0
|
||||
00000001 800f0000 b0e40001 % mov r0, t1
|
||||
0000ffff % end
|
||||
|
||||
[test]
|
||||
bump 1 f32(0.1, 0.2, 0.3, 0.5) 2.0 0.3
|
||||
draw quad
|
||||
% WARP transposes the matrix for TEXBEM/TEXBEML, but not for BEM.
|
||||
if(!warp) probe (250, 500) f32(0.58, 0.27, 0.73, 0.42) 32
|
||||
if(!warp) probe (750, 500) f32(0.47, 0.33, 0.67, 0.53) 16
|
||||
|
||||
[pixel shader d3dbc-hex]
|
||||
% TODO: Convert to assembly.
|
||||
ffff0101 % ps_1_1
|
||||
00000042 b00f0000 % tex t0
|
||||
00000044 b00f0001 b0e40000 % texbeml t1, t0
|
||||
00000001 800f0000 b0e40001 % mov r0, t1
|
||||
0000ffff % end
|
||||
|
||||
[test]
|
||||
bump 1 f32(0.1, 0.2, 0.3, 0.5) 2.0 0.3
|
||||
draw quad
|
||||
% Besides transposing the matrix, WARP also uses the texcoord t1.z (0.4)
|
||||
% as a luminance factor, instead of the textured value t0.z (0.3 or 0.2).
|
||||
if(!warp) probe (250, 500) f32(0.522, 0.243, 0.657, 0.378) 32
|
||||
if(!warp) probe (750, 500) f32(0.329, 0.231, 0.469, 0.371) 16
|
||||
|
||||
[pixel shader d3dbc-hex]
|
||||
% TODO: Convert to assembly.
|
||||
ffff0104 % ps_1_4
|
||||
00000051 a00f0000 3dcccccd 3e4ccccd 3e99999a 3ecccccd % def c0, 0.1, 0.2, 0.3, 0.4
|
||||
00000051 a00f0001 3e99999a 3ecccccd 3f000000 3f19999a % def c1, 0.3, 0.4, 0.5, 0.6
|
||||
00000001 800f0000 a0e40000 % mov r0, c0
|
||||
00000001 800f0001 a0e40001 % mov r1, c1
|
||||
% Note that NVidia will crash if we use c0/c1 directly here.
|
||||
00000059 80030002 80e40001 80e40000 % bem r2.xy, r1, r0
|
||||
00000001 80030000 80e40002 % mov r0.xy, r2
|
||||
0000ffff % end
|
||||
|
||||
[test]
|
||||
bump 2 f32(0.2, 0.3, 0.5, 0.6) 2.0 0.3
|
||||
draw quad
|
||||
probe (320, 240) f32(0.42, 0.55, 0.3, 0.4) 1
|
||||
Reference in New Issue
Block a user