CmD3D11HardwareBuffer.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include "CmD3D11Prerequisites.h"
  3. #include "CmHardwareBuffer.h"
  4. namespace CamelotFramework
  5. {
  6. class CM_D3D11_EXPORT D3D11HardwareBuffer : public HardwareBuffer
  7. {
  8. public:
  9. enum BufferType
  10. {
  11. BT_VERTEX = 0x1,
  12. BT_INDEX = 0x2,
  13. BT_CONSTANT = 0x4,
  14. BT_GROUP_GENERIC = 0x8,
  15. BT_STRUCTURED = BT_GROUP_GENERIC | 0x10,
  16. BT_RAW = BT_GROUP_GENERIC | 0x20,
  17. BT_INDIRECTARGUMENT = BT_GROUP_GENERIC | 0x40,
  18. BT_APPENDCONSUME = BT_GROUP_GENERIC | 0x80
  19. };
  20. D3D11HardwareBuffer(BufferType btype, GpuBufferUsage usage, UINT32 elementCount, UINT32 elementSize,
  21. D3D11Device& device, bool useSystemMem = false, bool streamOut = false, bool randomGpuWrite = false, bool useCounter = false);
  22. ~D3D11HardwareBuffer();
  23. /** See HardwareBuffer. */
  24. void readData(UINT32 offset, UINT32 length, void* pDest);
  25. /** See HardwareBuffer. */
  26. void writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags = BufferWriteType::Normal);
  27. /** See HardwareBuffer. We perform a hardware copy here. */
  28. void copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset,
  29. UINT32 dstOffset, UINT32 length, bool discardWholeBuffer = false);
  30. /// Get the D3D-specific buffer
  31. ID3D11Buffer* getD3DBuffer(void) { return mD3DBuffer; }
  32. protected:
  33. BufferType mBufferType;
  34. bool mRandomGpuWrite;
  35. bool mUseCounter;
  36. UINT32 mElementCount;
  37. UINT32 mElementSize;
  38. ID3D11Buffer* mD3DBuffer;
  39. bool mUseTempStagingBuffer;
  40. D3D11HardwareBuffer* mpTempStagingBuffer;
  41. bool mStagingUploadNeeded;
  42. D3D11Device& mDevice;
  43. D3D11_BUFFER_DESC mDesc;
  44. /** See HardwareBuffer. */
  45. void* lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options);
  46. /** See HardwareBuffer. */
  47. void unlockImpl(void);
  48. };
  49. }