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.

108 lines
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. // TOGL CODE LICENSE
  3. //
  4. // Copyright 2011-2014 Valve Corporation
  5. // All Rights Reserved.
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8. // of this software and associated documentation files (the "Software"), to deal
  9. // in the Software without restriction, including without limitation the rights
  10. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. // copies of the Software, and to permit persons to whom the Software is
  12. // furnished to do so, subject to the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be included in
  15. // all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. //
  25. // cglmquery.h
  26. // GLMgr queries
  27. //
  28. //===============================================================================
  29. #ifndef CGLMQUERY_H
  30. #define CGLMQUERY_H
  31. #pragma once
  32. //===============================================================================
  33. // forward declarations
  34. class GLMContext;
  35. class CGLMQuery;
  36. //===============================================================================
  37. enum EGLMQueryType
  38. {
  39. EOcclusion,
  40. EFence,
  41. EGLMQueryCount
  42. };
  43. struct GLMQueryParams
  44. {
  45. EGLMQueryType m_type;
  46. };
  47. class CGLMQuery
  48. {
  49. // leave everything public til it's running
  50. public:
  51. friend class GLMContext; // only GLMContext can make CGLMTex objects
  52. friend struct IDirect3DDevice9;
  53. friend struct IDirect3DQuery9;
  54. GLMContext *m_ctx; // link back to parent context
  55. GLMQueryParams m_params; // params created with
  56. GLuint m_name; // name of the query object per se - could be fence, could be query object ... NOT USED WITH GL_ARB_sync!
  57. #ifdef HAVE_GL_ARB_SYNC
  58. GLsync m_syncobj; // GL_ARB_sync object. NOT USED WITH GL_NV_fence or GL_APPLE_fence!
  59. #else
  60. GLuint m_syncobj;
  61. #endif
  62. bool m_started;
  63. bool m_stopped;
  64. bool m_done;
  65. bool m_nullQuery; // was gl_nullqueries true at Start time - if so, continue to act like a null query through Stop/IsDone/Complete time
  66. // restated - only Start should examine the convar.
  67. static uint s_nTotalOcclusionQueryCreatesOrDeletes;
  68. CGLMQuery( GLMContext *ctx, GLMQueryParams *params );
  69. ~CGLMQuery( );
  70. // for an occlusion query:
  71. // Start = BeginQuery query-start goes into stream
  72. // Stop = EndQuery query-end goes into stream - a fence is also set so we can probe for completion
  73. // IsDone = TestFence use the added fence to ask if query-end has passed (i.e. will Complete block?)
  74. // Complete = GetQueryObjectuivARB(uint id, enum pname, uint *params) - extract the sample count
  75. // for a fence query:
  76. // Start = SetFence fence goes into command stream
  77. // Stop = NOP fences are self finishing - no need to call Stop on a fence
  78. // IsDone = TestFence ask if fence passed
  79. // Complete = FinishFence
  80. void Start ( void );
  81. void Stop ( void );
  82. bool IsDone ( void );
  83. void Complete ( uint *result );
  84. // accessors for the started/stopped state
  85. bool IsStarted ( void );
  86. bool IsStopped ( void );
  87. };
  88. #endif