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.

129 lines
3.4 KiB

  1. //===== Copyright � 1996-2006, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: interface to asynchronous lighting preview creator
  4. //
  5. //===========================================================================//
  6. #ifndef LPREVIEW_THREAD_H
  7. #define LPREVIEW_THREAD_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier0/threadtools.h"
  12. #include "bitmap/bitmap.h"
  13. #include "bitmap/floatbitmap.h"
  14. #include "tier1/utlvector.h"
  15. #include "mathlib/lightdesc.h"
  16. #include "tier1/utlintrusivelist.h"
  17. class CLightingPreviewLightDescription : public LightDesc_t
  18. {
  19. public:
  20. CLightingPreviewLightDescription *m_pNext;
  21. CUtlVector<CLightingPreviewLightDescription*> m_TempChildren;
  22. int m_nObjectID;
  23. float m_flJitterAmount; // for area lights - how much to
  24. // randomly perturb light pos when
  25. // tracing
  26. class CIncrementalLightInfo *m_pIncrementalInfo;
  27. bool m_bLowRes; // whether to generate at 1/16 screen res
  28. bool m_bDidIndirect; // whether or not we tried to generate pseudo lights yet
  29. CLightingPreviewLightDescription( void )
  30. {
  31. m_flJitterAmount = 0;
  32. m_bLowRes = true;
  33. m_bDidIndirect = false;
  34. }
  35. void Init( int obj_id )
  36. {
  37. m_pNext = NULL;
  38. m_pIncrementalInfo = NULL;
  39. m_nObjectID = obj_id;
  40. m_bDidIndirect = false;
  41. }
  42. };
  43. enum HammerToLightingPreviewMessageType
  44. {
  45. // messages from hammer to preview task
  46. LPREVIEW_MSG_STOP, // no lighting previews open - stop working
  47. LPREVIEW_MSG_EXIT, // we're exiting program - shut down
  48. LPREVIEW_MSG_GEOM_DATA, // we have new shadow geometry data
  49. LPREVIEW_MSG_G_BUFFERS, // we have new g buffer data from the renderer
  50. LPREVIEW_MSG_LIGHT_DATA, // new light data in m_pLightList
  51. };
  52. enum LightingPreviewToHammerMessageType
  53. {
  54. // messages from preview task to hammer
  55. LPREVIEW_MSG_DISPLAY_RESULT, // we have a result image
  56. };
  57. struct MessageToLPreview
  58. {
  59. HammerToLightingPreviewMessageType m_MsgType;
  60. MessageToLPreview( HammerToLightingPreviewMessageType mtype)
  61. {
  62. m_MsgType = mtype;
  63. }
  64. MessageToLPreview( void)
  65. {
  66. }
  67. // this structure uses a fat format for the args instead of separate classes for each
  68. // message. the messages are small anyway, since pointers are used for anything of size.
  69. FloatBitMap_t *m_pDefferedRenderingBMs[4]; // if LPREVIEW_MSG_G_BUFFERS
  70. CUtlIntrusiveList<CLightingPreviewLightDescription> m_LightList; // if LPREVIEW_MSG_LIGHT_DATA
  71. Vector m_EyePosition; // for LPREVIEW_MSG_LIGHT_DATA & G_BUFFERS
  72. CUtlVector<Vector> *m_pShadowTriangleList; // for LPREVIEW_MSG_GEOM_DATA
  73. int m_nBitmapGenerationCounter; // for LPREVIEW_MSG_G_BUFFERS
  74. };
  75. struct MessageFromLPreview
  76. {
  77. LightingPreviewToHammerMessageType m_MsgType;
  78. Bitmap_t *m_pBitmapToDisplay; // for LPREVIEW_MSG_DISPLAY_RESULT
  79. int m_nBitmapGenerationCounter; // for LPREVIEW_MSG_DISPLAY_RESULT
  80. MessageFromLPreview( LightingPreviewToHammerMessageType msgtype )
  81. {
  82. m_MsgType = msgtype;
  83. }
  84. MessageFromLPreview( void )
  85. {
  86. }
  87. };
  88. extern CMessageQueue<MessageToLPreview> g_HammerToLPreviewMsgQueue;
  89. extern CMessageQueue<MessageFromLPreview> g_LPreviewToHammerMsgQueue;
  90. extern ThreadHandle_t g_LPreviewThread;
  91. extern CInterlockedInt n_gbufs_queued;
  92. extern CInterlockedInt n_result_bms_queued;
  93. extern Bitmap_t *g_pLPreviewOutputBitmap;
  94. // the lighting preview thread entry point
  95. unsigned LightingPreviewThreadFN( void *thread_start_arg );
  96. // the lighting preview handler. call often
  97. void HandleLightingPreview( void );
  98. #endif