msaaLoad.hlsl 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // RUN: %dxc -Emain -Tps_6_0 %s | %opt -S -hlsl-dxil-reduce-msaa-to-single | %FileCheck %s
  2. // Check that we overrode the sample index with 0 Here: -------------------------------------------------------------------V
  3. // CHECK: %TextureLoad = call %dx.types.ResRet.i32 @dx.op.textureLoad.i32(i32 66, %dx.types.Handle %texi_texture_2dMS, i32 0
  4. // Check for integer and half-float loads:
  5. // CHECK: %TextureLoad{{[0-9]+}} = call %dx.types.ResRet.f32 @dx.op.textureLoad.f32(i32 66, %dx.types.Handle %texh_texture_2dMS, i32 0
  6. // CHECK: %TextureLoad{{[0-9]+}} = call %dx.types.ResRet.f32 @dx.op.textureLoad.f32(i32 66, %dx.types.Handle %tex_texture_2dMS, i32 0
  7. // Check texture load from single-sampled wasn't altered: (This should be 1) ---------------------------------------------------------V
  8. // CHECK: %TextureLoad{{[0-9]+}} = call %dx.types.ResRet.f32 @dx.op.textureLoad.f32(i32 66, %dx.types.Handle %singleSampledTex_texture_2d, i32 1, i32 1, i32 1, i32 undef, i32 undef, i32 undef, i32 undef)
  9. // Check texture load from UAV wasn't altered: (This should be 1) ---------------------------------------------------------------------V
  10. // CHECK: %TextureLoad{{[0-9]+}} = call %dx.types.ResRet.f32 @dx.op.textureLoad.f32(i32 66, %dx.types.Handle %floatRWUAV_UAV_2d, i32 undef, i32 1, i32 1, i32 undef, i32 undef, i32 undef, i32 undef)
  11. Texture2DMS<float4> tex : register(t2);
  12. Texture2DMS<half4> texh : register(t3);
  13. Texture2DMS<int4> texi : register(t4);
  14. Texture2D<float4> singleSampledTex: register(t5);
  15. RWTexture2D<float4> floatRWUAV: register(u0);
  16. struct PSInput
  17. {
  18. float4 position : SV_POSITION;
  19. float4 color : COLOR;
  20. };
  21. float4 main(PSInput input) : SV_TARGET
  22. {
  23. uint width, height, samples;
  24. tex.GetDimensions(width, height, samples);
  25. float4 resolved = float4(0, 0, 0, 0);
  26. for (uint i = 0; i < samples; ++i)
  27. {
  28. int2 iPos = int2(input.position.xy);
  29. //nonsensical loads from half and integer, just for test:
  30. iPos += texi.Load(iPos, i).x;
  31. resolved.g += texh.Load(iPos, i).g;
  32. resolved += tex.Load(iPos, i);
  33. }
  34. // Add a load from a single-sampled resource to check we didn't override that one's mip-level too:
  35. return resolved / samples + singleSampledTex.Load(int3(1, 1, 1)) + floatRWUAV.Load(int3(1,1,1));
  36. }