Commit Graph

162 Commits

Author SHA1 Message Date
Hajime Hoshi
ba93794a72 internal/atlas: images were not collected by GC 2023-11-04 04:37:40 +09:00
Hajime Hoshi
c01ceeaa6a ebiten: replace (*Image).Dispose with Deallocate
Closes #2808
2023-11-03 17:45:39 +09:00
Hajime Hoshi
8a44ef4f6c internal/atlas: bug fix: (*Image).Deallocate (*Shader).Deallocate were not concurrent-safe
Updates #2162
2023-11-03 17:12:04 +09:00
Hajime Hoshi
bdd8916bb1 ebiten: replace (*ebiten.Shader).Dispose with Deallocate
Updates #2808
2023-11-03 16:25:18 +09:00
Hajime Hoshi
97d1e073e2 internal/atlas: refactoring 2023-11-03 14:52:19 +09:00
Hajime Hoshi
258f0fd941 internal/atlas: remvoe 'disposed' state
Updates #2808
2023-11-03 14:35:57 +09:00
Hajime Hoshi
d72c4ec90b internal/atlas: refactoring 2023-11-03 14:19:59 +09:00
Hajime Hoshi
55702a7c28 internal/atlas: refactoring: ensure ReadPixels to be processed in a frame
This enables to call (*Image).At from HandleInput, which might be
called outside of a frame.

Updates #1704
2023-10-25 00:48:09 +09:00
Hajime Hoshi
b94c3fa9bb internal/atlas: split EndFrame into EndFrame and SwapBuffers
This enables to do something asynchronously while executing SwapBuffers
in a different goroutine.

This is a preparation for HandleInput.

Updates #1704
2023-10-24 00:22:04 +09:00
Hajime Hoshi
e80e981bf5 internal/atlas: let callers retry ReadPixels instead of blocking
This is a preparation to implement HandleInput, which might call
(*Image).At in its callback.

Updates #1704
2023-10-20 02:30:32 +09:00
Hajime Hoshi
913824beba internal/atlas: close channels on the sender side just in case 2023-10-19 12:14:54 +09:00
Hajime Hoshi
ad51e22252 internal/atlas: bug fix: ReadPixels crashed when inFrame was false
This change fixes the issue by letting ReadPixels return a channel
and executing this asynchronously when needed.

Closes #2815
2023-10-19 03:56:54 +09:00
Hajime Hoshi
7a921e03da internal/atlas: bug fix: inFrame was not correctly updated
Updates #2814
2023-10-19 02:08:28 +09:00
Hajime Hoshi
7d517bfb63 internal/buffered: move buffering to internal/atlas
Closes #2814
2023-10-19 01:56:18 +09:00
Hajime Hoshi
19ee79e2cb internal/buffered: remove unnecessary deferred functions for shaders 2023-10-18 23:36:41 +09:00
Hajime Hoshi
315450474a internal/atlas: add comments 2023-10-18 01:01:21 +09:00
Hajime Hoshi
27fd10595b internal/ui: refactoring: reduce global functions and prefer Get() 2023-10-15 03:40:48 +09:00
Hajime Hoshi
f269b61903 internal/atlas: introduce a managed byte slice pool
A managed byte slice from the new byte slice pool has a function
to release and put it back to the pool explicitly, and this doesn't
rely on GCs.

Updates #1681
Closes #2804
2023-10-09 20:32:32 +09:00
Hajime Hoshi
34d577a5ff Revert "internal/atlas: reintroduce a byte pool"
This reverts commit 7e17b25c56.

Reason: the current byte pool suppresses allocations to some extent, but doesn't suppress GCs.

Updates #1681
2023-10-09 14:40:05 +09:00
Hajime Hoshi
7e17b25c56 internal/atlas: reintroduce a byte pool
The old byte pool depnded on lifetimes of command queues, and this
was tricky.

The new byte pool uses runtime.SetFinalizer so this should be much
easier to use.

Updates #1681
2023-10-09 03:28:29 +09:00
Hajime Hoshi
6e5361c328 internal/restorable: use clearImage to avoid allocations
Bytes from a pool in a command queue is now pretty hard to use correctly
as the lifetime of a queue is not clear.

Remove the byte pools once. Let's reconsider pool usages later.

This change also removes imagesWithBuffers as this is no longer needed.
imagesWithBuffers was necessary to ensure all the bytes from the pool
of the command queue was used before the queue flushes the commands,
as the command queue cleared the pool after flushing. The lifetimes
were pretty ticky.
2023-10-09 00:42:58 +09:00
Hajime Hoshi
4ca3fa5e57
internal/graphicsdriver: replace Region with image.Rectangle (#2791)
Closes #2790
2023-09-28 14:29:55 +09:00
Hajime Hoshi
534370f7b1 internal/graphics: enable to specify regions for each source image
This is a preparation to specify different sizes of source images.

Updates #1870
2023-08-27 21:15:01 +09:00
Hajime Hoshi
7ea3cd4738 internal/atlas: bug fix: copy the image slice before iterating it
Closes #2729
2023-08-23 16:41:34 +09:00
Hajime Hoshi
a9d9143d90 internal/atlas: replace a map with a set with a slice
Updates #2601
2023-08-19 15:08:49 +09:00
Hajime Hoshi
3b2251a858 internal/atlas: refactoring: improve a comment 2023-08-19 05:24:20 +09:00
Hajime Hoshi
be68f50f96 internal/atlas: refactoring: rename a variable 2023-08-19 05:20:39 +09:00
Hajime Hoshi
3c49f81b5c internal/atlas: replace a global map with a member
This should be a pure performance improvement.

Updates #2601
2023-08-19 05:02:35 +09:00
Hajime Hoshi
32f1436576 internal/atlas: refactoring: remove (probably) unnecessary logics 2023-08-19 04:36:40 +09:00
Hajime Hoshi
1e2a4cb4b1 internal/atlas: refactoring: remove unnecessary logics
Updates #2601
2023-08-19 04:06:43 +09:00
Hajime Hoshi
e1041ea20e internal/atlas: replace a global map with a struct member
This should be a pure performance improvement.

Updates #2586
Updates #2601
2023-08-19 03:25:17 +09:00
Hajime Hoshi
77fd15145b internal/atlas: add a test for a bug fix
Closes #2728
2023-08-19 01:36:05 +09:00
Hajime Hoshi
ea1f596cda internal/atlas: bug fix: possible overflowing on 32bit machines 2023-08-19 01:19:15 +09:00
Hajime Hoshi
98cb77d94f internal/atlas: refactoring 2023-08-06 16:03:57 +09:00
Hajime Hoshi
32ed22f91c internal/atlas: refactoring 2023-08-06 15:59:15 +09:00
Hajime Hoshi
0433dfac99 internal/atlas: reland: clarify the logic when to update usedAsDestination
This is a reland of 2c9f5d9dad.

As the name is `usedAsDestination`, this should be updated whenever
the image is used as a rendering destination.

Confirmed that this change didn't cause a performance regression
like #2586.

Updates #2586
Updates #2676
2023-08-06 15:59:11 +09:00
Hajime Hoshi
dcc8794883 Revert "internal/atlas: clarify the logic when to update usedAsDestination"
This reverts commit 2c9f5d9dad.

Reason: test failures
2023-08-06 15:25:55 +09:00
Hajime Hoshi
2c9f5d9dad internal/atlas: clarify the logic when to update usedAsDestination
As the name is `usedAsDestination`, this should be updated whenever
the image is used as a rendering destination.

Confirmed that this change didn't cause a performance regression
like #2586.

Updates #2586
Updates #2676
2023-08-06 15:23:19 +09:00
Hajime Hoshi
a50d9e6291 internal/atlas: check overflows 2023-08-06 13:46:41 +09:00
Hajime Hoshi
1ae5e022b6 internal/atlas: change when to count up usedAsDestinationCount
An image has a counter to count how many times an image is used.

Before this change, the counter was updated only when an image was moved
from a source backend to a destination backend. This seemed not enough,
and an image was likely moved to a source backend more often than
necessary (#2676).

However, there was also an issue that the counter was updated too
aggressively and the image was unlikely moved from a destination to
a source image (#2586).

In order to resolve this dilemma, let's adopt an intermediate way:
count up the counter at most once per frame.

Updates #2586
Updates #2676
2023-08-06 13:27:28 +09:00
Hajime Hoshi
63df6168d9 internal/shader: use plural forms for Kage compiler directives
This change renames

```
//kage:unit texel
//kage:unit pixel
```

to

```
//kage:unit texels
//kage:unit pixels
```

.

Closes #2717
2023-08-01 11:41:38 +09:00
Hajime Hoshi
ce25583438 internal/atlas: refactoring: move temporaryBytes to internal/graphicscommand 2023-08-01 00:11:40 +09:00
Hajime Hoshi
0fb1cdcfbd internal/atlas: bug fix: there should be multiple temporaryBytes objects for pipelining
Closes #2716
2023-07-31 16:18:17 +09:00
Hajime Hoshi
3869e2e4f6 internal/ui: refactoring: integrate the render thread usages into internal/graphicscommand
Updates #2664
2023-07-30 03:50:49 +09:00
Hajime Hoshi
20edb04e5e internal/restorable: refactoring: add EndFrame 2023-05-08 01:09:25 +09:00
Hajime Hoshi
b32258ab8c internal/atlas: refactoring 2023-04-29 13:41:39 +09:00
Hajime Hoshi
d2c991b774 all: refactoring: use image.Rectangle 2023-04-28 01:03:38 +09:00
Hajime Hoshi
cdcffd7d4f internal/restorable: refactoring: use image.Rectangle 2023-04-28 00:42:40 +09:00
Hajime Hoshi
d9a2b0922d internal/atlas: refactoring: remove unnecessary calculations 2023-04-28 00:26:09 +09:00
Hajime Hoshi
9e61b52a70 internal/atlas: refactoring: use image.Rectangle 2023-04-27 23:55:11 +09:00