Commit Graph

357 Commits

Author SHA1 Message Date
Hajime Hoshi
ca73f17dd4 restorable: Bug fix: Fill didn't invalidate its dependencies
Fixes #1170
2020-05-25 23:37:25 +09:00
Hajime Hoshi
8738d182fb restoreble: Add test with shaders rendering an image
Updates #1168
2020-05-25 02:32:23 +09:00
Hajime Hoshi
732f288d20 restorable: Add Shader (WIP) 2020-05-25 00:50:01 +09:00
Hajime Hoshi
a4d419bab1 graphicscommand: Merge DrawTriangles and DrawShader 2020-05-24 02:36:09 +09:00
Hajime Hoshi
7b77164710 restorable: Ignore the error when restoring failed due to being not ready
(driver.Graphics).BeginFrame tries to restore the images, but
the context might be lost at that time yet. If the attempt to
restore the context because the driver is not ready, return
silently.

Fixes #1133
2020-04-12 20:01:18 +09:00
Hajime Hoshi
47d5c3b5e1 Add testing package 2020-04-01 18:10:48 +09:00
Hajime Hoshi
46601bb516 graphics: Fill the screenshot in black when the screen is not transparent
Fixes #997
2020-02-06 03:08:16 +09:00
Hajime Hoshi
b3bdf51905
graphicscommand: Return the error immediately (#1060)
Now grpahicscommand saves the error and shows the error after a
while. This was good to simplify the API but was the cause to hide
some issues.

This change fixes all the errors to be returned immediately, and
buffer this in the ebiten package instead.

Fixes #971
2020-01-19 01:18:56 +09:00
Hajime Hoshi
42056c2d61 restorable: Refactoring: Remove Clear
Fill now fills the whole texture.
2019-12-02 03:03:07 +09:00
Hajime Hoshi
e42cff071c restorable: Merge two 'copy' into one
Fixes #983
2019-11-16 02:10:53 +09:00
Hajime Hoshi
aa6fc67736 Revert "graphics: Avoid all copying pixels"
This reverts commit c60a32a479.

Reason: This breaks backward comptibility and it was not obvious how to fix examples.
2019-11-16 02:04:46 +09:00
Hajime Hoshi
c60a32a479 graphics: Avoid all copying pixels
This is a breaking change: ReplacePixels now takes the ownership
of the given pixels.

Fixes #983
2019-11-16 01:51:36 +09:00
Hajime Hoshi
f1091910bd Revert "graphicscommand: Remove copying pixels"
This reverts commit 339a96b7e6.

Reason: this causes panic on extending textures
2019-11-16 00:43:22 +09:00
Hajime Hoshi
339a96b7e6 graphicscommand: Remove copying pixels
Now ReplacePixels takes the ownership.

Updates #983
2019-11-16 00:29:37 +09:00
Hajime Hoshi
cbe4844fa0 Fix misspellings 2019-10-12 01:10:53 +09:00
Hajime Hoshi
7e7751bd43 restorable: Performance tuning
This is based on the result of examples/set (Wasm).
2019-10-04 02:02:36 +09:00
Hajime Hoshi
86b4e9ffeb restorable: Bug fix: Do not mutate graphics.QuadIndices 2019-09-29 02:57:11 +09:00
Hajime Hoshi
6c8c064a58 restorable: Add TestMutateSlices 2019-09-29 02:36:06 +09:00
Hajime Hoshi
9cb631e30f Reland: graphics: Reuse vertices backend and reduce allocating
This is a reland of 74f1e5519f.

The vertex slice is now copied before saving as the drawing
history items.
2019-09-29 01:36:00 +09:00
Hajime Hoshi
4feb0a4f3e restorable: Bug fix: indices has to be copied 2019-09-29 01:30:26 +09:00
Hajime Hoshi
0a872b342a shareable: Change the argument to color.RGBA at Fill
The argument will be copied explicitly.
2019-09-21 21:16:46 +09:00
Hajime Hoshi
1c2c932c6c graphics: Remove MakeVolatile/IsVolatile 2019-09-21 14:53:52 +09:00
Hajime Hoshi
3023cc69c3 restorable: Remove (*Image).Size() 2019-09-21 05:40:05 +09:00
Hajime Hoshi
d491cab465 restorable: Remvoe unused arguments 2019-09-21 03:44:45 +09:00
Hajime Hoshi
70a38dc09a graphicscommand: Move pixel->texel conversion to graphicscommand 2019-09-20 23:59:04 +09:00
Hajime Hoshi
915ed91f25 restorable: Remove (*Image).PutVertices 2019-09-20 23:44:09 +09:00
Hajime Hoshi
93dc9ad589 restorable: Refactoring: Remove (*Image).internalSize() 2019-09-20 01:55:18 +09:00
Hajime Hoshi
22c31da6c1 restorable: Bug fix: Do not include emptyImage into the dependency graph
Instead, add baseColor to Pixels and use it when restoring.

Fixes #928.
2019-08-27 08:17:14 +09:00
Hajime Hoshi
3960a4bbdf restorable: Add (*Image).Fill
This resets the infomation for restoring if possible. This makes
it more efficient to use offscreens.
2019-08-25 02:57:44 +09:00
Hajime Hoshi
b8eeded538 graphics: Remove 'resetRestoringState'
This is basically a revert of 2d079b123f

As filling can happen on a part of a shared image, resetting the
restoring state was wrong.
2019-08-25 02:18:51 +09:00
Hajime Hoshi
ccacc4a0b8 restorable: Refactoring: Make (*Image).Size() available even after disposing 2019-08-16 02:36:27 +09:00
Hajime Hoshi
6ba6cdc721 restorable: Bug fix: Dispose all the image before start restoring
A current texture ID and a new texture ID can be duplicated.
Disposing part of textures and creating textures at the same time
can make contradicted situation.
2019-08-16 01:00:09 +09:00
Hajime Hoshi
2cb1ea6fb4 restorable: Remove unnecessary call of clearImage
clearImage is already called in any cases.
2019-08-15 22:40:37 +09:00
Hajime Hoshi
0cbf126b80 restorable: Set nil to the image after disposing
This prevents a bug that a disposed image is used by clearImage.
2019-08-15 22:35:28 +09:00
Hajime Hoshi
9467a67136 restorable: Bug fix: Skip clearImage on emptyImage when restoring 2019-08-15 21:53:43 +09:00
Hajime Hoshi
4373bd8b89 restorable: Unify locks with shareable's backendsM and fix the deadlock
This change should make Image operations cuncurrent safe.

Updates #913
Fixes #915
2019-08-13 00:49:47 +09:00
Hajime Hoshi
14ce0c1bcb restorable: Bug fix: Lock before resolving stale states 2019-08-12 23:31:17 +09:00
Hajime Hoshi
9dd501720e restorable: Bug fix: Unlocking should happen after restoring 2019-08-12 23:19:03 +09:00
Hajime Hoshi
cbf36734f8 shareable: Bug fix: mutex should not be used at finalizers
Updates #913
2019-08-12 21:01:33 +09:00
Hajime Hoshi
28dd2f6e19 shareable: Refactoring: only finalizers have to be cared
Only finalizers are problematic since they can stop everything,
but other things are not. Let's care finalizers and just use
regular locks.

Updates #913
2019-08-12 20:17:40 +09:00
Hajime Hoshi
613b9bc02a restorable: Panic if an image is stale when restoring 2019-08-12 17:45:43 +09:00
Hajime Hoshi
1156dfdc7e restorable: Lock At operation between frames
Updates #913
2019-08-12 16:54:17 +09:00
Hajime Hoshi
d2719188b4 restorable: Do not call resolveDeferred at the end of a frame
This does not make sense.
2019-08-12 16:48:04 +09:00
Hajime Hoshi
628a8d559a restorable: Bug fix: Dispose should be deferred between frames (again)
Updates #913
2019-08-12 16:27:07 +09:00
Hajime Hoshi
4717baa840 restorable: Bug fix: Dispose should be deferred between frames
Updates #913
2019-08-12 16:26:07 +09:00
Hajime Hoshi
1a2a0aeb76 restorable: Defer operations between the end and the beginning of frames
Updates #913
2019-08-12 16:08:21 +09:00
Hajime Hoshi
b348223297 restorable: Refactoring
Reduces accesses to Image member from outside.
2019-07-21 16:44:00 +09:00
Hajime Hoshi
434802af6e restorable: Reland: Refactoring
This is reland of 7917b423f4be9494125c8de76a8a3def15561594

Fixed a bug that an image passed to Apply might not be initialized,
and there was no correct way to treat such an image. Now Apply
accepts only an initialized image.
2019-07-21 14:18:27 +09:00
Hajime Hoshi
a3b35e5fba Revert "restorable: Refactoring"
This reverts commit 777cab5cc3.

Reason: Test failures: https://travis-ci.org/hajimehoshi/ebiten/builds/561553656
2019-07-21 14:03:14 +09:00
Hajime Hoshi
777cab5cc3 restorable: Refactoring 2019-07-21 11:05:02 +09:00
Hajime Hoshi
0cf11d9af8 graphicscommand: Improve debug messages
This change also enables to dump volatile images.
2019-07-20 14:31:28 +09:00
Hajime Hoshi
2d079b123f restorable: Add ResetRestoringState to reset the state
After Fill command, the image doesn't have to keep the restoring
information. Now Fill command is as same as DrawTriangles, there
is no way for restorable.Image to know whether it can reset the
state or not. ResetRestoringState clears the state explicitly.
2019-07-20 14:04:02 +09:00
Hajime Hoshi
3f6628f1cc restorable: Replace Fill with Clear 2019-07-20 05:00:05 +09:00
Hajime Hoshi
0bf12d5519 graphics: Unify dumping logic 2019-07-20 01:46:33 +09:00
Hajime Hoshi
94852b07b2 graphics: Use ID for dumped internal images
Updates #900
2019-07-19 23:41:56 +09:00
Hajime Hoshi
38a1ee7f57 restorable: Split pixel records into regions
Fixes #897
2019-07-19 10:59:48 +09:00
Hajime Hoshi
b4dddd330a restorable: Refactoring: Use width/height instead of length at Pixels 2019-07-17 23:20:03 +09:00
Hajime Hoshi
efb6f9c453 graphicscommand: Remove CopyPixels command
This is an optimization. This change enables to avoid reading
pixels from GPU when extending an image.

Updates #897
2019-07-17 23:19:57 +09:00
Hajime Hoshi
736a840d53 restorable: More restricted Extend
As a side effect, ReplacePixels always record pixels even when
restoring is not needed. As CopyPixels reads pixels in any cases,
this shortcut was originally useless.
2019-07-17 22:15:37 +09:00
Hajime Hoshi
353d81fd58 restorable: Rename NewImageFromImage to Extend 2019-07-17 03:32:08 +09:00
Hajime Hoshi
91a4329f0d restorable: Disallow ReplacePixels for a part after Fill
This simplifies Pixels struct. This is a preparation to change
how to record pixels.

Updates #897
2019-07-17 03:15:03 +09:00
Hajime Hoshi
2735f4eddc restorable: Fix comments 2019-07-17 02:42:26 +09:00
Hajime Hoshi
349a290aa3 restorable: Refactoring 2019-07-16 03:08:26 +09:00
Hajime Hoshi
8ae2fef817 restorable: Refactoring: Do not have to update basePixels in some cases
If there is no draw-traiangles command, the image can keep its
basePixels.
2019-07-16 02:48:52 +09:00
Hajime Hoshi
6d20e3f951 restorable: Add assertion at fillImage 2019-07-16 02:18:52 +09:00
Hajime Hoshi
2b632d0707 restorable: Remove Pixels.Slice() 2019-07-16 02:03:15 +09:00
Hajime Hoshi
f3fa535afb restorable: Refactoring: Disallow nil at ReplacePixels 2019-07-16 01:44:56 +09:00
Hajime Hoshi
84aabd075f restorable: Use DrawTriangles to restore the image
This can avoid allocating a big byte slice.
2019-07-15 05:03:46 +09:00
Hajime Hoshi
7e4e9cc893 restorable: Refactoring 2019-07-15 04:17:52 +09:00
Hajime Hoshi
701c4eeb7c restorable: Fix comments 2019-07-15 03:24:18 +09:00
Hajime Hoshi
a7e7e007ca restorable: Bug fix: PutQuadVertices should take the source image
Fixes #898
2019-07-15 03:10:03 +09:00
Hajime Hoshi
aee26eec1e restorable: Refactoring: Replace CopyPixels with NewImageFromImage 2019-07-15 02:04:23 +09:00
Hajime Hoshi
fd9e376ff6 restorable: Add ClearPixels
This hides the implementation details of allocating byte slice.

This change also adds comments about #897.
2019-07-10 02:39:36 +09:00
Hajime Hoshi
f40798b586 graphics: Move const definitions to driver package
Let's keep 'graphics' package as a package for utility functions
or testable functions as much as possible.
2019-06-26 01:05:13 +09:00
Hajime Hoshi
93c31654da graphicscommand: Refactoring 2019-06-25 23:55:33 +09:00
Hajime Hoshi
09d473ea1b restorable: Add comments 2019-06-25 23:42:18 +09:00
Hajime Hoshi
cddb93b9f6 graphicscommand: Move the texel adjustment logic to graphicscommand package
This is a preparation for #879. The value of the texel adjustment
depends on the graphics driver (GLSL float precisions), and this
can be accessed only after the run loop runs. The place where
graphics commands are executed seems an appropriate place.

Updates #879
2019-06-22 03:52:51 +09:00
Hajime Hoshi
f3cdb0537b graphics: Move the vertices backend to ebiten package
Now restorable/sharable packages cannot use the same vertices
backend, but I think this won't affect the performance
significantly.
2019-06-22 00:02:22 +09:00
Hajime Hoshi
69ebc481e8 graphics: Refactoring: Unify PutVertex and PutQuadVertices implementation 2019-06-21 23:49:05 +09:00
Hajime Hoshi
008de78cec graphics: Refactoring: Change QuadVertices -> PutQuadVertices for consistency 2019-06-21 02:20:31 +09:00
Hajime Hoshi
ffb9871839 restorable: Bug fix: Skip the screen image to check invalidation 2019-05-28 11:29:34 +09:00
Hajime Hoshi
24822c0a10 restorable: Rename clear -> clearForInitialization 2019-05-26 23:13:54 +09:00
Hajime Hoshi
b41a333230 restorable: Reland: Refactoring 2019-05-26 22:16:25 +09:00
Hajime Hoshi
83254d30d9 restorable: Bug fix: semantic inconsistency at forceRestoring 2019-05-26 21:40:10 +09:00
Hajime Hoshi
da4fabeaa5 Revert "restorable: Refactoring"
This reverts commit 3c0cd47b1f.

Reason: Crash on macOS
2019-05-26 21:30:08 +09:00
Hajime Hoshi
3c0cd47b1f restorable: Refactoring 2019-05-26 21:24:44 +09:00
Hajime Hoshi
fcb5554aa1 driver: Add Graphics.NeedsRestoring 2019-05-26 19:46:12 +09:00
Acid147
21abd85a63 Small cleanup (#877)
* Remove unused variables and constants
* Remove redundant return statement
* Change flock.NewFlock to flock.New
2019-05-26 18:06:43 +09:00
Hajime Hoshi
cce41e8152 graphics: Rename DrawImage -> DrawTriangles for consistency 2019-04-22 23:12:36 +09:00
Hajime Hoshi
ccacf015c2 Revert "restorable: Bug fix: Guard images by mutex"
This reverts commit 7967f68073.

Reason: Wrong fix (syncing should be done at shareable package)
2019-02-19 10:15:23 +09:00
Hajime Hoshi
7967f68073 restorable: Bug fix: Guard images by mutex
The map must be guarded by mutex since this can be accessed by
multiple goroutines, including finalizer goroutine.

Fixes #820
2019-02-19 10:10:46 +09:00
Hajime Hoshi
b1b8d0b4b1 graphics: Move texel-region adjustment from shaders to program
This reduces GPU burden.
2019-02-16 14:50:03 +09:00
Hajime Hoshi
3f28592700 graphics: Refactoring: Remove PutVertex 2019-02-15 00:22:32 +09:00
Hajime Hoshi
7c506bc5bc restorable: Refactoring: Add (*Image).QuadVertices/PutVertex 2019-02-15 00:18:12 +09:00
Hajime Hoshi
fd250c8d8c graphics: Rename NextPowerOf2Int -> InternalImageSize and add image size adjustment
There is a minimum internal image size on some system like old iOS
devices. This change adds adjustment of the size.

Issue: #810
2019-02-14 23:06:01 +09:00
Hajime Hoshi
a2fe3d5962 restorable: Refactoring: Use InternalSize instead of NextPowerOf2Int 2019-02-14 22:39:19 +09:00
Hajime Hoshi
4e8c7f0a75 restorable: Rename SizePowerOf2 -> InternalSize 2019-02-14 20:56:38 +09:00
Hajime Hoshi
0546783ad5 restorable: Don't call (*graphicscommand.Image).Pixels twice (2) 2019-02-14 01:00:27 +09:00
Hajime Hoshi
3faa674e32 restorable: Don't call (*graphicscommand.Image).Pixels twice 2019-02-14 00:54:02 +09:00
Hajime Hoshi
27dbf1bbb7 restorable: Record more drawing image history items
Fixes #813
2019-02-13 10:45:08 +09:00