Macros.hlsl 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // MonoGame - Copyright (C) The MonoGame Team
  2. // This file is subject to the terms and conditions defined in
  3. // file 'LICENSE.txt', which is part of this source code package.
  4. #if !defined(MACROS_H)
  5. #define MACROS_H
  6. #if defined(SM4)
  7. // Macros for targetting shader model 4.0 (DX11)
  8. #define VS_SHADERMODEL vs_4_0
  9. #define PS_SHADERMODEL ps_4_0
  10. #define TECHNIQUE(name, vsname, psname ) \
  11. technique name { pass { VertexShader = compile vs_4_0_level_9_1 vsname (); PixelShader = compile ps_4_0_level_9_1 psname(); } }
  12. #define BEGIN_CONSTANTS cbuffer Parameters : register(b0) {
  13. #define MATRIX_CONSTANTS
  14. #define END_CONSTANTS };
  15. #define _vs(r)
  16. #define _ps(r)
  17. #define _cb(r)
  18. #define DECLARE_TEXTURE_FORMAT(Name, Format, Index) \
  19. Texture2D<Format> Name : register(t##Index); \
  20. sampler Name##Sampler : register(s##Index)
  21. #define DECLARE_TEXTURE(Name, Index) \
  22. Texture2D<float4> Name : register(t##Index); \
  23. sampler Name##Sampler : register(s##Index)
  24. #define DECLARE_CUBEMAP(Name, Index) \
  25. TextureCube<float4> Name : register(t##Index); \
  26. sampler Name##Sampler : register(s##Index)
  27. #define LOAD_TEXTURE(Name, texCoord) Name.Load(texCoord)
  28. #define SAMPLE_TEXTURE(Name, texCoord) Name.Sample(Name##Sampler, texCoord)
  29. #define SAMPLE_CUBEMAP(Name, texCoord) Name.Sample(Name##Sampler, texCoord)
  30. #define UNROLL [unroll]
  31. #else // !defined(SM4)
  32. #define SV_POSITION POSITION
  33. #define SV_TARGET0 COLOR
  34. #define VS_SHADERMODEL vs_3_0
  35. #define PS_SHADERMODEL ps_3_0
  36. #define BEGIN_CONSTANTS
  37. #define MATRIX_CONSTANTS
  38. #define END_CONSTANTS
  39. #define _vs(r) : register(vs, r)
  40. #define _ps(r) : register(ps, r)
  41. #define _cb(r)
  42. #define DECLARE_TEXTURE(Name, Index) \
  43. sampler2D Name : register(s##Index)
  44. #define DECLARE_CUBEMAP(Name, Index) \
  45. samplerCUBE Name : register(s##Index)
  46. #define DECLARE_TEXTURE_FORMAT(Name, Format, Index) \
  47. sampler2D Name : register(s##Index)
  48. #define SAMPLE_TEXTURE(Name, texCoord) tex2D(Name, texCoord)
  49. #define SAMPLE_CUBEMAP(Name, texCoord) texCUBE(Name, texCoord)
  50. #define LOAD_TEXTURE(Name, texCoord) tex2D(Name, texCoord.xy)
  51. #define UNROLL [unroll]
  52. #endif
  53. #endif // MACROS_H