storageBuffer.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import type { AbstractEngine } from "../Engines/abstractEngine";
  2. import type { DataBuffer } from "../Buffers/dataBuffer";
  3. import type { DataArray } from "../types";
  4. /**
  5. * This class is a small wrapper around a native buffer that can be read and/or written
  6. */
  7. export declare class StorageBuffer {
  8. private _engine;
  9. private _buffer;
  10. private _bufferSize;
  11. private _creationFlags;
  12. private _label?;
  13. /**
  14. * Creates a new storage buffer instance
  15. * @param engine The engine the buffer will be created inside
  16. * @param size The size of the buffer in bytes
  17. * @param creationFlags flags to use when creating the buffer (see Constants.BUFFER_CREATIONFLAG_XXX). The BUFFER_CREATIONFLAG_STORAGE flag will be automatically added.
  18. * @param label defines the label of the buffer (for debug purpose)
  19. */
  20. constructor(engine: AbstractEngine, size: number, creationFlags?: number, label?: string);
  21. private _create;
  22. /** @internal */
  23. _rebuild(): void;
  24. /**
  25. * Gets underlying native buffer
  26. * @returns underlying native buffer
  27. */
  28. getBuffer(): DataBuffer;
  29. /**
  30. * Updates the storage buffer
  31. * @param data the data used to update the storage buffer
  32. * @param byteOffset the byte offset of the data (optional)
  33. * @param byteLength the byte length of the data (optional)
  34. */
  35. update(data: DataArray, byteOffset?: number, byteLength?: number): void;
  36. /**
  37. * Reads data from the storage buffer
  38. * @param offset The offset in the storage buffer to start reading from (default: 0)
  39. * @param size The number of bytes to read from the storage buffer (default: capacity of the buffer)
  40. * @param buffer The buffer to write the data we have read from the storage buffer to (optional)
  41. * @param noDelay If true, a call to flushFramebuffer will be issued so that the data can be read back immediately. This can speed up data retrieval, at the cost of a small perf penalty (default: false).
  42. * @returns If not undefined, returns the (promise) buffer (as provided by the 4th parameter) filled with the data, else it returns a (promise) Uint8Array with the data read from the storage buffer
  43. */
  44. read(offset?: number, size?: number, buffer?: ArrayBufferView, noDelay?: boolean): Promise<ArrayBufferView>;
  45. /**
  46. * Disposes the storage buffer
  47. */
  48. dispose(): void;
  49. }