-
Notifications
You must be signed in to change notification settings - Fork 164
DirectXOffscreenContext to allow drawing into offscreen texture #1016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c20da90 to
823aecb
Compare
Needed to run benchmarks without vsync interference The code extracted from Direct3DSwingRedrawer with minimal changes ## Testing - manually in benchmarks with this code: ``` @OptIn(ExperimentalSkikoApi::class) class DirectXGraphicsContext() : DesktopGraphicsContext { private val context = DirectXOffscreenContext() private var texture: DirectXOffscreenContext.Texture? = null override fun surface(width: Int, height: Int): Surface { texture?.close() texture = context.Texture(width, height) return Surface.makeFromBackendRenderTarget( context.directContext, texture!!.backendRenderTarget, SurfaceOrigin.TOP_LEFT, SurfaceColorFormat.BGRA_8888, ColorSpace.sRGB, SurfaceProps(pixelGeometry = PixelGeometry.UNKNOWN) ) ?: throw IllegalStateException("Can't create Surface") } override suspend fun awaitGPUCompletion() { texture?.waitForCompletion() } override fun close() { texture?.close() context.close() } } interface DesktopGraphicsContext : GraphicsContext, AutoCloseable ``` - new test for SkiaSwingLayer - new test for DirectXOffscreenContext
823aecb to
0f21a8f
Compare
| renderDelegate: SkikoRenderDelegate, | ||
| analytics: SkiaLayerAnalytics = SkiaLayerAnalytics.Empty, | ||
| externalAccessibleFactory: ((Component) -> Accessible)? = null, | ||
| private val properties: SkiaLayerProperties = SkiaLayerProperties() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems unrelated + breaking compatibility for no reason. Can we avoid it in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed in the test - to pass the graphic API:
https://github.com/JetBrains/skiko/pull/1016/files#diff-f09f8e25b6e613b4acc42736872562fec343ba85cd033a84464e2ee426a1cbd7R188
As for compatibility, we don't support it in Skiko
Needed to run benchmarks without vsync interference. The code extracted from Direct3DSwingRedrawer with minimal changes. - implementation for other API will be added when it is needed (Metal is considered later) - there are no plans to make commonMain abstraction in `skiko` as it is not needed at the moment ## Testing - manually in benchmarks with this code: ``` @OptIn(ExperimentalSkikoApi::class) class DirectXGraphicsContext() : DesktopGraphicsContext { private val context = DirectXOffscreenContext() private var texture: DirectXOffscreenContext.Texture? = null override fun surface(width: Int, height: Int): Surface { texture?.close() texture = context.Texture(width, height) return Surface.makeFromBackendRenderTarget( context.directContext, texture!!.backendRenderTarget, SurfaceOrigin.TOP_LEFT, SurfaceColorFormat.BGRA_8888, ColorSpace.sRGB, SurfaceProps(pixelGeometry = PixelGeometry.UNKNOWN) ) ?: throw IllegalStateException("Can't create Surface") } override suspend fun awaitGPUCompletion() { texture?.waitForCompletion() } override fun close() { texture?.close() context.close() } } interface DesktopGraphicsContext : GraphicsContext, AutoCloseable ``` - new test for SkiaSwingLayer - new test for DirectXOffscreenContext (cherry picked from commit 1af72c1)
Needed to run benchmarks without vsync interference.
The code extracted from Direct3DSwingRedrawer with minimal changes.
skikoas it is not needed at the momentTesting