Class GLDevice
- All Implemented Interfaces:
Engine
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.arc3d.engine.Device
Device.StatsNested 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 TypeFieldDescriptionstatic final intThe reserved framebuffer that used for swapping buffers with window.static final intstatic final intThe default vertex array compared to custom vertex array objects.Fields inherited from class icyllis.arc3d.engine.Device
mCompiler, mDeviceIsLost, mOutOfMemoryEncountered, mStatsFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleancheckFence(long fence) Checks a fence on client side to see if signalled.voidvoidCallgetError()until there are no errors.booleancopyImage(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.booleanSpecial case ofcopyImage(icyllis.arc3d.opengl.GLImage, int, int, int, int, icyllis.arc3d.opengl.GLImage, int, int, int)that has same dimensions.booleancopyImage(@RawPtr GLImage src, int srcL, int srcT, int srcR, int srcB, @RawPtr GLImage dst, int dstX, int dstY, int level) Perform an image-to-image copy, with the specified regions.voiddeleteFence(long fence) Deletes an existing fence that previously returned byDevice.insertFence().voiddisconnect(boolean cleanup) Called by context when the underlying backend context is already or will be destroyed beforeImmediateContext.voidexecuteRenderCall(Consumer<GLDevice> renderCall) OpenGL only method.@Nullable @SharedPtr GLFramebufferfindOrCreateFramebuffer(@NonNull FramebufferDesc framebufferDesc) @Nullable @SharedPtr GLVertexArrayfindOrCreateVertexArray(@NonNull VertexInputLayout inputLayout, String label) voidprotected voidbooleangenerateMipmaps(@RawPtr Image image) Uses the base level of the image to compute the contents of the other mipmap levels.getCaps()Gets the capabilities of the context.intgetError()Polls an error code and sets the OOM and context lost state.getGL()longCreates a new fence and inserts it into the graphics queue.static @Nullable GLDevicemake(ContextOptions options, Object capabilities) Create aGLDevicewith OpenGL context current in the current thread.makeResourceProvider(Context context, long maxResourceBudget) protected @Nullable GpuRenderTargetonCreateRenderTarget(int width, int height, int sampleCount, int numColorTargets, Image @Nullable [] colorTargets, Image @Nullable [] resolveTargets, int @Nullable [] mipLevels, @Nullable Image depthStencilTarget, int surfaceFlags) protected 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 voidonResolveRenderTarget(GpuRenderTarget renderTarget, int resolveLeft, int resolveTop, int resolveRight, int resolveBottom) @Nullable GLRenderTargetonWrapBackendRenderTarget(BackendRenderTarget backendRenderTarget) protected GpuRenderTargetonWrapGLDefaultFramebuffer(int width, int height, int sampleCount, int depthBits, int stencilBits, BackendFormat format) protected @Nullable GLRenderTargetonWrapRenderableBackendTexture(BackendImage texture, int sampleCount, boolean ownership) protected voidpurgeResourcesNotUsedSince(long timeMillis) voidvoidrecordRenderCall(Consumer<GLDevice> renderCall) voidBlocks the current thread and waits for GPU to finish outstanding works.booleanwritePixels(@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.Methods inherited from class icyllis.arc3d.engine.Device
checkOutOfMemory, createRenderTarget, getBackend, getCompressedBackendFormat, getContextID, getDefaultBackendFormat, getExecutingThread, getGlobalResourceCache, getIndexPool, getInstancePool, getLogger, getMaxSurfaceSampleCount, getOpsRenderPass, getOptions, getRendererProvider, getShaderCodeSource, getShaderCompiler, getStats, getVertexPool, handleDirtyContext, hashCode, isDeviceLost, isDiscarded, isOnExecutingThread, isValid, markContextDirty, resolveRenderTarget, wrapBackendRenderTarget, wrapGLDefaultFramebuffer, wrapRenderableBackendTexture
-
Field Details
-
DEFAULT_FRAMEBUFFER
public static final int DEFAULT_FRAMEBUFFERThe reserved framebuffer that used for swapping buffers with window.- See Also:
-
DEFAULT_VERTEX_ARRAY
public static final int DEFAULT_VERTEX_ARRAYThe default vertex array compared to custom vertex array objects.- See Also:
-
DEFAULT_TEXTURE
public static final int DEFAULT_TEXTURE- See Also:
-
-
Method Details
-
make
Create aGLDevicewith OpenGL context current in the current thread.- Parameters:
options- the context options- Returns:
- the engine or null if failed to create
-
executeRenderCall
OpenGL only method. Execute the GL command as soon as possible. -
recordRenderCall
-
flushRenderCalls
public void flushRenderCalls() -
getCaps
Description copied from class:DeviceGets the capabilities of the context. -
getGL
-
disconnect
public void disconnect(boolean cleanup) Description copied from class:DeviceCalled 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.- Overrides:
disconnectin classDevice
-
makeResourceProvider
- Specified by:
makeResourceProviderin classDevice
-
onResetContext
protected void onResetContext(int resetBits) Description copied from class:DeviceCalled when the 3D context state is unknown. Subclass should emit any assumed 3D context state and dirty any state cache.- Overrides:
onResetContextin classDevice
-
clearErrors
public void clearErrors()CallgetError()until there are no errors. -
getError
public int getError()Polls an error code and sets the OOM and context lost state. -
freeGpuResources
protected void freeGpuResources()- Overrides:
freeGpuResourcesin classDevice
-
purgeResourcesNotUsedSince
protected void purgeResourcesNotUsedSince(long timeMillis) - Overrides:
purgeResourcesNotUsedSincein classDevice
-
purgeStaleResources
public void purgeStaleResources() -
findOrCreateFramebuffer
@SharedPtr public @Nullable @SharedPtr GLFramebuffer findOrCreateFramebuffer(@NonNull FramebufferDesc framebufferDesc) -
findOrCreateVertexArray
@SharedPtr public @Nullable @SharedPtr GLVertexArray findOrCreateVertexArray(@NonNull VertexInputLayout inputLayout, String label) -
onCreateRenderTarget
protected @Nullable GpuRenderTarget onCreateRenderTarget(int width, int height, int sampleCount, int numColorTargets, Image @Nullable [] colorTargets, Image @Nullable [] resolveTargets, int @Nullable [] mipLevels, @Nullable Image depthStencilTarget, int surfaceFlags) - Specified by:
onCreateRenderTargetin classDevice
-
onWrapRenderableBackendTexture
protected @Nullable GLRenderTarget onWrapRenderableBackendTexture(BackendImage texture, int sampleCount, boolean ownership) - Specified by:
onWrapRenderableBackendTexturein classDevice
-
onWrapGLDefaultFramebuffer
protected GpuRenderTarget onWrapGLDefaultFramebuffer(int width, int height, int sampleCount, int depthBits, int stencilBits, BackendFormat format) - Overrides:
onWrapGLDefaultFramebufferin classDevice
-
onWrapBackendRenderTarget
- Specified by:
onWrapBackendRenderTargetin classDevice
-
writePixels
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 todstColorType- the color type for this use of the surfacesrcColorType- the color type of the source datarowBytes- 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
Uses the base level of the image to compute the contents of the other mipmap levels.- Returns:
- success or not
-
copyImage
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
public boolean copyImage(Image src, int srcX, int srcY, Image dst, int dstX, int dstY, int width, int height) Special case ofcopyImage(icyllis.arc3d.opengl.GLImage, int, int, int, int, icyllis.arc3d.opengl.GLImage, int, int, int)that has same dimensions. -
copyImage
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_NEARESTandSamplerDesc.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
@Deprecated protected OpsRenderPass onGetOpsRenderPass(ImageProxyView writeView, Rect2i contentBounds, byte colorOps, byte stencilOps, float[] clearColor, Set<SurfaceProxy> sampledTextures, int pipelineFlags) Deprecated.- Specified by:
onGetOpsRenderPassin classDevice
-
onResolveRenderTarget
protected void onResolveRenderTarget(GpuRenderTarget renderTarget, int resolveLeft, int resolveTop, int resolveRight, int resolveBottom) - Specified by:
onResolveRenderTargetin classDevice
-
insertFence
public long insertFence()Description copied from class:DeviceCreates a new fence and inserts it into the graphics queue. CallsDevice.deleteFence(long)if the fence is no longer used.- Specified by:
insertFencein classDevice- Returns:
- the handle to the fence, or null if failed
-
checkFence
public boolean checkFence(long fence) Description copied from class:DeviceChecks a fence on client side to see if signalled. This method returns immediately.- Specified by:
checkFencein classDevice- Parameters:
fence- the handle to the fence- Returns:
- true if signalled, false otherwise
-
deleteFence
public void deleteFence(long fence) Description copied from class:DeviceDeletes an existing fence that previously returned byDevice.insertFence().- Specified by:
deleteFencein classDevice- Parameters:
fence- the handle to the fence, cannot be null
-
addFinishedCallback
- Specified by:
addFinishedCallbackin classDevice
-
checkFinishedCallbacks
public void checkFinishedCallbacks()- Specified by:
checkFinishedCallbacksin classDevice
-
waitForQueue
public void waitForQueue()Description copied from class:DeviceBlocks the current thread and waits for GPU to finish outstanding works.- Specified by:
waitForQueuein classDevice
-