SamplerKind.hlsl 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
  2. // CHECK: DepthOutput=0
  3. // CHECK: SampleFrequency=1
  4. // CHECK: NORMAL 0 sample
  5. // CHECK: TEXCOORD 0 noperspective
  6. // CHECK: g_txDiffuse_texture_2d
  7. // CHECK: g_samLinear_sampler
  8. //--------------------------------------------------------------------------------------
  9. // File: BasicHLSL11_PS.hlsl
  10. //
  11. // The pixel shader file for the BasicHLSL11 sample.
  12. //
  13. // Copyright (c) Microsoft Corporation. All rights reserved.
  14. //--------------------------------------------------------------------------------------
  15. //--------------------------------------------------------------------------------------
  16. // Globals
  17. //--------------------------------------------------------------------------------------
  18. cbuffer cbPerObject : register( b0 )
  19. {
  20. float4 g_vObjectColor : packoffset( c0 );
  21. };
  22. cbuffer cbPerFrame : register( b1 )
  23. {
  24. float3 g_vLightDir : packoffset( c0 );
  25. float g_fAmbient : packoffset( c0.w );
  26. };
  27. //--------------------------------------------------------------------------------------
  28. // Textures and Samplers
  29. //--------------------------------------------------------------------------------------
  30. Texture2D g_txDiffuse : register( t0 );
  31. SamplerState g_samLinear : register( s0 );
  32. SamplerComparisonState g_samLinearC : register( s1 );
  33. RWTexture2D<float4> uav1 : register( u3 );
  34. //--------------------------------------------------------------------------------------
  35. // Input / Output structures
  36. //--------------------------------------------------------------------------------------
  37. struct PS_INPUT
  38. {
  39. sample float3 vNormal : NORMAL;
  40. noperspective float2 vTexcoord : TEXCOORD0;
  41. };
  42. float cmpVal;
  43. //--------------------------------------------------------------------------------------
  44. // Pixel Shader
  45. //--------------------------------------------------------------------------------------
  46. float4 main( PS_INPUT Input) : SV_TARGET
  47. {
  48. float4 vDiffuse = g_txDiffuse.Sample( g_samLinear, Input.vTexcoord );
  49. vDiffuse += g_txDiffuse.CalculateLevelOfDetail(g_samLinear, Input.vTexcoord);
  50. vDiffuse += g_txDiffuse.Gather(g_samLinear, Input.vTexcoord);
  51. vDiffuse += g_txDiffuse.SampleCmp(g_samLinearC, Input.vTexcoord, cmpVal);
  52. vDiffuse += g_txDiffuse.GatherCmp(g_samLinearC, Input.vTexcoord, cmpVal);
  53. float fLighting = saturate( dot( g_vLightDir, Input.vNormal ) );
  54. fLighting = max( fLighting, g_fAmbient );
  55. return vDiffuse * fLighting * uav1.Load(int2(0,0));
  56. }