Commit Graph

2285 Commits

Author SHA1 Message Date
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
bfc2fffba6 graphicsdriver/opengl: Move comments 2020-06-24 23:52:39 +09:00
Hajime Hoshi
20b5be0886 graphicsdriver: Bug fix: Tie-breaking when picking a texel
When a texel is picked on texel-borders of a texture, the behavior
(tie-breaking) depends on GPU and unexpected. This change fixes this
issue by shifting 1/512 [texel] when picking a texel up.

Updates #1212
2020-06-24 20:51:16 +09:00
Hajime Hoshi
545342262f examples/shader: Show an image 2020-06-24 01:41:27 +09:00
Hajime Hoshi
f10263fff7 shader: Bug fix: Test failures 2020-06-21 22:32:54 +09:00
Hajime Hoshi
c36d2165e6 shader: Parse number literals in unary expressions correctly
Fixes #1190
2020-06-21 21:47:27 +09:00
Hajime Hoshi
29b70bea95 shader: Parse number literals in binary expressions correctly
Updates #1190
2020-06-21 21:32:40 +09:00
Hajime Hoshi
afc39a100c shader: Reduce the calls of parseExpr so that unneeded variables are reduced 2020-06-21 16:39:26 +09:00
Hajime Hoshi
ac9bb92885 shader: Refactoring: Reduce calls of parseExpr at definings 2020-06-21 05:26:23 +09:00
Hajime Hoshi
40e581c19f shader: Allow to mix an int and a float in a binary expression
Updates #1190
2020-06-21 03:34:55 +09:00
Hajime Hoshi
eb136daa39 testing: Bug fix: Compile error 2020-06-21 02:26:59 +09:00
Hajime Hoshi
ea9fae1faa shader: Abort parsing correctly when an error is found 2020-06-21 02:18:21 +09:00
Hajime Hoshi
912135d1e7 shaderir: Use constant.Value for number literals
Updates #1190
2020-06-21 01:30:23 +09:00
Hajime Hoshi
4b5de9f445 shaderir: Refactoring: Add OpFromToken 2020-06-20 23:27:54 +09:00
Hajime Hoshi
28948a9976 shaderir: Add (*Type).serialize again 2020-06-20 21:08:08 +09:00
Hajime Hoshi
255da0367f shader: Bug fix: a binary expression for an int and a float did not work 2020-06-20 18:10:23 +09:00
Hajime Hoshi
5e0e12d290 shader: Bug fix: Resolve types in a binary expression correctly 2020-06-20 17:49:23 +09:00
Hajime Hoshi
f36d6c02a9 shader: Refactoring: Remove detectType 2020-06-20 17:20:44 +09:00
Hajime Hoshi
3da0af5de2 shader: Make parseExpr return types
Updates #1190
2020-06-19 03:19:07 +09:00
Hajime Hoshi
afb4e6dc3d shaderir: Misspelling 2020-06-18 01:28:17 +09:00
Hajime Hoshi
b620b4334e buffered: Bug fix: Corner case of the race condition
Updates #1195
2020-06-17 03:31:54 +09:00
Hajime Hoshi
0beddf5519 buffered: Bug fix: Race condition at checkDealeydCommandsNil
This change also renames checkDealeydCommandsNil to
checkDealeydCommandsFlushed, which makes more sense.

Updates #1195
2020-06-17 03:19:35 +09:00
Hajime Hoshi
2869885816 shaderir: Fix the initial variable values on GLSL
This is for consistency with number literals we are introducing.

Updates #1190
2020-06-17 01:59:02 +09:00
Hajime Hoshi
d9cf1095d4 buffered: Bug fix: Race conndition on delayedCommands
This CL fixes the race condtion on delayedCommands, which can be
accessed and set to nil at the same time.

This CL separates some operations for delayedCommands into slow-
paths and fast-paths, and use mutex only at slow-paths for
performance. The implementation is based on sync.Once.

Fixes #1195
2020-06-16 23:22:18 +09:00
Hajime Hoshi
1735dda586 shareable: Rename border -> padding 2020-06-16 12:48:20 +09:00
Hajime Hoshi
484473b6d9 graphicscommand: Span to 1/3 pixels
The center of pixels is problematic as the behavior depends on GPU.
In order to avoid this, align the vertices with about 1/3 pixels.

Updates #929
Fixes #1171
2020-06-16 03:56:53 +09:00
Hajime Hoshi
1785b6a670 examples/moire: Add a smaller scale, and remove AdjustTexel function from shaders
This can reproduce the bug reported at #669.

Apparently, the fix (8827520d4a) is
no longer required after 3550abef7a.
That's pretty odd, but examples/moire proves this fact.

Updates #669
Updates #759
2020-06-15 00:29:34 +09:00
Hajime Hoshi
d74f7d3a77 shareable: Add gaps between images
After this change, each image on the texture atlases has a
transparent border around it.

This change removes the hack to round texels not to violate the
source regions.

Fixes #1194
Updates #1171
2020-06-14 18:05:41 +09:00
Hajime Hoshi
22919909d7 shareable: Refactoring 2020-06-14 15:30:03 +09:00
Hajime Hoshi
d98713728a uidriver/glfw: Bug fix: SetVsyncEnabled(false) did not work before the main loop
Fixes #1197
2020-06-14 11:50:58 +09:00
Hajime Hoshi
620981a09a ebiten: Make ebiten.Image and buffered.Image 1:1
This change creates a new buffered.Image even for a sub-image. This
can increase a memory usage a little, but decrease the GPU memory
usage since only the necessary pixels are allocated on a texture
atlas.

Fixes #896
Updates #1194
2020-06-14 11:15:38 +09:00
Hajime Hoshi
e023425be0 graphicsdriver/metal: Reduce calls of SetLayer 2020-06-14 05:07:33 +09:00
Hajime Hoshi
1395ab5e84 buffered: Defer ReplacePixels when possible 2020-06-14 04:41:51 +09:00
Hajime Hoshi
cf3436da21 buffered: Skip filling operation if possible 2020-06-14 04:17:57 +09:00
Hajime Hoshi
96fa0565e4 buffered: Remove mutex and use sync/atomic for performance
This change also enables to remove the optimization at
(*buffered.Image).ReplacePixels.

  // This commit w/ the optimization
  BenchmarkImageDrawOver-8           60225             19241 ns/op

  // This commit w/o the optimization
  BenchmarkImageDrawOver-8           66567             17700 ns/op

  // The previous w/ the optimization
  BenchmarkImageDrawOver-8           62355             19580 ns/op

  // The previous w/o the optimization
  BenchmarkImageDrawOver-8           54460             22768 ns/op

Updates #1137
2020-06-14 01:16:23 +09:00
Hajime Hoshi
40906676e6 buffered: Add 'Pixels' and remove 'At'
This is a preparation to make shareable.Image and ebiten.Image 1:1
Now sub-images doesn't have its own shareable.Image.

Updates #896
Updates #1194
2020-06-13 21:01:50 +09:00
Hajime Hoshi
d04fdbde61 shader: Add more tests 2020-06-11 23:26:32 +09:00
Hajime Hoshi
f39c591252 shader: Enable more Go syntax 2020-06-11 01:13:03 +09:00
Hajime Hoshi
4a60c01f03 shader: Implement assigning 2020-06-10 22:29:45 +09:00
Hajime Hoshi
d0027ebc5f shader: Bug fix: Skip tests on browsers
With wasmbrowsertest, file system is not available.
2020-06-08 12:32:15 +09:00
Hajime Hoshi
91fb8e92d8 shader: Implment defining variables in multiple-value context 2020-06-08 12:15:09 +09:00
Hajime Hoshi
75706504bf shader: Add testdata directory 2020-06-08 11:18:27 +09:00
Hajime Hoshi
acba49952c shaderir: Add a test for nested function calls 2020-06-08 02:19:37 +09:00
Hajime Hoshi
399bb93044 shaderir: Add space lines between functions 2020-06-08 01:41:47 +09:00
Hajime Hoshi
84fb951729 shader: Implement variable initialization in multiple-value context 2020-06-08 01:33:12 +09:00
Hajime Hoshi
1ca5dd16b2 shader: Let parseExpr return multiple values 2020-06-08 01:17:11 +09:00
Hajime Hoshi
bee79e3b67 shader: Refactoring 2020-06-07 23:50:53 +09:00
Hajime Hoshi
2c1e71931e shader: Move some functions 2020-06-07 23:33:47 +09:00
Hajime Hoshi
3fd8062fbe shader: Let detectType return multiple types 2020-06-07 23:32:50 +09:00
Hajime Hoshi
c986da8970 shader: Implement function call 2020-06-07 22:23:20 +09:00
Hajime Hoshi
2ffbd49602 shader: Use shaderir.Type instead of typ struct 2020-06-07 22:06:06 +09:00
Hajime Hoshi
9a5481459a shaderir: Remove inout params 2020-06-07 19:24:27 +09:00
Hajime Hoshi
e64c806698 shader: Let parseExpr return statements for Call 2020-06-07 19:24:27 +09:00
Hajime Hoshi
6d779965f9 shader: Fix misspelling 2020-06-07 17:03:40 +09:00
Hajime Hoshi
869a61d9be shader: Parse initial values of variables 2020-06-07 16:25:04 +09:00
Hajime Hoshi
e14cd559b6 shader: Remove variable.init 2020-06-07 05:20:04 +09:00
Hajime Hoshi
147c82f212 shader: Bug fix: Test compile error 2020-06-07 00:52:51 +09:00
Hajime Hoshi
ba36d5a8e9 shader: Reland: Add a predefined uniform variable: __viewportSize 2020-06-07 00:14:09 +09:00
Hajime Hoshi
dde7d00231 shader: Accept an ast directly
This is a preparation to modify the AST before passign to Compile.
2020-06-06 23:12:01 +09:00
Hajime Hoshi
fe308f1971 Revert "shader: Add a predefined uniform variable: Internal_ViewportSize"
This reverts commit 6f411842f0.

Reason: Test failures on internal/restorable
2020-06-05 04:36:09 +09:00
Hajime Hoshi
6f411842f0 shader: Add a predefined uniform variable: Internal_ViewportSize 2020-06-05 03:00:43 +09:00
Hajime Hoshi
3dbf4c0a83 shader: Enable to specify entrypoint names 2020-06-05 01:11:39 +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
fc44589705 shader: Format 2020-06-03 23:58:05 +09:00
Hajime Hoshi
762b9788a0 shader: Parse fragment entry point 2020-06-03 23:56:08 +09:00
Hajime Hoshi
382ba75139 shader: Enable to put global variables anywhere 2020-06-03 23:19:07 +09:00
Hajime Hoshi
39c09a4f88 shaderir: Change the param order of fragment shaders 2020-06-03 02:01:50 +09:00
Hajime Hoshi
cd3d396975 shader: Implement vertex shader entry point 2020-06-03 01:03:27 +09:00
Hajime Hoshi
fa5b2ed730 shaderir: Change the param order 2020-06-03 00:46:52 +09:00
Hajime Hoshi
3118657fff shaderir: Fix integer literals 2020-06-02 21:45:33 +09:00
Hajime Hoshi
909ba638a3 shader: Add more shadowing tests 2020-06-01 03:24:43 +09:00
Hajime Hoshi
37cc30bc38 shader: Add define (:=) 2020-06-01 02:23:27 +09:00
Hajime Hoshi
6fa7b4bb5a shader: Analyze blocks and shadowings 2020-06-01 00:58:33 +09:00
Hajime Hoshi
5de0493294 shader: Implement multiple out params 2020-05-31 19:20:53 +09:00
Hajime Hoshi
afd114e606 shader: Parse function bodies 2020-05-31 19:03:33 +09:00
Hajime Hoshi
91e5dde320 shader: Parse return 2020-05-31 18:01:12 +09:00
Hajime Hoshi
ddba8a911f shader: Parse function signatures 2020-05-31 16:20:36 +09:00
Hajime Hoshi
5ea5dfccfc shader: Remove stmt 2020-05-31 02:23:51 +09:00
Hajime Hoshi
1ede103ce6 shader: Add tests for uniform variables 2020-05-31 02:06:41 +09:00
Hajime Hoshi
e7323e04bf shader: Remove sorting 2020-05-31 01:47:12 +09:00
Hajime Hoshi
8cb70062b7 shader: Remove dumping and original types 2020-05-31 01:25:24 +09:00
Hajime Hoshi
eb1b06c326 graphicscommand: Adjust texels 2020-05-30 22:41:14 +09:00
Hajime Hoshi
e25a6f4d46 graphicsdriver/opengl: Remove isTexture on desktops 2020-05-30 20:56:13 +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
1042eb71e0 shaderir: Rename Sampler2D -> Texture2D 2020-05-30 17:48:56 +09:00
Hajime Hoshi
c0cd7ec59c restorable: Update comments 2020-05-30 16:06:22 +09:00
Hajime Hoshi
b2eee7ee8a graphicscommand: Adjust regions for secondory and following images correctly 2020-05-30 15:52:56 +09:00
Hajime Hoshi
915aecb960 graphicscomand: Fix comments 2020-05-30 15:08:28 +09:00
Hajime Hoshi
90e03a65c0 graphicscommand: Update comments 2020-05-30 05:19:49 +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
f92253487f buffered: Add Shader 2020-05-30 03:36:28 +09:00
Hajime Hoshi
218b6fc172 mipmap: Add Shader 2020-05-29 04:12:41 +09:00
Hajime Hoshi
18c59e44aa shareable: Allow multiple call of (*Shader).Dispose 2020-05-29 03:47:06 +09:00
Hajime Hoshi
9c637c65be shareable: Add Shader 2020-05-29 00:15:42 +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