From b9545f7422deb526219136755c60ce55e559ec98 Mon Sep 17 00:00:00 2001 From: Shaun Ren Date: Thu, 14 Aug 2025 19:29:46 -0400 Subject: [PATCH] tests/hlsl: Add sample bias tests for cube textures. --- tests/hlsl/sample-bias.shader_test | 74 ++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/tests/hlsl/sample-bias.shader_test b/tests/hlsl/sample-bias.shader_test index a56190d25..737d1098a 100644 --- a/tests/hlsl/sample-bias.shader_test +++ b/tests/hlsl/sample-bias.shader_test @@ -70,3 +70,77 @@ probe (0,0) rgba(4.0, 0.0, 10.0, 0.0) uniform 0 float4 8.5 0.0 0.0 0.0 draw quad probe (0,0) rgba(0.0, 0.0, 10.0, 0.0) + +[require] +% Reset requirements + +[srv 0] +size (cube, 2) +levels 2 + +1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 +1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 +1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 +1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 +1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 +1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 + +0.0 0.0 1.0 0.0 +0.0 0.0 1.0 0.0 +0.0 0.0 1.0 0.0 +0.0 0.0 1.0 0.0 +0.0 0.0 1.0 0.0 +0.0 0.0 1.0 0.0 + +[pixel shader] +sampler s; +TextureCube t; +uniform float bias; + +float4 main(float2 coord : texcoord) : sv_target +{ + /* Choice of initial mipmap level is hardware-dependent, and in practice + * varies too much to be reasonably covered by ULPS. Quantize instead. */ + return floor(t.SampleBias(s, float3(coord, 1), bias) * 5) * 2; +} + +[test] +uniform 0 float 7.9 +draw quad +probe (0, 0) f32(10.0, 0.0, 10.0, 0.0) + +uniform 0 float 8.4 +draw quad +probe (0, 0) f32(4.0, 0.0, 10.0, 0.0) + +uniform 0 float 8.9 +draw quad +probe (0, 0) f32(0.0, 0.0, 10.0, 0.0) + +[require] +shader model >= 3.0 +options: backcompat + +[pixel shader fail(sm>=5.1) todo(sm<5.1)] +sampler s; +float bias; + +float4 main(float2 coord : texcoord) : sv_target +{ + /* Choice of initial mipmap level is hardware-dependent, and in practice + * varies too much to be reasonably covered by ULPS. Quantize instead. */ + return floor(texCUBEbias(s, float4(coord, 1, bias)) * 5) * 2; +} + +[test] +uniform 0 float 7.9 +todo draw quad +probe (0, 0) f32(10.0, 0.0, 10.0, 0.0) + +uniform 0 float 8.4 +todo draw quad +probe (0, 0) f32(4.0, 0.0, 10.0, 0.0) + +uniform 0 float 8.9 +todo draw quad +probe (0, 0) f32(0.0, 0.0, 10.0, 0.0)