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.

825 lines
46 KiB

  1. //========== Copyright (c) 2005, Valve Corporation, All rights reserved. ========
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef CMATQUEUEDRENDERCONTEXT_H
  7. #define CMATQUEUEDRENDERCONTEXT_H
  8. #include "imatrendercontextinternal.h"
  9. #include "cmatrendercontext.h"
  10. #include "tier1/callqueue.h"
  11. #include "tier1/utlenvelope.h"
  12. #include "tier1/memstack.h"
  13. #include "mathlib/mathlib.h"
  14. #include "tier0/memdbgon.h"
  15. #if defined( _WIN32 )
  16. #pragma once
  17. #endif
  18. #ifndef MATSYS_INTERNAL
  19. #error "This file is private to the implementation of IMaterialSystem/IMaterialSystemInternal"
  20. #endif
  21. class CMaterialSystem;
  22. class CMatQueuedMesh;
  23. class CMatQueuedIndexBuffer;
  24. class CPrimList;
  25. //-----------------------------------------------------------------------------
  26. #define DEFINE_QUEUED_CALL_0( FuncName, ClassName, pObject ) void FuncName() { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)())&ClassName::FuncName); }
  27. #define DEFINE_QUEUED_CALL_1( FuncName, ArgType1, ClassName, pObject ) void FuncName( ArgType1 a1 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1))&ClassName::FuncName, a1 ); }
  28. #define DEFINE_QUEUED_CALL_2( FuncName, ArgType1, ArgType2, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2))&ClassName::FuncName, a1, a2 ); }
  29. #define DEFINE_QUEUED_CALL_3( FuncName, ArgType1, ArgType2, ArgType3, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3))&ClassName::FuncName, a1, a2, a3 ); }
  30. #define DEFINE_QUEUED_CALL_4( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4))&ClassName::FuncName, a1, a2, a3, a4 ); }
  31. #define DEFINE_QUEUED_CALL_5( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5))&ClassName::FuncName, a1, a2, a3, a4, a5 ); }
  32. #define DEFINE_QUEUED_CALL_6( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6))&ClassName::FuncName, a1, a2, a3, a4, a5, a6 ); }
  33. #define DEFINE_QUEUED_CALL_7( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7 ); }
  34. #define DEFINE_QUEUED_CALL_8( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8 ); }
  35. #define DEFINE_QUEUED_CALL_9( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8, ArgType9 a9 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8, a9 ); }
  36. #define DEFINE_QUEUED_CALL_11( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8, ArgType9 a9, ArgType10 a10, ArgType11 a11 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11 ); }
  37. #define DEFINE_QUEUED_CALL_12( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8, ArgType9 a9, ArgType10 a10, ArgType11 a11, ArgType12 a12 ) { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 ); }
  38. #define DEFINE_QUEUED_CALL_0C( FuncName, ClassName, pObject ) void FuncName() const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)() const)ClassName::FuncName); }
  39. #define DEFINE_QUEUED_CALL_1C( FuncName, ArgType1, ClassName, pObject ) void FuncName( ArgType1 a1 ) const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1) const)ClassName::FuncName, a1 ); }
  40. #define DEFINE_QUEUED_CALL_2C( FuncName, ArgType1, ArgType2, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2 ) const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2) const)ClassName::FuncName, a1, a2 ); }
  41. #define DEFINE_QUEUED_CALL_3C( FuncName, ArgType1, ArgType2, ArgType3, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3 ) const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3) const)ClassName::FuncName, a1, a2, a3 ); }
  42. #define DEFINE_QUEUED_CALL_4C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4 ) const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4) const)ClassName::FuncName, a1, a2, a3, a4 ); }
  43. #define DEFINE_QUEUED_CALL_5C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5 ) const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5) const)ClassName::FuncName, a1, a2, a3, a4, a5 ); }
  44. #define DEFINE_QUEUED_CALL_6C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6 ) const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6) const)ClassName::FuncName, a1, a2, a3, a4, a5, a6 ); }
  45. #define DEFINE_QUEUED_CALL_7C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7 ) const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7) const)ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7 ); }
  46. #define DEFINE_QUEUED_CALL_8C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8 ) const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8) const)ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8 ); }
  47. #define DEFINE_QUEUED_CALL_9C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8, ArgType9 a9 ) const { (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9) const)ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8, a9 ); }
  48. #define DEFINE_QUEUED_CALL_AFTER_BASE_0( FuncName, ClassName, pObject ) void FuncName() { BaseClass::FuncName(); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)())&ClassName::FuncName ); }
  49. #define DEFINE_QUEUED_CALL_AFTER_BASE_1( FuncName, ArgType1, ClassName, pObject ) void FuncName( ArgType1 a1 ) { BaseClass::FuncName( a1 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1))&ClassName::FuncName, a1 ); }
  50. #define DEFINE_QUEUED_CALL_AFTER_BASE_2( FuncName, ArgType1, ArgType2, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2 ) { BaseClass::FuncName( a1, a2 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2))&ClassName::FuncName, a1, a2 ); }
  51. #define DEFINE_QUEUED_CALL_AFTER_BASE_3( FuncName, ArgType1, ArgType2, ArgType3, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3 ) { BaseClass::FuncName( a1, a2, a3 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3))&ClassName::FuncName, a1, a2, a3 ); }
  52. #define DEFINE_QUEUED_CALL_AFTER_BASE_4( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4 ) { BaseClass::FuncName( a1, a2, a3, a4 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4))&ClassName::FuncName, a1, a2, a3, a4 ); }
  53. #define DEFINE_QUEUED_CALL_AFTER_BASE_5( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5 ) { BaseClass::FuncName( a1, a2, a3, a4, a5 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5))&ClassName::FuncName, a1, a2, a3, a4, a5 ); }
  54. #define DEFINE_QUEUED_CALL_AFTER_BASE_6( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6 ) { BaseClass::FuncName( a1, a2, a3, a4, a5, a6 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6))&ClassName::FuncName, a1, a2, a3, a4, a5, a6 ); }
  55. #define DEFINE_QUEUED_CALL_AFTER_BASE_7( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7 ) { BaseClass::FuncName( a1, a2, a3, a4, a5, a6, a7 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7 ); }
  56. #define DEFINE_QUEUED_CALL_AFTER_BASE_8( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8 ) { BaseClass::FuncName( a1, a2, a3, a4, a5, a6, a7, a8 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8 ); }
  57. #define DEFINE_QUEUED_CALL_AFTER_BASE_9( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8, ArgType9 a9 ) { BaseClass::FuncName( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8, a9 ); }
  58. #define DEFINE_QUEUED_CALL_AFTER_BASE_0C( FuncName, ClassName, pObject ) void FuncName() const { BaseClass::FuncName(); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)())&ClassName::FuncName ); }
  59. #define DEFINE_QUEUED_CALL_AFTER_BASE_1C( FuncName, ArgType1, ClassName, pObject ) void FuncName( ArgType1 a1 ) const { BaseClass::FuncName( a1 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1))&ClassName::FuncName, a1 ); }
  60. #define DEFINE_QUEUED_CALL_AFTER_BASE_2C( FuncName, ArgType1, ArgType2, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2 ) const { BaseClass::FuncName( a1, a2 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2))&ClassName::FuncName, a1, a2 ); }
  61. #define DEFINE_QUEUED_CALL_AFTER_BASE_3C( FuncName, ArgType1, ArgType2, ArgType3, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3 ) const { BaseClass::FuncName( a1, a2, a3 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3))&ClassName::FuncName, a1, a2, a3 ); }
  62. #define DEFINE_QUEUED_CALL_AFTER_BASE_4C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4 ) const { BaseClass::FuncName( a1, a2, a3, a4 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4))&ClassName::FuncName, a1, a2, a3, a4 ); }
  63. #define DEFINE_QUEUED_CALL_AFTER_BASE_5C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5 ) const { BaseClass::FuncName( a1, a2, a3, a4, a5 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5))&ClassName::FuncName, a1, a2, a3, a4, a5 ); }
  64. #define DEFINE_QUEUED_CALL_AFTER_BASE_6C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6 ) const { BaseClass::FuncName( a1, a2, a3, a4, a5, a6 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6))&ClassName::FuncName, a1, a2, a3, a4, a5, a6 ); }
  65. #define DEFINE_QUEUED_CALL_AFTER_BASE_7C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7 ) const { BaseClass::FuncName( a1, a2, a3, a4, a5, a6, a7 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7 ); }
  66. #define DEFINE_QUEUED_CALL_AFTER_BASE_8C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8 ) const { BaseClass::FuncName( a1, a2, a3, a4, a5, a6, a7, a8 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8 ); }
  67. #define DEFINE_QUEUED_CALL_AFTER_BASE_9C( FuncName, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ClassName, pObject ) void FuncName( ArgType1 a1, ArgType2 a2, ArgType3 a3, ArgType4 a4, ArgType5 a5, ArgType6 a6, ArgType7 a7, ArgType8 a8, ArgType9 a9 ) const { BaseClass::FuncName( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); (*(const_cast<CMatCallQueue *>(&m_queue))).QueueCall( pObject, (void (ClassName::*)(ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9))&ClassName::FuncName, a1, a2, a3, a4, a5, a6, a7, a8, a9 ); }
  68. //-----------------------------------------------------------------------------
  69. #define Unsupported( funcName ) ExecuteOnce( Msg( "CMatQueuedRenderContext: %s is unsupported\n", #funcName ) )
  70. #define FATAL_QUEUE 1
  71. #ifdef FATAL_QUEUE
  72. #define CannotSupport() ExecuteOnce( Msg( "Called function that cannot be supported\n" ) ); ExecuteOnce( DebuggerBreakIfDebugging() )
  73. #else
  74. #define CannotSupport() ExecuteOnce( Msg( "Called function that cannot be supported\n" ) )
  75. #endif
  76. //-----------------------------------------------------------------------------
  77. //
  78. //-----------------------------------------------------------------------------
  79. class CMatQueuedRenderContext : public CMatRenderContextBase
  80. {
  81. typedef CMatRenderContextBase BaseClass;
  82. public:
  83. CMatQueuedRenderContext()
  84. : m_pHardwareContext( NULL ),
  85. m_iRenderDepth( 0 ),
  86. m_pQueuedMesh( NULL ),
  87. m_WidthBackBuffer( 0 ),
  88. m_HeightBackBuffer( 0 ),
  89. m_FogMode( MATERIAL_FOG_NONE ),
  90. m_flFogStart( 0 ),
  91. m_flFogEnd( 0 ),
  92. m_flFogZ( 0 ),
  93. m_flFogMaxDensity( 1.0 )
  94. {
  95. memset( &m_FogColor, 0, sizeof(m_FogColor) );
  96. }
  97. void CycleDynamicBuffers( ); // For use in mat_queue_mode 1 only
  98. void Init( CMaterialSystem *pMaterialSystem, CMatRenderContextBase *pHardwareContext );
  99. void Shutdown();
  100. void CompactMemory();
  101. bool IsInitialized() const { return ( m_pHardwareContext != NULL ); }
  102. void BeginQueue( CMatRenderContextBase *pInitialState = NULL );
  103. void EndQueue( bool bCallQueued = false );
  104. void BeginRender();
  105. void EndRender();
  106. void CallQueued( bool bTermAfterCall = false );
  107. void FlushQueued();
  108. ICallQueue * GetCallQueue();
  109. CMatCallQueue * GetCallQueueInternal() { return &m_queue; }
  110. DEFINE_QUEUED_CALL_0( EvictManagedResources, IShaderAPI, g_pShaderAPI );
  111. bool OnDrawMesh( IMesh *pMesh, int firstIndex, int numIndices );
  112. bool OnDrawMesh( IMesh *pMesh, CPrimList *pLists, int nLists );
  113. bool OnDrawMeshModulated( IMesh *pMesh, const Vector4D &diffuseModulation, int firstIndex, int numIndices );
  114. bool OnSetFlexMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes );
  115. bool OnSetColorMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes );
  116. bool OnSetPrimitiveType( IMesh *pMesh, MaterialPrimitiveType_t type );
  117. DEFINE_QUEUED_CALL_1( Flush, bool, IMatRenderContext, m_pHardwareContext );
  118. DEFINE_QUEUED_CALL_0( SwapBuffers, IMatRenderContextInternal, m_pHardwareContext );
  119. void SetRenderTargetEx( int nRenderTargetID, ITexture *pTexture );
  120. void GetRenderTargetDimensions( int &, int &) const;
  121. void GetViewport( int& x, int& y, int& width, int& height ) const;
  122. void Bind( IMaterial *, void * );
  123. DEFINE_QUEUED_CALL_AFTER_BASE_1( BindLocalCubemap, ITexture *, IMatRenderContext, m_pHardwareContext );
  124. DEFINE_QUEUED_CALL_AFTER_BASE_1( BindLightmapPage, int, IMatRenderContext, m_pHardwareContext );
  125. DEFINE_QUEUED_CALL_2( DepthRange, float, float, IMatRenderContext, m_pHardwareContext );
  126. DEFINE_QUEUED_CALL_3( ClearBuffers, bool, bool, bool, IMatRenderContext, m_pHardwareContext );
  127. void ReadPixels( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat, ITexture *pRenderTargetTexture = NULL );
  128. void ReadPixelsAsync( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat, ITexture *pRenderTargetTexture = NULL, CThreadEvent *pPixelsReadEvent = NULL );
  129. void ReadPixelsAsyncGetResult( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat, CThreadEvent *pGetResultEvent = NULL );
  130. void SetLightingState( const MaterialLightingState_t &desc );
  131. void SetLights( int nCount, const LightDesc_t *pLights );
  132. void SetLightingOrigin( Vector vLightingOrigin );
  133. void SetAmbientLightCube( LightCube_t cube );
  134. DEFINE_QUEUED_CALL_1( CopyRenderTargetToTexture, ITexture *, IMatRenderContext, m_pHardwareContext );
  135. DEFINE_QUEUED_CALL_AFTER_BASE_2( SetFrameBufferCopyTexture, ITexture *, int, IMatRenderContext, m_pHardwareContext );
  136. // matrix api
  137. void MatrixMode( MaterialMatrixMode_t);
  138. void PushMatrix();
  139. void PopMatrix();
  140. void LoadMatrix( const VMatrix& matrix );
  141. void LoadMatrix( const matrix3x4_t& matrix );
  142. void MultMatrix( const VMatrix& matrix );
  143. void MultMatrixLocal( const VMatrix& matrix );
  144. void MultMatrix( const matrix3x4_t& matrix );
  145. void MultMatrixLocal( const matrix3x4_t& matrix );
  146. void LoadIdentity();
  147. void Ortho( double, double, double, double, double, double);
  148. void PerspectiveX( double, double, double, double);
  149. void PerspectiveOffCenterX( double, double, double, double, double, double, double, double );
  150. void PickMatrix( int, int, int, int);
  151. void Rotate( float, float, float, float);
  152. void Translate( float, float, float);
  153. void Scale( float, float, float);
  154. // end matrix api
  155. void Viewport( int x, int y, int width, int height );
  156. DEFINE_QUEUED_CALL_1( CullMode, MaterialCullMode_t, IMatRenderContext, m_pHardwareContext );
  157. DEFINE_QUEUED_CALL_0( FlipCullMode, IMatRenderContext, m_pHardwareContext );
  158. DEFINE_QUEUED_CALL_0( BeginGeneratingCSMs, IMatRenderContext, m_pHardwareContext );
  159. DEFINE_QUEUED_CALL_0( EndGeneratingCSMs, IMatRenderContext, m_pHardwareContext );
  160. DEFINE_QUEUED_CALL_3( PerpareForCascadeDraw, int, float, float, IMatRenderContext, m_pHardwareContext );
  161. void FogMode( MaterialFogMode_t fogMode );
  162. void FogStart( float fStart );
  163. void FogEnd( float fEnd );
  164. void SetFogZ( float fogZ );
  165. MaterialFogMode_t GetFogMode( void );
  166. void GetFogDistances( float *fStart, float *fEnd, float *fFogZ );
  167. void FogMaxDensity( float flMaxDensity );
  168. void FogColor3f( float r, float g, float b );
  169. void FogColor3fv( float const* rgb );
  170. void FogColor3ub( unsigned char r, unsigned char g, unsigned char b );
  171. void FogColor3ubv( unsigned char const* rgb );
  172. void GetFogColor( unsigned char *rgb );
  173. int GetCurrentNumBones( ) const;
  174. void SetNumBoneWeights( int nBoneCount );
  175. DELEGATE_TO_OBJECT_4( IMesh *, CreateStaticMesh, VertexFormat_t, const char *, IMaterial *, VertexStreamSpec_t *, m_pHardwareContext );
  176. DEFINE_QUEUED_CALL_1( DestroyStaticMesh, IMesh *, IMatRenderContext, m_pHardwareContext );
  177. IMesh * GetDynamicMesh(bool, IMesh *, IMesh *, IMaterial * );
  178. IMesh* GetDynamicMeshEx( VertexFormat_t, bool, IMesh*, IMesh*, IMaterial* );
  179. // ------------ New Vertex/Index Buffer interface ----------------------------
  180. DELEGATE_TO_OBJECT_3( IVertexBuffer *, CreateStaticVertexBuffer, VertexFormat_t, int, const char *, m_pHardwareContext );
  181. DELEGATE_TO_OBJECT_3( IIndexBuffer *, CreateStaticIndexBuffer, MaterialIndexFormat_t, int, const char *, m_pHardwareContext );
  182. DELEGATE_TO_OBJECT_1V( DestroyVertexBuffer, IVertexBuffer *, m_pHardwareContext );
  183. DELEGATE_TO_OBJECT_1V( DestroyIndexBuffer, IIndexBuffer *, m_pHardwareContext );
  184. DELEGATE_TO_OBJECT_3( IVertexBuffer *, GetDynamicVertexBuffer, int, VertexFormat_t, bool, m_pHardwareContext );
  185. IIndexBuffer * GetDynamicIndexBuffer( );
  186. DELEGATE_TO_OBJECT_7V( BindVertexBuffer, int, IVertexBuffer *, int, int, int, VertexFormat_t, int, m_pHardwareContext );
  187. DELEGATE_TO_OBJECT_2V( BindIndexBuffer, IIndexBuffer *, int, m_pHardwareContext );
  188. DELEGATE_TO_OBJECT_3V( Draw, MaterialPrimitiveType_t, int, int, m_pHardwareContext );
  189. // ------------ End ----------------------------
  190. int SelectionMode( bool )
  191. {
  192. CannotSupport();
  193. return 0;
  194. }
  195. void SelectionBuffer( unsigned int *, int )
  196. {
  197. CannotSupport();
  198. }
  199. DEFINE_QUEUED_CALL_0( ClearSelectionNames, IMatRenderContext, m_pHardwareContext );
  200. DEFINE_QUEUED_CALL_1( LoadSelectionName, int, IMatRenderContext, m_pHardwareContext );
  201. DEFINE_QUEUED_CALL_1( PushSelectionName, int, IMatRenderContext, m_pHardwareContext );
  202. DEFINE_QUEUED_CALL_0( PopSelectionName, IMatRenderContext, m_pHardwareContext );
  203. DEFINE_QUEUED_CALL_3( ClearColor3ub, unsigned char, unsigned char, unsigned char, IMatRenderContext, m_pHardwareContext );
  204. DEFINE_QUEUED_CALL_4( ClearColor4ub, unsigned char, unsigned char, unsigned char, unsigned char, IMatRenderContext, m_pHardwareContext );
  205. DEFINE_QUEUED_CALL_3( OverrideDepthEnable, bool, bool, bool, IMatRenderContext, m_pHardwareContext );
  206. DEFINE_QUEUED_CALL_2( OverrideAlphaWriteEnable, bool, bool, IMatRenderContext, m_pHardwareContext );
  207. DEFINE_QUEUED_CALL_2( OverrideColorWriteEnable, bool, bool, IMatRenderContext, m_pHardwareContext );
  208. DEFINE_QUEUED_CALL_1( DrawScreenSpaceQuad, IMaterial *, IMatRenderContext, m_pHardwareContext );
  209. void SyncToken( const char *p );
  210. // Allocate and delete query objects.
  211. OcclusionQueryObjectHandle_t CreateOcclusionQueryObject();
  212. DEFINE_QUEUED_CALL_1( DestroyOcclusionQueryObject, OcclusionQueryObjectHandle_t, IMatRenderContext, m_pHardwareContext );
  213. DEFINE_QUEUED_CALL_1( BeginOcclusionQueryDrawing, OcclusionQueryObjectHandle_t, IMatRenderContext, m_pHardwareContext );
  214. DEFINE_QUEUED_CALL_1( EndOcclusionQueryDrawing, OcclusionQueryObjectHandle_t, IMatRenderContext, m_pHardwareContext );
  215. DEFINE_QUEUED_CALL_1( ResetOcclusionQueryObject, OcclusionQueryObjectHandle_t, IMatRenderContext, m_pHardwareContext );
  216. int OcclusionQuery_GetNumPixelsRendered( OcclusionQueryObjectHandle_t );
  217. void SetFlashlightState( const FlashlightState_t &s, const VMatrix &m );
  218. DEFINE_QUEUED_CALL_AFTER_BASE_1( SetHeightClipMode, MaterialHeightClipMode_t, IMatRenderContext, m_pHardwareContext );
  219. DEFINE_QUEUED_CALL_AFTER_BASE_1( SetHeightClipZ, float, IMatRenderContext, m_pHardwareContext );
  220. bool EnableClipping( bool bEnable );
  221. DEFINE_QUEUED_CALL_1( EnableUserClipTransformOverride, bool, IMatRenderContext, m_pHardwareContext );
  222. void UserClipTransform( const VMatrix &m );
  223. IMorph *CreateMorph( MorphFormat_t format, const char *pDebugName )
  224. {
  225. CannotSupport();
  226. return NULL;
  227. }
  228. DEFINE_QUEUED_CALL_1( DestroyMorph, IMorph *, IMatRenderContext, m_pHardwareContext );
  229. DEFINE_QUEUED_CALL_1( BindMorph, IMorph *, IMatRenderContext, m_pHardwareContext );
  230. void ReadPixelsAndStretch( Rect_t *pSrcRect, Rect_t *pDstRect, unsigned char *pBuffer, ImageFormat dstFormat, int nDstStride );
  231. void GetWindowSize( int &width, int &height ) const;
  232. void DrawScreenSpaceRectangle( IMaterial *pMaterial,
  233. int destx, int desty,
  234. int width, int height,
  235. float src_texture_x0, float src_texture_y0, // which texel you want to appear at
  236. // destx/y
  237. float src_texture_x1, float src_texture_y1, // which texel you want to appear at
  238. // destx+width-1, desty+height-1
  239. int src_texture_width, int src_texture_height, // needed for fixup
  240. void *pClientRenderable = NULL,
  241. int nXDice = 1,
  242. int nYDice = 1 );
  243. void LoadBoneMatrix( int i, const matrix3x4_t &m );
  244. DEFINE_QUEUED_CALL_AFTER_BASE_5( PushRenderTargetAndViewport, ITexture *, int, int, int, int, IMatRenderContext, m_pHardwareContext );
  245. DEFINE_QUEUED_CALL_AFTER_BASE_6( PushRenderTargetAndViewport, ITexture *, ITexture *, int, int, int, int, IMatRenderContext, m_pHardwareContext );
  246. DEFINE_QUEUED_CALL_AFTER_BASE_1( PushRenderTargetAndViewport, ITexture *, IMatRenderContext, m_pHardwareContext );
  247. DEFINE_QUEUED_CALL_AFTER_BASE_0( PushRenderTargetAndViewport, IMatRenderContext, m_pHardwareContext );
  248. DEFINE_QUEUED_CALL_AFTER_BASE_0( PopRenderTargetAndViewport, IMatRenderContext, m_pHardwareContext );
  249. DEFINE_QUEUED_CALL_1( BindLightmapTexture, ITexture *, IMatRenderContext, m_pHardwareContext );
  250. void CopyRenderTargetToTextureEx( ITexture *pTexture, int i, Rect_t *pSrc, Rect_t *pDst );
  251. void CopyTextureToRenderTargetEx( int i, ITexture *pTexture, Rect_t *pSrc, Rect_t *pDst );
  252. DEFINE_QUEUED_CALL_2( SetFloatRenderingParameter, int, float, IMatRenderContext, m_pHardwareContext );
  253. DEFINE_QUEUED_CALL_2( SetIntRenderingParameter, int, int, IMatRenderContext, m_pHardwareContext );
  254. DEFINE_QUEUED_CALL_2( SetTextureRenderingParameter, int, ITexture *, IMatRenderContext, m_pHardwareContext );
  255. void SetVectorRenderingParameter( int i, const Vector &v )
  256. {
  257. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::SetVectorRenderingParameter, i, RefToVal( v ) );
  258. }
  259. float GetFloatRenderingParameter(int parm_number) const
  260. {
  261. CannotSupport();
  262. return 0;
  263. }
  264. int GetIntRenderingParameter(int parm_number) const
  265. {
  266. CannotSupport();
  267. return 0;
  268. }
  269. ITexture *GetTextureRenderingParameter(int parm_number) const
  270. {
  271. CannotSupport();
  272. return 0;
  273. }
  274. Vector GetVectorRenderingParameter(int parm_number) const
  275. {
  276. CannotSupport();
  277. return Vector(0,0,0);
  278. }
  279. virtual void SetStencilState( const ShaderStencilState_t &state )
  280. {
  281. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::SetStencilState, RefToVal( state ) );
  282. }
  283. DEFINE_QUEUED_CALL_5( ClearStencilBufferRectangle, int, int, int, int, int, IMatRenderContext, m_pHardwareContext );
  284. DEFINE_QUEUED_CALL_2( SetShadowDepthBiasFactors, float, float, IMatRenderContext, m_pHardwareContext );
  285. void PushCustomClipPlane( const float *p )
  286. {
  287. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::PushCustomClipPlane, m_queue.CopyArray( p, 4 ) );
  288. }
  289. DEFINE_QUEUED_CALL_0( PopCustomClipPlane, IMatRenderContext, m_pHardwareContext );
  290. virtual void GetMaxToRender( IMesh *pMesh, bool bMaxUntilFlush, int *pMaxVerts, int *pMaxIndices );
  291. virtual int GetMaxVerticesToRender( IMaterial *pMaterial );
  292. virtual int GetMaxIndicesToRender( );
  293. DEFINE_QUEUED_CALL_0( DisableAllLocalLights, IMatRenderContext, m_pHardwareContext );
  294. int CompareMaterialCombos( IMaterial *pMaterial1, IMaterial *pMaterial2, int lightmapID1, int lightmapID2 )
  295. {
  296. CannotSupport();
  297. return 0;
  298. }
  299. IMesh *GetFlexMesh();
  300. void SetFlashlightStateEx( const FlashlightState_t &s, const VMatrix &m, ITexture *p )
  301. {
  302. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::SetFlashlightStateEx, RefToVal( s ), RefToVal( m ), p );
  303. }
  304. void PushScissorRect( const int nLeft, const int nTop, const int nRight, const int nBottom )
  305. {
  306. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::PushScissorRect, nLeft, nTop, nRight, nBottom );
  307. }
  308. void PopScissorRect( )
  309. {
  310. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::PopScissorRect );
  311. }
  312. virtual void DrawInstances( int nInstanceCount, const MeshInstanceData_t *pInstance );
  313. virtual void PushDeformation( const DeformationBase_t *pDef )
  314. {
  315. CannotSupport();
  316. }
  317. void PopDeformation( )
  318. {
  319. CannotSupport();
  320. }
  321. int GetNumActiveDeformations( ) const
  322. {
  323. return 0;
  324. }
  325. ITexture *GetLocalCubemap()
  326. {
  327. return m_pLocalCubemapTexture;
  328. }
  329. DEFINE_QUEUED_CALL_2( ClearBuffersObeyStencil, bool, bool, IMatRenderContext, m_pHardwareContext );
  330. DEFINE_QUEUED_CALL_3( ClearBuffersObeyStencilEx, bool, bool, bool, IMatRenderContext, m_pHardwareContext );
  331. DEFINE_QUEUED_CALL_0( PerformFullScreenStencilOperation, IMatRenderContext, m_pHardwareContext );
  332. DEFINE_QUEUED_CALL_1( SetRenderingPaint, bool, IMatRenderContext, m_pHardwareContext );
  333. bool GetUserClipTransform( VMatrix &worldToView )
  334. {
  335. CannotSupport();
  336. return false;
  337. }
  338. bool InFlashlightMode( void ) const
  339. {
  340. CannotSupport();
  341. return false;
  342. }
  343. bool IsRenderingPaint() const
  344. {
  345. CannotSupport();
  346. return false;
  347. }
  348. virtual void SetFlashlightMode( bool bEnable )
  349. {
  350. m_bFlashlightEnable = bEnable;
  351. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::SetFlashlightMode, bEnable );
  352. }
  353. virtual bool GetFlashlightMode( void ) const { return m_bFlashlightEnable; }
  354. virtual bool IsCullingEnabledForSinglePassFlashlight( void ) const { return m_bCullingEnabledForSinglePassFlashlight; }
  355. virtual void EnableCullingForSinglePassFlashlight( bool bEnable )
  356. {
  357. m_bCullingEnabledForSinglePassFlashlight = bEnable;
  358. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::EnableCullingForSinglePassFlashlight, bEnable );
  359. }
  360. virtual bool IsCascadedShadowMapping() const
  361. {
  362. CannotSupport();
  363. return false;
  364. }
  365. virtual void SetCascadedShadowMapping( bool bEnable )
  366. {
  367. m_bCascadedShadowMappingEnabled = bEnable;
  368. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::SetCascadedShadowMapping, bEnable );
  369. }
  370. virtual void SetCascadedShadowMappingState( const CascadedShadowMappingState_t &state, ITexture *pDepthTextureAtlas )
  371. {
  372. state, pDepthTextureAtlas;
  373. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::SetCascadedShadowMappingState, RefToVal( state ), pDepthTextureAtlas );
  374. }
  375. void BeginPIXEvent( unsigned long color, const char *pszName )
  376. {
  377. #ifdef PROFILE
  378. if ( IsX360() )
  379. {
  380. m_pHardwareContext->BeginPIXEvent( color, pszName );
  381. }
  382. #endif
  383. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::BeginPIXEvent, color, m_queue.Copy( pszName ) );
  384. }
  385. void EndPIXEvent( )
  386. {
  387. #ifdef PROFILE
  388. if ( IsX360() )
  389. {
  390. m_pHardwareContext->EndPIXEvent( );
  391. }
  392. #endif
  393. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::EndPIXEvent );
  394. }
  395. void SetPIXMarker( unsigned long color, const char *pszName )
  396. {
  397. #ifdef PROFILE
  398. if ( IsX360() )
  399. {
  400. m_pHardwareContext->SetPIXMarker( color, pszName );
  401. }
  402. #endif
  403. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::SetPIXMarker, color, m_queue.Copy( pszName ) );
  404. }
  405. DEFINE_QUEUED_CALL_0( ForceHardwareSync, IMatRenderContextInternal, m_pHardwareContext );
  406. DEFINE_QUEUED_CALL_0( BeginFrame, IMatRenderContextInternal, m_pHardwareContext );
  407. DEFINE_QUEUED_CALL_0( EndFrame, IMatRenderContextInternal, m_pHardwareContext );
  408. DEFINE_QUEUED_CALL_0( BeginMorphAccumulation, IMatRenderContextInternal, m_pHardwareContext );
  409. DEFINE_QUEUED_CALL_0( EndMorphAccumulation, IMatRenderContextInternal, m_pHardwareContext );
  410. virtual void AccumulateMorph( IMorph* pMorph, int nMorphCount, const MorphWeight_t* pWeights )
  411. {
  412. // FIXME: Must copy off the morph weights here. Not sure the pattern for this.
  413. Assert( 0 );
  414. }
  415. virtual bool GetMorphAccumulatorTexCoord( Vector2D *pTexCoord, IMorph *pIMorph, int nVertex )
  416. {
  417. // FIXME: We must assign morph ids in the queued mode
  418. // and pass the ids down to the morph mgr to get the texcoord
  419. Assert(0);
  420. pTexCoord->Init();
  421. return false;
  422. }
  423. virtual void SetFlexWeights( int nFirstWeight, int nCount, const MorphWeight_t* pWeights )
  424. {
  425. Assert(0);
  426. }
  427. // Subdivision surface interface
  428. virtual int GetSubDBufferWidth()
  429. {
  430. Assert( 0 );
  431. return 0;
  432. }
  433. virtual float* LockSubDBuffer( int nNumRows )
  434. {
  435. Assert( 0 );
  436. return NULL;
  437. }
  438. virtual void UnlockSubDBuffer()
  439. {
  440. Assert( 0 );
  441. }
  442. DEFINE_QUEUED_CALL_1( UpdateGameTime, float, IMatRenderContext, m_pHardwareContext );
  443. //-------------------------------------------------------------------------
  444. DEFINE_QUEUED_CALL_AFTER_BASE_1( SetCurrentMaterialInternal, IMaterialInternal *, IMatRenderContextInternal, m_pHardwareContext );
  445. DEFINE_QUEUED_CALL_AFTER_BASE_1( SetCurrentProxy, void *, IMatRenderContextInternal, m_pHardwareContext );
  446. int GetLightmapPage()
  447. {
  448. CannotSupport();
  449. return 0;
  450. }
  451. void ForceDepthFuncEquals( bool )
  452. {
  453. CannotSupport();
  454. }
  455. void BindStandardTexture( Sampler_t, TextureBindFlags_t nBindFlags, StandardTextureId_t )
  456. {
  457. CannotSupport();
  458. }
  459. void GetLightmapDimensions( int *, int * )
  460. {
  461. CannotSupport();
  462. }
  463. MorphFormat_t GetBoundMorphFormat()
  464. {
  465. CannotSupport();
  466. return (MorphFormat_t)0;
  467. }
  468. void DrawClearBufferQuad( unsigned char, unsigned char, unsigned char, unsigned char, bool, bool, bool )
  469. {
  470. CannotSupport();
  471. }
  472. #ifdef _PS3
  473. void DrawReloadZcullQuad()
  474. {
  475. CannotSupport();
  476. }
  477. #endif // _PS3
  478. void BeginBatch( IMesh* pIndices );
  479. void BindBatch( IMesh* pVertices, IMaterial *pAutoBind = NULL );
  480. void DrawBatch( MaterialPrimitiveType_t primType, int firstIndex, int numIndices );
  481. void EndBatch();
  482. // Color correction related methods..
  483. // Client cannot call IColorCorrectionSystem directly because it is not thread-safe
  484. // FIXME: Make IColorCorrectionSystem threadsafe?
  485. virtual ColorCorrectionHandle_t AddLookup( const char *pName );
  486. virtual void LockLookup( ColorCorrectionHandle_t handle );
  487. virtual void LoadLookup( ColorCorrectionHandle_t handle, const char *pLookupName );
  488. virtual void UnlockLookup( ColorCorrectionHandle_t handle );
  489. virtual bool RemoveLookup( ColorCorrectionHandle_t handle );
  490. DEFINE_QUEUED_CALL_1( EnableColorCorrection, bool, IColorCorrectionSystem, g_pColorCorrectionSystem );
  491. DEFINE_QUEUED_CALL_0( ResetLookupWeights, IColorCorrectionSystem, g_pColorCorrectionSystem );
  492. DEFINE_QUEUED_CALL_2( SetLookupWeight, ColorCorrectionHandle_t, float, IColorCorrectionSystem, g_pColorCorrectionSystem );
  493. DEFINE_QUEUED_CALL_2( SetResetable, ColorCorrectionHandle_t, bool, IColorCorrectionSystem, g_pColorCorrectionSystem );
  494. DEFINE_QUEUED_CALL_1( SetFullScreenDepthTextureValidityFlag, bool, IMatRenderContext, m_pHardwareContext );
  495. void SetToneMappingScaleLinear( const Vector &scale )
  496. {
  497. m_LastSetToneMapScale = scale;
  498. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::SetToneMappingScaleLinear, RefToVal( scale ) );
  499. }
  500. Vector GetToneMappingScaleLinear( void )
  501. {
  502. return m_LastSetToneMapScale;
  503. }
  504. #if defined( _GAMECONSOLE )
  505. void BeginConsoleZPass( const WorldListIndicesInfo_t &indicesInfo )
  506. {
  507. uint nSpaceLeft = Indices().GetSize() - Indices().GetUsed();
  508. if( nSpaceLeft >= indicesInfo.m_nTotalIndices )
  509. {
  510. // there's enough indices in the primary (non-spillover) index buffer that's resident in memory for 3 frames,
  511. // and that's not a ring buffer. We don't need to worry about these indices being overwritten by anything due
  512. // to ring buffer ending and restarting: there's another (spillover) ring buffer that does that
  513. BeginConsoleZPass2( 0 );
  514. }
  515. else
  516. {
  517. // there's some spillover from the main dynamic index buffer; thus, we need to compute the spillover and defer the decision
  518. // about whether we have enough space in spillover buffer to start z prepass for later
  519. // in the very worst case, we'll waste ( indicesInfo.m_nMaxBatchIndices - 1 ) indices
  520. // in the end of the main dynamic IB
  521. BeginConsoleZPass2( indicesInfo.m_nTotalIndices - nSpaceLeft + indicesInfo.m_nMaxBatchIndices - 1 );
  522. }
  523. }
  524. #endif
  525. void DeferredBeginBatch( );
  526. void DeferredDrawPrimList( IMesh *pMesh, CPrimList *pLists, int nLists );
  527. void DeferredSetFlexMesh( IMesh *pStaticMesh, int nVertexOffsetInBytes );
  528. #if defined( _X360 )
  529. DEFINE_QUEUED_CALL_1( PushVertexShaderGPRAllocation, int, IMatRenderContext, m_pHardwareContext );
  530. DEFINE_QUEUED_CALL_0( PopVertexShaderGPRAllocation, IMatRenderContext, m_pHardwareContext );
  531. DEFINE_QUEUED_CALL_0( FlushHiStencil, IMatRenderContext, m_pHardwareContext );
  532. #endif
  533. #if defined( _GAMECONSOLE )
  534. DEFINE_QUEUED_CALL_1( BeginConsoleZPass2, int, IMatRenderContext, m_pHardwareContext );
  535. DEFINE_QUEUED_CALL_0( EndConsoleZPass, IMatRenderContext, m_pHardwareContext );
  536. #endif
  537. #if defined( _PS3 )
  538. DEFINE_QUEUED_CALL_0( FlushTextureCache, IMatRenderContext, m_pHardwareContext );
  539. #endif
  540. DEFINE_QUEUED_CALL_1( AntiAliasingHint, int, IMatRenderContext, m_pHardwareContext );
  541. // A special path used to tick the front buffer while loading on the 360
  542. DEFINE_QUEUED_CALL_5( SetNonInteractiveLogoTexture, ITexture *, float, float, float, float, IMatRenderContext, m_pHardwareContext );
  543. DEFINE_QUEUED_CALL_4( SetNonInteractivePacifierTexture, ITexture *, float, float, float, IMatRenderContext, m_pHardwareContext );
  544. DEFINE_QUEUED_CALL_2( SetNonInteractiveTempFullscreenBuffer, ITexture *, MaterialNonInteractiveMode_t, IMatRenderContext, m_pHardwareContext );
  545. DEFINE_QUEUED_CALL_1( EnableNonInteractiveMode, MaterialNonInteractiveMode_t, IMatRenderContext, m_pHardwareContext );
  546. DEFINE_QUEUED_CALL_0( RefreshFrontBufferNonInteractive, IMatRenderContext, m_pHardwareContext );
  547. DELEGATE_TO_OBJECT_1V( FlipCulling, bool, g_pShaderAPI );
  548. // DEFINE_QUEUED_CALL_1( EnableSinglePassFlashlightMode, bool, IMatRenderContext, m_pHardwareContext );
  549. virtual void EnableSinglePassFlashlightMode( bool bEnable )
  550. {
  551. m_bSinglePassFlashlightMode = bEnable;
  552. m_queue.QueueCall( m_pHardwareContext, &IMatRenderContext::EnableSinglePassFlashlightMode, bEnable );
  553. }
  554. virtual bool SinglePassFlashlightModeEnabled( void ) const { return m_bSinglePassFlashlightMode; }
  555. //--------------------------------------------------------
  556. // Memory allocation calls for queued mesh, et. al.
  557. //--------------------------------------------------------
  558. byte *AllocVertices( int nVerts, int nVertexSize, bool *pUsingExternalMemory );
  559. byte *AllocIndices( int nIndices, int nIndexSize, bool *pUsingExternalMemory );
  560. byte *ReallocVertices( byte *pVerts, int nVertsOld, int nVertsNew, int nVertexSize, bool bExternalMemory );
  561. byte *ReallocIndices( byte *pIndices, int nIndicesOld, int nIndicesNew, int nIndexSize, bool bExternalMemory );
  562. void FreeVertices( byte *pVerts, int nVerts, int nVertexSize );
  563. void FreeIndices( byte *pIndices, int nIndices, int nIndexSize );
  564. //--------------------------------------------------------
  565. // debug logging - no-op in queued context
  566. //--------------------------------------------------------
  567. virtual void Printf( char *fmt, ... ) {};
  568. virtual void PrintfVA( char *fmt, va_list vargs ){};
  569. virtual float Knob( char *knobname, float *setvalue=NULL ) { return 0.0f; };
  570. #if defined( DX_TO_GL_ABSTRACTION ) && !defined( _GAMECONSOLE )
  571. void DoStartupShaderPreloading( void ) {}
  572. #endif
  573. #if defined( INCLUDE_SCALEFORM )
  574. //--------------------------------------------------------
  575. // scaleform calls
  576. //
  577. // *** NOTE - THREAD SAFETY ***
  578. // SFUI is not mutexed. If you add functions to this list check it is safe
  579. // to call them in parallel with the main thread
  580. //--------------------------------------------------------
  581. DEFINE_QUEUED_CALL_5( SetScaleformSlotViewport, int, int, int, int, int, IMatRenderContext, m_pHardwareContext );
  582. DEFINE_QUEUED_CALL_1( RenderScaleformSlot, int, IMatRenderContext, m_pHardwareContext );
  583. DEFINE_QUEUED_CALL_4( SetScaleformCursorViewport, int, int, int, int, IMatRenderContext, m_pHardwareContext );
  584. DEFINE_QUEUED_CALL_0( RenderScaleformCursor, IMatRenderContext, m_pHardwareContext );
  585. // Unused on PC
  586. DEFINE_QUEUED_CALL_1( ForkRenderScaleformSlot, int, IMatRenderContext, m_pHardwareContext );
  587. DEFINE_QUEUED_CALL_1( JoinRenderScaleformSlot, int, IMatRenderContext, m_pHardwareContext );
  588. void AdvanceAndRenderScaleformSlot( int slot )
  589. {
  590. // always run advance slot on the main thread
  591. ScaleformUI()->AdvanceSlot( slot );
  592. // renderSlot can be queued
  593. RenderScaleformSlot( slot );
  594. }
  595. void AdvanceAndRenderScaleformCursor()
  596. {
  597. // always run advance slot on the main thread
  598. ScaleformUI()->AdvanceCursor();
  599. // renderSlot can be queued
  600. RenderScaleformCursor();
  601. }
  602. #endif // INCLUDE_SCALEFORM
  603. virtual ColorCorrectionHandle_t FindLookup( const char *pName );
  604. private:
  605. void QueueMatrixSync();
  606. void DeferredDrawInstances( int nInstanceCount, const MeshInstanceData_t *pInstances );
  607. #ifndef MS_NO_DYNAMIC_BUFFER_COPY
  608. FORCEINLINE CMemoryStack &Vertices()
  609. {
  610. return m_Vertices;
  611. }
  612. FORCEINLINE CMemoryStack &Indices()
  613. {
  614. return m_Indices;
  615. }
  616. #else
  617. FORCEINLINE CMemoryStack &Vertices()
  618. {
  619. return *m_pVertices;
  620. }
  621. FORCEINLINE CMemoryStack &Indices()
  622. {
  623. return *m_pIndices;
  624. }
  625. #endif
  626. //friend class CMatQueuedMesh;
  627. friend class CCallQueueExternal;
  628. CMatCallQueue m_queue;
  629. CMatQueuedMesh *m_pQueuedMesh;
  630. CMatQueuedMesh *m_pQueuedFlexMesh;
  631. CMatQueuedIndexBuffer *m_pQueuedIndexBuffer;
  632. CMatRenderContextBase *m_pHardwareContext;
  633. int m_iRenderDepth;
  634. int m_WidthBackBuffer, m_HeightBackBuffer;
  635. int m_nBoneCount;
  636. MaterialFogMode_t m_FogMode;
  637. float m_flFogStart;
  638. float m_flFogEnd;
  639. float m_flFogZ;
  640. float m_flFogMaxDensity;
  641. color24 m_FogColor;
  642. CMemoryStack m_Vertices;
  643. CMemoryStack m_Indices;
  644. #ifdef MS_NO_DYNAMIC_BUFFER_COPY
  645. #define RENDER_CONTEXT_STACKS 3
  646. static CMemoryStack s_Vertices[RENDER_CONTEXT_STACKS];
  647. static CMemoryStack s_Indices[RENDER_CONTEXT_STACKS];
  648. static int s_nCurStack;
  649. static bool s_bInitializedStacks;
  650. private:
  651. CMemoryStack *m_pVertices;
  652. CMemoryStack *m_pIndices;
  653. #endif
  654. class CCallQueueExternal : public ICallQueue
  655. {
  656. void QueueFunctorInternal( CFunctor *pFunctor )
  657. {
  658. GET_OUTER( CMatQueuedRenderContext, m_CallQueueExternal )->m_queue.QueueFunctor( pFunctor );
  659. pFunctor->Release();
  660. }
  661. };
  662. CCallQueueExternal m_CallQueueExternal;
  663. };
  664. //-----------------------------------------------------------------------------
  665. #include "tier0/memdbgoff.h"
  666. #endif // CMATQUEUEDRENDERCONTEXT_H