Class ByteBufferNativeMemory

java.lang.Object
dev.engine.core.memory.ByteBufferNativeMemory
All Implemented Interfaces:
NativeMemory

public class ByteBufferNativeMemory extends Object implements NativeMemory
Web implementation of NativeMemory backed by a ByteBuffer.

Used by the TeaVM WebGPU backend where java.lang.foreign.MemorySegment is not available.

  • Constructor Details

    • ByteBufferNativeMemory

      public ByteBufferNativeMemory(int size)
    • ByteBufferNativeMemory

      public ByteBufferNativeMemory(ByteBuffer buffer)
  • Method Details

    • buffer

      public ByteBuffer buffer()
      Returns the underlying ByteBuffer for passing to WebGPU APIs.
    • putFloat

      public void putFloat(long offset, float value)
      Specified by:
      putFloat in interface NativeMemory
    • putInt

      public void putInt(long offset, int value)
      Specified by:
      putInt in interface NativeMemory
    • putByte

      public void putByte(long offset, byte value)
      Specified by:
      putByte in interface NativeMemory
    • putShort

      public void putShort(long offset, short value)
      Specified by:
      putShort in interface NativeMemory
    • putLong

      public void putLong(long offset, long value)
      Specified by:
      putLong in interface NativeMemory
    • putDouble

      public void putDouble(long offset, double value)
      Specified by:
      putDouble in interface NativeMemory
    • getFloat

      public float getFloat(long offset)
      Specified by:
      getFloat in interface NativeMemory
    • getInt

      public int getInt(long offset)
      Specified by:
      getInt in interface NativeMemory
    • getByte

      public byte getByte(long offset)
      Specified by:
      getByte in interface NativeMemory
    • getShort

      public short getShort(long offset)
      Specified by:
      getShort in interface NativeMemory
    • getLong

      public long getLong(long offset)
      Specified by:
      getLong in interface NativeMemory
    • getDouble

      public double getDouble(long offset)
      Specified by:
      getDouble in interface NativeMemory
    • size

      public long size()
      Specified by:
      size in interface NativeMemory
    • putFloatArray

      public void putFloatArray(long offset, float[] data)
      Description copied from interface: NativeMemory
      Bulk write of a float array starting at the given byte offset.
      Specified by:
      putFloatArray in interface NativeMemory
    • putIntArray

      public void putIntArray(long offset, int[] data)
      Description copied from interface: NativeMemory
      Bulk write of an int array starting at the given byte offset.
      Specified by:
      putIntArray in interface NativeMemory
    • copyFrom

      public void copyFrom(NativeMemory src)
      Description copied from interface: NativeMemory
      Copy all bytes from src into this memory at offset 0.
      Specified by:
      copyFrom in interface NativeMemory
    • slice

      public NativeMemory slice(long offset, long length)
      Description copied from interface: NativeMemory
      Returns a view of a sub-region of this memory.
      Specified by:
      slice in interface NativeMemory