Commit Graph

67 Commits

Author SHA1 Message Date
Hajime Hoshi
bc9e9d8562 ebiten: move the builtin shader to internal/builtinshader
Updates #2861
2024-04-20 21:23:37 +09:00
Hajime Hoshi
95f7204035 ebiten: make sure panicking with a disposed shader 2023-11-04 00:28:26 +09:00
Hajime Hoshi
c01ceeaa6a ebiten: replace (*Image).Dispose with Deallocate
Closes #2808
2023-11-03 17:45:39 +09:00
Hajime Hoshi
bdd8916bb1 ebiten: replace (*ebiten.Shader).Dispose with Deallocate
Updates #2808
2023-11-03 16:25:18 +09:00
Hajime Hoshi
d9797423e5 ebiten, internal/builtinshader: use an array instead of a map
runtime.mapaccess2 is one of heavy function calls.

Updates #2601
2023-08-20 05:20:52 +09:00
Hajime Hoshi
a0ffd8dd25 ebiten: enable texCoord at DrawRectShader even without a source image
imageSrcRegionOnTexture will return (0, 0) to (width, height) for
the pixel-unit mode.

Closes #2166
2023-08-01 04:14:36 +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
015ce2b262 internal/ui: refactoring: reduce APIs 2022-12-09 00:05:22 +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
Artem Yadelskyi
10415d417a
all: replace interface{} with any (#2430)
Closes #2429
2022-11-03 15:33:09 +09:00
Hajime Hoshi
534d82c17d internal/builtinshader: move Filter and Address from internal/graphicsdriver 2022-10-02 23:24:15 +09:00
Hajime Hoshi
0b45ca7057 ebiten: reduce duplicated shader compilations 2022-10-02 20:33:50 +09:00
Hajime Hoshi
a4e9a05b14 ebiten: reland: use Kage shaders instead of built-in shaders for a color matrix
This replaces the built-in shaders with Kage shadres. This is a
refactoring and doesn't degrade performance:

```
go test -bench=^BenchmarkColorMScale$ -run=^$ . -count=5
```

```
name           old time/op  new time/op  delta
ColorMScale-8   978ns ±15%  1184ns ±46%   ~     (p=0.413 n=4+5)
```

A follow-up change to remove the built-in shaders is needed.

Closes #2364
2022-10-02 15:35:40 +09:00
Hajime Hoshi
520c47f0e8 Revert "ebiten: use Kage shaders instead of built-in shaders for a color matrix"
This reverts commit 7fc79c50c3.

Reason: a color scale might be used with ColorM (DrawTriangles)

Updates #2364
2022-10-02 00:19:37 +09:00
Hajime Hoshi
7fc79c50c3 ebiten: use Kage shaders instead of built-in shaders for a color matrix
Closes #2364
2022-10-02 00:08:14 +09:00
Hajime Hoshi
284c9fcc7f update URLs in comments 2022-09-23 19:09:25 +09:00
Hajime Hoshi
3b50e57f19 internal/ui: move convertUniforms to ui.Shader
This is a preparation to use a Kage program as the screen filter.

Update #2046
2022-08-26 17:41:26 +09:00
Hajime Hoshi
16ff5c5039 internal/shaderir: change the naming convention: Num -> Count 2022-07-13 02:02:48 +09:00
Hajime Hoshi
6710808cd1 ebiten: compile shaders at NewShader
Closes #2035
2022-04-04 02:52:57 +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
b5bb576a58 internal/ui: refactoring: unexport ConvertUniforms 2022-03-21 17:05:50 +09:00
Hajime Hoshi
1d9982ee6d internal/ui: move the dependency on graphicscommand from ebiten to ui 2022-03-20 02:00:44 +09:00
Hajime Hoshi
e78f34aa26 internal/ui: add Image
This is a preparation for a refactoring. Image will be a proxy to
pass a graphics driver to the lower layer.
2022-03-20 01:39:05 +09:00
Hajime Hoshi
7d0f95e9be internal/graphicsdriver: refactoring: replace Uniform with []float32
Closes #2016
2022-03-13 03:42:13 +09:00
Hajime Hoshi
99f8e335ee ebiten: refactoring 2022-02-27 22:21:57 +09:00
Hajime Hoshi
566957dc1c internal/graphicsdriver/metal: invert Y at the vertex shader
Instead of using a negative height in the viewport, invert the Y direction
at the vertex shader. This is a little more readable as a negative height
is hacky.

This is a preparation for DirectX 12. DirectX 12's coodination system
is very similar to Metal, but doesn't treat a negative height in its
viewport unfortunately.

Updates #1007
2022-02-27 01:53:03 +09:00
Hajime Hoshi
df60c4c92d internal/driver: rename to internal/graphicsdriver 2022-02-06 20:41:32 +09:00
Hajime Hoshi
610ebbbab5 ebiten: Bug fix: zeroUniformValue panicked with vec2 or other vector/matrix types 2021-10-30 04:30:29 +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
718273c2d7 ebiten: Add a new shader function imageDstRegionOnTexture
Updates #1428
2020-12-09 11:36:29 +09:00
Hajime Hoshi
bf515bb594 Update version to v2.0.0-alpha 2020-10-04 04:30:40 +09:00
Hajime Hoshi
88c340f32d ebiten: Add comments about shaders 2020-09-23 17:13:18 +09:00
Hajime Hoshi
e406ebb1aa ebiten: Rename imageSrcTextureRegion -> imageSrcRegionOnTexture
Updates #1325
2020-09-19 19:36:53 +09:00
Hajime Hoshi
9f7d6962ff ebiten: Rename shader functions to get colors from textures
Updates #1325
2020-09-19 19:01:05 +09:00
Hajime Hoshi
b52de27d49 ebiten: Refactoring shader.go 2020-09-19 17:35:43 +09:00
Hajime Hoshi
806e30926c ebiten: Remove unreachable code 2020-09-17 20:57:13 +09:00
Hajime Hoshi
abbb929148 ebiten: Bug fix: Wrong uniform type was used
This change also includes PanicOnErrorAtImageAt, which panics when
an error is detected at (*Image).At. This function is only for testing.

Fixes #1349
2020-09-17 20:52:32 +09:00
Hajime Hoshi
5e15ebf580 ebiten: Set zero values for lacking uniform variables
Fixes #1338
2020-09-13 04:29:32 +09:00
Hajime Hoshi
850303b770 ebiten: Change the type of Uniforms to map[string]interface{}
Fixes #1324
2020-09-06 21:02:30 +09:00
Hajime Hoshi
dd7b0d81ae ebiten: Rename shader builtin functions
* imageSrcTextureSourceRegion -> imageSrcTextureRegion
 * image[N]TextureAt -> imageSrc[N]At
 * image[N]TextureBoundsAt -> imageSrc[N]BoundsAt

Updates #1325
2020-09-01 21:31:50 +09:00
Hajime Hoshi
20a01ed328 ebiten: Error when the entrypoint is missing
Fixes #1323
2020-09-01 00:37:16 +09:00
Hajime Hoshi
ed240b8393 ebiten: Add shader builtin functions: imageSrcTextureSourceRegion
Updates #1294
2020-08-12 03:34:46 +09:00
Hajime Hoshi
8bc1c8bbd8 ebiten: Rename shader internal variables 2020-08-11 05:18:14 +09:00
Hajime Hoshi
70acb9c1f6 shader: Rename shader bultin functions
Renamed image0TextureSize to imageSrcTextureSize, and removed the
other texture-size functions.

As texture-coordinates are always in image0's texture texels,
calculations with texels are always done with image0's texture texels.
Then, other texture-size functions are useless. To avoid confusion,
let's remove the functions and leave the necessary funciton.
2020-08-11 05:02:22 +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
Hajime Hoshi
68ca0c634e ebiten: Rename builtin shader functions
* textureDstSize -> imageDstTextureSize
 * texture[N]Size -> image[N]TextureSize
 * texture[N]At -> image[N]TextureAt

Updates #1287
2020-08-11 02:07:53 +09:00
Hajime Hoshi
a4334c5464 shader: Use arrays at uniform variables
Fixes #1274
2020-08-01 17:22:10 +09:00