Team Fortress 2 Source Code as on 22/4/2020
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.

91 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "BaseVSShader.h"
  8. #include "writez_vs20.inc"
  9. #include "white_ps20.inc"
  10. #include "white_ps20b.inc"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. ConVar gl_amd_occlusion_workaround( "gl_amd_occlusion_workaround", "1" );
  14. DEFINE_FALLBACK_SHADER( Occlusion, Occlusion_DX9 )
  15. BEGIN_VS_SHADER_FLAGS( Occlusion_DX9, "Help for Occlusion", SHADER_NOT_EDITABLE )
  16. BEGIN_SHADER_PARAMS
  17. END_SHADER_PARAMS
  18. SHADER_INIT_PARAMS()
  19. {
  20. }
  21. SHADER_FALLBACK
  22. {
  23. if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
  24. {
  25. return "Occlusion_DX8";
  26. }
  27. return 0;
  28. }
  29. SHADER_INIT
  30. {
  31. }
  32. SHADER_DRAW
  33. {
  34. SHADOW_STATE
  35. {
  36. pShaderShadow->EnableColorWrites( false );
  37. pShaderShadow->EnableAlphaWrites( false );
  38. pShaderShadow->EnableDepthWrites( false );
  39. DECLARE_STATIC_VERTEX_SHADER( writez_vs20 );
  40. SET_STATIC_VERTEX_SHADER( writez_vs20 );
  41. // No pixel shader on Direct3D, doubles fill rate
  42. if ( g_pHardwareConfig->PlatformRequiresNonNullPixelShaders() )
  43. {
  44. DECLARE_STATIC_PIXEL_SHADER( white_ps20 );
  45. SET_STATIC_PIXEL_SHADER( white_ps20 );
  46. // Workaround for weird AMD bug - if sRGB write isn't enabled here then sRGB write enable in subsequent world rendering passes will randomly not take effect (even though we're enabling it) in the driver.
  47. if ( ( IsLinux() || IsWindows() ) && gl_amd_occlusion_workaround.GetBool() )
  48. {
  49. pShaderShadow->EnableSRGBWrite( true );
  50. }
  51. }
  52. // Set stream format (note that this shader supports compression)
  53. unsigned int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED;
  54. int nTexCoordCount = 1;
  55. int userDataSize = 0;
  56. pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
  57. }
  58. DYNAMIC_STATE
  59. {
  60. DECLARE_DYNAMIC_VERTEX_SHADER( writez_vs20 );
  61. SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );
  62. SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
  63. SET_DYNAMIC_VERTEX_SHADER( writez_vs20 );
  64. // No pixel shader on Direct3D, doubles fill rate
  65. if ( g_pHardwareConfig->PlatformRequiresNonNullPixelShaders() )
  66. {
  67. DECLARE_DYNAMIC_PIXEL_SHADER( white_ps20 );
  68. SET_DYNAMIC_PIXEL_SHADER( white_ps20 );
  69. }
  70. }
  71. Draw();
  72. }
  73. END_SHADER