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.

103 lines
2.7 KiB

  1. //========= Copyright (c) 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. DEFINE_FALLBACK_SHADER( WriteZ, WriteZ_DX9 )
  14. BEGIN_VS_SHADER_FLAGS( WriteZ_DX9, "Help for WriteZ", SHADER_NOT_EDITABLE )
  15. BEGIN_SHADER_PARAMS
  16. END_SHADER_PARAMS
  17. SHADER_INIT_PARAMS()
  18. {
  19. }
  20. SHADER_FALLBACK
  21. {
  22. return 0;
  23. }
  24. SHADER_INIT
  25. {
  26. SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
  27. }
  28. SHADER_DRAW
  29. {
  30. SHADOW_STATE
  31. {
  32. pShaderShadow->EnableColorWrites( false );
  33. pShaderShadow->EnableAlphaWrites( false );
  34. DECLARE_STATIC_VERTEX_SHADER( writez_vs20 );
  35. SET_STATIC_VERTEX_SHADER( writez_vs20 );
  36. // No pixel shader on Direct3D, doubles fill rate
  37. if ( g_pHardwareConfig->PlatformRequiresNonNullPixelShaders() )
  38. {
  39. DECLARE_STATIC_PIXEL_SHADER( white_ps20 );
  40. SET_STATIC_PIXEL_SHADER( white_ps20 );
  41. }
  42. // Set stream format (note that this shader supports compression)
  43. unsigned int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED;
  44. int nTexCoordCount = 1;
  45. int userDataSize = 0;
  46. pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
  47. }
  48. DYNAMIC_STATE
  49. {
  50. DECLARE_DYNAMIC_VERTEX_SHADER( writez_vs20 );
  51. SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
  52. SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
  53. SET_DYNAMIC_VERTEX_SHADER( writez_vs20 );
  54. // No pixel shader on Direct3D, doubles fill rate
  55. if ( g_pHardwareConfig->PlatformRequiresNonNullPixelShaders() )
  56. {
  57. DECLARE_DYNAMIC_PIXEL_SHADER( white_ps20 );
  58. SET_DYNAMIC_PIXEL_SHADER( white_ps20 );
  59. }
  60. }
  61. Draw();
  62. }
  63. void ExecuteFastPath( int *dynVSIdx, int *dynPSIdx, IMaterialVar** params, IShaderDynamicAPI * pShaderAPI,
  64. VertexCompressionType_t vertexCompression, CBasePerMaterialContextData **pContextDataPtr, BOOL bCSMEnabled )
  65. {
  66. DECLARE_DYNAMIC_VERTEX_SHADER( writez_vs20 );
  67. SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
  68. SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
  69. SET_DYNAMIC_VERTEX_SHADER( writez_vs20 );
  70. *dynVSIdx = _vshIndex.GetIndex();
  71. // No pixel shader on Direct3D, doubles fill rate
  72. if ( IsOSXOpenGL() )
  73. {
  74. DECLARE_DYNAMIC_PIXEL_SHADER( white_ps20 );
  75. SET_DYNAMIC_PIXEL_SHADER( white_ps20 );
  76. *dynPSIdx = _pshIndex.GetIndex();
  77. }
  78. else
  79. {
  80. *dynPSIdx = 0;
  81. }
  82. }
  83. END_SHADER