ScreenQuadVS.hlsl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s
  2. //
  3. // Copyright (c) Microsoft. All rights reserved.
  4. // This code is licensed under the MIT License (MIT).
  5. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
  6. // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
  7. // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
  8. // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
  9. //
  10. // Developed by Minigraph
  11. //
  12. // Author: James Stanard
  13. //
  14. // A vertex shader for full-screen effects without a vertex buffer. The
  15. // intent is to output an over-sized triangle that encompasses the entire
  16. // screen. By doing so, we avoid rasterization inefficiency that could
  17. // result from drawing two triangles with a shared edge.
  18. //
  19. // Use null input layout
  20. // Draw(3)
  21. #include "PresentRS.hlsli"
  22. [RootSignature(Present_RootSig)]
  23. void main(
  24. in uint VertID : SV_VertexID,
  25. out float4 Pos : SV_Position,
  26. out float2 Tex : TexCoord0
  27. )
  28. {
  29. // For VertID << 1
  30. // CHECK: shl i32
  31. // For & 2
  32. // CHECK: and i32
  33. // CHECK: and i32
  34. // For float2(uint2
  35. // CHECK: uitofp
  36. // CHECK: uitofp
  37. // Texture coordinates range [0, 2], but only [0, 1] appears on screen.
  38. Tex = float2(uint2(VertID, VertID << 1) & 2);
  39. Pos = float4(lerp(float2(-1, 1), float2(1, -1), Tex), 0, 1);
  40. }