Package icyllis.arc3d.engine
Class Context
java.lang.Object
icyllis.arc3d.core.RefCnt
icyllis.arc3d.engine.Context
- All Implemented Interfaces:
RefCounted
- Direct Known Subclasses:
ImmediateContext
,RecordingContext
This class is a public API, except where noted.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Device
protected final Thread
protected ResourceProvider
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Checks if calling from the context-creating thread, or throws a runtime exception.protected void
Override this method to invoke de-allocation of the underlying resource.abstract void
Frees GPU resources created and held by the Context.final int
The 3D API backing this context.final Caps
getCaps()
final BackendFormat
getCompressedBackendFormat
(int compressionType) Retrieve theBackendFormat
for a givenCompressionType
.final int
An identifier for this context.long
Returns the number of bytes of the Context's gpu memory cache budget that are currently in use.long
Returns the number of bytes of the Context's resource cache that are currently purgeable.final BackendFormat
getDefaultBackendFormat
(int colorType, boolean renderable) Retrieve the defaultBackendFormat
for a givenColorType
and renderability.final Device
final org.slf4j.Logger
long
Returns the size of Context's gpu memory cache budget in bytes.final int
Gets the maximum supported render target size.final int
getMaxSurfaceSampleCount
(int colorType) Gets the maximum supported sample count for a color type.final int
Gets the maximum supported texture size.final ContextOptions
final Thread
final RendererProvider
final ResourceProvider
final SharedResourceCache
protected boolean
init
(BaseContextOptions options) boolean
final boolean
final boolean
final boolean
abstract void
performDeferredCleanup
(long msNotUsed) Purge GPU resources on the Context that haven't been used in the past 'msNotUsed' milliseconds or are otherwise marked for deletion, regardless of whether the context is under budget.
-
Field Details
-
mDevice
-
mOwnerThread
-
mResourceProvider
-
-
Constructor Details
-
Context
-
-
Method Details
-
getBackend
public final int getBackend()The 3D API backing this context.- Returns:
- see
Engine.BackendApi
-
getDefaultBackendFormat
Retrieve the defaultBackendFormat
for a givenColorType
and renderability. It is guaranteed that this backend format will be the one used by the followingColorType
andSurfaceCharacterization.createBackendFormat(int, BackendFormat)
.The caller should check that the returned format is valid (nullability).
- Parameters:
colorType
- seeImageDesc
renderable
- true if the format will be used as color attachments
-
getCompressedBackendFormat
Retrieve theBackendFormat
for 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 final 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
-
isImmediate
public final boolean isImmediate() -
getDevice
-
matches
-
getOptions
-
getContextID
@Internal public final int getContextID()An identifier for this context. The id is used by all compatible contexts. For example, if Images are created on one thread using an image creation context, then fed into a Recorder on second thread (which has a recording context) and finally replayed on a third thread with a direct context, then all three contexts will report the same id. It is an error for an image to be used with contexts that report different ids. -
isDeviceLost
public boolean isDeviceLost() -
getCaps
-
getResourceProvider
-
getMaxTextureSize
public final int getMaxTextureSize()Gets the maximum supported texture size. -
getMaxRenderTargetSize
public final int getMaxRenderTargetSize()Gets the maximum supported render target size. -
freeGpuResources
public abstract void freeGpuResources()Frees GPU resources created and held by the Context. Can be called to reduce GPU memory pressure. Any resources that are still in use (e.g. being used by work submitted to the GPU) will not be deleted by this call. If the caller wants to make sure all resources are freed, then they should first make sure to submit and wait on any outstanding work. -
performDeferredCleanup
public abstract void performDeferredCleanup(long msNotUsed) Purge GPU resources on the Context that haven't been used in the past 'msNotUsed' milliseconds or are otherwise marked for deletion, regardless of whether the context is under budget. -
getCurrentBudgetedBytes
public long getCurrentBudgetedBytes()Returns the number of bytes of the Context's gpu memory cache budget that are currently in use. -
getCurrentPurgeableBytes
public long getCurrentPurgeableBytes()Returns the number of bytes of the Context's resource cache that are currently purgeable. -
getMaxBudgetedBytes
public long getMaxBudgetedBytes()Returns the size of Context's gpu memory cache budget in bytes. -
getRendererProvider
-
getLogger
public final org.slf4j.Logger getLogger() -
init
-
deallocate
protected void deallocate()Description copied from class:RefCnt
Override this method to invoke de-allocation of the underlying resource.- Specified by:
deallocate
in classRefCnt
-
getOwnerThread
- Returns:
- the context-creating thread
-
isOwnerThread
public final boolean isOwnerThread()- Returns:
- true if calling from the context-creating thread
-
checkOwnerThread
public final void checkOwnerThread()Checks if calling from the context-creating thread, or throws a runtime exception.
-