gfxD3D11VertexBuffer.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2015 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 _GFXD3D_VERTEXBUFFER_H_
  23. #define _GFXD3D_VERTEXBUFFER_H_
  24. #include "gfx/D3D11/gfxD3D11Device.h"
  25. #include "core/util/safeDelete.h"
  26. class GFXD3D11VertexBuffer : public GFXVertexBuffer
  27. {
  28. public:
  29. ID3D11Buffer *vb;
  30. StrongRefPtr<GFXD3D11VertexBuffer> mVolatileBuffer;
  31. void *mLockedBuffer;
  32. #ifdef TORQUE_DEBUG
  33. #define _VBGuardString "GFX_VERTEX_BUFFER_GUARD_STRING"
  34. U8 *mDebugGuardBuffer;
  35. #endif TORQUE_DEBUG
  36. bool mIsFirstLock;
  37. bool mClearAtFrameEnd;
  38. GFXD3D11VertexBuffer();
  39. GFXD3D11VertexBuffer( GFXDevice *device,
  40. U32 numVerts,
  41. const GFXVertexFormat *vertexFormat,
  42. U32 vertexSize,
  43. GFXBufferType bufferType );
  44. virtual ~GFXD3D11VertexBuffer();
  45. void lock(U32 vertexStart, U32 vertexEnd, void **vertexPtr);
  46. void unlock();
  47. void prepare() {}
  48. // GFXResource interface
  49. virtual void zombify();
  50. virtual void resurrect();
  51. };
  52. //-----------------------------------------------------------------------------
  53. // This is for debugging vertex buffers and trying to track down which vbs
  54. // aren't getting free'd
  55. inline GFXD3D11VertexBuffer::GFXD3D11VertexBuffer() : GFXVertexBuffer(0,0,0,0,(GFXBufferType)0)
  56. {
  57. vb = NULL;
  58. mIsFirstLock = true;
  59. lockedVertexEnd = lockedVertexStart = 0;
  60. mClearAtFrameEnd = false;
  61. mLockedBuffer = NULL;
  62. #ifdef TORQUE_DEBUG
  63. mDebugGuardBuffer = NULL;
  64. #endif
  65. }
  66. inline GFXD3D11VertexBuffer::GFXD3D11VertexBuffer( GFXDevice *device,
  67. U32 numVerts,
  68. const GFXVertexFormat *vertexFormat,
  69. U32 vertexSize,
  70. GFXBufferType bufferType )
  71. : GFXVertexBuffer( device, numVerts, vertexFormat, vertexSize, bufferType )
  72. {
  73. vb = NULL;
  74. mIsFirstLock = true;
  75. mClearAtFrameEnd = false;
  76. lockedVertexEnd = lockedVertexStart = 0;
  77. mLockedBuffer = NULL;
  78. #ifdef TORQUE_DEBUG
  79. mDebugGuardBuffer = NULL;
  80. #endif
  81. }
  82. #endif // _GFXD3D_VERTEXBUFFER_H_