Class Device
- All Implemented Interfaces:
Engine
- Direct Known Subclasses:
GLDevice,VulkanDevice
Device represents a logical GPU device and provides shared context info
of the backend 3D API. A Device is created with an ImmediateContext.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface icyllis.arc3d.engine.Engine
Engine.BackendApi, Engine.BudgetType, Engine.BufferUsageFlags, Engine.DepthStencilFlags, Engine.GLBackendState, Engine.ImageCreateFlags, Engine.ImageType, Engine.IndexType, Engine.IOType, Engine.LoadOp, Engine.LoadStoreOps, Engine.PrimitiveType, Engine.ShaderFlags, Engine.StoreOp, Engine.SurfaceOrigin, Engine.VertexAttribType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Capsprotected final ShaderCompilerprotected booleanprotected booleanprotected final Device.StatsFields inherited from interface icyllis.arc3d.engine.Engine
CLAMP_TYPE_AUTO, CLAMP_TYPE_MANUAL, CLAMP_TYPE_NONE, COLOR_ENCODING_FLOAT, COLOR_ENCODING_UNORM, COLOR_ENCODING_UNORM_PACK16, COLOR_ENCODING_UNORM_PACK32, COLOR_ENCODING_UNORM_SRGB, INVALID_RESOURCE_HANDLE, LAST_MASK_FORMAT, MASK_FORMAT_A565, MASK_FORMAT_A8, MASK_FORMAT_ARGB, MASK_FORMAT_COUNT, Ownership_Borrowed, Ownership_Owned -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidabstract booleancheckFence(long fence) Checks a fence on client side to see if signalled.abstract voidfinal booleanChecks if we detected an OOM from the underlying 3D API and if so returns true and resets the internal OOM state to false.final @Nullable @SharedPtr GpuRenderTargetcreateRenderTarget(int numColorTargets, Image @Nullable [] colorTargets, Image @Nullable [] resolveTargets, int @Nullable [] mipLevels, @Nullable Image depthStencilTarget, int surfaceFlags) Deprecated.abstract voiddeleteFence(long fence) Deletes an existing fence that previously returned byinsertFence().voiddisconnect(boolean cleanup) Called by context when the underlying backend context is already or will be destroyed beforeImmediateContext.protected voidintgetCaps()Gets the capabilities of the context.@Nullable BackendFormatgetCompressedBackendFormat(int compressionType) Retrieve theBackendFormatfor a givenCompressionType.int@Nullable BackendFormatgetDefaultBackendFormat(int colorType, boolean renderable) Retrieve the defaultBackendFormatfor a givenColorTypeand renderability.final Threadfinal GlobalResourceCacheDeprecated.Deprecated.final org.slf4j.LoggerintgetMaxSurfaceSampleCount(int colorType) Gets the maximum supported sample count for a color type.final @Nullable OpsRenderPassgetOpsRenderPass(ImageProxyView writeView, Rect2i contentBounds, byte colorOps, byte stencilOps, float[] clearColor, Set<SurfaceProxy> sampledTextures, int pipelineFlags) Deprecated.final RendererProviderfinal ShaderCodeSourcefinal ShaderCompilerGets the compiler used for compiling AkSL into backend shader code.final Device.StatsgetStats()Deprecated.protected voidhandleDirtyContext(int state) inthashCode()abstract longCreates a new fence and inserts it into the graphics queue.booleanReturns true if GPU is gone.booleanfinal booleanbooleanisValid()abstract ResourceProvidermakeResourceProvider(Context context, long maxResourceBudget) final voidmarkContextDirty(int state) The engine object normally assumes that no outsider is setting state within the underlying 3D API's context/device/whatever.protected abstract @Nullable @SharedPtr GpuRenderTargetonCreateRenderTarget(int width, int height, int sampleCount, int numColorTargets, Image @Nullable [] colorTargets, Image @Nullable [] resolveTargets, int @Nullable [] mipLevels, @Nullable Image depthStencilTarget, int surfaceFlags) Deprecated.protected abstract OpsRenderPassonGetOpsRenderPass(ImageProxyView writeView, Rect2i contentBounds, byte colorOps, byte stencilOps, float[] clearColor, Set<SurfaceProxy> sampledTextures, int pipelineFlags) Deprecated.protected voidonResetContext(int resetBits) Called when the 3D context state is unknown.protected abstract voidonResolveRenderTarget(GpuRenderTarget renderTarget, int resolveLeft, int resolveTop, int resolveRight, int resolveBottom) Deprecated.abstract @Nullable @SharedPtr GpuRenderTargetonWrapBackendRenderTarget(BackendRenderTarget backendRenderTarget) Deprecated.protected @Nullable @SharedPtr GpuRenderTargetonWrapGLDefaultFramebuffer(int width, int height, int sampleCount, int depthBits, int stencilBits, BackendFormat format) Deprecated.protected abstract @Nullable @SharedPtr GpuRenderTargetonWrapRenderableBackendTexture(BackendImage texture, int sampleCount, boolean ownership) Deprecated.protected voidpurgeResourcesNotUsedSince(long timeMillis) voidresolveRenderTarget(GpuRenderTarget renderTarget, int resolveLeft, int resolveTop, int resolveRight, int resolveBottom) Deprecated.abstract voidBlocks the current thread and waits for GPU to finish outstanding works.@Nullable @SharedPtr GpuRenderTargetwrapBackendRenderTarget(BackendRenderTarget backendRenderTarget) Deprecated.final @Nullable @SharedPtr GpuRenderTargetwrapGLDefaultFramebuffer(int width, int height, int sampleCount, int depthBits, int stencilBits, BackendFormat format) Deprecated.@Nullable @SharedPtr GpuRenderTargetwrapRenderableBackendTexture(BackendImage texture, int sampleCount, boolean ownership) Deprecated.
-
Field Details
-
mCaps
-
mCompiler
-
mStats
-
mOutOfMemoryEncountered
protected volatile boolean mOutOfMemoryEncountered -
mDeviceIsLost
protected volatile boolean mDeviceIsLost
-
-
Constructor Details
-
Device
-
-
Method Details
-
getLogger
public final org.slf4j.Logger getLogger() -
getExecutingThread
- Returns:
- the command-executing thread
-
isOnExecutingThread
public final boolean isOnExecutingThread()- Returns:
- true if calling from the command-executing thread
-
getDefaultBackendFormat
Retrieve the defaultBackendFormatfor a givenColorTypeand renderability. It is guaranteed that this backend format will be the one used by the followingColorTypeand.invalid reference
SurfaceCharacterization#createBackendFormat(int, BackendFormat)The caller should check that the returned format is valid (nullability).
- Parameters:
colorType- seeImageDescrenderable- true if the format will be used as color attachments
-
getCompressedBackendFormat
Retrieve theBackendFormatfor a givenCompressionType. This is guaranteed to match the backend format used by the following createCompressedBackendTexture methods that take aCompressionType.The caller should check that the returned format is valid (nullability).
- Parameters:
compressionType- seeImageDesc
-
getMaxSurfaceSampleCount
public int getMaxSurfaceSampleCount(int colorType) Gets the maximum supported sample count for a color type. 1 is returned if only non-MSAA rendering is supported for the color type. 0 is returned if rendering to this color type is not supported at all.- Parameters:
colorType- seeImageDesc
-
isValid
public boolean isValid()- Returns:
- initialized or not, if
ImmediateContextis created, it must be true
-
getBackend
@Internal public int getBackend() -
getOptions
-
getContextID
@Internal public int getContextID() -
isDiscarded
public boolean isDiscarded() -
hashCode
public int hashCode() -
getCaps
Gets the capabilities of the context. -
getShaderCompiler
Gets the compiler used for compiling AkSL into backend shader code. -
makeResourceProvider
-
getGlobalResourceCache
-
getShaderCodeSource
-
getRendererProvider
-
disconnect
public void disconnect(boolean cleanup) Called by context when the underlying backend context is already or will be destroyed beforeImmediateContext.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. -
isDeviceLost
public boolean isDeviceLost()Returns true if GPU is gone. -
getStats
-
markContextDirty
public final void markContextDirty(int state) The engine object normally assumes that no outsider is setting state within the underlying 3D API's context/device/whatever. This call informs the engine that the state was modified, and it shouldn't make assumptions about the state. -
handleDirtyContext
protected void handleDirtyContext(int state) -
onResetContext
protected void onResetContext(int resetBits) Called when the 3D context state is unknown. Subclass should emit any assumed 3D context state and dirty any state cache. -
getVertexPool
Deprecated. -
getInstancePool
Deprecated. -
getIndexPool
Deprecated. -
freeGpuResources
protected void freeGpuResources() -
purgeResourcesNotUsedSince
protected void purgeResourcesNotUsedSince(long timeMillis) -
createRenderTarget
@Deprecated @SharedPtr public final @Nullable @SharedPtr GpuRenderTarget createRenderTarget(int numColorTargets, Image @Nullable [] colorTargets, Image @Nullable [] resolveTargets, int @Nullable [] mipLevels, @Nullable Image depthStencilTarget, int surfaceFlags) Deprecated.Overridden by backend-specific derived class to create objects.Image size and format support will have already been validated in base class before onCreateImage is called.
-
onCreateRenderTarget
@Deprecated @OverrideOnly @SharedPtr protected abstract @Nullable @SharedPtr GpuRenderTarget onCreateRenderTarget(int width, int height, int sampleCount, int numColorTargets, Image @Nullable [] colorTargets, Image @Nullable [] resolveTargets, int @Nullable [] mipLevels, @Nullable Image depthStencilTarget, int surfaceFlags) Deprecated. -
wrapRenderableBackendTexture
@Deprecated @SharedPtr public @Nullable @SharedPtr GpuRenderTarget wrapRenderableBackendTexture(BackendImage texture, int sampleCount, boolean ownership) Deprecated.This makes the backend texture be renderable. IfsampleCountis > 1 and the underlying API uses separate MSAA render buffers then a MSAA render buffer is created that resolves to the texture.Ownership specifies rules for external GPU resources imported into Engine. If false, Engine will assume the client will keep the resource alive and Engine will not free it. If true, Engine will assume ownership of the resource and free it.
- Parameters:
texture- the backend texture must be single sample- Returns:
- a non-cacheable render target, or null if failed
-
onWrapRenderableBackendTexture
@Deprecated @SharedPtr protected abstract @Nullable @SharedPtr GpuRenderTarget onWrapRenderableBackendTexture(BackendImage texture, int sampleCount, boolean ownership) Deprecated. -
wrapGLDefaultFramebuffer
@Deprecated @SharedPtr public final @Nullable @SharedPtr GpuRenderTarget wrapGLDefaultFramebuffer(int width, int height, int sampleCount, int depthBits, int stencilBits, BackendFormat format) Deprecated. -
onWrapGLDefaultFramebuffer
@Deprecated @OverrideOnly @SharedPtr protected @Nullable @SharedPtr GpuRenderTarget onWrapGLDefaultFramebuffer(int width, int height, int sampleCount, int depthBits, int stencilBits, BackendFormat format) Deprecated. -
wrapBackendRenderTarget
@Deprecated @SharedPtr public @Nullable @SharedPtr GpuRenderTarget wrapBackendRenderTarget(BackendRenderTarget backendRenderTarget) Deprecated. -
onWrapBackendRenderTarget
@Deprecated @SharedPtr public abstract @Nullable @SharedPtr GpuRenderTarget onWrapBackendRenderTarget(BackendRenderTarget backendRenderTarget) Deprecated. -
getOpsRenderPass
@Deprecated public final @Nullable OpsRenderPass getOpsRenderPass(ImageProxyView writeView, Rect2i contentBounds, byte colorOps, byte stencilOps, float[] clearColor, Set<SurfaceProxy> sampledTextures, int pipelineFlags) Deprecated.Returns aOpsRenderPasswhichrecord draw commands to.invalid reference
OpsTasks- Parameters:
writeView- the render target to be rendered tocontentBounds- the clipped content bounds of the render passcolorOps- the color load/store opsstencilOps- the stencil load/store opsclearColor- the color used to clear the color buffersampledTextures- list of all textures to be sampled in the render pass (no refs)pipelineFlags- combination of flags of all pipelines to be used in the render pass- Returns:
- a render pass used to record draw commands, or null if failed
-
onGetOpsRenderPass
@Deprecated protected abstract OpsRenderPass onGetOpsRenderPass(ImageProxyView writeView, Rect2i contentBounds, byte colorOps, byte stencilOps, float[] clearColor, Set<SurfaceProxy> sampledTextures, int pipelineFlags) Deprecated. -
resolveRenderTarget
@Deprecated public void resolveRenderTarget(GpuRenderTarget renderTarget, int resolveLeft, int resolveTop, int resolveRight, int resolveBottom) Deprecated.Resolves MSAA. The resolve rectangle must already be in the native destination space. -
onResolveRenderTarget
@Deprecated protected abstract void onResolveRenderTarget(GpuRenderTarget renderTarget, int resolveLeft, int resolveTop, int resolveRight, int resolveBottom) Deprecated. -
insertFence
public abstract long insertFence()Creates a new fence and inserts it into the graphics queue. CallsdeleteFence(long)if the fence is no longer used.- Returns:
- the handle to the fence, or null if failed
-
checkFence
public abstract boolean checkFence(long fence) Checks a fence on client side to see if signalled. This method returns immediately.- Parameters:
fence- the handle to the fence- Returns:
- true if signalled, false otherwise
-
deleteFence
public abstract void deleteFence(long fence) Deletes an existing fence that previously returned byinsertFence().- Parameters:
fence- the handle to the fence, cannot be null
-
addFinishedCallback
-
checkFinishedCallbacks
public abstract void checkFinishedCallbacks() -
waitForQueue
public abstract void waitForQueue()Blocks the current thread and waits for GPU to finish outstanding works. -
checkOutOfMemory
public final boolean checkOutOfMemory()Checks if we detected an OOM from the underlying 3D API and if so returns true and resets the internal OOM state to false. Otherwise, returns false.
-