Class TracingWgpuBindings

java.lang.Object
dev.engine.graphics.webgpu.TracingWgpuBindings
All Implemented Interfaces:
WgpuBindings

public class TracingWgpuBindings extends Object implements WgpuBindings
Logging decorator for WgpuBindings. Wraps any implementation and traces every WebGPU API call at TRACE level, making it easy to compare the engine's call sequence against working examples.

Usage:

var bindings = new TracingWgpuBindings(new JWebGpuBindings());
var device = new WgpuRenderDevice(window, bindings);
  • Constructor Details

    • TracingWgpuBindings

      public TracingWgpuBindings(WgpuBindings delegate)
  • Method Details

    • initialize

      public boolean initialize()
      Description copied from interface: WgpuBindings
      Initializes the WebGPU loader/library. Returns true if successful.
      Specified by:
      initialize in interface WgpuBindings
    • isAvailable

      public boolean isAvailable()
      Description copied from interface: WgpuBindings
      Returns true if the native WebGPU library is available.
      Specified by:
      isAvailable in interface WgpuBindings
    • configureSurface

      public long configureSurface(long instance, long device, WindowHandle window)
      Description copied from interface: WgpuBindings
      Configures a presentation surface for the given window. Desktop: creates a wgpu surface using WindowHandle.surfaceInfo(). Web: configures the canvas context. Returns a surface/context handle, or 0 if not supported (headless).
      Specified by:
      configureSurface in interface WgpuBindings
    • getSurfaceTextureView

      public long getSurfaceTextureView(long surface)
      Description copied from interface: WgpuBindings
      Gets the current surface texture view for rendering. Returns 0 if no surface is configured (offscreen/headless).
      Specified by:
      getSurfaceTextureView in interface WgpuBindings
    • releaseSurfaceTextureView

      public void releaseSurfaceTextureView(long textureView)
      Description copied from interface: WgpuBindings
      Releases a surface texture view obtained from getSurfaceTextureView.
      Specified by:
      releaseSurfaceTextureView in interface WgpuBindings
    • surfacePresent

      public void surfacePresent(long surface)
      Description copied from interface: WgpuBindings
      Presents the current surface texture to the screen. Desktop: calls wgpuSurfacePresent. Web: no-op (browser presents after submit).
      Specified by:
      surfacePresent in interface WgpuBindings
    • surfaceFormat

      public int surfaceFormat()
      Description copied from interface: WgpuBindings
      Returns the texture format used by the presentation surface. Defaults to BGRA8 (desktop wgpu-native). Web browsers may use RGBA8.
      Specified by:
      surfaceFormat in interface WgpuBindings
    • hasSurface

      public boolean hasSurface()
      Description copied from interface: WgpuBindings
      Returns true if a presentation surface is available.
      Specified by:
      hasSurface in interface WgpuBindings
    • setPresentMode

      public void setPresentMode(int mode)
      Description copied from interface: WgpuBindings
      Sets the present mode for surface configuration. Must be called before configureSurface.
      Specified by:
      setPresentMode in interface WgpuBindings
    • createInstance

      public long createInstance()
      Description copied from interface: WgpuBindings
      Creates a WebGPU instance.
      Specified by:
      createInstance in interface WgpuBindings
    • instanceProcessEvents

      public void instanceProcessEvents(long instance)
      Description copied from interface: WgpuBindings
      Processes pending events on the instance.
      Specified by:
      instanceProcessEvents in interface WgpuBindings
    • instanceRelease

      public void instanceRelease(long instance)
      Description copied from interface: WgpuBindings
      Releases the instance.
      Specified by:
      instanceRelease in interface WgpuBindings
    • instanceRequestAdapter

      public long instanceRequestAdapter(long instance)
      Description copied from interface: WgpuBindings
      Requests an adapter from the instance (synchronous). Returns the adapter handle, or 0 on failure.
      Specified by:
      instanceRequestAdapter in interface WgpuBindings
    • adapterRelease

      public void adapterRelease(long adapter)
      Description copied from interface: WgpuBindings
      Releases the adapter.
      Specified by:
      adapterRelease in interface WgpuBindings
    • adapterRequestDevice

      public long adapterRequestDevice(long instance, long adapter)
      Description copied from interface: WgpuBindings
      Requests a device from the adapter (synchronous). Requires the instance handle for event processing. Returns the device handle, or 0 on failure.
      Specified by:
      adapterRequestDevice in interface WgpuBindings
    • deviceGetQueue

      public long deviceGetQueue(long device)
      Description copied from interface: WgpuBindings
      Gets the device's queue.
      Specified by:
      deviceGetQueue in interface WgpuBindings
    • deviceRelease

      public void deviceRelease(long device)
      Description copied from interface: WgpuBindings
      Releases the device.
      Specified by:
      deviceRelease in interface WgpuBindings
    • deviceGetLimits

      public WgpuBindings.DeviceLimits deviceGetLimits(long device)
      Description copied from interface: WgpuBindings
      Queries device limits. Returns null if not supported.
      Specified by:
      deviceGetLimits in interface WgpuBindings
    • deviceCreateBuffer

      public long deviceCreateBuffer(long device, long size, int usage)
      Description copied from interface: WgpuBindings
      Creates a GPU buffer.
      Specified by:
      deviceCreateBuffer in interface WgpuBindings
      Parameters:
      device - the device handle
      size - buffer size in bytes
      usage - combined WebGPU buffer usage flags
      Returns:
      buffer handle
    • bufferRelease

      public void bufferRelease(long buffer)
      Description copied from interface: WgpuBindings
      Releases a buffer.
      Specified by:
      bufferRelease in interface WgpuBindings
    • queueWriteBuffer

      public void queueWriteBuffer(long queue, long buffer, int offset, ByteBuffer data, int size)
      Description copied from interface: WgpuBindings
      Writes data to a buffer via the queue.
      Specified by:
      queueWriteBuffer in interface WgpuBindings
      Parameters:
      queue - the queue handle
      buffer - the destination buffer handle
      offset - byte offset into the buffer
      data - direct ByteBuffer with data to write
      size - number of bytes to write
    • bufferMapReadSync

      public void bufferMapReadSync(long instance, long buffer, int size, int maxPolls)
      Description copied from interface: WgpuBindings
      Maps a buffer for reading (synchronous, polls instance events).
      Specified by:
      bufferMapReadSync in interface WgpuBindings
      Parameters:
      instance - the instance handle (for event polling)
      buffer - the buffer handle
      size - number of bytes to map
      maxPolls - maximum number of event poll iterations
    • bufferGetConstMappedRange

      public void bufferGetConstMappedRange(long buffer, int offset, int size, ByteBuffer dest)
      Description copied from interface: WgpuBindings
      Gets the mapped range of a buffer into the provided direct ByteBuffer.
      Specified by:
      bufferGetConstMappedRange in interface WgpuBindings
    • bufferUnmap

      public void bufferUnmap(long buffer)
      Description copied from interface: WgpuBindings
      Unmaps a previously mapped buffer.
      Specified by:
      bufferUnmap in interface WgpuBindings
    • deviceCreateTexture

      public long deviceCreateTexture(long device, int width, int height, int depthOrLayers, int format, int dimension, int usage)
      Description copied from interface: WgpuBindings
      Creates a texture.
      Specified by:
      deviceCreateTexture in interface WgpuBindings
      Parameters:
      device - the device handle
      width - texture width
      height - texture height
      depthOrLayers - depth (for 3D) or array layers
      format - WebGPU texture format ordinal (from
      invalid reference
      WgpuTextureFormat
      )
      dimension - 0 = 2D, 1 = 3D
      usage - combined WebGPU texture usage flags
      Returns:
      texture handle
    • textureCreateView

      public long textureCreateView(long texture, int format, int viewDimension, int arrayLayerCount)
      Description copied from interface: WgpuBindings
      Creates a texture view.
      Specified by:
      textureCreateView in interface WgpuBindings
      Parameters:
      texture - the texture handle
      format - WebGPU texture format ordinal
      viewDimension - view dimension ordinal (from
      invalid reference
      WgpuTextureViewDimension
      )
      arrayLayerCount - number of array layers
      Returns:
      texture view handle
    • textureRelease

      public void textureRelease(long texture)
      Description copied from interface: WgpuBindings
      Releases a texture.
      Specified by:
      textureRelease in interface WgpuBindings
    • textureViewRelease

      public void textureViewRelease(long textureView)
      Description copied from interface: WgpuBindings
      Releases a texture view.
      Specified by:
      textureViewRelease in interface WgpuBindings
    • queueWriteTexture

      public void queueWriteTexture(long queue, long texture, int width, int height, int depthOrLayers, int bytesPerRow, ByteBuffer data)
      Description copied from interface: WgpuBindings
      Writes pixel data to a texture via the queue.
      Specified by:
      queueWriteTexture in interface WgpuBindings
      Parameters:
      queue - the queue handle
      texture - the destination texture handle
      width - write region width
      height - write region height
      depthOrLayers - write region depth/layers
      bytesPerRow - bytes per row in the source data
      data - direct ByteBuffer with pixel data
    • deviceCreateSampler

      public long deviceCreateSampler(long device, int addressU, int addressV, int addressW, int magFilter, int minFilter, int mipmapFilter, float lodMinClamp, float lodMaxClamp, int compare, float maxAnisotropy)
      Description copied from interface: WgpuBindings
      Creates a sampler.
      Specified by:
      deviceCreateSampler in interface WgpuBindings
      Parameters:
      device - the device handle
      addressU - address mode U ordinal (from
      invalid reference
      WgpuAddressMode
      )
      addressV - address mode V ordinal
      addressW - address mode W ordinal
      magFilter - mag filter ordinal (from
      invalid reference
      WgpuFilterMode
      )
      minFilter - min filter ordinal
      mipmapFilter - mipmap filter ordinal (from
      invalid reference
      WgpuMipmapFilterMode
      )
      Returns:
      sampler handle
    • samplerRelease

      public void samplerRelease(long sampler)
      Description copied from interface: WgpuBindings
      Releases a sampler.
      Specified by:
      samplerRelease in interface WgpuBindings
    • deviceCreateShaderModule

      public long deviceCreateShaderModule(long device, String wgsl)
      Description copied from interface: WgpuBindings
      Creates a shader module from WGSL source.
      Specified by:
      deviceCreateShaderModule in interface WgpuBindings
      Parameters:
      device - the device handle
      wgsl - WGSL shader source code
      Returns:
      shader module handle, or 0 if creation failed
    • shaderModuleIsValid

      public boolean shaderModuleIsValid(long shaderModule)
      Description copied from interface: WgpuBindings
      Returns true if the shader module handle is valid.
      Specified by:
      shaderModuleIsValid in interface WgpuBindings
    • shaderModuleRelease

      public void shaderModuleRelease(long shaderModule)
      Description copied from interface: WgpuBindings
      Releases a shader module.
      Specified by:
      shaderModuleRelease in interface WgpuBindings
    • deviceCreateBindGroupLayout

      public long deviceCreateBindGroupLayout(long device, WgpuBindings.BindGroupLayoutEntry[] entries)
      Description copied from interface: WgpuBindings
      Creates a bind group layout with the given entries.
      Specified by:
      deviceCreateBindGroupLayout in interface WgpuBindings
      Parameters:
      device - the device handle
      entries - array of WgpuBindings.BindGroupLayoutEntry descriptors
      Returns:
      bind group layout handle
    • bindGroupLayoutRelease

      public void bindGroupLayoutRelease(long layout)
      Description copied from interface: WgpuBindings
      Releases a bind group layout.
      Specified by:
      bindGroupLayoutRelease in interface WgpuBindings
    • deviceCreatePipelineLayout

      public long deviceCreatePipelineLayout(long device, long[] bindGroupLayouts)
      Description copied from interface: WgpuBindings
      Creates a pipeline layout from bind group layouts.
      Specified by:
      deviceCreatePipelineLayout in interface WgpuBindings
      Parameters:
      device - the device handle
      bindGroupLayouts - array of bind group layout handles
      Returns:
      pipeline layout handle
    • pipelineLayoutRelease

      public void pipelineLayoutRelease(long layout)
      Description copied from interface: WgpuBindings
      Releases a pipeline layout.
      Specified by:
      pipelineLayoutRelease in interface WgpuBindings
    • deviceCreateRenderPipeline

      public long deviceCreateRenderPipeline(long device, WgpuBindings.RenderPipelineDescriptor desc)
      Description copied from interface: WgpuBindings
      Creates a render pipeline.
      Specified by:
      deviceCreateRenderPipeline in interface WgpuBindings
      Parameters:
      device - the device handle
      desc - the pipeline descriptor
      Returns:
      render pipeline handle
    • renderPipelineRelease

      public void renderPipelineRelease(long pipeline)
      Description copied from interface: WgpuBindings
      Releases a render pipeline.
      Specified by:
      renderPipelineRelease in interface WgpuBindings
    • deviceCreateBindGroup

      public long deviceCreateBindGroup(long device, long layout, WgpuBindings.BindGroupEntry[] entries)
      Description copied from interface: WgpuBindings
      Creates a bind group.
      Specified by:
      deviceCreateBindGroup in interface WgpuBindings
      Parameters:
      device - the device handle
      layout - the bind group layout handle
      entries - array of bind group entry descriptors
      Returns:
      bind group handle
    • bindGroupRelease

      public void bindGroupRelease(long bindGroup)
      Description copied from interface: WgpuBindings
      Releases a bind group.
      Specified by:
      bindGroupRelease in interface WgpuBindings
    • deviceCreateCommandEncoder

      public long deviceCreateCommandEncoder(long device)
      Description copied from interface: WgpuBindings
      Creates a command encoder.
      Specified by:
      deviceCreateCommandEncoder in interface WgpuBindings
    • commandEncoderBeginRenderPass

      public long commandEncoderBeginRenderPass(long encoder, WgpuBindings.RenderPassDescriptor desc)
      Description copied from interface: WgpuBindings
      Begins a render pass on the command encoder.
      Specified by:
      commandEncoderBeginRenderPass in interface WgpuBindings
      Parameters:
      encoder - the command encoder handle
      desc - the render pass descriptor
      Returns:
      render pass encoder handle
    • commandEncoderCopyBufferToBuffer

      public void commandEncoderCopyBufferToBuffer(long encoder, long src, int srcOffset, long dst, int dstOffset, int size)
      Description copied from interface: WgpuBindings
      Copies data between buffers.
      Specified by:
      commandEncoderCopyBufferToBuffer in interface WgpuBindings
    • commandEncoderCopyTextureToBuffer

      public void commandEncoderCopyTextureToBuffer(long encoder, long texture, long buffer, int width, int height, int bytesPerRow, int rowsPerImage)
      Description copied from interface: WgpuBindings
      Copies a texture to a buffer.
      Specified by:
      commandEncoderCopyTextureToBuffer in interface WgpuBindings
    • commandEncoderFinish

      public long commandEncoderFinish(long encoder)
      Description copied from interface: WgpuBindings
      Finishes the command encoder, producing a command buffer.
      Specified by:
      commandEncoderFinish in interface WgpuBindings
      Parameters:
      encoder - the command encoder handle
      Returns:
      command buffer handle
    • commandEncoderRelease

      public void commandEncoderRelease(long encoder)
      Description copied from interface: WgpuBindings
      Releases a command encoder.
      Specified by:
      commandEncoderRelease in interface WgpuBindings
    • commandBufferRelease

      public void commandBufferRelease(long commandBuffer)
      Description copied from interface: WgpuBindings
      Releases a command buffer.
      Specified by:
      commandBufferRelease in interface WgpuBindings
    • queueSubmit

      public void queueSubmit(long queue, long commandBuffer)
      Description copied from interface: WgpuBindings
      Submits a command buffer to the queue.
      Specified by:
      queueSubmit in interface WgpuBindings
    • renderPassEnd

      public void renderPassEnd(long renderPass)
      Description copied from interface: WgpuBindings
      Ends the render pass.
      Specified by:
      renderPassEnd in interface WgpuBindings
    • renderPassRelease

      public void renderPassRelease(long renderPass)
      Description copied from interface: WgpuBindings
      Releases the render pass encoder.
      Specified by:
      renderPassRelease in interface WgpuBindings
    • renderPassSetPipeline

      public void renderPassSetPipeline(long renderPass, long pipeline)
      Description copied from interface: WgpuBindings
      Sets the pipeline on the render pass.
      Specified by:
      renderPassSetPipeline in interface WgpuBindings
    • renderPassSetVertexBuffer

      public void renderPassSetVertexBuffer(long renderPass, int slot, long buffer, int offset, int size)
      Description copied from interface: WgpuBindings
      Sets a vertex buffer on the render pass.
      Specified by:
      renderPassSetVertexBuffer in interface WgpuBindings
    • renderPassSetIndexBuffer

      public void renderPassSetIndexBuffer(long renderPass, long buffer, int indexFormat, int offset, int size)
      Description copied from interface: WgpuBindings
      Sets the index buffer on the render pass.
      Specified by:
      renderPassSetIndexBuffer in interface WgpuBindings
    • renderPassSetBindGroup

      public void renderPassSetBindGroup(long renderPass, int groupIndex, long bindGroup)
      Description copied from interface: WgpuBindings
      Sets the bind group on the render pass.
      Specified by:
      renderPassSetBindGroup in interface WgpuBindings
    • renderPassSetViewport

      public void renderPassSetViewport(long renderPass, float x, float y, float w, float h, float minDepth, float maxDepth)
      Description copied from interface: WgpuBindings
      Sets the viewport on the render pass.
      Specified by:
      renderPassSetViewport in interface WgpuBindings
    • renderPassSetScissorRect

      public void renderPassSetScissorRect(long renderPass, int x, int y, int width, int height)
      Description copied from interface: WgpuBindings
      Sets the scissor rect on the render pass.
      Specified by:
      renderPassSetScissorRect in interface WgpuBindings
    • renderPassSetStencilReference

      public void renderPassSetStencilReference(long renderPass, int ref)
      Description copied from interface: WgpuBindings
      Sets the stencil reference on the render pass.
      Specified by:
      renderPassSetStencilReference in interface WgpuBindings
    • renderPassDraw

      public void renderPassDraw(long renderPass, int vertexCount, int instanceCount, int firstVertex, int firstInstance)
      Description copied from interface: WgpuBindings
      Draws primitives.
      Specified by:
      renderPassDraw in interface WgpuBindings
    • renderPassDrawIndexed

      public void renderPassDrawIndexed(long renderPass, int indexCount, int instanceCount, int firstIndex, int baseVertex, int firstInstance)
      Description copied from interface: WgpuBindings
      Draws indexed primitives.
      Specified by:
      renderPassDrawIndexed in interface WgpuBindings