binary-op.assign.opaque.array.hlsl 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Run: %dxc -T ps_6_0 -E main
  2. Texture2D gTextures[1];
  3. SamplerState gSamplers[2];
  4. // Copy to static variable
  5. // CHECK: [[src:%\d+]] = OpAccessChain %_ptr_UniformConstant_type_2d_image %gTextures %int_0
  6. // CHECK-NEXT: [[elm:%\d+]] = OpLoad %type_2d_image [[src]]
  7. // CHECK-NEXT: [[val:%\d+]] = OpCompositeConstruct %_arr_type_2d_image_uint_1 [[elm]]
  8. // CHECK-NEXT: OpStore %sTextures [[val]]
  9. static Texture2D sTextures[1] = gTextures;
  10. struct Samplers {
  11. SamplerState samplers[2];
  12. };
  13. struct Resources {
  14. Texture2D textures[1];
  15. Samplers samplers;
  16. };
  17. float4 doSample(Texture2D t, SamplerState s[2]);
  18. float4 main() : SV_Target {
  19. Resources r;
  20. // Copy to struct field
  21. // CHECK: OpAccessChain %_ptr_UniformConstant_type_2d_image %gTextures %int_0
  22. // CHECK-NEXT: OpLoad
  23. // CHECK-NEXT: OpCompositeConstruct %_arr_type_2d_image_uint_1
  24. r.textures = gTextures;
  25. // CHECK: OpAccessChain %_ptr_UniformConstant_type_sampler %gSamplers %int_0
  26. // CHECK-NEXT: OpLoad
  27. // CHECK-NEXT: OpAccessChain %_ptr_UniformConstant_type_sampler %gSamplers %int_1
  28. // CHECK-NEXT: OpLoad
  29. // CHECK-NEXT: OpCompositeConstruct %_arr_type_sampler_uint_2
  30. r.samplers.samplers = gSamplers;
  31. // Copy to local variable
  32. // CHECK: [[r:%\d+]] = OpAccessChain %_ptr_Function__arr_type_2d_image_uint_1 %r %int_0
  33. // CHECK-NEXT: OpAccessChain %_ptr_Function_type_2d_image [[r]] %int_0
  34. // CHECK-NEXT: OpLoad
  35. // CHECK-NEXT: OpCompositeConstruct %_arr_type_2d_image_uint_1
  36. Texture2D textures[1] = r.textures;
  37. SamplerState samplers[2];
  38. // CHECK: [[r:%\d+]] = OpAccessChain %_ptr_Function__arr_type_sampler_uint_2 %r %int_1 %int_0
  39. // CHECK-NEXT: OpAccessChain %_ptr_Function_type_sampler [[r]] %int_0
  40. // CHECK-NEXT: OpLoad
  41. // CHECK-NEXT: OpAccessChain %_ptr_Function_type_sampler [[r]] %int_1
  42. // CHECK-NEXT: OpLoad
  43. // CHECK-NEXT: OpCompositeConstruct %_arr_type_sampler_uint_2
  44. samplers = r.samplers.samplers;
  45. // Copy to function parameter
  46. // CHECK: OpAccessChain %_ptr_Function_type_sampler %samplers %int_0
  47. // CHECK-NEXT: OpLoad
  48. // CHECK-NEXT: OpAccessChain %_ptr_Function_type_sampler %samplers %int_1
  49. // CHECK-NEXT: OpLoad
  50. // CHECK-NEXT: OpCompositeConstruct %_arr_type_sampler_uint_2
  51. return doSample(textures[0], samplers);
  52. }
  53. float4 doSample(Texture2D t, SamplerState s[2]) {
  54. return t.Sample(s[1], float2(0.1, 0.2));
  55. }