Commit Graph

91 Commits

Author SHA1 Message Date
Hajime Hoshi
7c459c152b internal/atlas: bug fix: compile error 2022-10-16 20:02:42 +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
37369a2f4b internal/atlas: add TestMaxImageSizeJust 2022-06-10 14:30:18 +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
9ee56ac320 inetrnal/atlas: remove unnecessary (and risky) locks 2022-06-08 10:05:15 +09:00
Hajime Hoshi
3b6a080519 internal/atlas: bug fix: use the global lock for shaders
Closes #2129
2022-06-08 10:00:31 +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