offsets.hlsl 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // RUN: %dxc -E Range -T ps_6_0 %s | FileCheck %s -check-prefix=CHK_RANGE
  2. // RUN: %dxc -E VarOffset -T ps_6_0 -DOFFSETS=argOffsets %s | FileCheck %s -check-prefix=CHK_VAROFF
  3. // RUN: %dxc -E VarOffset -T ps_6_0 -DOFFSETS=cbufOffsets %s | FileCheck %s -check-prefix=CHK_VAROFF
  4. // RUN: %dxc -E VarOffset -T ps_6_0 -DOFFSETS=constOffsets %s | FileCheck %s -check-prefix=CHK_VAROFF
  5. // RUN: %dxc -E VarOffset -T ps_6_0 -DOFFSETS=validOffsets %s | FileCheck %s -check-prefix=CHK_VALID
  6. // CHK_RANGE: error: Offsets to texture access operations must be between -8 and 7.
  7. // CHK_RANGE: error: Offsets to texture access operations must be between -8 and 7.
  8. // CHK_RANGE: error: Offsets to texture access operations must be between -8 and 7.
  9. // CHK_RANGE: error: Offsets to texture access operations must be between -8 and 7.
  10. // CHK_RANGE: error: Offsets to texture access operations must be between -8 and 7.
  11. // CHK_RANGE: error: Offsets to texture access operations must be between -8 and 7.
  12. // CHK_VAROFF: Offsets to texture access operations must be immediate values
  13. // CHK_VAROFF: Offsets to texture access operations must be immediate values
  14. // CHK_VAROFF: Offsets to texture access operations must be immediate values
  15. // CHK_VAROFF: Offsets to texture access operations must be immediate values
  16. // CHK_VAROFF: Offsets to texture access operations must be immediate values
  17. // CHK_VAROFF: Offsets to texture access operations must be immediate values
  18. // Just make sure it compiles without errors
  19. // CHK_VALID: define void
  20. // CHK_VALID: ret void
  21. Texture1D t1;
  22. Texture2D t2;
  23. Texture3D t3;
  24. SamplerState s;
  25. SamplerComparisonState sc;
  26. float4 Range(float3 str : STR) : SV_TARGET
  27. {
  28. float4 res = 0.0;
  29. res += t1.Sample(s, str.x, -10);
  30. res += t2.Sample(s, str.xy, int2(-18,19));
  31. res += t3.Sample(s, str, int3(-10,1,3));
  32. res += t1.Load(0, 90);
  33. res += t2.Load(1, int2(80, 90));
  34. res += t3.Load(2, int3(-1, -2, 11));
  35. return res;
  36. }
  37. #ifndef OFFSETS
  38. #define OFFSETS argOffsets
  39. #endif
  40. uint3 cbufOffsets[4];
  41. float4 VarOffset(float3 str : STR, uint3 argOffsets[4] : O, uint a : A) : SV_TARGET
  42. {
  43. uint b = 3 + a;
  44. uint v = 3;
  45. const uint3 constOffsets[4] = {uint3(a,a,a), argOffsets[0], cbufOffsets[0], uint3(b,b,b)};
  46. uint3 validOffsets[4] = {uint3(v,v,v), uint3(1,1,1), uint3(2,2,2), uint3(3,3,3)};
  47. float4 res = 0.0;
  48. res += t2.Sample(s, str.x, OFFSETS[0].x);
  49. res += t2.Sample(s, str.xy, OFFSETS[0].xy);
  50. res += t3.Sample(s, str, OFFSETS[0]);
  51. res += t1.Load(0, OFFSETS[0].x);
  52. res += t2.Load(1, OFFSETS[0].xy);
  53. res += t3.Load(2, OFFSETS[0]);
  54. return res;
  55. }