From a6e121613ffa61640ec25a45c3da4a7f88542bc0 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 5 Nov 2022 02:31:28 +0900 Subject: [PATCH] internal/graphicsdriver/directx: bug fix: wrong SDK version for Xbox One --- internal/graphicsdriver/directx/api_windows.go | 3 --- internal/graphicsdriver/directx/graphics_windows.go | 2 +- internal/microsoftgdk/microsoftgdk_windows.go | 11 +++++++++++ internal/microsoftgdk/notmicrosoftgdk.go | 4 ++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/graphicsdriver/directx/api_windows.go b/internal/graphicsdriver/directx/api_windows.go index edf9bf505..1d54d197b 100644 --- a/internal/graphicsdriver/directx/api_windows.go +++ b/internal/graphicsdriver/directx/api_windows.go @@ -62,9 +62,6 @@ const ( _D3D12_MIN_DEPTH = 0.0 _D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION = 16384 _D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES = 0xffffffff - _D3D12_SDK_VERSION = (_D3D12_SDK_VERSION_MAJOR << 16) | _D3D12_SDK_VERSION_MINOR - _D3D12_SDK_VERSION_MAJOR = 2 - _D3D12_SDK_VERSION_MINOR = 4 _D3D12XBOX_DEFAULT_SIZE_BYTES = 0xffffffff ) diff --git a/internal/graphicsdriver/directx/graphics_windows.go b/internal/graphicsdriver/directx/graphics_windows.go index 3b994da27..8a2f2bc85 100644 --- a/internal/graphicsdriver/directx/graphics_windows.go +++ b/internal/graphicsdriver/directx/graphics_windows.go @@ -303,7 +303,7 @@ func (g *Graphics) initializeXbox(useWARP bool, useDebugLayer bool) (ferr error) } params := &_D3D12XBOX_CREATE_DEVICE_PARAMETERS{ - Version: _D3D12_SDK_VERSION, // TODO: Can we always use the same value? + Version: microsoftgdk.D3D12SDKVersion(), GraphicsCommandQueueRingSizeBytes: _D3D12XBOX_DEFAULT_SIZE_BYTES, GraphicsScratchMemorySizeBytes: _D3D12XBOX_DEFAULT_SIZE_BYTES, ComputeScratchMemorySizeBytes: _D3D12XBOX_DEFAULT_SIZE_BYTES, diff --git a/internal/microsoftgdk/microsoftgdk_windows.go b/internal/microsoftgdk/microsoftgdk_windows.go index 470e57585..163417585 100644 --- a/internal/microsoftgdk/microsoftgdk_windows.go +++ b/internal/microsoftgdk/microsoftgdk_windows.go @@ -87,6 +87,17 @@ func D3D12DLLName() string { } } +func D3D12SDKVersion() uint32 { + switch C.XSystemGetDeviceType() { + case _XSystemDeviceType_XboxOne, _XSystemDeviceType_XboxOneS, _XSystemDeviceType_XboxOneX, _XSystemDeviceType_XboxOneXDevkit: + return (1 << 16) | 10 + case _XSystemDeviceType_XboxScarlettLockhart, _XSystemDeviceType_XboxScarlettAnaconda, _XSystemDeviceType_XboxScarlettDevkit: + return (2 << 16) | 4 + default: + return 0 + } +} + func init() { if r := C.XGameRuntimeInitialize(); uint32(r) != uint32(windows.S_OK) { panic(fmt.Sprintf("microsoftgdk: XSystemGetDeviceType failed: HRESULT(%d)", uint32(r))) diff --git a/internal/microsoftgdk/notmicrosoftgdk.go b/internal/microsoftgdk/notmicrosoftgdk.go index e5b0b323e..17cd17f45 100644 --- a/internal/microsoftgdk/notmicrosoftgdk.go +++ b/internal/microsoftgdk/notmicrosoftgdk.go @@ -27,3 +27,7 @@ func MonitorResolution() (int, int) { func D3D12DLLName() string { return "" } + +func D3D12SDKVersion() uint32 { + return 0 +}