sample_kwd.hlsl 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // RUN: %dxc -T ps_6_0 -Od -E main %s | FileCheck %s
  2. // Used to check the following, but allocas are now gone, so they no longer exist.
  3. //
  4. // %precise = alloca float, align 4
  5. // %globallycoherent = alloca i32, align 4
  6. // %sample = alloca float, align 4
  7. // %center = alloca float, align 4
  8. // CHECK: call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %MyBuffer_UAV_structbuf, i32 0, i32 0)
  9. // CHECK: call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %MyBuffer_UAV_structbuf, i32 0, i32 16)
  10. // CHECK: call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %MyBuffer_UAV_structbuf, i32 0, i32 32)
  11. // CHECK: call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %MyBuffer_UAV_structbuf, i32 0, i32 48)
  12. // Check function parameters are accepted
  13. float3 foo(float3 sample) {
  14. return sample;
  15. }
  16. // Check member fields are accepted
  17. struct S {
  18. float4 center;
  19. float4 precise;
  20. float4 sample;
  21. float4 globallycoherent;
  22. };
  23. RWStructuredBuffer<S> MyBuffer;
  24. float4 main(float4 input : SV_POSITION) : SV_TARGET
  25. {
  26. // Check declarations are accepted
  27. float precise = 1.0f;
  28. int globallycoherent = 1;
  29. float sample;
  30. // Check assignments are accepted
  31. sample = 1.0f;
  32. globallycoherent += 10;
  33. // Check declaration group is accepted
  34. float left, center = 1.0, right;
  35. // Check parentheses are accepted
  36. // (they go through the path for type cast in frontend)
  37. float w = (center).x;
  38. return float4(foo(float3(precise, globallycoherent, sample)), w) +
  39. MyBuffer[0].center + MyBuffer[0].precise +
  40. MyBuffer[0].sample + MyBuffer[0].globallycoherent;
  41. }