Commit Graph

527 Commits

Author SHA1 Message Date
Hajime Hoshi
446a6dc952 internal/graphics: deprecated some built-in functions
Updates #1870
2023-08-29 00:06:54 +09:00
Hajime Hoshi
db34930ae8 internal/graphics: add built-in Kage functions
This change adds these Kage functions:

* imageDstOrigin
* imageDstSrc
* imageSrcNOrigin
* imageSrcNSrc

and deprecates these functions:

* imageDstRegionOnTexture
* imageSrcRegionOnTexture

Closes #1870
2023-08-28 15:06:45 +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
fd5e2d39c0 internal/graphics: add uniform variables for source image sizes
Updates #1870
2023-08-25 07:30:52 +09:00
Hajime Hoshi
3493358fd2 internal/graphics: use the terms 'image' and 'texture' appropriately 2023-08-24 02:36:51 +09:00
Hajime Hoshi
407d7bd43f internal/graphics: optimization: remove boundary checks
Before:

```
$ go build -gcflags="-d=ssa/check_bce" ./internal/graphics
internal/graphics/vertex.go:83:9: Found IsSliceInBounds
internal/graphics/vertex.go:85:5: Found IsInBounds
internal/graphics/vertex.go:86:5: Found IsInBounds
...
```

After:

```
$ go build -gcflags="-d=ssa/check_bce" ./internal/graphics
internal/graphics/vertex.go:83:11: Found IsSliceInBounds
internal/graphics/shader.go:134:37: Found IsSliceInBounds
```

Updates #2601
2023-08-20 15:38:07 +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
56b4cdc3c4 internal/graphics: use pixels for offsets 2023-04-26 00:38:23 +09:00
Hajime Hoshi
9d2178cf71 internal/shaderir: rename the built-in func to get a texel to __texelAt 2023-04-23 22:57:30 +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
df32901dce internal/shader: refactoring 2023-04-16 18:37:06 +09:00
Hajime Hoshi
31273c875f internal/graphics: rename constants 2023-03-23 20:48:39 +09:00
Hajime Hoshi
ce9274a29d ebiten: remove the restriction for len(indices) at Draw*
Closes #2460
2023-03-23 20:01:15 +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
034f9c2db8 internal/graphicsdriver/opengl: reland: refactoring: remove usages of graphics.IndicesCount
Updates #2460
2023-03-22 20:13:29 +09:00
Hajime Hoshi
8cbf545e0f internal/graphicsdriver/opengl: revert commits for graphics.Indices
This change reverts these commits:

* 13d3a0487b
* 4cd98d512e

Reason: this caused crashes on Android.

Updates #2460
Closes #2610
2023-03-22 17:28:45 +09:00
Hajime Hoshi
13d3a0487b internal/graphicsdriver/opengl: refactoring: remove usages of graphics.IndicesCount
Updates #2460
2023-03-22 13:33:34 +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
88e5d5e059 Revert "internal/shaderir: refactoring: remove Program.TextureNum"
This reverts commit c2bea16776.

Reason: test compilation errors
2022-12-24 15:53:16 +09:00
Hajime Hoshi
c2bea16776 internal/shaderir: refactoring: remove Program.TextureNum 2022-12-24 15:15:41 +09:00
Hajime Hoshi
f9650fbb8c internal/graphics: update error messages 2022-12-24 14:34:02 +09:00
Hajime Hoshi
0d173834a6 all: speed optimization 2022-12-03 23:09:41 +09:00
Hajime Hoshi
61f1d8b69f internal/graphics: remove the common vertices backend
It was actually impossible to use the common vertices backend in a
thread-safe manner, and actually this caused race conditions.

This changes fixes the issue by giving up a central backend, and
letting images have their own vertices buffer.

Closes #2473
2022-12-03 01:02:23 +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
f7c44f086f replace Ebiten with Ebitengine in comments 2022-08-29 11:17:17 +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
b8367da7e2 internal/graphics: optimize imageSrcNUnsafeAt 2022-07-11 01:07:06 +09:00
Hajime Hoshi
32de5ec2d0 internal/graphics: refactoring 2022-04-05 11:12:25 +09:00
Hajime Hoshi
c6e5582c56 Revert "internal/graphics: refactoring"
This reverts commit b6cc164e96.

Reason: wrong shader program
2022-04-04 14:31:37 +09:00
Hajime Hoshi
b6cc164e96 internal/graphics: refactoring 2022-04-04 14:30:51 +09:00
Hajime Hoshi
6710808cd1 ebiten: compile shaders at NewShader
Closes #2035
2022-04-04 02:52:57 +09:00
Hajime Hoshi
02db3bad53 internal/graphicscommand: remove the dependency on a graphics driver from compileShader
Updates #2035
2022-04-04 02:09:08 +09:00
Hajime Hoshi
35a5c88901 internal/graphics: rename constants 2022-03-12 04:01:48 +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
r3vit
57c45a13e4
Remove dot imports from tests - Remove dot imports (#1837)
Closes #1824
2021-10-02 19:58:48 +09:00
Hajime Hoshi
9c5b7b56b2 internal/graphics: Reafctoring 2021-06-28 23:28:43 +09:00
Hajime Hoshi
c725937cc6 internal/graphics: Reuse the vertices backend
This is basically a reland of 9cb631e30f.
This change locks the vertices backend at the end-frame phase to
protect from vertices usages by other goroutines.

Updates #1546
Closes #1681
2021-06-27 02:31:01 +09:00
Hajime Hoshi
41f060b1d2 ebiten: Use the common vertices backend at DrawTriangles 2021-03-20 20:25:42 +09:00
Hajime Hoshi
15a0c53918 internal/graphics: Refactoring 2021-03-20 20:18:02 +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
c8b98f13fb internal/graphics: Always use the vertex backend to reduce GC
Closes #1521
2021-03-03 22:23:15 +09:00
Hajime Hoshi
718273c2d7 ebiten: Add a new shader function imageDstRegionOnTexture
Updates #1428
2020-12-09 11:36:29 +09:00
Hajime Hoshi
00f3d83d4c Remove supporting GopherJS
Fixes #1129
2020-10-07 01:10:09 +09:00
Hajime Hoshi
bf515bb594 Update version to v2.0.0-alpha 2020-10-04 04:30:40 +09:00
Hajime Hoshi
cb73230301 graphics: Revive the special allocating method for vertices for Wasm
It looks like the allocation cost is pretty high even on Wasm.
Revive the special method not only on GopherJS but also on Wasm.

examples/sprites kept 30FPS without this fix, but keeps 35FPS with
this fix, on Hajime's MacBook Pro 2020 (macOS Catalina 10.15.6).

Updates #797
2020-09-21 04:21:21 +09:00
Hajime Hoshi
609a3c4e22 ebiten: Bug fix: Fix the texel calculation
In shaders, texCoord is always in texture0's texels. Convert them
at imageNTextureAt functions correctly.

Fixes #1290
2020-08-11 04:15:07 +09:00
Hajime Hoshi
69f87d5fd1 ebiten: Add new shader builtin functions: image[N]TextureBoundAt
Fixes #1287
2020-08-11 03:24:54 +09:00