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.

86 lines
2.4 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ============
  2. //
  3. // cglmquery.h
  4. // GLMgr queries
  5. //
  6. //===============================================================================
  7. #ifndef CGLMQUERY_H
  8. #define CGLMQUERY_H
  9. #pragma once
  10. //===============================================================================
  11. // forward declarations
  12. class GLMContext;
  13. class CGLMQuery;
  14. //===============================================================================
  15. enum EGLMQueryType
  16. {
  17. EOcclusion,
  18. EFence,
  19. EGLMQueryCount
  20. };
  21. struct GLMQueryParams
  22. {
  23. EGLMQueryType m_type;
  24. };
  25. class CGLMQuery
  26. {
  27. // leave everything public til it's running
  28. public:
  29. friend class GLMContext; // only GLMContext can make CGLMTex objects
  30. friend struct IDirect3DDevice9;
  31. friend struct IDirect3DQuery9;
  32. GLMContext *m_ctx; // link back to parent context
  33. GLMQueryParams m_params; // params created with
  34. GLuint m_name; // name of the query object per se - could be fence, could be query object ... NOT USED WITH GL_ARB_sync!
  35. #ifdef HAVE_GL_ARB_SYNC
  36. GLsync m_syncobj; // GL_ARB_sync object. NOT USED WITH GL_NV_fence or GL_APPLE_fence!
  37. #else
  38. GLuint m_syncobj;
  39. #endif
  40. bool m_started;
  41. bool m_stopped;
  42. bool m_done;
  43. bool m_nullQuery; // was gl_nullqueries true at Start time - if so, continue to act like a null query through Stop/IsDone/Complete time
  44. // restated - only Start should examine the convar.
  45. static uint s_nTotalOcclusionQueryCreatesOrDeletes;
  46. CGLMQuery( GLMContext *ctx, GLMQueryParams *params );
  47. ~CGLMQuery( );
  48. // for an occlusion query:
  49. // Start = BeginQuery query-start goes into stream
  50. // Stop = EndQuery query-end goes into stream - a fence is also set so we can probe for completion
  51. // IsDone = TestFence use the added fence to ask if query-end has passed (i.e. will Complete block?)
  52. // Complete = GetQueryObjectuivARB(uint id, enum pname, uint *params) - extract the sample count
  53. // for a fence query:
  54. // Start = SetFence fence goes into command stream
  55. // Stop = NOP fences are self finishing - no need to call Stop on a fence
  56. // IsDone = TestFence ask if fence passed
  57. // Complete = FinishFence
  58. void Start ( void );
  59. void Stop ( void );
  60. bool IsDone ( void );
  61. void Complete ( uint *result );
  62. // accessors for the started/stopped state
  63. bool IsStarted ( void );
  64. bool IsStopped ( void );
  65. };
  66. #endif