Hajime Hoshi
7418576c16
internal/ui: re-enable skipping to render the final screen when possible
...
With Metal, nextDrawable could return immediately when a command buffer
is empty. To avoid high CPU usage, this change adds a slight sleep in
this case.
With DirectX, Present waits for a while even though nothing is updated,
then that's fine.
Updates #2341
Updates #2342
Updates #2520
2023-01-03 23:09:28 +09:00
Hajime Hoshi
edb952c9e7
internal/graphicsdriver/metal: add comments
2023-01-03 22:10:33 +09:00
Hajime Hoshi
34941ca083
all: separate the rendering thread from the main thread
...
Updates #1704
Closes #2512
2022-12-30 22:57:34 +09:00
Hajime Hoshi
8d020ad414
internal/graphicsdriver/metal: refactoring
2022-12-29 15:27:51 +09:00
Hajime Hoshi
5e17791e4e
internal/ui: bug fix: an offscreen was broken with SetScreenClearedEveryFrame(false)
...
Updates #2500
Closes #2510
2022-12-29 14:57:07 +09:00
Hajime Hoshi
0756be0b68
cmd/ebitenmobile: use an independent thread for rendering on iOS
...
Closes #2508
2022-12-28 23:37:13 +09:00
Hajime Hoshi
ece60af1b7
internal/graphicsdriver/metal: stop using presentsWithTransaction
...
presentsWithTransaction caused many troubles. The critical thing was
that nextDrawable sometimes took more than one second when a user
inputs with NSTextView.
Fortunately, applications work well even without presentsWithTransaction.
Updates #1029
Updates #1196
Updates #1745
Updates #1974
2022-12-27 19:00:56 +09:00
Hajime Hoshi
0a6813c17f
internal/graphics: use flatten []float32 slice instead of [][]float32
...
Closes #2479
2022-12-03 20:23:58 +09:00
Hajime Hoshi
0b9cbaa1ed
internal/shader: introduce integer vectors (ivec2, ivec3, ivec4)
...
Closes #1911
2022-11-21 00:31:23 +09:00
TotallyGamerJet
fb612ab443
internal/cocoa, internal/graphicsdriver/mtl: remove usages of NSInvocations to directly call ID.Send ( #2464 )
...
purego now supports using floats as arguments.
We can remove these instances of NSInvocation that
only existed to circumvent that feature.
Updates #1162
2022-11-20 23:48:22 +09:00
Hajime Hoshi
9a75e266d4
internal/graphicsdriver: fix comments
2022-11-20 23:18:40 +09:00
Hajime Hoshi
7961654927
internal/graphicsdriver/metal: bug fix: wrong alignment for vec3
2022-11-20 23:14:09 +09:00
TotallyGamerJet
56ec19caa1
all: use RTLD_LAZY in dlopen for darwin ( #2453 )
...
dlopen requires either RTLD_LAZY or RTLD_NOW but there was neither.
Updates #1162
2022-11-14 04:44:51 +09:00
Hajime Hoshi
a406904a51
internal/graphicsdriver: refactoring
2022-11-12 21:03:54 +09:00
Hajime Hoshi
419bb4c1e9
all: use uint32 instead of float32 for uniform values
...
This is a preparation for other types of uniform values.
Updates #2305
2022-11-12 20:28:07 +09:00
Hajime Hoshi
d73e8f785d
internal/graphicsdriver: render various destination regions as one command
...
Closes #2232
2022-11-04 20:49:44 +09:00
Hajime Hoshi
0afb6fd22a
internal/graphicsdriver/metal: reduce rendering paths for even-odd rendering
2022-11-04 16:17:51 +09:00
Hajime Hoshi
384dee7160
internal/graphicscommand: remove unused uniform variables
...
This improves possibility of merging graphics commands by reducing
uniform variables.
Updates #2232
2022-11-03 22:45:17 +09:00
Artem Yadelskyi
10415d417a
all: replace interface{}
with any
( #2430 )
...
Closes #2429
2022-11-03 15:33:09 +09:00
Artem Yadelskyi
5b53cef59e
all: remove old // +build
comments ( #2431 )
...
Closes #2325
2022-11-03 12:55:14 +09:00
Hajime Hoshi
a5993f09a2
internal/graphicscommand: refactoring: add preserved uniform variables at the graphicscommand package
...
This is a preparation to skip setting unnecessary uniform variables
like dstRegion.
Updates #2232
2022-10-30 22:30:52 +09:00
Hajime Hoshi
690e73c11b
all: replace reflect.SliceHeader with unsafe.Slice
...
Closes #2420
2022-10-30 12:25:30 +09:00
Hajime Hoshi
b019a3723a
internal/ui: optimize GPU usages when the screen doesn't have to be updated
...
This change skips rendering when 1) the screen is not cleared every frame
(`SetScreenClearedEveryFrame(false)`) and 2) Draw doesn't draw anything
onto the screen. The GPU usages decreased on some machines (e.g. GPU usage
was 10% with an empty Ebitengine project and became 2-3 % on a Windows
machine).
Updates #2341
2022-10-28 18:51:06 +09:00
Hajime Hoshi
da5f5ea327
ebiten: add blend factors
...
Updates #2382
2022-10-18 00:21:13 +09:00
Hajime Hoshi
46a218c278
internal/graphicsdriver/metal/mtl: bug fix: wrong renaming
...
Updates #2382
2022-10-17 01:11:54 +09:00
Hajime Hoshi
871a8869db
ebiten: bug fix: wrong renaming
...
Updates #2382
2022-10-17 01:00:23 +09:00
Hajime Hoshi
180e456a8e
ebiten: rename members of Blend
...
Updates #2382
2022-10-17 00:51:55 +09:00
Hajime Hoshi
e03825bf08
ebiten: add BlendOperationSubtract and BlendOperationReverseSubtract
...
Updates #2382
2022-10-17 00:30:24 +09:00
Hajime Hoshi
09a7d39874
internal/graphicsdriver: add Blend struct
...
This is a preparation to specify blend factors and blend operators.
Updates #2382
2022-10-16 01:08:26 +09:00
Hajime Hoshi
1d9f1474e9
internal/graphicsdriver: rename constants
2022-10-15 21:14:59 +09:00
Hajime Hoshi
272d0c6a3f
internal/graphicsdriver: rename Operator -> BlendFactor
...
Updates #2382
2022-10-15 17:34:03 +09:00
Hajime Hoshi
08e6f5af86
internal/graphicsdriver: remove FramebufferYDirection
2022-10-14 00:05:59 +09:00
Hajime Hoshi
69cdd2b178
internal/graphicsdriver/metal: refactoring
2022-10-04 00:29:18 +09:00
Hajime Hoshi
080d936d42
internal/graphics: remove unused arguments from DrawTriangles
...
Updates #2369
2022-10-02 22:13:31 +09:00
Hajime Hoshi
5f7db485f2
internal/graphicsdriver/metal: remove the built-in shaders
...
Updates #2369
2022-10-02 20:34:38 +09:00
Hajime Hoshi
5e459bbe42
internal/graphicsdriver/opengl, metal, directx: use premultiplied alpha format for color scales
...
Updates #2365
2022-10-02 13:38:21 +09:00
Hajime Hoshi
eb3c45c8af
Revert "internal/graphicsdriver/opengl, metal, directx: skip multiplying a scale when a color matrix is used"
...
This reverts commit b457dc3307
.
Reason: a color scale might be used with ColorM (DrawTriangles)
2022-10-02 00:19:41 +09:00
Hajime Hoshi
b457dc3307
internal/graphicsdriver/opengl, metal, directx: skip multiplying a scale when a color matrix is used
2022-10-01 18:14:22 +09:00
Hajime Hoshi
4203a3b68a
internal/graphicsdriver/opengl, metal, directx: add comments
...
Updates #1212
2022-10-01 15:21:02 +09:00
Hajime Hoshi
a10f3d1dad
internal/graphicsdriver/opengl, metal, directx: refactoring: clean up the built-in shaders
2022-10-01 14:35:26 +09:00
Hajime Hoshi
cff64894cc
internal/affine: refactoring: use slices instead of array pointers
...
This doesn't change the performance at the test using ColorM:
```
name old time/op new time/op delta
ColorMScale-8 1.11µs ±43% 1.23µs ±70% ~ (p=1.000 n=5+5)
```
2022-09-30 22:20:32 +09:00
Hajime Hoshi
45b2bd7b2b
internal/graphicsdriver/metal/mtl: remove a TODO comment
2022-09-16 11:48:59 +09:00
Hajime Hoshi
963eb2756a
all: fix TODO comments
2022-09-16 02:02:02 +09:00
Hajime Hoshi
2cbc5e7b60
internal/cocoa: remove IsIOS
...
Use `runtime.GOOS == "ios"` instead.
Closes #1415
2022-09-15 01:04:37 +09:00
Hajime Hoshi
655cd4bf68
all: remove the build tag
...
Updates #1415
2022-09-15 00:23:40 +09:00
Terra Brown
a1cc44833d
add errcheck static analysis ( #2293 )
...
Closes #2287
2022-09-10 01:52:46 +09:00
Hajime Hoshi
bb406c9b8f
internal/graphicsdriver/metal: bug fix: go vet failed
...
view must not be copied.
Updates #2282
2022-09-06 19:09:21 +09:00
Hajime Hoshi
35f597e682
internal/graphicsdriver: refactoring: remove FilterScreen
...
Closes #2282
2022-09-06 19:04:15 +09:00
Hajime Hoshi
bd43b42ee5
internal/ui: reland the screen shader in Kage
...
This change relads a part of the change to use the screen shader
instead of FilterScreen, but with the issue on iOS fixed.
Let's remove FilterScreen later.
Updates #2282
2022-09-06 18:48:19 +09:00
Hajime Hoshi
63e3c4adea
Revert "internal/graphics: remove FilterScreen and use an original Kage program instead"
...
This reverts these commits
* 3259ef3daf
* 7c55065490
* 5bb70f485e
Reason: iOS crash. Probably we have to prepare a special rendering
pipeline for the final screen.
Closes #2278
2022-08-30 01:56:06 +09:00
Hajime Hoshi
b2f874a244
image/rectangle: read pixels only for necessary parts
...
Closes #2274
2022-08-27 23:23:33 +09:00
Hajime Hoshi
5bb70f485e
internal/graphics: remove FilterScreen and use an original Kage program instead
...
Updates #2046
2022-08-26 17:41:29 +09:00
TotallyGamerJet
05470f7706
internal/graphicsdriver/metal: remove C for macOS ( #2243 )
...
Updates #1162
2022-08-18 01:39:34 +09:00
Hajime Hoshi
70f5e84098
internal/graphicsdriver: rename ReplacePixels to WritePixels
...
Updates #2236
2022-08-08 03:05:04 +09:00
mattn
2bacecca24
fix typos ( #2227 )
2022-08-03 22:40:39 +09:00
Herczog Zoltán
fabf3fb374
internal/graphicsdriver/metal: remove supportsMetal check ( #2223 )
...
Closes #2211
2022-07-31 21:20:53 +09:00
Hajime Hoshi
afed6a83c6
internal/graphics: change the naming convention: Num -> Count
...
This change also renames ebiten.MaxIndicesNum -> ebiten.MaxIndicesCount.
2022-07-13 02:02:44 +09:00
Hajime Hoshi
7d725f3e58
Revert "internal/graphicscommand: bug fix: using an image just after ReplacePixels might fail on Metal"
...
This reverts commit c31cc4ecff
.
Reason: This didn't fix the issue.
Updates #2154
2022-07-04 11:50:06 +09:00
Hajime Hoshi
c31cc4ecff
internal/graphicscommand: bug fix: using an image just after ReplacePixels might fail on Metal
...
Inserting a dummy rendering command after ReplacePixels and before
DrawTriangles solved the issue. This is a very dirty hack, but
there seems no other better way.
Closes #2154
2022-07-03 15:59:18 +09:00
Hajime Hoshi
afe1a93648
internal/graphicscommand, internal/graphicsdriver/metal: remove unused code
2022-07-03 15:23:52 +09:00
Hajime Hoshi
12533c2cce
Revert "internal/graphicsdriver/metal: bug fix: need to commit replace-pixels commands at DrawTriangles"
...
This reverts commit ac802cf0d0
.
Reason: This caused flickerings, and didn't solve #2154
Updates #2154
Closes #2174
2022-07-03 12:17:58 +09:00
Hajime Hoshi
ac802cf0d0
internal/graphicsdriver/metal: bug fix: need to commit replace-pixels commands at DrawTriangles
...
Closes #2154
2022-06-19 15:38:12 +09:00
Hajime Hoshi
07a558b38d
internal/graphicsdriver/metal: bug fix: the default driver must be initialized on the main thread
...
Closes #2147
2022-06-17 14:58:26 +09:00
Hajime Hoshi
138463e219
internal/ui: rename chooseGraphicsDriver -> newGraphicsDriver
2022-06-17 02:40:39 +09:00
Hajime Hoshi
7484df0c5e
internal/graphicsdriver/metal: replace Get with NewGraphics
...
This is a prepartion to return an error when a graphics driver, especially
DirectX, fails to initialize.
Updates #2142
2022-06-17 02:40:35 +09:00
Hajime Hoshi
195b060911
internal/graphicsdriver/metal: refactoring: initialize the driver at Get
2022-06-16 23:52:55 +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
fef79f4d3e
internal/graphicsdriver/metal: update the minimum version of macOS
...
Updates #2095
2022-05-18 00:09:04 +09:00
Hajime Hoshi
7409f01b17
internal/graphicsdriver/metal/mtl: bug fix: specify the language version explicitly
...
Updates #2086
2022-05-05 23:50:48 +09:00
Hajime Hoshi
736d77e0d2
internal/graphicsdriver: remove Graphics.NDCYDirection
2022-04-04 03:03:44 +09:00
Hajime Hoshi
02db3bad53
internal/graphicscommand: remove the dependency on a graphics driver from compileShader
...
Updates #2035
2022-04-04 02:09:08 +09:00
Hajime Hoshi
3fafc05411
internal/graphicsdriver: remove Graphics.HasHighPrecisionFloat
...
Updates #879
2022-04-02 05:19:30 +09:00
Hajime Hoshi
6bd3c81e27
internal/graphicsdriver/directx, internal/graphicsdriver/metal: bug fix: uniform matrix-array variables were passed wrongly
...
Updates #2036
2022-03-27 00:32:30 +09:00
Hajime Hoshi
eaad959472
internal/graphicsdriver/metal: remove println
2022-03-27 00:12:34 +09:00
Hajime Hoshi
f6d87f6ee8
internal/graphicsdriver/directx, internal/graphicsdriver/metal: bug fix: uniform matrix variables were passed wrongly
...
Updates #2036
2022-03-26 23:58:48 +09:00
Hajime Hoshi
79e93d3b12
internal/graphicsdriver: introduce the DirectX driver
...
Closes #1007
2022-03-26 20:09:34 +09:00
Hajime Hoshi
eeb5687b73
internal/graphicsdriver/metal, internal/graphicsdriver/opengl: change the return type to pointers
...
On second thought, returning pointers is more natural. Handling
nil is a caller's responsibility.
2022-03-24 13:20:36 +09:00
Hajime Hoshi
7bb7e45522
internal/graphicsdriver/metal, internal/graphicsdriver/opengl: change the return type to interface
...
Converting a nil with a pointer type to an interface type is no longer
a nil-nil interface, and then comparing with nil causes an unexpected
results.
2022-03-24 03:24:58 +09:00
Hajime Hoshi
09b0a0ffaf
internal/ui: refactoring: simplify the selection of graphics libraries
2022-03-23 02:21:53 +09:00
Hajime Hoshi
a74e7b1578
Revert "internal/graphicsdriver/metal: refactoring"
...
This reverts commit 1c57393393
.
Reason: nothing is rendered on iOS.
Closes #2022
2022-03-23 01:22:39 +09:00
Hajime Hoshi
cd57bccbfc
internal/graphicsdriver: let some functions return an error
...
This is a preparation for the DirectX driver.
Updates #1007
2022-03-21 22:23:12 +09:00
Hajime Hoshi
2e6bb8c4e2
internal/graphicsdriver/metal: add comments
2022-03-14 22:02:44 +09:00
Hajime Hoshi
7d0f95e9be
internal/graphicsdriver: refactoring: replace Uniform with []float32
...
Closes #2016
2022-03-13 03:42:13 +09:00
Hajime Hoshi
35a5c88901
internal/graphics: rename constants
2022-03-12 04:01:48 +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
c37ffecafd
internal/graphicsdriver/metal: reorder uniform variables
...
This might improve memory allocations.
This makes the code more consistent with HLSL's packing rule [1]
[1] https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-packing-rules
2022-03-05 22:12:08 +09:00
Hajime Hoshi
d4d4b9c070
internal/graphicsdriver/metal, internal/graphicsdriver/opengl: more efficient modulo
2022-03-04 03:47:55 +09:00
Hajime Hoshi
b22309a0e5
internal/graphicsdriver: replace Pixels with ReadPixels
...
Now preparing a byte slice is the caller's responsibility.
2022-02-27 20:03:13 +09:00
Hajime Hoshi
566957dc1c
internal/graphicsdriver/metal: invert Y at the vertex shader
...
Instead of using a negative height in the viewport, invert the Y direction
at the vertex shader. This is a little more readable as a negative height
is hacky.
This is a preparation for DirectX 12. DirectX 12's coodination system
is very similar to Metal, but doesn't treat a negative height in its
viewport unfortunately.
Updates #1007
2022-02-27 01:53:03 +09:00
divVerent
f2209a0b51
internal/atlas: optimization: send premultiplied alpha from vertex to fragment shader. ( #1996 )
...
Note that this applies only to the builtin shaders - interface for Kage stays
unchanged for compatibility.
Minor compatibility delta: when interpolating alpha values, previous code has
created nonsense values, such as, when interpolating from
fully-transparent-black (0,0,0,0) to opaque-white (1,1,1,1), something like
half-transparent-grey (0.25,0.25,0.25,0.5) where half-transparent-white
(0.5,0.5,0.5,0.5) is used by the new code.
I assume this is a strict improvement, however this may warrant some testing.
Possible later improvement could be moving the premultiplication from fragment
shader to CPU. Did not do this as it makes the code rather inconsistent of Kage
vs built-in shader usage.
Updates #1772
2022-02-24 02:27:50 +09:00
Hajime Hoshi
8b7273b74a
internal/graphicsdriver/metal: call PresentDrawable only when necessary
2022-02-22 01:37:13 +09:00
Hajime Hoshi
ee911fd892
internal/graphicsdriver/metal: fix an error message
2022-02-20 22:01:36 +09:00
Hajime Hoshi
1c57393393
internal/graphicsdriver/metal: refactoring
2022-02-13 01:00:20 +09:00
Hajime Hoshi
162f62f54e
internal/graphicsdriver/metal/mtl: bug fix: test compile error
2022-02-11 23:23:22 +09:00
Hajime Hoshi
176e984a58
internal/ui: refactoring: remove dependency on the package mtl
2022-02-11 23:11:49 +09:00
Hajime Hoshi
6f3c6d6c1b
internal/graphicsdriver/meta: rename function
2022-02-11 22:47:13 +09:00
Hajime Hoshi
cc4e2f08be
internal/graphicsdriver/metal: rename files
2022-02-11 21:49:05 +09:00
Hajime Hoshi
df60c4c92d
internal/driver: rename to internal/graphicsdriver
2022-02-06 20:41:32 +09:00
Hajime Hoshi
d0a6ce6567
internal/graphicsdriver/metal: disable presentsWithTransaction in the fullscreen mode
...
Updates #1745
Closes #1974
2022-01-26 03:55:14 +09:00