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
f593725bf9
Revert "internal/packing: refactoring"
...
This reverts these commits
* 8fa36cc7ef
.
* e08078d84a
Reason: test failures
Updates #2327
2022-11-11 19:35:13 +09:00
Hajime Hoshi
e08078d84a
internal/packing: refactoring
...
Now pages are automatically extended by Alloc.
Updates #2327
2022-11-11 19:12:23 +09:00
Hajime Hoshi
2855095ac9
all: unify terms for buffers and flushing
2022-10-16 19:47:00 +09:00
Hajime Hoshi
475dc6394f
internal/atlas: remove an unnecessary mutex
...
Updates #2390
2022-10-16 15:29:02 +09:00
Hajime Hoshi
27cb149475
internal/graphicscommand: bug fix: resolve unsent WritePixels commands
...
(*Image).WritePixels doens't send a command to the queue immediately
but caches commands internally. However, the package atlas assumed
that pixel data was sent to the cache every end of a frame. Then, byte
slices for pixels were corrupted.
This change fixes the issue by resolving all the images when flushing
commands.
Closes #2390
2022-10-16 15:19:25 +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
daf349ab72
internal/graphicscommand: bug fix: present at the end of the frame explicitly
...
Before this change, presenting happened when the rendering destination
was the final screen. Now this assumption is wrong as the final screen
might be used in the middle of the commands due to DrawFinalScreen.
Instead, this change adds a new argument `present` to FlushCommands to
present the screen explicitly at the end of the frame.
Closes #2386
2022-10-15 01:54:46 +09:00
Hajime Hoshi
99e777b0c5
internal/atlas: do not adjust pixels for DrawTriangles(Shader)
...
Adjusting pixels is needed to avoid strainge rendering to avoid unexpected
rendering (#1171 ). However, this adjustment caused unexpected holes
especially in a thick stroke.
This change moves the logic of adjusting pixels from atlas to
graphics.QuadVertices so that adjusting works only for DrawImage and
DrawRectShader.
Updates #1171
Updates #1843
2022-10-11 02:09:20 +09:00
Hajime Hoshi
61cabbf2e7
internal/atlas: optimization
2022-10-03 00:06:50 +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
3da30b3b78
internal/atlas: remove unused arguments from DrawTriangles
...
Updates #2369
2022-10-02 23:06:27 +09:00
Hajime Hoshi
de8f85651d
internal/restorable: remove unused arguments from DrawTriangles
...
Updates #2369
2022-10-02 22:51:34 +09:00
Hajime Hoshi
311aa7dcf8
all: use Kage shaders in internal packages
...
Updates #2369
2022-10-02 19:17:09 +09:00
Hajime Hoshi
d0556af8a4
internal/atlas: refactoring
2022-09-15 01:52:05 +09:00
Hajime Hoshi
31945563d8
internal/atlas: optimize adjustDestinationPixel
...
```
go test -bench=BenchmarkAdjustPixel -run=^$ -count=5 ./internal/atlas/
```
```
name old time/op new time/op delta
AdjustPixel-8 2.59ns ± 1% 2.12ns ± 1% -18.16% (p=0.008 n=5+5)
```
2022-09-15 01:50:47 +09:00
Hajime Hoshi
9319266c01
internal/atlas: add a benchmark for adjustDestinationPixel
2022-09-15 01:25:26 +09:00
Hajime Hoshi
67ceaf5874
internal/atlas: rename replacePixels -> writePixels
2022-09-13 06:39:29 -07:00
Hajime Hoshi
cdf83ad2fc
internal/atlas: dispose images at ReadPixels
...
Without resolveDeferred() at ReadPixels, many images are never disposed
in tests.
Updates #2292
2022-09-01 23:54:57 +09:00
Hajime Hoshi
ae41530f1c
internal/graphicscommand: move availableFilename to graphicscommand
2022-08-31 13:26:14 +09:00
Hajime Hoshi
8ce84c6596
internal/atlas: rename ReplacePixels -> WritePixels
2022-08-08 03:24:46 +09:00
Hajime Hoshi
af894d5c83
internal/restorable: rename ReplacePixels -> WritePixels
...
Updates #2236
2022-08-08 03:16:26 +09:00
Hajime Hoshi
bf5f7ee34d
internal/restorable: refactoring: replace At with ReadPixels
...
Updates #1995
2022-08-05 23:37:27 +09:00
mattn
3cd0daac67
go generate ./... with Go 1.19 ( #2228 )
2022-08-03 20:48:02 +09:00
Hajime Hoshi
764ec8c794
internal/atlas: refactoring
2022-08-02 01:13:46 +09:00
Hajime Hoshi
afed6a83c6
internal/graphics: change the naming convention: Num -> Count
...
This change also renames ebiten.MaxIndicesNum -> ebiten.MaxIndicesCount.
2022-07-13 02:02:44 +09:00
Hajime Hoshi
8522bfd0bf
internal/graphicscommand: bug fix: replacePixelsCommand should not read pixels
...
Reading pixels, writing pixels, and using the image as a source might
cause a flaky behavior with Metal. Stop reading pixels if possible.
Closes #2180
2022-07-05 23:30:26 +09:00
Hajime Hoshi
dd805c9414
internal/atlas: remove a wrong comment
...
(*restrable.Image).ReplacePixels can take overlapped regions.
See TestOverlappedPixels.
Updates #2180
2022-07-05 13:59:23 +09:00
Hajime Hoshi
253f2757d1
internal/atlas: add a test to modify pixels after ReplacePixels call
2022-06-11 23:44:29 +09:00
Hajime Hoshi
03567f74f9
internal/atlas: bug fix: respect injected maxSize for testings
2022-06-10 14:25:08 +09:00
Hajime Hoshi
7c458f519e
internal/atlas: remove unnecessary comments
2022-06-10 13:53:24 +09:00
Hajime Hoshi
6b814888b5
internal/atlas: always use DrawTriangles at putOnAtlas
...
DrawTriangles was introduced at #1508 , and apparently there is no
reason we should use ReplacePixels here. So, simplify the logic by
using only DrawTriangles.
2022-06-10 02:58:04 +09:00
Hajime Hoshi
bdae45be8f
internal/atlas: add assertions
2022-06-10 02:38:35 +09:00
Hajime Hoshi
116e131ccf
internal/atlas: rename ImageTypeIsolated -> ImageTypeUnmanaged
2022-06-10 02:11:08 +09:00
Hajime Hoshi
b40022b286
internal/atlas: stop using padding for ImageTypeVolatile and ImageTypeIsolated
...
Closes #2131
2022-06-10 00:54:48 +09:00
Hajime Hoshi
9e34103491
internal/atlas: refactoring: make paddingSize a method
...
Updates #2131
2022-06-10 00:23:25 +09:00
Hajime Hoshi
5290605b2d
internal/atlas: add comments
2022-06-08 11:18:08 +09:00
Hajime Hoshi
81f91658ff
internal/atlas: refactoring: remove SetVolatile and SetIsolate
...
Pass an image type to NewImage instead.
2022-06-08 01:08:00 +09:00
Hajime Hoshi
b8e8d72377
internal/restorable: rename ImageTypeScreenFramebuffer -> ImageTypeScreen
2022-06-07 23:45:35 +09:00
Hajime Hoshi
73c893e977
internal/restorable: refactoring: unify NewScreenFramebufferImage and NewImage
2022-06-06 09:33:50 +09:00
Hajime Hoshi
7f10744514
internal/atlas: add an assertion at putOnAtlas
2022-06-06 09:01:04 +09:00
Hajime Hoshi
9bf5f2188f
internal/atlas: add an assertion at SetIsolated
2022-06-06 08:25:43 +09:00
Hajime Hoshi
86a0a4154d
internal/atlas: rename SetIsolate -> SetIsolated
2022-06-06 07:17:45 +09:00
Hajime Hoshi
b9012fc6ed
internal/atlas: unify the term 'isolate' and 'independent' to 'isolate'
2022-06-06 00:28:23 +09:00
Hajime Hoshi
faf1e7350d
internal/atlas: bug fix: wrong logic to create a new mask with edges
...
* Fixed wrong operator orders
* Cleared an allocated region explicitlly
Closes #2089
2022-05-08 23:06:10 +09:00
Hajime Hoshi
928d82c685
internal/atlas: potential bug fix: restore images before other image manipulations
...
From the reported stack trace, there could be a potential issue in
atlas.BeginFrame: images were manipulated before the images are restored.
Restoring images assumes that all images are not stale, but manipulating
images like putOnAtlas might cause other images stale in ReplacePixels.
Though we failed to reproduce the case, this fix should make sense.
Updates #2075
2022-04-18 02:19:46 +09:00
Hajime Hoshi
6710808cd1
ebiten: compile shaders at NewShader
...
Closes #2035
2022-04-04 02:52:57 +09:00
Hajime Hoshi
f75a70dc40
internal/graphicscommand: treat []float32 instead of interface{} for uniform variables
2022-04-03 03:51:52 +09:00
Hajime Hoshi
351ef9fbb7
internal/atlas, internal/graphicsdriver: move the adjusting-pixel logic to atlas
...
Now pixels are adjusted even when the graphics driver doesn't have
high-precision floats, but this should not be problematic. This was
introduced at 9bff33472a
, but the
adjusting way is much different from the current way.
Updates #879
Closes #1820
2022-04-02 05:15:29 +09:00
Hajime Hoshi
34e23f5256
internal/restorable: treat texels instead of pixels
...
Updates #1820
2022-04-02 04:25:27 +09:00
Hajime Hoshi
0c6362c93a
internal/atlas: move the color scaling from internal/atlas to ebiten
...
Updates #1820
2022-04-02 02:47:56 +09:00
Hajime Hoshi
81b9f91f86
internal/graphicscommand: compile shaders lazily
...
With DirectX, the graphics driver cannot be determined until the
main loop starts, as a transparent window cannot be treated with
DirectX so far. On the other hand, compiling shaders requires a
graphics driver as it requires information about Y directions of
NDCs and framebuffers.
This change delays compiling shaders until the graphics commands
are actually executed in the main loop.
Updates #1007
Updates #2019
2022-03-21 21:09:02 +09:00
Hajime Hoshi
fc96eb30a1
internal/atlas: simplify the logic by adding paddings to the mask
2022-03-21 16:13:21 +09:00
Hajime Hoshi
5c3f8915d1
internal/atlas: add an argument check
2022-03-21 15:11:38 +09:00
Hajime Hoshi
4f070915b2
internal/atlas: bug fix: do not use the padding when a mask is specified
...
With paddings, a mask size was not appropriate.
As a simple solution, let's not use paddings when a mask is specified.
2022-03-21 05:50:31 +09:00
Hajime Hoshi
b3f4d6c522
internal/atlas: add a new parameter specifying a mask for ReplacePixels
2022-03-21 03:56:04 +09:00
Hajime Hoshi
5c79b86412
internal/restorable: add a new parameter specifying a mask for ReplacePixels
2022-03-21 03:08:58 +09:00
Hajime Hoshi
11ff0ab48c
internal/atlas: refactoring: remove arguments from Pixels
2022-03-20 18:28:57 +09:00
Hajime Hoshi
367a9ec5bf
internal/atlas: refactoring
2022-03-20 18:07:29 +09:00
Hajime Hoshi
b59dd45239
internal/buffered: separate ReplacePixels with the large-area and small-area versions
...
For the large-area version, this doesn't require a graphics driver.
This is necessary to ensure that ReplacePixels never needs a graphics
driver.
2022-03-20 04:13:31 +09:00
Hajime Hoshi
4cbce71b2b
internal/graphicscommand: move the choice of graphics drivers to internal/ui
2022-03-20 02:51:31 +09:00
Hajime Hoshi
7d0f95e9be
internal/graphicsdriver: refactoring: replace Uniform with []float32
...
Closes #2016
2022-03-13 03:42:13 +09:00
divVerent
f2209a0b51
internal/atlas: optimization: send premultiplied alpha from vertex to fragment shader. ( #1996 )
...
Note that this applies only to the builtin shaders - interface for Kage stays
unchanged for compatibility.
Minor compatibility delta: when interpolating alpha values, previous code has
created nonsense values, such as, when interpolating from
fully-transparent-black (0,0,0,0) to opaque-white (1,1,1,1), something like
half-transparent-grey (0.25,0.25,0.25,0.5) where half-transparent-white
(0.5,0.5,0.5,0.5) is used by the new code.
I assume this is a strict improvement, however this may warrant some testing.
Possible later improvement could be moving the premultiplication from fragment
shader to CPU. Did not do this as it makes the code rather inconsistent of Kage
vs built-in shader usage.
Updates #1772
2022-02-24 02:27:50 +09:00
Hajime Hoshi
f17d222a4b
internal/atlas: resolve deferred every frame instead of every tick
...
Resolving defferred functions doesn't have to be done every tick. Rather,
this should be done every frame as this is related to rendering.
2022-02-14 03:45:58 +09:00
Hajime Hoshi
df60c4c92d
internal/driver: rename to internal/graphicsdriver
2022-02-06 20:41:32 +09:00
Hajime Hoshi
8321cecfdd
internal/atlas: typo
2022-01-19 23:44:59 +09:00
Hajime Hoshi
d1a5a161d7
internal/atlas: typo
2022-01-08 23:33:59 +09:00
Hajime Hoshi
0680ca413d
internal/atlas: bug fix: the offscreen must be an independent image
...
Closes #1938
2022-01-08 23:25:06 +09:00
Hajime Hoshi
0238549cfb
internal/atlas, initernal/graphics: Better buffer size calculation
2021-10-31 17:20:39 +09:00
Hajime Hoshi
d236d73a1f
internal/atlas, initernal/graphics: Bug fix: Needed to reset 'notFullyUsedTime'
2021-10-31 17:18:07 +09:00
Hajime Hoshi
06f4142ca0
internal/driver: Optimization: Replace interface{} with driver.Uniform
...
Converting a value from/to interface{} can create a value in heap
and this is not efficient.
2021-10-30 02:58:28 +09:00
Hajime Hoshi
4b64eadfe5
internal/mipmap, internal/atlas: Integrate for-loops for color scaling
2021-09-23 00:28:20 +09:00
Hajime Hoshi
91a7288027
internal/atlas: Better pixel allocations
...
Updates #1681
Updates #1788
2021-08-26 03:35:21 +09:00
Hajime Hoshi
9c321375c9
internal/atlas: Bug fix: pix was reset at a wrong timing
...
Closes #1788
2021-08-25 22:10:57 +09:00
Hajime Hoshi
4e6a5a9fa2
internal/atlas: Bug fix: Wrong screenshot size
...
Updates #1736
2021-07-29 16:33:54 +09:00
Hajime Hoshi
18903db1c6
internal/atlas: Bug fix: Unexpected padding in screenshots
...
Closes #1736
2021-07-29 16:09:29 +09:00
Hajime Hoshi
21aa96f9f5
internal/affine: Refactoring: Make ColorM interface
2021-07-27 12:10:22 +09:00
Hajime Hoshi
b466a0cbd7
ebiten: Add EvenOdd to DrawTrianglesOptions and DrawShaderTrianglesOptions
...
Updates #844
Closes #1684
2021-07-05 03:35:55 +09:00
Hajime Hoshi
699bb095c3
internal/atlas: Better algorithm to release the temporary pixels
2021-06-26 23:29:45 +09:00
Hajime Hoshi
38ce46328a
internal/atlas: Reuse byte array for ReplacePixels
...
This reduces memory allocation at ReplacePixels.
Updates #1681
2021-06-26 03:48:25 +09:00
Hajime Hoshi
414a64ce78
internal/atlas: Allow extending a texture atlas
...
As PBO is no longer used (#1678 ), using a big atlas with
ReplacePixels is no longer problematic.
Closes #1674
Updates #1675
2021-06-24 21:35:36 +09:00
Hajime Hoshi
fa8e271f2a
internal/atlas: Bug fix: Set the minimum texture size to 8192px
...
Closes #1675
Updates #1674
2021-06-19 18:52:08 +09:00
Hajime Hoshi
26b9fa20c1
internal/graphics: Bug fix: Race condition at QuadVertices
...
QuadVertices or verticesBackend.slice reused its backend slice.
This caused a race condition. QuadVertices can be accessed from
multiple goroutines, and resetting the head and copying the data
at internal/graphicscommand might not be synced.
This change fixes this issue by basically reverting
9cb631e30f
.
Closes #1546
2021-03-20 16:32:13 +09:00
Hajime Hoshi
3e7217cb86
internal/atlas: Add comments to moveTo
2021-03-12 00:26:38 +09:00
Hajime Hoshi
ec677a258f
Rename internal/shareable -> internal/atlas
...
Also the terms are renamed:
* shared -> on an atlas
* not shared -> isolated
Closes #1529
2021-03-12 00:22:08 +09:00