Commit Graph

357 Commits

Author SHA1 Message Date
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
Hajime Hoshi
7329880f40 restorable: Make the image stale when volatile state changes 2020-08-19 21:13:05 +09:00
Hajime Hoshi
8aef1f9080 restorable: Enable to set the 'volatile' state later
Updates #1309
2020-08-19 00:57:23 +09:00
Hajime Hoshi
64a6b39240 Revert "restorable: Do not record pixels if restoring is not requried"
This reverts commit 5e1f263d6d.

Reason: Issue #1304
2020-08-17 00:00:12 +09:00
Hajime Hoshi
5e1f263d6d restorable: Do not record pixels if restoring is not requried
Fixes #1022
2020-08-16 20:07:17 +09:00
Hajime Hoshi
71e65fa1b7 cmd/ebitenmobile: Use an explict way to detect context lost on Android
Fixes #1176
2020-08-15 01:39:08 +09:00
Hajime Hoshi
a45e241da1 shaderir/metal: Implement the shader IR compiler for Metal
Fixes #1165
2020-08-08 19:14:57 +09:00
Hajime Hoshi
5506491c03 graphicsdriver/opengl: Bug fix: Binding the same texture multiple times did not work
Updates #1193
2020-07-19 04:34:53 +09:00
Hajime Hoshi
36e9803cea shader: Enable to get pixels from multiple images
Updates #1193
2020-07-19 02:33:43 +09:00
Hajime Hoshi
5dd073fcbb restorable, graphicscommand: Remove uniform variables 2020-07-19 01:55:01 +09:00
Hajime Hoshi
e0d5763a60 shader: Use the fixed number of images for shaders
This changes uses arrays rather than slices in order to avoid heap
allocations.

Updates #1193
2020-07-18 18:27:47 +09:00
Hajime Hoshi
7f70797a6d ebiten: Rename DrawTriaglesWithShaderOptions.Textures to Images 2020-07-15 03:49:05 +09:00
Hajime Hoshi
d217bc6033 ebiten: Sparate textures from uniforms at DrawTrianglesWithShader
Updates #1193
Updates #1239
2020-07-09 01:59:21 +09:00
Hajime Hoshi
b83f0acc4d Remove source-region information from vertices
Fixes #1210
2020-07-02 23:38:39 +09:00
Hajime Hoshi
71c9e7ac40 driver: Add Region and sourceRegion parameter at Draw
This is a preparation to remove source-region information from
vertices.

Updates #1210
2020-07-02 03:26:05 +09:00
Hajime Hoshi
4c640d2500 buffered, restorable: Remove copying pixels
Instead, the callers (ebiten.NewImageFromImage and
(*ebiten.Image).ReplacePixels) have responsibility to copy the
pixels now. This change should reduce unnecessary copying pixels.

Updates #1222
2020-07-01 02:56:40 +09:00
Hajime Hoshi
1fe2f47701 graphicscommand: Remove the source-region parts from the uniform variables 2020-06-30 00:44:05 +09:00
Hajime Hoshi
dea3785750 shareable, restorable, graphicscommand: Remove making arrays at DrawTriangles
Updates #1220
2020-06-29 13:37:37 +09:00
Hajime Hoshi
a1abe6b728 restorable: Add padding when renderingn the empty image 2020-06-26 14:01:49 +09:00
Hajime Hoshi
2a63512c6e driver: Add AddressUnsafe
This skips the source-region check and reduces 'if' branches from
shader programs.

AddressUnsafe is internal only so far. We might expose this value
later.

Updates #1210
2020-06-25 01:00:38 +09:00
Hajime Hoshi
ba36d5a8e9 shader: Reland: Add a predefined uniform variable: __viewportSize 2020-06-07 00:14:09 +09:00
Hajime Hoshi
2f843c49a6 shader: Fix the case when the source image is nil for shaders 2020-06-04 01:35:35 +09:00
Hajime Hoshi
2bdef2e8c4 restorable: Add an explicit way to detect context-lost
isTexture was used to detect context-lost and called every frame.
This was not good for performance.

This change adds a way to notify context-lost from the WebGL
handlers directly, and the package restorable uses it instead of
calling (*Image).isInvalaidated.

Fixes #1175
2020-05-30 20:29:15 +09:00
Hajime Hoshi
117fd61d27 restorable: Do not dispose objects when restoring on browsers
This fix suppresses warnings on the Chrome console.
2020-05-30 19:24:03 +09:00
Hajime Hoshi
c0cd7ec59c restorable: Update comments 2020-05-30 16:06:22 +09:00
Hajime Hoshi
833a364ba8 testing: Bug fix: Image's size should not be in uniform variables 2020-05-30 05:16:50 +09:00
Hajime Hoshi
1c980a16f5 graphicsdriver/opengl: Ignore non-existent uniform locations
Shader users should not have to care about the existence of uniform
variables.

Updates #1168
2020-05-27 11:39:11 +09:00
Hajime Hoshi
f80719ef9a driver: Use slices for uniform variables instead of maps
Fixes #1172
2020-05-26 23:50:11 +09:00
Hajime Hoshi
f14f3b6456 restorable: Fix comments 2020-05-26 00:28:00 +09:00
Hajime Hoshi
7b9cc8deb4 restorable: Add tests to dispose shaders
When a shader is disposed, all the images depending on it should
become stale, i.e., discard its all the rendering history items,
because they cannot be restored due to the lack of data on the GPU.
2020-05-26 00:20:11 +09:00
Hajime Hoshi
8e6f19b37a restorable: Add a test using shaders with multiple sources 2020-05-25 23:57:55 +09:00