Class SegmentNativeMemory

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

public class SegmentNativeMemory extends Object implements NativeMemory
Desktop implementation of NativeMemory backed by a MemorySegment.

Used by all native backends (OpenGL, Vulkan, desktop WebGPU) where the JVM has direct memory access via the Foreign Function invalid input: '&' Memory API.

  • Constructor Details

    • SegmentNativeMemory

      public SegmentNativeMemory(MemorySegment segment)
  • Method Details

    • segment

      public MemorySegment segment()
      Returns the underlying MemorySegment for backends that need raw access.
    • 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