Commit Graph

251 Commits

Author SHA1 Message Date
Hajime Hoshi
2de64088dc internal/graphicscommand: reduce boundary checks
This can be confirmed by this command:

```
go build -gcflags="-d=ssa/check_bce" ./internal/graphicscommand/
```

Updates #2601
2023-08-21 03:15:31 +09:00
Hajime Hoshi
c00795416a internal/graphicscommand: remove a redundant boundary check
The boundary is already checked the above 'copy' call. This can be
confirmed by the result of this command.

```
go build -gcflags="-d=ssa/check_bce" ./internal/graphicscommand/
```
2023-08-20 15:45:19 +09:00
Hajime Hoshi
3b67b91bb2 internal/graphicscommand: remove redundant buffers
Now there are two command queues, uint32sBuffer doesn't have to have
two buffers.
2023-08-19 17:15:48 +09:00
Hajime Hoshi
fcec771f34 internal/graphicscommand: clear uniform variables explicitly
This change is a performance optimization.

(*uint32sBuffer).alloc doesn't clear the uniform values. Without
clearing the values explicitly, CanMergeWithDrawTrianglesCommand
might return false even though two commands can be merged.
2023-08-19 16:19:14 +09:00
Hajime Hoshi
e270dea460 internal/graphicsdriver: use []PixelsArgs for ReadPixels
Closes #2592
2023-08-17 03:06:48 +09:00
Hajime Hoshi
842c3cbfcd internal/graphicscommand: use a slice to values instead of pointers
This should reduce heap allocations.
2023-08-16 23:23:30 +09:00
Hajime Hoshi
377b0b8502 internal/graphicscommand: rename WritePixelsArgs -> PixelsArgs
Updates #2592
2023-08-16 22:34:56 +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
f81dbd9288 internal/graphicsdriver: flush commands asynchronously whenever possible
Closes #2664
2023-07-30 22:44:13 +09:00
Hajime Hoshi
a7e4665f71 internal/graphicscommand: use multiple command queues
This is a preparation for asynchronous rendering.

Updates #2664
2023-07-30 22:42:58 +09:00
Hajime Hoshi
81b7fd7641 internal/graphicscommand: refactoring 2023-07-30 18:37:18 +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
guangwu
54e1263565
all: unnecessary use of fmt.Sprintf (#2691)
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-07-05 16:36:29 +09:00
Hajime Hoshi
ecf07ad09e internal/graphicscommand: speed optimization: reduce boundary checks
Co-authored-by: Egon Elbre <egonelbre@gmail.com>
2023-05-04 12:55:53 +09:00
Hajime Hoshi
e98acd3dc7 internal/graphicsdriver: refactoring: use image.Rectangle 2023-04-29 01:12:05 +09:00
Hajime Hoshi
56b4cdc3c4 internal/graphics: use pixels for offsets 2023-04-26 00:38:23 +09:00
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
Hajime Hoshi
2f55bb1b3d internal/atlas, internal/graphicscommand: refactoring 2023-04-19 21:43:08 +09:00
Hajime Hoshi
eb6a773d3f internal/graphicscommand: remove unnecessary space chars 2023-04-18 01:19:28 +09:00
Hajime Hoshi
c7ca9cb321 ebiten: omit the exceeding part of vertices at Draw* 2023-03-23 21:23:33 +09:00
Hajime Hoshi
31273c875f internal/graphics: rename constants 2023-03-23 20:48:39 +09:00
Hajime Hoshi
81581df2b9 internal/graphicscommand: reland: add graphics.MaxVertexFloatCount and use it instead of IndicesCount
This change is reland of 54e2790a06
but with a fix for WebGL. Also, this changes the logic when len(vertices)
exceeds the maximum: just remove the last part.

Updates #2460
2023-03-23 18:01:09 +09:00
Hajime Hoshi
c59bcbdb5b Revert "internal/graphicscommand: add graphics.MaxVertexFloatCount and use it instead of IndicesCount"
This reverts commit 54e2790a06.

Reason: test failures on browsers:

`GOOS=js GOARCH=wasm go test . -shuffle=1679547510163000000` failed
https://github.com/hajimehoshi/ebiten/actions/runs/4497182906/jobs/7912544699
2023-03-23 14:15:04 +09:00
Hajime Hoshi
54e2790a06 internal/graphicscommand: add graphics.MaxVertexFloatCount and use it instead of IndicesCount
Updates #2460
2023-03-23 13:49:05 +09:00
Hajime Hoshi
3f2ac129d2 internal/graphicscommand: refactoring: remove unnecessary restrictions for indices
Updates #2460
2023-03-23 13:28:11 +09:00
Hajime Hoshi
61ee811579 internal/graphicsdriver: define Resetter 2023-03-22 18:35:46 +09:00
Hajime Hoshi
39aaf7fe37 ebiten: update comments
Updates #2601
2023-03-14 13:07:40 +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
e1992347b7 internal/graphicscommand: rename SetRenderingThread -> SetRenderThread 2022-12-30 13:51:32 +09:00
Hajime Hoshi
c321d069a8 internal/graphicscommand: remove unnecessary type parameters 2022-12-10 00:43:41 +09:00
Hajime Hoshi
0d173834a6 all: speed optimization 2022-12-03 23:09:41 +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
4ff9a12930 internal/graphicscommand: refactoring 2022-11-12 22:26:28 +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
50021ef3e4 internal/graphicscommand: use buffers for []float32 to reduce allocations 2022-11-04 21:55:44 +09:00
Hajime Hoshi
d73e8f785d internal/graphicsdriver: render various destination regions as one command
Closes #2232
2022-11-04 20:49:44 +09:00
Hajime Hoshi
1839dd0b9b internal/graphicscommand: bug fix: test failures on Linux 2022-11-04 03:55:05 +09:00
Hajime Hoshi
80e3baae9f internal/graphicscommand: reduce allocations of float32 slices 2022-11-04 02:34:44 +09:00
Hajime Hoshi
c4e4e55d75 internal/shaderir: cache reachable uniform variables
Updates #2232
2022-11-04 01:28:24 +09:00
Hajime Hoshi
384dee7160 internal/graphicscommand: remove unused uniform variables
This improves possibility of merging graphics commands by reducing
uniform variables.

Updates #2232
2022-11-03 22:45:17 +09:00
Hajime Hoshi
a5993f09a2 internal/graphicscommand: refactoring: add preserved uniform variables at the graphicscommand package
This is a preparation to skip setting unnecessary uniform variables
like dstRegion.

Updates #2232
2022-10-30 22:30:52 +09:00
Hajime Hoshi
ac61126473 internal/graphicscommand: always flush buffers
After #2423 is fixed, buffers should be able to be flushed safely
anytime.

Updates #2391
Updates #2423
2022-10-30 10:51:41 +09:00
Hajime Hoshi
5eceabd172 Revert "internal/graphicscommand: bug fix: flush image buffers"
This reverts commit d6910eb9ab.

Reason: The wasm flakiness occured again

Updates #2391
Updates #2423
2022-10-30 02:32:28 +09:00
Hajime Hoshi
d6910eb9ab internal/graphicscommand: bug fix: flush image buffers
This is basically a revert for 4d5b608d0c.
This caused a crash on Windows.

Even after this fix, the browser tests seem no longer flaky, but
I am not 100% sure.

Updates #2391
Closes #2423
2022-10-30 02:21:56 +09:00
Hajime Hoshi
b019a3723a internal/ui: optimize GPU usages when the screen doesn't have to be updated
This change skips rendering when 1) the screen is not cleared every frame
(`SetScreenClearedEveryFrame(false)`) and 2) Draw doesn't draw anything
onto the screen. The GPU usages decreased on some machines (e.g. GPU usage
was 10% with an empty Ebitengine project and became 2-3 % on a Windows
machine).

Updates #2341
2022-10-28 18:51:06 +09:00
Hajime Hoshi
180e456a8e ebiten: rename members of Blend
Updates #2382
2022-10-17 00:51:55 +09:00
Hajime Hoshi
2855095ac9 all: unify terms for buffers and flushing 2022-10-16 19:47:00 +09:00
Hajime Hoshi
4d5b608d0c internal/graphicscommand: bug fix: suppress test flakiness on browsers
Closes #2391
2022-10-16 17:55:23 +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