Commit Graph

192 Commits

Author SHA1 Message Date
Hajime Hoshi
cf92158e33 ebiten: bug fix: add an indirect function call for a fragment shader
Closes #2245
Closes #2247
2022-08-17 16:37:37 +09:00
Hajime Hoshi
205245b094 internal/shader: implement a new built-in function discard
Closes #1969
2022-08-09 11:31:59 +09:00
Hajime Hoshi
16ff5c5039 internal/shaderir: change the naming convention: Num -> Count 2022-07-13 02:02:48 +09:00
Hajime Hoshi
a5179b9491 internal/shaderir/glsl: bug fix: test failures with OpenGL
Updates #2186
2022-07-09 02:43:48 +09:00
Hajime Hoshi
c01821ca5c internal/shader: use all functions for vector comparisons
Updates #2186
2022-07-09 02:30:16 +09:00
Hajime Hoshi
5c63c4a4aa internal/graphicsdriver/metal: support macOS 10.12 by removing packed types
From the Metal shading language specification [1] Table 2.2.3, attribute
variables in Ebitengine's vertices don't have to be packed. Then, we can
remove `packed` types.

[1] https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf

Closes #2107
2022-05-28 23:57:59 +09:00
Hajime Hoshi
2d912a2387 internal/shaderir/hlsl: bug fix: wrong offset of uniform array variables
Closes #2038
2022-03-27 01:49:52 +09:00
Hajime Hoshi
d30a31b16c internal/shaderir/hlsl: add function forward declarations 2022-03-26 19:10:03 +09:00
Hajime Hoshi
dcccd27629 internal/shaderir/msl: bug fix: mod for a vector and a scalar didn't work
Updates #2029
2022-03-26 02:57:38 +09:00
Hajime Hoshi
52376170a4 internal/shaderir: bug fix: float4x4(x) initialized all the components unexpectedly
See https://docs.microsoft.com/en-us/windows/win32/direct3d9/casting-and-conversion#parameter-value-modifiers

Updates #1007
2022-03-26 02:05:35 +09:00
Hajime Hoshi
cfd0de5c41 internal/shaderir: make outputs for unexpected operators consistent 2022-03-26 01:40:02 +09:00
Hajime Hoshi
4893b13acc internal/shaderir: add internal/shaderir/hlsl
Updates #1007
2022-03-26 01:31:05 +09:00
Hajime Hoshi
a617576879 internal/shaderir: replace Mul with ComponentWiseMul and MatrixMul
This is a preparation for DirectX / HLSL.

Updates #1007
2022-03-13 19:17:46 +09:00
Hajime Hoshi
044d41dd2d internal/shaderir: change Op from string to int
This is a preparation to distinguish Hadamard product and matrix
product for HLSL.

Updates #1007
2022-03-13 16:20:04 +09:00
Hajime Hoshi
98e2d86ea3 internal/shaderir/msl: refactoring 2022-03-12 00:18:55 +09:00
Hajime Hoshi
5715539a0f internal/shaderir/glsl, internal/shaderir/msl: refactoring 2022-03-11 15:18:38 +09:00
Hajime Hoshi
e63709a2a5 internal/shaderir/glsl: refactoring 2022-03-11 02:03:15 +09:00
Hajime Hoshi
6f00221051 internal/shaderir/msl: rename the package name
Updates #2010
2022-03-10 16:25:11 +09:00
Hajime Hoshi
47bfd0db9e internal/shaderir/metal: rename to msl
Closes #2010
2022-03-10 00:14:06 +09:00
Hajime Hoshi
5e5e3c64ac internal/shaderir/metal: remove a redundant case 2022-03-09 02:54:31 +09:00
Hajime Hoshi
15064dbdc1 internal/shaderir/glsl, internal/shaderir/metal: simplify function names 2022-03-09 01:43:36 +09:00
Hajime Hoshi
df2133186d internal/shaderir: bug fix: test failures 2022-03-04 19:01:58 +09:00
Hajime Hoshi
3c1e64dd67 internal/shaderir/metal: bug fix: define the 'mod' function correctly
Closes #2006
2022-03-04 18:05:44 +09:00
Hajime Hoshi
bf48a0b11a internal/shaderir: bug fix: test failures 2022-01-12 01:57:06 +09:00
Hajime Hoshi
08ddb4233b internal/shaderir/glsl: bug fix: % was not available on old GLSLs
Use a new utility function modInt instead.

Closes #1951
2022-01-12 01:41:09 +09:00
Hajime Hoshi
00e2b15e2a shaderir: Bug fix: A wrong argument for fmt.Sprintf
This change also improves the result of espcae analysis.

Closes #1863
2021-11-02 00:05:07 +09:00
r3vit
57c45a13e4
Remove dot imports from tests - Remove dot imports (#1837)
Closes #1824
2021-10-02 19:58:48 +09:00
Hajime Hoshi
d5150a194c internal/shaderir/glfw: Insert a dummy function to touch uniform array variables
Closes #1754
2021-08-15 18:06:41 +09:00
Hajime Hoshi
853c1f2b92 internal/shaderir/glsl: Bug fix: Remove uncalled functions
Some built-in functions like dFdx is not available in a vertex shader,
then a function that calls such built-in function should not be in
a vertex shader.

Closes #1701
2021-07-09 20:22:40 +09:00
Hajime Hoshi
dd46221968 graphicsdriver/opengl: Enable dFdx for mobiles
Fixes #1404
2020-11-21 19:40:11 +09:00
Hajime Hoshi
b72848dc97 shaderir: Bug fix: Test failures
Updates #1404
2020-11-21 19:17:31 +09:00
Hajime Hoshi
b1d7a5f595 shaderir/glsl: Enable dFdx for WebGL
With WebGL1, an extension is required for dFdx. On the other hand,
with WebGL2, GLSL ES 300 is required and the extension is forbidden.
This change fixes shaderir/glsl to switch the output depends on the
WebGL version.

This change also adds a new build tag 'ebitenwebgl1' forcing WebGL 1.

Updates #1404
2020-11-21 19:07:54 +09:00
Hajime Hoshi
185e367295 shader: Implement cap function
Fixes #1361
2020-10-17 23:36:09 +09:00
Hajime Hoshi
bf515bb594 Update version to v2.0.0-alpha 2020-10-04 04:30:40 +09:00
Hajime Hoshi
3c71eba446 shaderir: Bug fix: Implement atan2 for Metal correctly
Fixes #1360
2020-09-22 04:29:34 +09:00
Hajime Hoshi
2fb1033183 shader: Initialize output parameters explicitly 2020-09-12 00:35:14 +09:00
Hajime Hoshi
99dcb14582 shaderir/glsl: Refactoring 2020-09-10 02:11:21 +09:00
Hajime Hoshi
e1ae9bdde0 shaderir/glsl, shaderir/metal: Refactoring 2020-09-10 02:04:28 +09:00
Hajime Hoshi
337f44c916 shader: Add Metal tests
Fixes #1340
2020-09-10 01:19:02 +09:00
Hajime Hoshi
031f8376e9 shaderir: Refactoring 2020-09-08 03:51:29 +09:00
Hajime Hoshi
3b040e5f22 Fix test failures 2020-09-08 03:10:59 +09:00
Hajime Hoshi
1786be55f7 shader: Refactoring 2020-09-08 02:43:41 +09:00
Hajime Hoshi
0a0401e217 shader: Refactoring: Simplify calculation of LocalVarIndexOffset 2020-09-08 02:42:43 +09:00
Hajime Hoshi
f61a916e4a shaderir/glsl: Bug fix: Calculate local variable indices correctly
Fixes #1339
2020-09-08 00:19:07 +09:00
Hajime Hoshi
29c7b7687f shaderir: Add Program.UniformNames
Updates #1324
2020-09-06 03:41:17 +09:00
Hajime Hoshi
f5829b2cf3 shader: Check at least one variable on left side of :=
Updates #1330
2020-09-03 01:15:41 +09:00
Hajime Hoshi
06ed4f5444 shader: Implement len function
Fixes #1279
2020-08-16 02:07:39 +09:00
Hajime Hoshi
f6c3e0579f shaderir: Adopt the precision 10 for float literals
Adopted the same precision of (*math/big.Float).String().
2020-08-13 00:01:16 +09:00
Hajime Hoshi
f71346da6c shaderir: Add bool/int/float conversion
Updates #1289
2020-08-11 23:04:55 +09:00
Hajime Hoshi
5d2606b6a5 shader: Bug fix: Wrong local variable indices in blocks 2020-08-10 01:09:02 +09:00
Hajime Hoshi
dee8690502 shaderir/glsl: Bug fix: Copying an array did not work on GLSL
Fixes #1286
2020-08-09 22:18:58 +09:00
Hajime Hoshi
646518f2e8 shaderir: Fix the test side: local variables for 'for' stmts must be reserved 2020-08-09 22:12:35 +09:00
Hajime Hoshi
b73fecae79 shaderir: Add tests for different counter types 2020-08-09 21:44:06 +09:00
Hajime Hoshi
2707915376 shaderir/glsl, shaderir/metal: Bug fix: Wrong local variables with multiple 'for' statements 2020-08-09 20:12:56 +09:00
Hajime Hoshi
80361443cc shaderir/glsl, shaderir/metal: Bug fix: Wrong local variables in for 2020-08-09 20:06:13 +09:00
Hajime Hoshi
ee9257e626 shaderir: Use pointers for Block 2020-08-09 18:00:55 +09:00
Hajime Hoshi
07514a37c8 shaderir/glsl: Bug fix: Initialize an array
Updates #1285
2020-08-09 04:59:29 +09:00
Hajime Hoshi
febdc46ad5 shaderir/metal: Better array initialization
Updates #1285
2020-08-09 04:40:15 +09:00
Hajime Hoshi
a536b3ee25 shaderir/metal: Bug fix: Array initialization
Updates #1285
2020-08-09 04:22:12 +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
18b3859e20 shaderir: Export IsValidSwizzling
This is a preparation for compiling the IR to Metal.

Updates #1165
2020-08-08 19:08:10 +09:00
Hajime Hoshi
00ccc8ad85 shaderir/glsl: Refactoring 2020-08-07 01:53:22 +09:00
Hajime Hoshi
6576a1da76 shaderir/glsl: Refactoring 2020-08-06 17:53:28 +09:00
Hajime Hoshi
6003d85f75 shaderir: Remove some builtin functions
'degrees' and 'radians' are not defined in Metal.
2020-08-05 02:06:28 +09:00
Hajime Hoshi
ffee5eb6b8 shaderir/glsl: Fix the panic messages 2020-08-05 01:50:41 +09:00
Hajime Hoshi
c22ec580bc shaderir: Remove bultin functions for bvec 2020-08-05 01:41:06 +09:00
Hajime Hoshi
8bac08cbd9 Add internal/shaderir/glsl 2020-08-03 23:27:27 +09:00
Hajime Hoshi
79e252c158 shaderir: Refactoring 2020-08-02 00:09:12 +09:00
Hajime Hoshi
fa60e31997 shaderir: Bug fix: Pass tests 2020-08-01 21:22:47 +09:00
Hajime Hoshi
4bd01fd038 graphicsdriver/opengl: Implement shaders for browsers
Fixes #1166
2020-08-01 20:27:46 +09:00
Hajime Hoshi
bab05874cd shaderir: Remove unnecessary empty lines 2020-08-01 19:04:10 +09:00
Hajime Hoshi
a4334c5464 shader: Use arrays at uniform variables
Fixes #1274
2020-08-01 17:22:10 +09:00
Hajime Hoshi
da5642cd0e graphicsdriver/opengl: Add type checks of uniform variables 2020-08-01 02:01:51 +09:00
Hajime Hoshi
004b279e4f shader: Add array initialization
Updates #1235
2020-07-29 22:43:51 +09:00
Hajime Hoshi
d9c54bc0d0 shader: Implement an array variable
Updates #1235
2020-07-29 02:27:05 +09:00
Hajime Hoshi
a43efb66b2 shaderir: Bug fix: Function prototypes were required for GLSL
Fixes #1267
2020-07-28 00:04:03 +09:00
Hajime Hoshi
c8fa937a0a shaderir: Format 2020-07-20 02:12:31 +09:00
Hajime Hoshi
385ff8efdf shader: Bug fix: Wrong local variable names at for-loop
Fixes #1245
2020-07-13 22:49:15 +09:00
Hajime Hoshi
2ca551cdc6 shader: Implement 'for' statement
Fixes #1230
2020-07-13 01:44:05 +09:00
Hajime Hoshi
f95ca46c99 shaderir: Add Stmt.ForVarType and use constant.Value
Updates #1230
2020-07-12 22:31:12 +09:00
Hajime Hoshi
291d69500b shaderir: Add Stmt.ForVarIndex
Updates #1230
2020-07-12 21:55:07 +09:00
Hajime Hoshi
202bb34bac shaderir: Add builtin funcs dfdx, dfdy, fwidth
Fixes #1242
2020-07-11 21:50:10 +09:00
Hajime Hoshi
aecd29325e shaderir: Bug fix: Wrong function names for some bulitin funcs 2020-07-11 21:46:21 +09:00
Hajime Hoshi
776de77744 shaderir: Remove and rename some builtin functions
Apparently matrixCompMult and outerProduct are not portable.

We adopted the naming rule foobar instead of fooBar.
2020-07-11 21:43:24 +09:00
Hajime Hoshi
4021c24534 shader: Separate uniform variables and texture variabls
Textures cannot be treated as a regular variable, then they should
be treated differently from other uniform variables.

Add a new function texture0At replacing texture2D.

Updates #1239
2020-07-08 01:12:07 +09:00
Hajime Hoshi
98ae0826c7 shaderir: Bug fix: Early-returns in the entry points didn't work
Fixes #1238
2020-07-05 17:57:57 +09:00
Hajime Hoshi
380b7382ac shader: Add 'if'
Updates #1230
2020-07-05 02:33:49 +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
afb4e6dc3d shaderir: Misspelling 2020-06-18 01:28:17 +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
f39c591252 shader: Enable more Go syntax 2020-06-11 01:13:03 +09:00
Hajime Hoshi
399bb93044 shaderir: Add space lines between functions 2020-06-08 01:41:47 +09:00
Hajime Hoshi
9a5481459a shaderir: Remove inout params 2020-06-07 19:24:27 +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