Commit Graph

224 Commits

Author SHA1 Message Date
Hajime Hoshi
dbb167c2d0 internal/graphicsdriver/directx: refactoring 2023-03-27 13:57:25 +09:00
Hajime Hoshi
549e6120b5 internal/graphicsdriver/directx: refactoring: reduce indentations 2023-03-26 22:56:15 +09:00
Hajime Hoshi
fe5c3354fc internal/graphicsdriver/directx: bug fix: missing error checking 2023-03-26 18:52:55 +09:00
Hajime Hoshi
c9469a64ee internal/graphicsdriver/directx: refactoring: add graphicsInfra 2023-03-26 18:31:42 +09:00
Hajime Hoshi
0b46d2b799 internal/graphicsdriver/directx: refactoring 2023-03-26 00:49:30 +09:00
Hajime Hoshi
902d7244eb internal/graphicsdriver/directx: rename structs for a new DirectX 11 implementation
Updates #2613
2023-03-26 00:32:47 +09:00
Hajime Hoshi
d6525a2782 internal/graphicsdriver/directx: refactoring 2023-03-25 16:52:58 +09:00
Hajime Hoshi
c394bdcf7c internal/graphicsdriver/directx: separate a part for images and shaders 2023-03-25 15:54:28 +09:00
Hajime Hoshi
4811386d8a internal/graphicsdriver/directx: separate a part for DirectX 12
Updates #2613
2023-03-25 15:35:47 +09:00
Hajime Hoshi
488bce7e36 internal/graphicsdriver/directx: remove unnecessary comments 2023-03-25 13:53:00 +09:00
Hajime Hoshi
c1e83432c0 internal/graphicsdriver/directx: refactoring: split api_windows.go 2023-03-25 12:07:04 +09:00
Hajime Hoshi
4ec27262ed internal/graphicsdriver/directx: refactoring 2023-03-25 01:34:29 +09:00
Hajime Hoshi
90723025cc internal/graphicsdriver/directx: reuse vertices/indices buffers whenever possible 2023-03-23 11:34:39 +09:00
Hajime Hoshi
e5525a04d5 internal/graphicsdriver/directx: refactoring: remove usages of graphics.IndicesCount
Updates #2460
2023-03-23 11:25:29 +09:00
Hajime Hoshi
ad90ae3475 internal/graphicsdriver/directx: refactoring 2023-03-22 21:52:14 +09:00
Hajime Hoshi
a5a5de2f3f internal/graphicsdriver/directx: reduce memory usages for writing pixels
Updates #2294
Updates #2582
2023-03-01 00:11:34 +09:00
Hajime Hoshi
264f0bad42 internal/graphicsdriver/directx: reduce memory usages when reading pixels
Updates #2294
Updates #2582
2023-02-28 22:55:21 +09:00
Hajime Hoshi
f58d7e1ab5 internal/graphicsdriver/directx: bug fix: getting pixels with non-zero position might not work 2023-02-25 02:08:50 +09:00
Pierre Curto
4de807cc44
all: fix typos (#2558)
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2023-01-28 19:06:38 +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
8b588587cc internal/graphicsdriver/directx: do not cache a vertex shader when an error occurs 2022-12-25 04:27:15 +09:00
Hajime Hoshi
8e1bd4eaba internal/graphicsdriver/directx: refactoring 2022-12-24 18:05:47 +09:00
Hajime Hoshi
fda0b1cbcb internal/graphicsdriver/directx: reuse a compiled vertex shader if possible
D3DCompile can be a very slow function, and let's skip this if possible.
2022-12-24 17:44:54 +09:00
Hajime Hoshi
1b4f68d775 internal/graphicsdriver/directx: call D3DCompile in parallel
D3DCompile can be very slow on some old machines.

See also https://bugs.chromium.org/p/angleproject/issues/detail?id=422
2022-12-24 01:22:33 +09:00
Hajime Hoshi
de8184ac10 internal/graphicsdriver/directx: implement suspend/resume for Xbox 2022-12-23 17:28:03 +09:00
Hajime Hoshi
102a2d2138 internal/graphicsdriver/directx: change the default feature level to 11_0
The feature level 12_0 causes some issues on some machines. As we now
have EBITENGINE_DIRECTX_FEATURE_LEVEL, let's go back to the default
feature level 11_0.

Updates #2486
2022-12-07 21:16:47 +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
67430362cc internal/graphicsdriver/directx: add EBITENGINE_DIRECTX_FEATURE_LEVEL
A fix for #2447 was a breaking-change as the DirectX driver was no longer
available for some old graphics card.

To support such old cards, provide a new environment variable
EBITENGINE_DIRECTX_FEATURE_LEVEL to specify a feature level.
The possible values are 11_0, 11_1, 12_0, 12_1, and 12_2. The default
value is 12_0.

Closes #2466
2022-11-21 02:46:07 +09:00
Hajime Hoshi
0b9cbaa1ed internal/shader: introduce integer vectors (ivec2, ivec3, ivec4)
Closes #1911
2022-11-21 00:31:23 +09:00
Hajime Hoshi
c7c9500ba6 internal/graphicsdriver/directx: bug fix: a software adaptor was unexpectedly chosen
Closes #2459
2022-11-16 15:46:17 +09:00
Hajime Hoshi
1ecac8d834 all: allow integer uniform variables for Kage shaders
Closes #2305
Updates #2448
2022-11-13 01:49:24 +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
2deceaa0af internal/graphicsdriver/directx: specify DX level 12
The DirectX initialization passed but crashed later on some old machines
supporting the feature level 11 but not 12.

This change fixes the issue by changing the required feature level from
11 to 12 so that the initialization fails and OpenGL is used as the
fallback.

Closes #2447
2022-11-12 12:25:24 +09:00
Hajime Hoshi
303965e1a9 all: remove unnecessary copying
Copying []byte to string should copy the data if necessary, as the
Go specification assures that strings are immutable.
2022-11-11 00:28:47 +09:00
Hajime Hoshi
915fff96f8 all: reduce reflect usages 2022-11-09 13:24:31 +09:00
Hajime Hoshi
262ff351f4 internal/graphicsdriver/directx: bug fix: ScheduleFrameEventX might not return S_OK on Xbox One 2022-11-05 15:09:38 +09:00
Hajime Hoshi
a6e121613f internal/graphicsdriver/directx: bug fix: wrong SDK version for Xbox One 2022-11-05 02:31:28 +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
1ce29e2afa internal/graphicsdriver/directx: reduce rendering paths for even-odd rendering 2022-11-04 18:18:08 +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
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
2cf651bed8 internal/graphicsdriver/directx: resize the swap buffer chain at the end of a frame
Updates #2144
2022-10-25 00:35:09 +09:00
Hajime Hoshi
da5f5ea327 ebiten: add blend factors
Updates #2382
2022-10-18 00:21:13 +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
35e9f26681 internal/graphicsdriver/directx: refactoring 2022-10-15 12:16:41 +09:00
Hajime Hoshi
08e6f5af86 internal/graphicsdriver: remove FramebufferYDirection 2022-10-14 00:05:59 +09:00
Hajime Hoshi
080d936d42 internal/graphics: remove unused arguments from DrawTriangles
Updates #2369
2022-10-02 22:13:31 +09:00
Hajime Hoshi
a9574627e8 internal/graphicsdriver/directx: remove the built-in shaders
Updates #2369
2022-10-02 21:35:23 +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
8a7d860632 all: unify Windows error handlings for Windows HANDLE
Updates #2366
2022-10-02 02:22:06 +09:00
Hajime Hoshi
a9ba0db3d1 internal/glfwwin, internal/graphicsdriver/directx: bug fix: wrong error handlings for Windows HANDLE
Closes #2366
2022-10-02 01:57:24 +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
c7fcfe5bf7 internal/graphicsdriver/directx: refactoring
This makes more explicit that the pixels are sent after the slice
for the pixels finishes modification.
2022-09-19 00:31:44 +09:00
Hajime Hoshi
cfdf59ef8d internal/graphicsdriver/directx: revert changes to remove GetCopyableFootprints
This reverts these commits
* ccddd4ee20
* 8e40c2ce7e
* 2eb1efe3cc

Without GetCopyableFootprints, the test results on 32bit Windows seemed
much more flaky. This didn't fix the memory issue like #2294 anyway.
2022-09-19 00:26:59 +09:00
Hajime Hoshi
ccddd4ee20 internal/graphicsdriver/directx: refactoring: make the lifetime of uploadingStagingBuffer more explicit 2022-09-19 00:16:53 +09:00
Hajime Hoshi
8e40c2ce7e internal/graphicsdriver/directx: refactoring 2022-09-19 00:06:43 +09:00
Hajime Hoshi
2eb1efe3cc internal/graphicsdriver/directx: stop using GetCopyableFootprints
GetCopyableFootprints seems very conservative and returns a quite
big memory size. Instead of using the info from GetCopyableFootprints
let's use our own minimum footprint.
2022-09-18 23:10:15 +09:00
Hajime Hoshi
fccb43e15b internal/graphicsdriver/directx: remove .errcheck_excludes_windows
These DirectX functions don't return any value and should not affect
the last error. Then it should be fine to ignore the returning values
from syscall.Syscall*.

Updates #2287
2022-09-10 03:03:18 +09:00
Terra Brown
a1cc44833d
add errcheck static analysis (#2293)
Closes #2287
2022-09-10 01:52:46 +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
37bae461d1 internal/graphicsdriver/directx: bug fix: processtest failures
The command allocators should be reset only when the frame index was
updated.

Closes #2249
2022-09-02 12:48:06 +09:00
Hajime Hoshi
c126dea7fb Revert "internal/graphicsdriver/directx: bug fix: do not reset command allocators at Begin"
This reverts commit 9d303e8dc5.

Reason: A GPU memory leak (#2292). Though this reverting reveals the error #2249
again, a memory leak is more critical. Then revert the change once, and then
take time to investigate how to resolve #2249.

Closes #2292
Updates #2249
2022-09-02 02:27:40 +09:00
Hajime Hoshi
cdf83ad2fc internal/atlas: dispose images at ReadPixels
Without resolveDeferred() at ReadPixels, many images are never disposed
in tests.

Updates #2292
2022-09-01 23:54:57 +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
313c70f4b4 internal/graphicsdriver/directx: support 32bit Windows
Closes #2088
2022-08-28 00:04:55 +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
Hajime Hoshi
9d303e8dc5 internal/graphicsdriver/directx: bug fix: do not reset command allocators at Begin
Closes #2249
2022-08-17 22:37:26 +09:00
Hajime Hoshi
bb2df24f83 internal/graphicsdriver/directx: use DXGI_PRESENT_TEST when the screen is invisible
This change also reduces FPS to about 10 when the screen is invisible
in order to save CPU power.

Closes #2181
2022-08-17 00:10:44 +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
Hajime Hoshi
2aa595de52 Revert "internal/graphicsdriver/directx: bug fix: check the error at CreateGraphicsPipelineState at initialization"
This reverts commit c183555cc8.

Reason: this didn't help anything on the reporter's machine
2022-07-31 00:46:26 +09:00
Hajime Hoshi
c183555cc8 internal/graphicsdriver/directx: bug fix: check the error at CreateGraphicsPipelineState at initialization
CreateGraphicsPipelineState someitmes causes an error
DXGI_ERROR_DEVICE_HUNG, but we failed to know why.

Instead of fixing this, check the error earlier and use the fallback
grpahics library OpenGL in this case.

Updates #2198
2022-07-29 16:20:09 +09:00
Hajime Hoshi
9ea399e7cc internal/graphicsdriver/directx: typo 2022-07-20 01:24:08 +09:00
Hajime Hoshi
7025f195a7 internal/graphicsdriver/directx: check DirectX availability earlier for Wine
Closes #2114
2022-07-20 01:22:45 +09:00
Hajime Hoshi
e861080145 internal/graphicsdriver/directx: early error check for Wine
Updates #2114
2022-07-19 23:55:44 +09:00
Hajime Hoshi
f8acd5e7ee internal/graphicsdriver/directx: bug fix: D3D12CreateDevice could be called without creating a device 2022-07-19 03:22:46 +09:00
Hajime Hoshi
0f9ec45709 internal/graphicsdriver/directx: refactoring 2022-07-18 23:36:42 +09:00
Hajime Hoshi
b31ce0a568 internal/graphicsdriver/directx: update comments 2022-07-15 13:33:45 +09:00
Hajime Hoshi
b48c2aa103 internal/graphicsdriver/directx: bug fix: too many constant buffers could be allocated
Closes #2204
2022-07-15 03:40:24 +09:00
Hajime Hoshi
e3d025bf4f internal/graphicsdriver/directx: fix a wrong constant usage 2022-07-15 02:49:01 +09:00
Hajime Hoshi
8d74039617 internal/graphicsdriver/directx: increment numDescriptorsPerFrame
16 seems too conservative. Let's double it.

Updates #2188
2022-07-15 02:42:23 +09:00
Hajime Hoshi
9a35366380
internal/graphicsdriver/directx: batch ResourceBarrier commands (#2203)
Updates #2188
2022-07-15 02:34:38 +09:00
Hajime Hoshi
41edd98675 Revert "internal/graphicsdriver/directx: batch ExecuteCommandList"
This reverts commit f92107c2ee.

Reason: Performance regression

Updates #2188
2022-07-15 01:06:08 +09:00
Hajime Hoshi
f92107c2ee internal/graphicsdriver/directx: batch ExecuteCommandList
Updates #2188
2022-07-15 00:51:02 +09:00
Hajime Hoshi
82d31c5fb7 internal/graphicsdriver/directx: remove redundant resetting of allocators
Updates #2202
2022-07-15 00:13:28 +09:00
Hajime Hoshi
479483b76d internal/graphicsdriver/directx: bug fix: need to reset command allocators
Closes #2202
2022-07-14 21:21:55 +09:00