Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.8 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "BaseVSShader.h"
  8. #include "common_hlsl_cpp_consts.h"
  9. #include "Downsample_ps20.inc"
  10. #include "Downsample_ps20b.inc"
  11. // NOTE: This has to be the last file included!
  12. #include "tier0/memdbgon.h"
  13. BEGIN_VS_SHADER_FLAGS( Downsample, "Help for Downsample", SHADER_NOT_EDITABLE )
  14. BEGIN_SHADER_PARAMS
  15. END_SHADER_PARAMS
  16. SHADER_INIT
  17. {
  18. LoadTexture( BASETEXTURE );
  19. }
  20. SHADER_FALLBACK
  21. {
  22. return 0;
  23. }
  24. SHADER_DRAW
  25. {
  26. bool bForceSRGBReadAndWrite = false;
  27. SHADOW_STATE
  28. {
  29. pShaderShadow->EnableDepthWrites( false );
  30. pShaderShadow->EnableAlphaWrites( true );
  31. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  32. // Render targets are pegged as sRGB on togl OSX, so just force these reads and writes
  33. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadAndWrite );
  34. pShaderShadow->EnableSRGBWrite( bForceSRGBReadAndWrite );
  35. int fmt = VERTEX_POSITION;
  36. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  37. pShaderShadow->SetVertexShader( "Downsample_vs20", 0 );
  38. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  39. {
  40. DECLARE_STATIC_PIXEL_SHADER( downsample_ps20b );
  41. SET_STATIC_PIXEL_SHADER( downsample_ps20b );
  42. }
  43. else
  44. {
  45. DECLARE_STATIC_PIXEL_SHADER( downsample_ps20 );
  46. SET_STATIC_PIXEL_SHADER( downsample_ps20 );
  47. }
  48. }
  49. DYNAMIC_STATE
  50. {
  51. BindTexture( SHADER_SAMPLER0, bForceSRGBReadAndWrite ? TEXTURE_BINDFLAGS_SRGBREAD : TEXTURE_BINDFLAGS_NONE, BASETEXTURE, -1 );
  52. int width, height;
  53. pShaderAPI->GetBackBufferDimensions( width, height );
  54. float v[4];
  55. float dX = 1.0f / width;
  56. float dY = 1.0f / height;
  57. v[0] = -dX;
  58. v[1] = -dY;
  59. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, v, 1 );
  60. v[0] = -dX;
  61. v[1] = dY;
  62. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, v, 1 );
  63. v[0] = dX;
  64. v[1] = -dY;
  65. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, v, 1 );
  66. v[0] = dX;
  67. v[1] = dY;
  68. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3, v, 1 );
  69. // Setup luminance threshold (all values are scaled down by max luminance)
  70. // v[0] = 1.0f / MAX_HDR_OVERBRIGHT;
  71. v[0] = 0.0f;
  72. pShaderAPI->SetPixelShaderConstant( 0, v, 1 );
  73. pShaderAPI->SetVertexShaderIndex( 0 );
  74. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  75. {
  76. DECLARE_DYNAMIC_PIXEL_SHADER( downsample_ps20b );
  77. SET_DYNAMIC_PIXEL_SHADER( downsample_ps20b );
  78. }
  79. else
  80. {
  81. DECLARE_DYNAMIC_PIXEL_SHADER( downsample_ps20 );
  82. SET_DYNAMIC_PIXEL_SHADER( downsample_ps20 );
  83. }
  84. }
  85. Draw();
  86. }
  87. END_SHADER