Class GLDevice

java.lang.Object
icyllis.arc3d.engine.Device
icyllis.arc3d.opengl.GLDevice
All Implemented Interfaces:
Engine

public final class GLDevice extends Device
The OpenGL device.
  • Field Details Link icon

    • DEFAULT_FRAMEBUFFER Link icon

      public static final int DEFAULT_FRAMEBUFFER
      The reserved framebuffer that used for swapping buffers with window.
      See Also:
    • DEFAULT_VERTEX_ARRAY Link icon

      public static final int DEFAULT_VERTEX_ARRAY
      The default vertex array compared to custom vertex array objects.
      See Also:
    • DEFAULT_TEXTURE Link icon

      public static final int DEFAULT_TEXTURE
      See Also:
  • Method Details Link icon

    • make Link icon

      @Nullable public static GLDevice make(ContextOptions options, Object capabilities)
      Create a GLDevice with OpenGL context current in the current thread.
      Parameters:
      options - the context options
      Returns:
      the engine or null if failed to create
    • executeRenderCall Link icon

      public void executeRenderCall(Consumer<GLDevice> renderCall)
      OpenGL only method. Execute the GL command as soon as possible.
    • recordRenderCall Link icon

      public void recordRenderCall(Consumer<GLDevice> renderCall)
    • flushRenderCalls Link icon

      public void flushRenderCalls()
    • getCaps Link icon

      public GLCaps getCaps()
      Description copied from class: Device
      Gets the capabilities of the context.
      Overrides:
      getCaps in class Device
    • getGL Link icon

      public GLInterface getGL()
    • disconnect Link icon

      public void disconnect(boolean cleanup)
      Description copied from class: Device
      Called by context when the underlying backend context is already or will be destroyed before ImmediateContext.

      If cleanup is true, free allocated resources (other than ResourceCache) before returning and ensure no backend 3D API calls will be made after this method returns. Otherwise, no cleanup should be attempted, immediately cease making backend API calls.

      Overrides:
      disconnect in class Device
    • makeResourceProvider Link icon

      public GLResourceProvider makeResourceProvider(Context context, long maxResourceBudget)
      Specified by:
      makeResourceProvider in class Device
    • onResetContext Link icon

      protected void onResetContext(int resetBits)
      Description copied from class: Device
      Called when the 3D context state is unknown. Subclass should emit any assumed 3D context state and dirty any state cache.
      Overrides:
      onResetContext in class Device
    • clearErrors Link icon

      public void clearErrors()
      Call getError() until there are no errors.
    • getError Link icon

      public int getError()
      Polls an error code and sets the OOM and context lost state.
    • freeGpuResources Link icon

      protected void freeGpuResources()
      Overrides:
      freeGpuResources in class Device
    • purgeResourcesNotUsedSince Link icon

      protected void purgeResourcesNotUsedSince(long timeMillis)
      Overrides:
      purgeResourcesNotUsedSince in class Device
    • purgeStaleResources Link icon

      public void purgeStaleResources()
    • findOrCreateFramebuffer Link icon

      @Nullable @SharedPtr public @SharedPtr GLFramebuffer findOrCreateFramebuffer(@Nonnull FramebufferDesc framebufferDesc)
    • findOrCreateVertexArray Link icon

      @Nullable @SharedPtr public @SharedPtr GLVertexArray findOrCreateVertexArray(@Nonnull VertexInputLayout inputLayout, String label)
    • onCreateRenderTarget Link icon

      @Nullable protected GpuRenderTarget onCreateRenderTarget(int width, int height, int sampleCount, int numColorTargets, @Nullable Image[] colorTargets, @Nullable Image[] resolveTargets, @Nullable int[] mipLevels, @Nullable Image depthStencilTarget, int surfaceFlags)
      Specified by:
      onCreateRenderTarget in class Device
    • onWrapRenderableBackendTexture Link icon

      @Nullable protected GLRenderTarget onWrapRenderableBackendTexture(BackendImage texture, int sampleCount, boolean ownership)
      Specified by:
      onWrapRenderableBackendTexture in class Device
    • onWrapGLDefaultFramebuffer Link icon

      protected GpuRenderTarget onWrapGLDefaultFramebuffer(int width, int height, int sampleCount, int depthBits, int stencilBits, BackendFormat format)
      Overrides:
      onWrapGLDefaultFramebuffer in class Device
    • onWrapBackendRenderTarget Link icon

      @Nullable public GLRenderTarget onWrapBackendRenderTarget(BackendRenderTarget backendRenderTarget)
      Specified by:
      onWrapBackendRenderTarget in class Device
    • writePixels Link icon

      public boolean writePixels(@RawPtr @RawPtr Image texture, int x, int y, int width, int height, int dstColorType, int srcColorType, int rowBytes, long pixels)
      Updates the pixels in a rectangle of an image. No sRGB/linear conversions are performed. The write operation can fail because of the surface doesn't support writing (e.g. read only), the color type is not allowed for the format of the texture or if the rectangle written is not contained in the texture.
      Parameters:
      texture - the image to write to
      dstColorType - the color type for this use of the surface
      srcColorType - the color type of the source data
      rowBytes - the row bytes, must be a multiple of srcColorType's bytes-per-pixel.
      pixels - the pointer to the texel data for base level image
      Returns:
      true if succeeded, false if not
    • generateMipmaps Link icon

      public boolean generateMipmaps(@RawPtr @RawPtr Image image)
      Uses the base level of the image to compute the contents of the other mipmap levels.
      Returns:
      success or not
    • copyImage Link icon

      public boolean copyImage(@RawPtr @RawPtr GLImage src, int srcL, int srcT, int srcR, int srcB, @RawPtr @RawPtr GLImage dst, int dstX, int dstY, int level)
      Perform an image-to-image copy, with the specified regions. Scaling is not allowed.

      If their dimensions are same and formats are compatible, then this method will attempt to perform copy. Otherwise, this method will attempt to perform blit, which may include format conversion.

      Only mipmap level level of 2D images will be copied, without any multisampled buffer and depth/stencil buffer.

      Returns:
      success or not
    • copyImage Link icon

      public boolean copyImage(Image src, int srcX, int srcY, Image dst, int dstX, int dstY, int width, int height)
    • copyImage Link icon

      public boolean copyImage(Image src, int srcL, int srcT, int srcR, int srcB, Image dst, int dstL, int dstT, int dstR, int dstB, int filter)
      Perform a surface-to-surface copy, with the specified regions.

      If their dimensions are same and formats are compatible, then this method will attempt to perform copy. Otherwise, this method will attempt to perform blit, which may include resampling and format conversion. filter can be one of SamplerDesc.FILTER_NEAREST and SamplerDesc.FILTER_LINEAR.

      Only mipmap level 0 of 2D images will be copied, without any multisampled buffer and depth/stencil buffer.

      Returns:
      success or not
    • onGetOpsRenderPass Link icon

      protected OpsRenderPass onGetOpsRenderPass(ImageProxyView writeView, Rect2i contentBounds, byte colorOps, byte stencilOps, float[] clearColor, Set<SurfaceProxy> sampledTextures, int pipelineFlags)
      Specified by:
      onGetOpsRenderPass in class Device
    • onResolveRenderTarget Link icon

      protected void onResolveRenderTarget(GpuRenderTarget renderTarget, int resolveLeft, int resolveTop, int resolveRight, int resolveBottom)
      Specified by:
      onResolveRenderTarget in class Device
    • insertFence Link icon

      public long insertFence()
      Description copied from class: Device
      Creates a new fence and inserts it into the graphics queue. Calls Device.deleteFence(long) if the fence is no longer used.
      Specified by:
      insertFence in class Device
      Returns:
      the handle to the fence, or null if failed
    • checkFence Link icon

      public boolean checkFence(long fence)
      Description copied from class: Device
      Checks a fence on client side to see if signalled. This method returns immediately.
      Specified by:
      checkFence in class Device
      Parameters:
      fence - the handle to the fence
      Returns:
      true if signalled, false otherwise
    • deleteFence Link icon

      public void deleteFence(long fence)
      Description copied from class: Device
      Deletes an existing fence that previously returned by Device.insertFence().
      Specified by:
      deleteFence in class Device
      Parameters:
      fence - the handle to the fence, cannot be null
    • addFinishedCallback Link icon

      public void addFinishedCallback(FlushInfo.FinishedCallback callback)
      Specified by:
      addFinishedCallback in class Device
    • checkFinishedCallbacks Link icon

      public void checkFinishedCallbacks()
      Specified by:
      checkFinishedCallbacks in class Device
    • waitForQueue Link icon

      public void waitForQueue()
      Description copied from class: Device
      Blocks the current thread and waits for GPU to finish outstanding works.
      Specified by:
      waitForQueue in class Device