Commit Graph

377 Commits

Author SHA1 Message Date
Hajime Hoshi
49582519c1 all: add a compiler directive kage:unit
This change adds a new compiler directive 'kage:unit' to Kage. This
takes one of these two values: 'pixel' and 'texel'. The default value
is 'texel'.

With the pixel-unit mode, all the built-in functions treats pixels
instead of texels, and the texCoord argument of Fragment is in pixels.
This simplifies shader programs as programs no longer have the notion
of texels.

With the texel-unit mode, the behavior is the same as the current
behavior.

Closes #1431
2023-04-23 22:11:57 +09:00
divVerent
cc24796270
internal/restorable: optimize removeDuplicatedRegions from O((n+m)^2) to O(n*m + m^2) (#2631)
This is achieved by replacing the function by one that only adds a single
new region, and only considers duplicates between the previously existing
region and the one newly added one, thereby removing previously redundant
checking of each previously existing region against each other.

This speeds up AAAAXY loading on a Moto G7 Play from 52.27 seconds to
8.15 seconds.

Closes #2626
2023-04-09 02:31:22 +09:00
Hajime Hoshi
84146510ce internal/restorable: refactoring 2023-03-10 22:29:59 +09:00
Hajime Hoshi
46173ffec6 internal/restorable: refactoring 2023-03-10 01:57:07 +09:00
Hajime Hoshi
8f2097d55e internal/restorable: reduce more duplicated regions 2023-03-09 23:17:02 +09:00
Hajime Hoshi
f3b49e6543 internal/restorable: reduce more duplicated regions 2023-03-09 22:57:57 +09:00
Hajime Hoshi
367606f274 internal/restorable: remove duplicated regions from i.staleRegions
Updates #2375
Updates #2581
2023-03-09 17:15:56 +09:00
Hajime Hoshi
22d74e78b2 internal/restorable: reduce allocations at readPixelsFromGPU
Updates #2375
2023-03-08 16:43:43 +09:00
Hajime Hoshi
da55397420 internal/restorable: remove empty regions at appendRegionsForDrawTriangles 2023-03-08 16:32:41 +09:00
Hajime Hoshi
f298b9541b internal/restorable: use a cache for pixels at readPixelsFromGPU
Updates #2375
2023-03-08 16:27:38 +09:00
Hajime Hoshi
7f182e7814 internal/restorable: skip basePixels.Clear when the region is empty 2023-03-08 16:21:45 +09:00
Hajime Hoshi
e4fffaf963 internal/restorable: reduce allocations
Updates #2375
2023-03-08 16:07:41 +09:00
Hajime Hoshi
7f3cff5e7c internal/restorable: revive pixelsForRestore
pixelsForRestore was removed at 09e0320309
as the regions for restoring were minimized. However, this caused a
regression and increased allocations on Android.

This fix revives pixelsForRestore, but as a map with region keys and
byte slice values. pixelsForRestore no longer represents a byte slice
for an entire image.

Updates #2375
2023-03-08 14:52:44 +09:00
Hajime Hoshi
e5bb89aa35 internal/restorable: use a special shader to clear an image
This reduces one extra internal texture.
2023-03-01 15:47:03 +09:00
Hajime Hoshi
42aa5fa604 internal/restorable: bug fix: an extended image has a wrong state (especially with OpenGL ES) 2023-02-28 08:48:25 -08:00
Hajime Hoshi
62e08e7356 internal/restorable: fix comments 2023-02-26 12:26:22 +09:00
Hajime Hoshi
110ba5403d internal/buffered: remove redundant pixel data if possible 2023-02-26 01:55:43 +09:00
Hajime Hoshi
df944fdf90 internal/restorble: clear pixels when possible to save memory 2023-02-26 00:12:34 +09:00
Hajime Hoshi
f04d9d6925 internal/restoring: avoid using staleRegions when alwaysReadPixelsFromGPU is true
Updates #2582
2023-02-25 23:26:28 +09:00
Hajime Hoshi
965fd4cac8 internal/restoring: bug fix: stop keeping pixel data on 32bit architecture
Updates #4259
2023-02-25 23:11:42 +09:00
Hajime Hoshi
a0a80bbc1f internal/restorable: do not reset basePixels at makeStale
This information is still available even after context-lost happens,
so this doesn't have to be reset.
2023-02-25 21:13:35 +09:00
Hajime Hoshi
aca42e4046 internal/restorable: use sparate regions instead of a big unified region 2023-02-25 15:40:48 +09:00
Hajime Hoshi
09e0320309 internal/restorable: minimize a region for restoring 2023-02-25 15:10:32 +09:00
Hajime Hoshi
ff926b2e9f internal/restorable: reland (2nd): use a smaller size rectangle for staleRegion 2023-02-24 21:25:47 -08:00
Hajime Hoshi
ec6f425fa0 Revert "internal/restorable: reland: use a smaller size rectangle for staleRegion"
This reverts these commits:

* 0755523776
* e36007a3a3

Reason: TestImageOptionsFill fails with OpenGL ES (https://github.com/hajimehoshi/ebiten/actions/runs/4264894196/jobs/7423561399)
2023-02-25 03:12:26 +09:00
Hajime Hoshi
0755523776 internal/restorable: bug fix: pixel info was unexpectedly lost 2023-02-25 02:43:58 +09:00
Hajime Hoshi
e36007a3a3 internal/restorable: reland: use a smaller size rectangle for staleRegion 2023-02-25 02:09:22 +09:00
Hajime Hoshi
185529f1cb Revert "internal/restorable: use a smaller size rectangle for staleRegion"
This reverts commit e4debfd466.

Reason: test failures on Windows: https://github.com/hajimehoshi/ebiten/actions/runs/4262488629/jobs/7418053241
2023-02-24 21:56:32 +09:00
Hajime Hoshi
e4debfd466 internal/restorable: use a smaller size rectangle for staleRegion 2023-02-24 21:33:39 +09:00
Hajime Hoshi
745a69aeaa internal/restorable: update comments 2023-02-24 18:25:17 +09:00
Pierre Curto
4de807cc44
all: fix typos (#2558)
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2023-01-28 19:06:38 +09:00
Hajime Hoshi
89c64f83e3 ebiten: performance improvement by reducing allocations of []float32 2022-12-03 21:53:56 +09:00
Hajime Hoshi
0a6813c17f internal/graphics: use flatten []float32 slice instead of [][]float32
Closes #2479
2022-12-03 20:23:58 +09:00
Hajime Hoshi
419bb4c1e9 all: use uint32 instead of float32 for uniform values
This is a preparation for other types of uniform values.

Updates #2305
2022-11-12 20:28:07 +09:00
Hajime Hoshi
fde964312c internal/packing: reland: refactoring
This change basically relands these commits:

 * e08078d84a
 * 8fa36cc7ef

but with a fix internal/restorable not to create too many images.

Updates #2327
2022-11-11 21:55:11 +09:00
Hajime Hoshi
f04e391cb4 all: rename emptyImage -> whiteImage 2022-10-21 15:26:56 +09:00
Hajime Hoshi
09a7d39874 internal/graphicsdriver: add Blend struct
This is a preparation to specify blend factors and blend operators.

Updates #2382
2022-10-16 01:08:26 +09:00
Hajime Hoshi
cb79e4eabe internal/restorable: improve pixelsForRestore usages
Updates #2375
2022-10-06 15:54:54 +09:00
Hajime Hoshi
c6b37e9809 internal/restorable: use pixelsForRestore only when restoring is needed
Updates #2375
2022-10-06 15:09:21 +09:00
Hajime Hoshi
34562c3337 internal/restorable: clear pixelsForRestore at Dispose
Updates #2375
2022-10-06 15:04:12 +09:00
Hajime Hoshi
e66bac5c3f internal/restorable: reuse byte slices for restoring
Updates #2375
2022-10-06 14:52:20 +09:00
Hajime Hoshi
85d8a5889a Revert "internal/restorable: reuse bytes instead of allocations"
This reverts commit 8cf3c31cf6.

Reason: This didn't improve the situation.

Updates #2375
2022-10-06 14:11:09 +09:00
Hajime Hoshi
8cf3c31cf6 internal/restorable: reuse bytes instead of allocations
Updates #2375
2022-10-06 12:41:47 +09:00
Hajime Hoshi
72983d966b all: remove unused conditions
Now Kage shaders are always used.

The situtation is different from when we fixed for #1355, so we removed
the fast path for #1335. We have to re-check the current performance.

Updates #1355
2022-10-02 23:50:48 +09:00
Hajime Hoshi
de8f85651d internal/restorable: remove unused arguments from DrawTriangles
Updates #2369
2022-10-02 22:51:34 +09:00
Hajime Hoshi
0ae2b1bc24 all: remove unnecessary conditions
Now a Kage shader is always used.
2022-10-02 22:30:59 +09:00
Hajime Hoshi
6fca8edc1b internal/graphicscommand: remove unused arguments from DrawTriangles
Updates #2369
2022-10-02 22:21:11 +09:00
Hajime Hoshi
311aa7dcf8 all: use Kage shaders in internal packages
Updates #2369
2022-10-02 19:17:09 +09:00
Hajime Hoshi
18fa00d25d internal/restorable: update comments 2022-09-14 02:20:11 +09:00
Hajime Hoshi
6179158812 internal/restorable: bug fix: no pixels were read only with DrawTriangles
Closes #2324
2022-09-14 02:17:14 +09:00