Commit Graph

2182 Commits

Author SHA1 Message Date
Hajime Hoshi
af5249de4d shaderir: Implement selector operator 2020-05-16 17:22:17 +09:00
Hajime Hoshi
d4d43ce193 shaderir: Allow specifying op for 'for' loop 2020-05-16 15:51:54 +09:00
Hajime Hoshi
9f4985943c shaderir: Allow integer literals 2020-05-16 03:40:33 +09:00
Hajime Hoshi
3cffe88334 shaderir: Add for-loop 2020-05-16 03:10:03 +09:00
Hajime Hoshi
931fec9100 shaderir: Refactoring 2020-05-15 03:37:14 +09:00
Hajime Hoshi
4b8e745824 shaderir: Refactoring 2020-05-15 03:12:23 +09:00
Hajime Hoshi
e6d78abd11 shaderir: Implement 'if' 2020-05-15 02:35:58 +09:00
Hajime Hoshi
71ee622997 shaderir: Use auto names for variables 2020-05-15 01:29:39 +09:00
Hajime Hoshi
1ed004ae05 shaderir: Avoid duplications of local variable names 2020-05-14 03:52:36 +09:00
Hajime Hoshi
32a88b3b03 shaderir: Add Return 2020-05-14 03:14:56 +09:00
Hajime Hoshi
d932787e36 shaderir: Add parsing expr and stmt 2020-05-14 02:13:10 +09:00
Hajime Hoshi
c75a35fd64 shaderir: Add more tests 2020-05-14 01:07:53 +09:00
Hajime Hoshi
3d7c102472 shaderir: Add func params 2020-05-13 23:31:17 +09:00
Hajime Hoshi
a3105d6fca shaderir: Add more tests 2020-05-13 02:10:59 +09:00
Hajime Hoshi
a5d570a7a8 Add shaderir 2020-05-12 01:18:18 +09:00
Hajime Hoshi
6d182c4b55 shader: Parse structs 2020-05-11 00:43:17 +09:00
Hajime Hoshi
90fdececa0 shader: Refactoring 2020-05-11 00:00:21 +09:00
Hajime Hoshi
ba9d27b8ba shader: Rename type -> basicType 2020-05-10 23:28:05 +09:00
Hajime Hoshi
02eafb2929 shader: Forbid unexported global variables 2020-05-10 21:57:12 +09:00
Hajime Hoshi
a39376ad47 shader: Add stmtBlock 2020-05-10 21:45:12 +09:00
Hajime Hoshi
73255f4663 shader: Add more tests 2020-05-10 20:41:43 +09:00
Hajime Hoshi
8ede0b3891 shader: Bug fix: fix tests 2020-05-10 19:48:24 +09:00
Hajime Hoshi
b78194afd5 shader: Detect types from rhs 2020-05-10 19:37:09 +09:00
Hajime Hoshi
9430b6be37 shader: Parse assignments 2020-05-10 02:27:14 +09:00
Hajime Hoshi
1a7da0bc63 shader: Do not sort variables since the order matters 2020-05-10 01:21:34 +09:00
Hajime Hoshi
eaf93a532f shader: Unify parsing decls 2020-05-10 01:05:57 +09:00
Hajime Hoshi
4742c49c21 shader: Separate variable and constant 2020-05-10 00:39:26 +09:00
Hajime Hoshi
8b2a22fb47 shader: Parse return 2020-05-10 00:23:40 +09:00
Hajime Hoshi
5e6be91eac shader: Parse block variables 2020-05-09 23:45:53 +09:00
Hajime Hoshi
e848eacedf shader: Parse arguments and returns 2020-05-09 19:21:01 +09:00
Hajime Hoshi
7ba434ad6d shader: Start parsing functions 2020-05-09 18:05:55 +09:00
Hajime Hoshi
1b2c29f6f3 shader: Refactoring 2020-05-09 17:32:10 +09:00
Hajime Hoshi
195c51fe51 shader: Rename test name 2020-05-09 17:19:05 +09:00
Hajime Hoshi
00b32a663e shader: Add token positions to the error message 2020-05-09 16:47:07 +09:00
Hajime Hoshi
c8045210ac shader: Fix comments 2020-05-09 05:13:43 +09:00
Hajime Hoshi
fc0604805a shader: Parse constants 2020-05-09 04:21:45 +09:00
Hajime Hoshi
ffae970c26 shader: Parse uniform and global variables 2020-05-09 03:38:37 +09:00
Hajime Hoshi
b3df3a7864 Add shader package
Updates #482
2020-05-09 01:11:40 +09:00
Hajime Hoshi
4fa52dcc56 Remove MonoGame support
Fixes #1148
2020-05-08 19:32:28 +09:00
Hajime Hoshi
274245e39c graphicsdriver/metal: Refactoring: Invert the viewport's Y direction 2020-05-08 18:12:30 +09:00
Hajime Hoshi
8029dc352a driver: Use framebuffer's Y directions 2020-05-08 16:49:19 +09:00
Hajime Hoshi
c43ba6e17d graphicsdriver/metal: Update comments 2020-05-08 05:49:38 +09:00
Hajime Hoshi
7068eb9284 graphicsdriver/metal: Simplify the projection matrix 2020-05-08 05:06:09 +09:00
Hajime Hoshi
cfe1aa1191 monogame: Add a variable for a namespace that will be overwritten 2020-04-24 16:46:56 +09:00
Hajime Hoshi
9b8c547342 graphicscommand: Do not flush (glFlush) when commands are empty
Fixes #1140
2020-04-23 00:51:28 +09:00
Hajime Hoshi
7ad3343e9c graphicsdriver/monogame: Implement Pixels
Updates #1078
2020-04-22 02:23:16 +09:00
Hajime Hoshi
33e850a6d4 driver: Bug fix: (Key).String might cause infinite loop 2020-04-22 00:32:35 +09:00
Hajime Hoshi
0e75540f8e monogame: Add IsKeyPressed
Updates #1078
2020-04-21 22:48:57 +09:00
Hajime Hoshi
ea99743e0d driver: Add (Key).String() 2020-04-21 22:43:53 +09:00
Hajime Hoshi
691e42f806 graphicsdriver/monogame: Bug fix: An underlying image size should be adjusted 2020-04-21 02:43:47 +09:00
Hajime Hoshi
bbf9b219ec buffered: Skip mutex at ReplacePixels when possible
Updates #1137
2020-04-19 00:18:19 +09:00
Hajime Hoshi
3550abef7a shareable: Replace At with Pixels
This change replaces the API At with Pixels to reduce mutex locks.

Updates #1137
2020-04-18 21:05:51 +09:00
Hajime Hoshi
bbeb0d14e6 buffered: Defer filling an image
This change defers filling an image so that successive fillings
can be merged into one for more efficient rendering.

Fixes #1134
2020-04-18 02:11:25 +09:00
Hajime Hoshi
514c3faebd buffered: Remove unnecessary line and add comments 2020-04-17 21:50:42 +09:00
Hajime Hoshi
b9e0b5f04b graphicsdriver/monogame: Change the V direction 2020-04-17 21:36:59 +09:00
Hajime Hoshi
1d701577d6 buffered: Use the pending pixels when possible at At
(*Image).At can be unnecessarily slow since this tries to get
pixels from GPU. This change reduces the chance to read GPU by
using its pending pixels when possible.

Fixes #1137
2020-04-17 21:34:49 +09:00
Hajime Hoshi
4dad044ad1 monogame: Update
Updates #1078
2020-04-16 01:10:16 +09:00
Hajime Hoshi
de02bcf19f monogame: Update
Updates #1078
2020-04-14 03:23:54 +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
d0115f61ae graphicsdriver/monogame: Bug fix: Wrong viewport values 2020-04-11 18:56:50 +09:00
Hajime Hoshi
3437f35444 graphicscommand: Fix debug messages 2020-04-08 13:48:22 +09:00
Hajime Hoshi
f0c2c0e8e9 monogame: Set viewports
Updates #1078
2020-04-06 02:36:15 +09:00
Hajime Hoshi
7f64043ba5 monogame: Implement drawing screens
Updates #1078
2020-04-06 01:51:06 +09:00
Hajime Hoshi
7dd9150b86 monogame: Implement Draw temporarily
Updates #1078
2020-04-06 00:13:08 +09:00
Hajime Hoshi
44088cf14e monogame: Implement SetVertices
Updates #1078
2020-04-05 23:26:45 +09:00
Hajime Hoshi
08ac91fb50 monogame: Refactoring 2020-04-05 20:00:53 +09:00
Hajime Hoshi
3a5f0a7a95 graphicsdriver/monogame: Implement some functions
Updates #1078
2020-04-05 17:36:26 +09:00
Hajime Hoshi
fa90e48eec graphicscommand: Show the number of indices when dumping the command 2020-04-05 14:38:54 +09:00
Hajime Hoshi
57a5783ca0 graphicsdriver/monogame: Implement ReplacePixels
Updates #1078
2020-04-05 04:44:48 +09:00
Hajime Hoshi
8809076682 graphicsdriver/monogame: Create a RenderTarget2D for an image
Updates #1078
2020-04-04 22:59:55 +09:00
Hajime Hoshi
6236ba1f00 Add internal/monogame
Updates #1078
2020-04-04 22:59:13 +09:00
Hajime Hoshi
eabe4152a7 graphicsdriver/opengl: Rename Driver -> Graphics 2020-04-04 17:23:38 +09:00
Hajime Hoshi
01d1afa25c graphicsdriver/metal: Rename Driver -> Graphics 2020-04-04 17:12:24 +09:00
Hajime Hoshi
6cbf37e855 Add graphicsdriver/monogame 2020-04-04 17:03:45 +09:00
Hajime Hoshi
8777140e91 driver: Simplify UIContext.Update 2020-04-03 00:18:27 +09:00
Hajime Hoshi
9b0d95cfcf clock: Integrate now.go and now_js.go
The monotonic timer already uses performance.now, then we don't
have to have the original code.
2020-04-02 01:52:00 +09:00
Hajime Hoshi
4179e6c122 Introduce 'monogame' build tag experimentally
Updates #1078
2020-04-01 23:42:17 +09:00
Hajime Hoshi
5ad9868d85 driver: Refactoring: Reorder functions 2020-04-01 21:28:00 +09:00
Hajime Hoshi
ab94cebd02 buffered: Use RunGame for tests 2020-04-01 18:32:14 +09:00
Hajime Hoshi
16280e9a5a testing: Use RunGame 2020-04-01 18:21:35 +09:00
Hajime Hoshi
47d5c3b5e1 Add testing package 2020-04-01 18:10:48 +09:00
Hajime Hoshi
a718ddbf7e driver: Add UIDriver.Draw
This is a preparation for XNA.

Updates #1078
2020-04-01 02:55:50 +09:00
Hajime Hoshi
ef5e917feb shareable: Remove old comments
This was introduced at cbf36734f8,
but the situation was changed at 9d867850dc
2020-04-01 00:58:33 +09:00
Hajime Hoshi
7ac6b0bfa3 Update dependencies 2020-03-31 03:32:38 +09:00
Hajime Hoshi
9a14d2fb14 thread: Fix comments
Fixes #1121
2020-03-29 16:27:12 +09:00
Hajime Hoshi
41d07706ae Revert "thread: Close channels"
This reverts commit 00e78c1eae.

Reason: (*Thread).Loop can be called multiple times on iOS.

Fixes #1121
2020-03-29 16:25:42 +09:00
Hajime Hoshi
b09fe7157b uidriver/glfw: Update comments 2020-03-29 01:33:23 +09:00
Hajime Hoshi
e3def4ae50 uidriver/glfw: Update comments 2020-03-29 01:12:53 +09:00
Hajime Hoshi
9d5c35f029 uidriver/glfw: Bug fix: Initilizing the window position and the size in this order on Windows
It looks like the order is different on Windows from Linux. We
are not sure why.

Updates #1118
2020-03-29 00:50:19 +09:00
Hajime Hoshi
b7ab3d2df4 uidriver/glfw: Avoid using the window position before initializing
Especially in the initial phase before calling Run/RunGame, the
window position is not reliable and then getting the device scale
factor does not make sense based on the window position. Avoid
using the window position, and instead use the glfw.Monitor in
this situation.
2020-03-29 00:09:08 +09:00
Hajime Hoshi
14200eb42c uidriver/glfw: Add comments 2020-03-29 00:02:33 +09:00
Hajime Hoshi
8480f888dd Revert "uidriver/glfw: Bug fix: Do not use the window position for monitors"
Revert "uidriver/glfw: Bug fix: compile error on Linux"

This reverts commit 0a5126f776.
This reverts commit 3e244d7a7c.

Reason: GetMonitor is available only on fullscreen mode
2020-03-28 23:56:03 +09:00
Hajime Hoshi
e628350d4e uidriver/glfw: Bug fix: Initializing order mattered
Especially on Linux, the window size and the window position must
be initialized in this order.

Fixes #1118
2020-03-28 23:37:21 +09:00
Hajime Hoshi
34acf788d2 uidriver/glfw: Bug fix: Call Maximize explictly instead of the hint
Fixes #1117
2020-03-28 22:34:01 +09:00
Hajime Hoshi
4fe5acd711 ui: Panic on MaximizeWindow when the window is not resizable
On Windows, the window could be maximized even when the window was
not resizable. This behavior is confusing. Forbid it so that the
behavior will be clearer.
2020-03-28 22:08:48 +09:00
Hajime Hoshi
3e244d7a7c uidriver/glfw: Bug fix: compile error on Linux 2020-03-28 21:29:24 +09:00
Hajime Hoshi
8cca713d74 uidriver/glfw: Bug fix: adjustWindowPosition should consider the monitor position 2020-03-28 21:26:57 +09:00
Hajime Hoshi
0a5126f776 uidriver/glfw: Bug fix: Do not use the window position for monitors
Especially in the initial phase before calling Run/RunGame, the
window position is not reliable and then getting the device scale
factor does not make sense based on the window position. Avoid
using the window position, and instead use the glfw.Monitor.
2020-03-28 21:13:30 +09:00
Hajime Hoshi
7b5fb0a0d0 ui: Bug fix: The window was not shown on the secondary monitor on launching
This change changes the behavior of WindowPosition /
SetWindowPosition. The window position is now a relative position
and the origin position is the left-upper of the current monitor.

Fixes #1115
2020-03-28 19:51:47 +09:00
Hajime Hoshi
5e4e76d75c devicescale: Fix comments 2020-03-28 16:31:38 +09:00
Hajime Hoshi
d16477617e devicescale: Bug fix: Wrong calculation to convert Y
Updates #807
Fixes #1113
2020-03-28 16:27:58 +09:00
Hajime Hoshi
4ec49dd4cf mobile/ebitenmobileview: Implement Android gamepad axes
Updates #1083
2020-03-25 01:15:43 +09:00
Hajime Hoshi
8fcee54849 mobile/ebitenmobileview: Implement Android gamepad buttons
This is still work in progress.

Updates #1083
2020-03-23 01:30:17 +09:00
Hajime Hoshi
63caca720b ui: Bug fix: Compile error on Windows 2020-03-21 22:16:23 +09:00
Hajime Hoshi
f317f3b5fd ui: Add fuctions to maximize or minimize the window
This change adds these functions:

  * MaximizeWindow
  * IsWindowMaximized
  * MinimizeWIndow
  * IsWindowMinimized
  * RestoreWindow

Fixes #994
2020-03-21 22:13:58 +09:00
Hajime Hoshi
978ee26898 ui: Add function aliases *OnUnfocused for *InBackground
Now a window can be floating with SetWindowFloating, the functions
that have suffix 'IsBackground' seems misleading. However, we
cannot rename them due to backward compatibility. Then, let's add
aliases and revisit them when updating the major version of Ebiten.

Fixes #1102
2020-03-21 00:42:00 +09:00
Hajime Hoshi
56358fd0c4 ui: Rename IsForeground -> IsFocused
Updates #1102
2020-03-21 00:12:47 +09:00
Hajime Hoshi
4ef3b3e804 ui: Add SetWindowFloating / IsWindowFloating
Fixes #880
2020-03-20 22:16:27 +09:00
Hajime Hoshi
c36d4678a3 mipmap: Bug fix: DrawTriangles with a scale-only color matrix should be optimized
Fixes #1101
2020-03-17 02:48:29 +09:00
Hajime Hoshi
6bc62b8f17 uidriver/glfw: Update comments 2020-03-15 15:42:05 +09:00
Hajime Hoshi
b4a9538e1d graphicsdriver/opengl/gl: Remove a misspelled unused const 2020-02-26 12:06:47 +09:00
Hajime Hoshi
5040b3bcfc thread: Add comments 2020-02-24 01:54:52 +09:00
Hajime Hoshi
00e78c1eae thread: Close channels 2020-02-24 01:50:23 +09:00
Hajime Hoshi
c166fe8eea Update GLFW to v3.3.2
Fixes #1086
2020-02-23 03:10:38 +09:00
Hajime Hoshi
3af869732c uidriver/mobile: Implement InputChars for gomobile-build
This change also fixes InputChars to return only printable Unicode
chars on Android.

Updates #237
2020-02-23 01:01:40 +09:00
Hajime Hoshi
de52eb75e4 mobile/ebitenmobileview: Implement InputChars on Android / ebitenmobile
Updates #237
2020-02-23 00:51:49 +09:00
Hajime Hoshi
a208a026f6 uidriver/mobile: Implement keyboard key inputs for gomobile-build
Updates #237
2020-02-22 23:57:16 +09:00
corfe83
b3c567de89
Fix another ~300 allocations per frame in my test project (#1089)
This simple change brings my simple test project from 752 allocations per frame to 474 allocations per frame. It seems a shame that go's escape analysis is not smart enough to leave this variable on the stack.

GeoM is a 24-byte struct and there is a slight perf difference that we are storing it in stack, but also copying it around with this change (instead of an 8-byte pointer). This could make things faster (due to stack / CPU cache) or slower (due to copying more memory) - when I try a stress test (drawing 100K images per frame), I can't see any actual performance difference (but I do see 100K fewer allocations, and GC is no longer running almost all the time).
2020-02-22 13:40:17 +09:00
corfe83
a18cddb39f
Reduce heap allocations in thread.go and input.go (#1085)
I've been doing some profiling of a very simple ebiten project, and noticed that thread.go was doing a bunch of unnecessary allocations to accomplish its work. This change seeks to reduce GC work.

Input.go was also doing some unnecessary allocations.

The thread.go change reduces the total number of allocations per frame from 1342 to 852 (~36% reduction). The input.go change reduces it further to 752 (~44% total reduction). Perf tests were done on windows.
2020-02-21 09:59:45 +09:00
Hajime Hoshi
5b7151595b mobile/ebitenmobileview: Handle keyboard keys on Android (ebitenmobile)
Updates #237
2020-02-20 01:53:51 +09:00
Hajime Hoshi
682f454fc2 input: Refactoring: Rename variables 2020-02-19 10:52:58 +09:00
Hajime Hoshi
875a529708 graphics: Allow ReplacePixels on a sub-image
Fixes #980
2020-02-16 22:18:07 +09:00
Hajime Hoshi
d9bd7ab07d buffered: Remove (*Image).Set
This is a preparation for ReplacePixels of a sub-image.

Updates #980
2020-02-16 21:45:28 +09:00
Hajime Hoshi
733c1b649a buffered: Bug fix: Copying pixels failed for the delayed commands
Fixes #1082
2020-02-16 20:16:04 +09:00
Hajime Hoshi
911b36ed98 buffered: Refactoring 2020-02-16 20:03:04 +09:00
Hajime Hoshi
405ae99b32 buffered: Refactoring: Flush delayed functions without the lock 2020-02-16 19:53:17 +09:00
Hajime Hoshi
ff8689cfcd buffered: Bug fix: Set and some functions before the main loop caused wrong results
invalidatePendingPixels was not called properly.

Fixes #1081
2020-02-16 19:06:48 +09:00
corfe83
61c2d7cfe8
Simple optimization in IsKeyPressed (#1080)
Simple optimization on IsKeyPressed to avoid iterating through whole map of possible keys.
2020-02-16 02:02:05 +09:00
Hajime Hoshi
883b25f257 uidriver/mobile: Refactoring 2020-02-12 00:36:34 +09:00
Hajime Hoshi
d59aea1db1 driver: Remove the return value from RunWithoutMainLoop 2020-02-11 23:56:53 +09:00
Hajime Hoshi
aef4b4ba53 uidriver/mobile: Refactoring: Give a default outside size 2020-02-11 23:29:52 +09:00
Hajime Hoshi
9298b044e3 graphicsdriver/metal: Bug fix: avoid using mtl.LoadActionDontCare
Fixes #1019
2020-02-11 20:29:03 +09:00
Hajime Hoshi
c927d33457 mobile/ebitenmobileview: Use the common uiContext for layouting
This means that the whole offscreen is cleared correctly.

This change is a little breaking change: SetScreenSize or other
functions no longer works on ebitenmobile. Use Layout instead.

Fixes #1019
2020-02-11 19:40:47 +09:00
Hajime Hoshi
a303487328 uidriver/mobile: Add comments 2020-02-11 14:45:50 +09:00
Hajime Hoshi
099ce1b3b4 Revert "ui: Add SetInitFocused"
This reverts commit bb04fc8a29.

Reason: glfw.Focused / glfw.FocusOnShow did not work

Updates #769
2020-02-10 01:10:40 +09:00
Hajime Hoshi
bb04fc8a29 ui: Add SetInitFocused
Updates #769
2020-02-09 23:45:59 +09:00
Hajime Hoshi
6250dd9f9b buffered: Bug fix: ebiten.Run must be called from the main thread
Updates #1027
2020-02-09 04:53:26 +09:00
Hajime Hoshi
32471af18f uidriver/js: Ensure that the checking-audio loop is finished when the game is finished
After the game loop is finished, any goroutines should not exist.
Otherwise, 'Go program has already exited' error can happen on
Wasm.

This change ensures that the goroutines are finished when the game
is finished. Note that time.Sleep was required to ensure that the
(*time.Ticker) ends.

Fixes #1027
2020-02-09 03:39:08 +09:00
Hajime Hoshi
4159c500bd buffered: Refactoring: Use defer
defer's performance will be much better as of Go 1.14.

https://tip.golang.org/doc/go1.14#runtime
2020-02-08 20:58:28 +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
d6d17a7e85 uidriver/js: Implement GamepadSDLID
Fixes #1053
2020-02-05 00:00:00 +09:00
Hajime Hoshi
802693fa20 uidriver/mobile: Implement IsForeground
This adds hooks on resuming/suspending the application, and
switches the foreground state there. This change also updates
the logic to suspend the game loop to be clearer.

Fixes #1037
2020-01-23 02:08:31 +09:00
Hajime Hoshi
38f49c3768 uidriver/js: Implement IsForeground
Updates #1037
2020-01-21 23:56:57 +09:00
Hajime Hoshi
59431e1cad graphicsdriver/opengl: Leave comments why we don't use PBO on Android
Unfotunately, PBO might slow Android applications expecially when
coming back from context lost. Ebiten sends a lot of draw calls to
replace pixels in such case.

Until we find a good solution, let's not use PBO on Android.

Fixes #988
2020-01-19 17:02:34 +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
5c285de3db uidriver/mobile: Prevent non-mobile environments from compiling 2020-01-18 21:15:56 +09:00
Hajime Hoshi
2b9cd5aed6 uidriver/mobile: Bug fix: Compile error
TravisCI doesn't compile for mobiles, so we missed this error.

Updates #1037
2020-01-18 17:39:36 +09:00
Zachary Burkett
6686044452 ui: Add IsForeground API to glfw driver (#1058)
Updates #1037
2020-01-16 10:47:23 +09:00
Hajime Hoshi
6eb05a0203 graphicsdriver/opengl: Enable to compile with gldebug 2020-01-13 18:55:30 +09:00
Hajime Hoshi
e797aed6c9 uidriver/glfw: Refactoring 2020-01-13 18:23:18 +09:00