Commit Graph

387 Commits

Author SHA1 Message Date
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
34e23f5256 internal/restorable: treat texels instead of pixels
Updates #1820
2022-04-02 04:25:27 +09:00
Hajime Hoshi
151dfffad6 internal/restorable: simplify canDetectContextLostExplicitly
This constant was set with some wrong assumptions:

 1. On Android, recovering was needed.
 2. On iOS, OpenGL ES was used when
    a. The architecture was 386 or amd64 == an emulator is used
    b. The build tag ebitengl was not specified
    c. gomobile-build was used
 3. On browsers, recovering was needed.

1., 2b, and 2c are correct.

2a. is not correct: Now emulators are available on all the
architectures with both Metal and OpenGL.

3. is not correct: Ebiten no longer recovers the contest lost.

Now, Ebiten can detect a context lost explicitly when

 1. On Android
 2. On iOS and on gomobile-build
    (When gomobile-build is used, OpenGL should always be used)

Based on this fact, this change changes the constant to a variable,
and fixes the logic to set the variable.
2022-03-23 03:01:59 +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
dfc9eeaaec internal/restorable: bug fix: the parameter mask was not passed correctly 2022-03-21 05:40:13 +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
e55dbbf3cd internal/restorable: add more tests 2022-03-21 03:04:52 +09:00
Hajime Hoshi
72a6ab8da4 internal/restorable: add more tests 2022-03-21 02:44:48 +09:00
Hajime Hoshi
924f7ea932 internal/restorable: refactoring 2022-03-21 01:26:48 +09:00
Hajime Hoshi
5fe6791b5d internal/graphicscommand: add a new paramter 'mask' to ReplacePixels 2022-03-21 01:11:01 +09:00
Hajime Hoshi
c1a0d83f8d internal/restorable: simplify the implementation of rect
Allow overlapped regions at pixelsRecords.

This removes the members `last*` for caching. These were introduced
at 7e7751bd43, and apparently these
are no longer needed.
2022-03-21 00:06:30 +09:00
Hajime Hoshi
54b4e87506 internal/restorable: bug fix: ReplacePixels on a sub-image might panic on Android
If regions by ReplacePixel are overlapped, this can panics. This can
happen only on Android, where a context lost can happen.

Thus, a sub-image cannot call a direct ReplacePixels. internal/buffer
has to care this.
2022-03-20 18:01:37 +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
Hajime Hoshi
77f765d483 internal/testing: bug fix: considering the case when Y is inverted
Closes #2003
2022-02-27 22:14:32 +09:00
Hajime Hoshi
b22309a0e5 internal/graphicsdriver: replace Pixels with ReadPixels
Now preparing a byte slice is the caller's responsibility.
2022-02-27 20:03:13 +09:00
Hajime Hoshi
df60c4c92d internal/driver: rename to internal/graphicsdriver 2022-02-06 20:41:32 +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
96dc80fd08 internal/restorable: Remove needsDisposingWhenRestoring
Now restoring from context lost doesn't work on browsers. Then,
the constant needsDisposingWhenRestoring is actually always true.
2021-10-23 23:46:29 +09:00
Hajime Hoshi
dddfe73604 internal/uidriver/mobile: Bug fix: iOS with ebitengl build tag didn't work correctly 2021-10-23 23:32:57 +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
dbe101a8ef internal/restorable: Remove draw-triangles-history items explicitly
Updates #1803
2021-09-09 12:57:50 +09:00
Hajime Hoshi
8f857daf3e internal/restorable: Bug fix: Forbid NewImage before the graphics driver is ready 2021-09-09 03:58:58 +09:00
Hajime Hoshi
a3570331dd internal/restorable: Delay initializing emptyImage
Now NeedsRestorable can always return a correct value.
2021-09-09 03:27:22 +09:00
Hajime Hoshi
60b8f82bfd graphicscommand: Dump internal image info on the debug mode
Closes #1714
2021-08-05 01:16:42 +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
6213c17abc internal/driver: Add Graphics.Initialize 2021-07-07 13:58:42 +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
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
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
b54ad73a2b Add go:build comments with go1.17beta1 fmt 2021-06-11 01:11:46 +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
6b3c51921c internal/driver: Remove Image.Sync
Syncing is no longer needed for Metal, and additionally, OpenGL's sync
implementation was mock.

Updates #1508
2021-02-26 23:16:28 +09:00
Hajime Hoshi
9341d21614
internal/shareable: Call DrawTriangles instead of ReplacePixels at makeShared (#1513)
When context losts never happen, reading pixels and call replace-pixels command are not needed.

Closes #1508
2021-02-26 12:56:22 +09:00
Hajime Hoshi
44bb004cb7 internal/restorable: Avoid allocating new slices for drawTrianglesHistory 2021-01-30 19:13:03 +09:00
Hajime Hoshi
de14a44c01 restorable: Replace a potentially dangerous pointer usage
Getting a poniter to a loop variable is potentially dangerous.
2020-12-20 13:28:17 +09:00
Hajime Hoshi
410766c984 restorable: Add more detailed information to the panic message
Updates #1427
2020-12-05 19:56:06 +09:00
Hajime Hoshi
ed494dbf59 restorable: Reland: Do not record pixels if restoring is not requried
This change also remove the restrictions of operations on
graphicscommand.Image. For example, now DrawTriangles and
ReplacePixels can be mixed on the same image.

Fixes #1022
2020-11-14 15:00:16 +09:00
Hajime Hoshi
c7330883ef restorable: Remove Fill and make (*ebiten.Image).Fill available for sub-images
Now a scissor (a clipping region) can be specified, we don't have to
worry about the rendering results out of the specified region.
Replace the implmenetation of the Fill with just a DrawTriangles with
an empty white image.

As a side effect, SubImage is avilable for Fill.

Fixes #1416
2020-11-08 02:50:06 +09:00
Hajime Hoshi
ed028110cf ebiten: Allow rendering on a sub-image by scissor test
Fixes #1255
2020-11-08 00:58:44 +09:00
Hajime Hoshi
a8f96ee9af graphicsdriver/metal: Add Sync to sync CPU and GPU asynchronously
Fixes #1414
2020-11-07 04:09:47 +09:00
Hajime Hoshi
48b46345d7 restorable: Refactoring 2020-11-04 02:03:47 +09:00
Hajime Hoshi
831c7ca6f4 restorable: Refactoring: Use the smaller empty image 2020-10-31 03:06:44 +09:00
Hajime Hoshi
fa53160e18 mipmap: Stop using negative mipmaps
Negative mipmaps tend to allocate extremely big images.

Instead, encourage to use images with explicit padding when enlarging
the image.

Fixes #1400
2020-10-31 02:52:40 +09:00
Hajime Hoshi
b2d618c2be mipmap, shareable: Refactoring: Remove SetGraphicsDriver 2020-10-13 01:36:52 +09:00
Hajime Hoshi
7a0e31a23a Clean up the 'js' build tags
Updates #1129
2020-10-07 01:33:10 +09:00
Hajime Hoshi
bf515bb594 Update version to v2.0.0-alpha 2020-10-04 04:30:40 +09:00
Hajime Hoshi
f3ef2e2af5 Performance optimization for the path without a shader
Fixes #1355
2020-09-21 05:43:24 +09:00