Commit Graph

2300 Commits

Author SHA1 Message Date
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
Hajime Hoshi
ca73f17dd4 restorable: Bug fix: Fill didn't invalidate its dependencies
Fixes #1170
2020-05-25 23:37:25 +09:00
Hajime Hoshi
1cfc1964bf graphicsdriver/opengl: Bug fix: fmt arguments 2020-05-25 02:36:45 +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
85730b433e graphicsdriver: Bug fix: Pass texture natives as uniform variables correctly 2020-05-25 02:31:54 +09:00
Hajime Hoshi
732f288d20 restorable: Add Shader (WIP) 2020-05-25 00:50:01 +09:00
Hajime Hoshi
9bf24ba545 graphicsdriver/opengl: Remove println and add error messages 2020-05-24 23:15:00 +09:00
Hajime Hoshi
fc50f9b0be testing: Refactoring 2020-05-24 22:30:11 +09:00
Hajime Hoshi
155c63ec76 graphicscommand: Move the shader program to testing package 2020-05-24 20:15:07 +09:00
Hajime Hoshi
465d8aa273 graphicscommand: Add IsShaderAvailable for other packages 2020-05-24 19:15:18 +09:00
Hajime Hoshi
c5aba02723 graphicscommand: Update comments 2020-05-24 16:54:28 +09:00
Hajime Hoshi
6506c20f4e graphicscommand: Use an image in the uniform variables 2020-05-24 16:43:08 +09:00
Hajime Hoshi
968c0a9b9a graphicscommand: Bug fix: test failures 2020-05-24 03:04:52 +09:00
Hajime Hoshi
d94b84b8de graphciscommand: Add coments 2020-05-24 02:51:37 +09:00
Hajime Hoshi
a4d419bab1 graphicscommand: Merge DrawTriangles and DrawShader 2020-05-24 02:36:09 +09:00
Hajime Hoshi
3ed9f8ee3b shaderir: Update comments 2020-05-24 02:07:57 +09:00
Hajime Hoshi
3306a957ba graphicscommand: Skip the shader test on browsers
Updates #482
2020-05-23 22:41:06 +09:00
Hajime Hoshi
521f9dcac5 graphicsdriver/opengl: Bug fix: deleted a wrong shader program
Updates #482
2020-05-23 22:40:49 +09:00
Hajime Hoshi
1a0d92267b driver: Add shader API and implement it on OpenGL
Updates #482
2020-05-23 22:09:12 +09:00
Hajime Hoshi
14e90a34aa shaderir: Add more builtin functions 2020-05-23 22:01:10 +09:00
Hajime Hoshi
f38ca35608 shaderir: Remove attribute variables from fragment shaders 2020-05-23 19:06:44 +09:00
Hajime Hoshi
125f85effe shaaderir: Use gl_FragColor 2020-05-23 18:18:22 +09:00
Hajime Hoshi
da4d5b1338 shaderir: Add more builtin functions 2020-05-23 18:07:32 +09:00
Hajime Hoshi
7937b302e3 shaderir: Do not use () for the callees 2020-05-23 18:06:50 +09:00
Hajime Hoshi
7b960a2df4 uidriver/glfw: Use the actual window size for the offscreen
On Windows, a specified window size might not match with the
actual window size when the size is too big. In this case, Ebiten
could not render the offscreen well and the upper side was cropped.

To avoid this, use the actual window size for the offscreen.

Fixes #1163
2020-05-22 18:18:38 +09:00
Hajime Hoshi
a338c7180c shaderir: Split vertex shader and fragment shader at Glsl() 2020-05-21 23:58:08 +09:00
Hajime Hoshi
8fd377f1e3 driver: Add ImageID and use this
This is a preparation to introduce shaders. Shader programs
require images as uniform variables, but the current way would make
API complex unnecessarily.
2020-05-20 00:11:08 +09:00
Hajime Hoshi
7ccc29e3c7 uidriver/js: Clean up 2020-05-19 04:08:33 +09:00
Hajime Hoshi
be1a8bddbf uidriver/js: Bug fix: Create goroutine for a function passed to rAF
This is necessary not to cause dead-lock.

Updates #1161
2020-05-19 03:28:20 +09:00
Hajime Hoshi
7f2092f964 graphicsdriver/opengl: Enable to bind multiple textures (in theory) 2020-05-17 23:57:42 +09:00
Hajime Hoshi
733c463e26 graphicsdriver/opengl: Treat a texture as a uniform variable 2020-05-17 23:25:49 +09:00
Hajime Hoshi
68ef41e256 graphicsdriver/opengl: Integrate uniform variables 2020-05-17 20:20:29 +09:00
Hajime Hoshi
ff311dd564 graphicsdriver/opengl: Pass uniform values to useProgram 2020-05-17 19:43:01 +09:00
Hajime Hoshi
84e2c6f994 graphicsdriver/opengl/gl: Bug fix: misuse of unsafe.Pointer 2020-05-17 19:42:23 +09:00
Hajime Hoshi
8ab12827c0 graphicsdriver/opengl: Refactoring 2020-05-17 19:01:46 +09:00
Hajime Hoshi
9cc128fb40 graphicsdriver/opengl: Integrate last uniform values 2020-05-17 18:36:33 +09:00
Hajime Hoshi
d12b406e0a graphicsdriver/opengl: Remove unused variables 2020-05-17 18:15:27 +09:00
Hajime Hoshi
29dbad28f9 shaderir: Add new lines 2020-05-17 17:06:21 +09:00
Hajime Hoshi
f4a1f90d92 graphicsdriver/opengl/gl: Reduce reflect usage 2020-05-17 14:28:13 +09:00
Hajime Hoshi
156ed320cc shaderir: Remove Variable and VariableType 2020-05-17 04:28:03 +09:00
Hajime Hoshi
094d845edd shaderir: Remove Ident 2020-05-17 03:00:57 +09:00
Hajime Hoshi
dbbe4ee09c shaderir: Add StructMember 2020-05-17 02:46:02 +09:00
Hajime Hoshi
8a6140a92f shaderir: Refactoring 2020-05-17 02:45:03 +09:00
Hajime Hoshi
e1d0800f19 shaderir: Bug fix: Wrong implementation of isValidSwizzling 2020-05-17 02:25:37 +09:00
Hajime Hoshi
7e274050a3 shaderir: Add swizzling 2020-05-17 02:24:35 +09:00
Hajime Hoshi
7648271eff shaderir: Implement bulit-in functions 2020-05-17 00:33:22 +09:00
Hajime Hoshi
6553c237a1 shaderir: Add comments 2020-05-16 23:42:32 +09:00
Hajime Hoshi
8f4e93338c shaderir: Implement sampler2D 2020-05-16 23:33:20 +09:00
Hajime Hoshi
316e502f4b shaderir: Add predefined macros 2020-05-16 23:29:01 +09:00
Hajime Hoshi
66e76597d8 shaderir: Implement fragment function 2020-05-16 23:07:24 +09:00
Hajime Hoshi
ddaed674dd shaderir: Implement vertex function 2020-05-16 22:50:20 +09:00
Hajime Hoshi
eb5a2efad8 shaderir: Implement return 2020-05-16 20:16:04 +09:00
Hajime Hoshi
57d80c185e shaderir: Implement call 2020-05-16 19:19:16 +09:00
Hajime Hoshi
5b69e81bd7 shaderir: Add more tests 2020-05-16 18:09:09 +09:00
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