Commit Graph

603 Commits

Author SHA1 Message Date
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
Hajime Hoshi
b3267a7126 internal/graphicsdriver/directx: bug fix: wrong offsets
* Wrong offsets were speicified when creating a constant buffer view and
  a shader resource view.
* Wrong root descriptor tables were speicified. For one draw command,
  one descriptor table for a constant buffer and textures should be used.

Updates #2198
Closes #2201
2022-07-14 03:01:40 +09:00
Hajime Hoshi
42d5d91829 internal/graphicsdriver/directx: unmap constant buffers appropriately
Updates #2198
2022-07-14 01:54:34 +09:00
Hajime Hoshi
6f182d1124 internal/graphicsdriver/directx: fix a suspicious error chceck 2022-07-14 01:45:21 +09:00
Hajime Hoshi
16ff5c5039 internal/shaderir: change the naming convention: Num -> Count 2022-07-13 02:02:48 +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
b27b7ec483 internal/graphicsdriver/directx: use CreateEventEx to follow the official example 2022-07-10 22:44:40 +09:00
Hajime Hoshi
4c121ae5eb internal/graphicsdriver/directx: bug fix: a wrong fence value was passed to SetEventOnCompletion 2022-07-10 22:24:39 +09:00
Hajime Hoshi
a22125a075 internal/graphicsdriver/directx: bug fix: ResizeBuffers failed without the flag
Closes #2193
2022-07-10 19:55:28 +09:00
Hajime Hoshi
bf0f3d304b internal/graphicsdriver/directx: add optimization flag to D3DCompile
Updates #2034
Updates #2188
2022-07-10 02:55:16 +09:00
Hajime Hoshi
0035ba0bd1 internal/graphicsdriver/directx: allow tearing when vsync is off
Updates #2034
Updates #2188
2022-07-10 01:17:36 +09:00
Hajime Hoshi
a32a137fa8 internal/graphicsdriver/directx: skip unnecessary flushing commands
Updates #2034
Updates #2188
2022-07-10 00:24:14 +09:00
Hajime Hoshi
55c7a2df6c internal/graphicsdriver/opengl/gl: bug fix: wrong build tags 2022-07-09 16:15:56 +09:00
Hajime Hoshi
28fd3ec9e5 add the ebitengine version build tags besides the ebiten version
Closes #2111
Updates #2190
2022-07-09 15:38:03 +09:00
Hajime Hoshi
428b1263d9 add ebitenginecbackend build tag besides ebitencbackend
Updates #2111
Updates #2190
2022-07-09 15:23:52 +09:00
Hajime Hoshi
204fb5935b add new environment variables with the EBITENGINE_ suffix
Updates #2111
Updates #2190
2022-07-09 15:00:28 +09:00
Hajime Hoshi
3d5031571d internal/graphicsdriver/directx: add the original source at D3DCompile errors 2022-07-09 01:59:51 +09:00
Hajime Hoshi
8522bfd0bf internal/graphicscommand: bug fix: replacePixelsCommand should not read pixels
Reading pixels, writing pixels, and using the image as a source might
cause a flaky behavior with Metal. Stop reading pixels if possible.

Closes #2180
2022-07-05 23:30:26 +09:00
Hajime Hoshi
47c65a92ae internal/graphicsdriver/directx: bug fix: ignore DXGI_STATUS_OCCLUDED
When a screen is locked, an Ebitengine application crashed as the
swap chain's Present returned DXGI_STATUS_OCCLUDED.

Let's ignore the error and continue to run the applications. In the
ideal world, an application should stop running during the screen lock,
so let's revisit this later.

This fix also fixes the issue that a Win32API GetCursorPos returned
an error ERROR_ACCESS_DENIED when the screen was locked.

Closes #2179
2022-07-04 12:55:36 +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
712940cb02 internal/graphicsdriver/directx: bug fix: leave mapped regions for constant buffers
Mapping for a constant buffer every frame might sometimes fails. We
are not sure the reason, but in the official examples, leaving mapped
regoins seems the way to go.

Updates #2084
Closes #2157
2022-06-23 17:09:46 +09:00
Hajime Hoshi
c93cecdc2b internal/graphicsdriver/directx: accept S_FALSE at ScheduleFrameEventX 2022-06-22 02:13:32 +09:00
Hajime Hoshi
7b05e59000 internal/graphicsdriver/directx: bug fix: wrong GUID for IDXGIDevice 2022-06-22 01:59:22 +09:00
Hajime Hoshi
8311ff1e46 internal/graphicsdriver/directx: bug fix: wrong pointer usage 2022-06-22 01:49:23 +09:00
Hajime Hoshi
7e92b79a00 internal/graphicsdriver/directx: implement swap chains for Xbox
Updates #2084
2022-06-21 12:21:00 +09:00
Hajime Hoshi
a641f9ede0 internal/graphicsdriver/directx: refactoring 2022-06-20 23:40:53 +09:00
Hajime Hoshi
969e87fb89 internal/graphicsdriver/directx: fix moveToNextFrame for Xbox
Updates #2084
2022-06-20 00:41:34 +09:00
Hajime Hoshi
f8e9dcf035 internal/graphicsdriver/directx: refactoring 2022-06-19 17:58:04 +09:00
Hajime Hoshi
08c8c8089a internal/graphicsdriver/directx: bug fix: clear constant buffers at the end of DrawTriangles
Constant buffers should not be reset while a stencil buffer is used.

Closes #2138
2022-06-19 17:13:34 +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
667bf2ff9d internal/graphicsdriver/directx: refactoring 2022-06-19 01:44:31 +09:00
Hajime Hoshi
2a5b64bf4d internal/graphicsdriver/directx: suppress warnings for depth buffers
Updates #2138
2022-06-19 00:21:04 +09:00
Hajime Hoshi
81b3d7bfac internal/graphicsdriver/directx: add an assertion 2022-06-18 22:33:07 +09:00
Hajime Hoshi
f7a108e693 internal/graphicsdriver/directx: refactoring 2022-06-18 21:53:41 +09:00
Hajime Hoshi
b71a4975dd internal/graphicsdriver/directx: bug fix: wrong state transitions at screen images
This change fixes the following issues:
 * There should be two resource states for presenting targets, so an image
   for the screen must have two resource states, though it had only one
   in the current implementation.
 * At removeImage, the screen image was removed unexpectedly.

Updates #2081
Closes #2151
2022-06-18 19:01:59 +09:00
Hajime Hoshi
522660c1f9 internal/graphicsdriver/directx: fix fence usages
Updates #2034
Updates #2138
Updates #2149
2022-06-18 15:44:54 +09:00
Hajime Hoshi
e78d888b24 internal/graphicsdriver/directx: handle error at Signal 2022-06-18 02:53:12 +09:00
Hajime Hoshi
0c38d6faeb internal/graphicsdriver/directx: add comment about frames
Updates #2034
2022-06-18 01:18:49 +09:00
Hajime Hoshi
a16ffef499 internal/graphicsdriver/directx: update frameIndex at present
This follows the official GDK samples.
2022-06-18 01:09:54 +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
b43312fe80 internal/graphicsdriver/directx: add comments
Updates #2142
2022-06-17 12:19:36 +09:00
Hajime Hoshi
2f84e77e74 internal/graphicsdriver/directx: fallback to OpenGL when initialization fails
Closes #2142
2022-06-17 12:12:44 +09:00
Hajime Hoshi
9962fc5ee5 internal/graphicsdriver/direct: replace Get -> NewGraphics
Updates #2142
2022-06-17 11:48:40 +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
a6d415ebf2
internal/graphicsdriver/opengl: replace Get with NewGraphics (#2146)
This is a prepartion to return an error when a graphics driver, especially
DirectX, fails to initialize.

Updates #2142
2022-06-17 02:02:29 +09:00
Hajime Hoshi
195b060911 internal/graphicsdriver/metal: refactoring: initialize the driver at Get 2022-06-16 23:52:55 +09:00
Hajime Hoshi
76d88b276a internal/graphicsdriver/directx: call C++ side for ID3D12GraphicsCommandList functions
Updates #2084
2022-06-13 22:35:58 +09:00
Hajime Hoshi
4aebcd2a04 internal/graphicsdriver/directx: bug fix: consider empty slices as arguments 2022-06-13 17:51:02 +09:00
Hajime Hoshi
c08d79d2ce internal/graphicsdriver/directx: keep runtime.KeepAlive for Xbox 2022-06-13 17:36:58 +09:00
Hajime Hoshi
4adf46c2b0 internal/graphicsdriver/directx: refactoring 2022-06-13 17:25:27 +09:00
Hajime Hoshi
348435f769 internal/graphicsdriver/directx: fix a constant value for Xbox
Updates #2084
2022-06-13 14:23:29 +09:00
Hajime Hoshi
aef5402831 internal/graphicsdriver/directx: remove unused function 2022-06-13 01:35:31 +09:00
Hajime Hoshi
bcb2fe8c93 internal/graphicsdriver/directx: enable D3D12SerializeRootSignature for Xbox
Updates #2084
2022-06-13 01:02:48 +09:00
Hajime Hoshi
08b52698c6 internal/graphicsdriver/directx: call C++ side for some functions for Xbox
Updates #2084
2022-06-11 19:37:17 +09:00
Hajime Hoshi
4a19d645b7 internal/graphicsdriver/opengl: remove a comment 2022-06-11 15:36:10 +09:00
Hajime Hoshi
71a32d2036 internal/ui: pass the canvas element directly instead of an ID 2022-06-11 15:34:17 +09:00
Hajime Hoshi
95628ee5f7 internal/ui: add a unique ID to the canvas for browsers 2022-06-11 15:24:50 +09:00
Hajime Hoshi
d42bb7d699 internal/graphicsdriver/directx: add a comment for Xbox
Updates #2084
2022-06-11 14:20:21 +09:00
Hajime Hoshi
826afcb9cc internal/graphicsdriver/directx: fix CopyTextureRegion for Xbox
Updates #2084
2022-06-10 22:51:04 +09:00
Hajime Hoshi
abef203a70 rename github.com/ebitne/purego -> github.com/ebitengine/purego 2022-06-10 21:59:01 +09:00
Hajime Hoshi
07aa906753 internal/graphicsdriver/directx: fix GetCPU/GPUDescriptorHandleForHeapStart for Xbox
Updates #2084
2022-06-10 21:35:20 +09:00
Hajime Hoshi
b9373c498b internal/graphicsdriver/directx: fix CreateCommandList for Xbox
Updates #2084
2022-06-10 16:44:07 +09:00
Hajime Hoshi
6ce8f77c53 gofmt 2022-06-06 00:28:19 +09:00
Hajime Hoshi
0256b0cfbf internal/graphicsdriver/directx: bug fix: disable fullscreen by Alt+Enter
By default, DirectX 12 tries to make the window fullscreen by Alt+Enter.
This caused application crashes. Let's disable this feature.

Closes #2123
2022-06-05 16:16:09 +09:00
Hajime Hoshi
d518e64e22 Revert "internal/graphicsdriver/directx: refactoring: add syscallN"
This reverts commit 55a490736a.

Reason: This has a potential risk of stack overflow.

Closes #2120
2022-06-04 13:58:01 +09:00
Hajime Hoshi
f69c550992 internal/graphicsdriver/directx: bug fix: go:nosplit was required for syscallN
Updates #2116
Closes #2117
2022-06-04 01:11:22 +09:00
Hajime Hoshi
55a490736a internal/graphicsdriver/directx: refactoring: add syscallN
syscall.SyscallN is available as of Go 1.18 so this change implemented
our original syscallN function.

syscallN also panics when a given function pointer is 0. This helps
debugging especially on Xbox.

Updates #2084
2022-06-03 21:56:34 +09:00
Hajime Hoshi
3e1b313221 internal/graphicsdriver/directx: bug fix: ID3D12Resource::Map sometimes retrying
Updates #2113
Closes #2116
2022-06-03 21:56:30 +09:00
Hajime Hoshi
532b476c4e Revert "internal/graphicsdriver/directx: pass nil for pReadRange at Map"
This reverts commit 3b13158cc0.

Reason: Specifying nil for reading ranges is not efficient
2022-06-03 13:59:34 +09:00
Hajime Hoshi
3b13158cc0 internal/graphicsdriver/directx: pass nil for pReadRange at Map
Updates #2113
2022-06-03 13:45:08 +09:00
Hajime Hoshi
c29c423686 internal/glfwwin, internal/graphicsdriver/directx: bug fix: HRESULT and Errno are imcompatible 2022-06-03 00:41:04 +09:00
Hajime Hoshi
4a9caf8afb internal/graphicsdriver/directx: ignore higher 32bit values for Errno
Updates #2113
2022-06-02 23:01:38 +09:00
Hajime Hoshi
fb03a1e351 internal/graphicsdriver/directx: bug fix: ID3D12Resource::Unmap does not return an value
Updates #2113
2022-06-02 12:52:58 +09:00
Hajime Hoshi
4a684c4195 treat Windows error values as uint32 instead of windows.Handle
The error value are defined as windows.Handle (64bit) in
golang.org/x/sys/windows, but an actual type should be HRESULT (32bit).
This causes an issue that a returning value from a Windows API was
recognized as a non-zero error value though the value was not an error,
when the value's lower 32-bits are all zero.

See also https://github.com/golang/go/issues/48736#issuecomment-1143993096

Updates #2113
2022-06-02 12:10:21 +09:00
Hajime Hoshi
b900f83a01 internal/graphicsdriver/directx: refactoring: remove an unused member Image.numRows 2022-06-02 01:53:27 +09:00
Hajime Hoshi
0dc6e4e64e internal/graphicsdriver/directx: use ID3D12Resource instead of ID3D12Resource1
Updates #2114
2022-06-02 01:26:02 +09:00
Hajime Hoshi
c99b948df3 internal/graphicsdriver/directx: refactoring
Updates #2084
2022-05-30 03:17:15 +09:00
Hajime Hoshi
d4226659ee internal/graphicsdriver/directx: initialize a device for Xbox
Updates #1162
2022-05-30 02:10:18 +09:00
Hajime Hoshi
59798d29f4 internal/graphicsdriver/directx: defer the initialization 2022-05-29 22:02:39 +09:00
Hajime Hoshi
b4491ab94d internal/graphicsdriver/directx: unify the naming convention with glfwwin 2022-05-29 21:18:23 +09:00
Hajime Hoshi
0081fa7a47 internal/graphicsdriver/directx: add a comment 2022-05-29 20:05:37 +09:00
Hajime Hoshi
ad380a32f4 internal/glfwwin: split GDK part to a new package internal/microsoftgdk
Updates #1162
2022-05-29 19:25:26 +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
d577cc5e7d internal/graphicsdriver/opengl/gl: rename files
Updates #1162
2022-05-27 18:31:40 +09:00
TotallyGamerJet
726e88e520
internal/graphics/opengl/gl: remove CGO in openGL on macOS (#2104)
Updates #1162
2022-05-27 18:26:53 +09:00
Hajime Hoshi
7030840efa internal/graphicsdriver/opengl/gl: refactoring 2022-05-25 02:24:40 +09:00
Hajime Hoshi
3745c0a2e0 internal/graphicsdriver/opengl/gl: remove an unused function GetBufferSubData
This is basically a revert of 86a0c7aa82
2022-05-24 20:45:45 +09:00
Hajime Hoshi
a1370a4791 internal/graphicsdriver/opengl: remove an unused member gl.getBufferSubData 2022-05-24 20:40:53 +09:00