2
0

gfxOcclusionQuery.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GFXOCCLUSIONQUERY_H_
  23. #define _GFXOCCLUSIONQUERY_H_
  24. #ifndef _GFXDEVICE_H_
  25. #include "gfx/gfxDevice.h"
  26. #endif
  27. /// A geometry visibility query object.
  28. /// @see GFXDevice::createOcclusionQuery
  29. class GFXOcclusionQuery : public GFXResource
  30. {
  31. protected:
  32. GFXDevice *mDevice;
  33. GFXOcclusionQuery( GFXDevice *device )
  34. : mDevice( device )
  35. {
  36. }
  37. public:
  38. /// The states returned by getStatus()
  39. /// If you modify this enum you should also modify statusToString()
  40. enum OcclusionQueryStatus
  41. {
  42. Unset, ///<
  43. Waiting, ///<
  44. Error, ///<
  45. Occluded,
  46. NotOccluded
  47. };
  48. virtual ~GFXOcclusionQuery() {}
  49. /// Prepares the query returning true if the last query
  50. /// has been processed and more geometry can be issued.
  51. /// @see getStatus
  52. virtual bool begin() = 0;
  53. /// Called after your geometry is drawn to submit
  54. /// the query for processing.
  55. virtual void end() = 0;
  56. /// Returns the status of the last submitted query. In general
  57. /// you should avoid blocking for the result until the frame
  58. /// following your query to keep from stalling the CPU.
  59. /// @return Status
  60. /// @param block If true CPU will block until the query finishes.
  61. /// @param data Number of pixels rendered, valid only if status returned is NotOccluded.
  62. virtual OcclusionQueryStatus getStatus( bool block, U32 *data = NULL ) = 0;
  63. /// Returns a status string.
  64. static String statusToString( OcclusionQueryStatus status );
  65. // GFXResource
  66. virtual void zombify() = 0;
  67. virtual void resurrect() = 0;
  68. virtual const String describeSelf() const = 0;
  69. };
  70. #endif // _GFXOCCLUSIONQUERY_H_