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.

98 lines
2.9 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ============
  2. //
  3. // cglmprogram.h
  4. // GLMgr buffers (index / vertex)
  5. // ... maybe add PBO later as well
  6. //===============================================================================
  7. #ifndef CGLMBUFFER_H
  8. #define CGLMBUFFER_H
  9. #pragma once
  10. // ext links
  11. // http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt
  12. //===============================================================================
  13. // tokens not in the SDK headers
  14. //#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
  15. // #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
  16. //#endif
  17. //===============================================================================
  18. // forward declarations
  19. class GLMContext;
  20. enum EGLMBufferType
  21. {
  22. kGLMVertexBuffer,
  23. kGLMIndexBuffer,
  24. kGLMUniformBuffer, // for bindable uniform
  25. kGLMPixelBuffer, // for PBO
  26. kGLMNumBufferTypes
  27. };
  28. // pass this in "options" to constructor to make a dynamic buffer
  29. #define GLMBufferOptionDynamic 0x00000001
  30. struct GLMBuffLockParams
  31. {
  32. uint m_offset;
  33. uint m_size;
  34. bool m_nonblocking;
  35. bool m_discard;
  36. };
  37. class CGLMBuffer
  38. {
  39. public:
  40. void Lock( GLMBuffLockParams *params, char **addressOut );
  41. void Unlock( void );
  42. //protected:
  43. friend class GLMContext; // only GLMContext can make CGLMBuffer objects
  44. friend class GLMTester;
  45. friend class IDirect3D9;
  46. friend class IDirect3DDevice9;
  47. CGLMBuffer ( GLMContext *ctx, EGLMBufferType type, uint size, uint options );
  48. ~CGLMBuffer ( );
  49. void SetModes ( bool asyncMap, bool explicitFlush, bool force = false );
  50. void FlushRange ( uint offset, uint size );
  51. GLMContext *m_ctx; // link back to parent context
  52. EGLMBufferType m_type;
  53. uint m_size;
  54. GLenum m_buffGLTarget; // GL_ARRAY_BUFFER_ARB / GL_ELEMENT_BUFFER_ARB
  55. GLuint m_name; // name of this program in the context
  56. uint m_revision; // bump anytime the size changes or buffer is orphaned
  57. bool m_enableAsyncMap; // mirror of the buffer state
  58. bool m_enableExplicitFlush; // mirror of the buffer state
  59. bool m_bound; // true if bound to context
  60. bool m_mapped; // is it currently mapped
  61. uint m_dirtyMinOffset; // when equal, range is empty
  62. uint m_dirtyMaxOffset;
  63. float *m_lastMappedAddress;
  64. // --------------------- pseudo-VBO support below here (explicitly for dynamic index buffers)
  65. bool m_pseudo; // true if the m_name is 0, and the backing is plain RAM
  66. // in pseudo mode, there is just one RAM buffer that acts as the backing.
  67. // expectation is that this mode would only be used for dynamic indices.
  68. // since indices have to be consumed (copied to command stream) prior to return from a drawing call,
  69. // there's no need to do any fencing or multibuffering. orphaning in particular becomes a no-op.
  70. char *m_pseudoBuf; // storage for pseudo buffer
  71. };
  72. #endif