From 62559f736600495441ea4309af05ef008581cfec Mon Sep 17 00:00:00 2001 From: cdozdil Date: Wed, 5 Jun 2024 21:57:23 +0300 Subject: [PATCH] casting fixes --- OptiScaler/NVNGX_DLSS_Dx12.cpp | 9 +++++++-- OptiScaler/backends/fsr2/FSR2Feature.h | 5 +++-- OptiScaler/bicubicscaling/BS_Dx12.cpp | 12 ++++++------ OptiScaler/imgui/imgui_common.h | 12 ++++++------ OptiScaler/imgui/imgui_overlay_vk.cpp | 2 +- OptiScaler/rcas/RCAS_Dx12.h | 4 ++-- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/OptiScaler/NVNGX_DLSS_Dx12.cpp b/OptiScaler/NVNGX_DLSS_Dx12.cpp index cc6afaa5..baad2797 100644 --- a/OptiScaler/NVNGX_DLSS_Dx12.cpp +++ b/OptiScaler/NVNGX_DLSS_Dx12.cpp @@ -167,7 +167,10 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_Ext(unsigned long long InApp spdlog::info("NVSDK_NGX_D3D12_Init_Ext AppId: {0}", InApplicationId); spdlog::info("NVSDK_NGX_D3D12_Init_Ext SDK: {0:x}", (unsigned int)InSDKVersion); appDataPath = InApplicationDataPath; - std::string str(appDataPath.begin(), appDataPath.end()); + + std::string str(appDataPath.length(), 0); + std::transform(appDataPath.begin(), appDataPath.end(), str.begin(), [](wchar_t c) { return (char)c; }); + spdlog::info("NVSDK_NGX_D3D12_Init_Ext InApplicationDataPath {0}", str); Config::Instance()->NVNGX_FeatureInfo_Paths.clear(); @@ -181,7 +184,9 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_Ext(unsigned long long InApp Config::Instance()->NVNGX_FeatureInfo_Paths.push_back(std::wstring(path)); std::wstring iniPathW(path); - std::string iniPath(iniPathW.begin(), iniPathW.end()); + + std::string iniPath(iniPathW.length(), 0); + std::transform(iniPathW.begin(), iniPathW.end(), iniPath.begin(), [](wchar_t c) { return (char)c; }); spdlog::debug("NVSDK_NGX_D3D12_Init_Ext PathListInfo[{1}] checking nvngx.ini file in: {0}", iniPath, i); diff --git a/OptiScaler/backends/fsr2/FSR2Feature.h b/OptiScaler/backends/fsr2/FSR2Feature.h index bbd7ccc3..e7347369 100644 --- a/OptiScaler/backends/fsr2/FSR2Feature.h +++ b/OptiScaler/backends/fsr2/FSR2Feature.h @@ -27,10 +27,11 @@ inline static std::string ResultToString(FfxErrorCode result) } } -inline void FfxLogCallback(FfxFsr2MsgType type, const wchar_t* message) +inline static void FfxLogCallback(FfxFsr2MsgType type, const wchar_t* message) { std::wstring string(message); - std::string str(string.begin(), string.end()); + std::string str(string.length(), 0); + std::transform(string.begin(), string.end(), str.begin(), [](wchar_t c) { return (char)c; }); //if (type == FFX_FSR2_MESSAGE_TYPE_ERROR) // spdlog::error("FSR2Feature::LogCallback FSR Runtime: {0}", str); diff --git a/OptiScaler/bicubicscaling/BS_Dx12.cpp b/OptiScaler/bicubicscaling/BS_Dx12.cpp index 8808a286..e428c27c 100644 --- a/OptiScaler/bicubicscaling/BS_Dx12.cpp +++ b/OptiScaler/bicubicscaling/BS_Dx12.cpp @@ -174,10 +174,10 @@ bool BS_Dx12::Dispatch(ID3D12Device* InDevice, ID3D12GraphicsCommandList* InCmdL InDevice->CreateUnorderedAccessView(OutResource, nullptr, &uavDesc, _cpuUavHandle[_counter]); // Create CBV for Constants - Constants constants; - constants.srcWidth = inDesc.Width; + Constants constants{}; + constants.srcWidth = static_cast(inDesc.Width); constants.srcHeight = inDesc.Height; - constants.destWidth = outDesc.Width; + constants.destWidth = static_cast(outDesc.Width); constants.destHeight = outDesc.Height; // Copy the updated constant buffer data to the constant buffer resource @@ -208,12 +208,12 @@ bool BS_Dx12::Dispatch(ID3D12Device* InDevice, ID3D12GraphicsCommandList* InCmdL if (_upsample) { - dispatchWidth = (outDesc.Width + InNumThreadsX - 1) / InNumThreadsX; + dispatchWidth = static_cast((outDesc.Width + InNumThreadsX - 1) / InNumThreadsX); dispatchHeight = (outDesc.Height + InNumThreadsY - 1) / InNumThreadsY; } else { - dispatchWidth = (inDesc.Width + InNumThreadsX - 1) / InNumThreadsX; + dispatchWidth = static_cast((inDesc.Width + InNumThreadsX - 1) / InNumThreadsX); dispatchHeight = (inDesc.Height + InNumThreadsY - 1) / InNumThreadsY; } @@ -335,7 +335,7 @@ BS_Dx12::BS_Dx12(std::string InName, ID3D12Device* InDevice, bool InUpsample) : // Compile shader blobs ID3DBlob* _recEncodeShader = CompileShader(_upsample ? upsampleCode.c_str() : downsampleCode.c_str(), "CSMain", "cs_5_0"); - + if (_recEncodeShader == nullptr) { spdlog::error("CS_Dx12::CS_Dx12 [{0}] CompileShader error!", _name); diff --git a/OptiScaler/imgui/imgui_common.h b/OptiScaler/imgui/imgui_common.h index ed1bc772..288d2ccc 100644 --- a/OptiScaler/imgui/imgui_common.h +++ b/OptiScaler/imgui/imgui_common.h @@ -425,7 +425,7 @@ private: { if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) { - spdlog::trace("WndProc ImGui handled, hWnd:{0:X} msg:{1:X} wParam:{2:X} lParam:{3:X}", (unsigned long)hWnd, msg, (unsigned long)wParam, (unsigned long)lParam); + spdlog::trace("WndProc ImGui handled, hWnd:{0:X} msg:{1:X} wParam:{2:X} lParam:{3:X}", (ULONG64)hWnd, msg, (ULONG64)wParam, (ULONG64)lParam); return TRUE; } @@ -489,7 +489,7 @@ private: case WM_XBUTTONDOWN: case WM_XBUTTONUP: case WM_XBUTTONDBLCLK: - spdlog::trace("WndProc switch handled, hWnd:{0:X} msg:{1:X} wParam:{2:X} lParam:{3:X}", (unsigned long)hWnd, msg, (unsigned long)wParam, (unsigned long)lParam); + spdlog::trace("WndProc switch handled, hWnd:{0:X} msg:{1:X} wParam:{2:X} lParam:{3:X}", (ULONG64)hWnd, msg, (ULONG64)wParam, (ULONG64)lParam); return TRUE; case WM_INPUT: @@ -516,7 +516,7 @@ private: } else - spdlog::trace("WndProc WM_INPUT hWnd:{0:X} msg:{1:X} wParam:{2:X} lParam:{3:X}", (unsigned long)hWnd, msg, (unsigned long)wParam, (unsigned long)lParam); + spdlog::trace("WndProc WM_INPUT hWnd:{0:X} msg:{1:X} wParam:{2:X} lParam:{3:X}", (ULONG64)hWnd, msg, (ULONG64)wParam, (ULONG64)lParam); return TRUE; @@ -1432,7 +1432,7 @@ public: if (_displayWidth == 0) { _displayWidth = Config::Instance()->CurrentFeature->DisplayWidth(); - _renderWidth = _displayWidth / 3.0; + _renderWidth = _displayWidth / 3.0f; _mipmapUpscalerQuality = 0; _mipmapUpscalerRatio = 3.0f; _mipBiasCalculated = log2((float)_renderWidth / (float)_displayWidth); @@ -1556,7 +1556,7 @@ public: _isVisible = false; _isResetRequested = false; - spdlog::debug("ImGuiCommon::Init Handle: {0:X}", (unsigned long)_handle); + spdlog::debug("ImGuiCommon::Init Handle: {0:X}", (ULONG64)_handle); // Setup Dear ImGui context IMGUI_CHECKVERSION(); @@ -1580,7 +1580,7 @@ public: if (_oWndProc == nullptr) _oWndProc = (WNDPROC)SetWindowLongPtr(InHwnd, GWLP_WNDPROC, (LONG_PTR)WndProc); - spdlog::debug("ImGuiCommon::Init _oWndProc: {0:X}", (unsigned long)_oWndProc); + spdlog::debug("ImGuiCommon::Init _oWndProc: {0:X}", (ULONG64)_oWndProc); if (!pfn_SetCursorPos_hooked) diff --git a/OptiScaler/imgui/imgui_overlay_vk.cpp b/OptiScaler/imgui/imgui_overlay_vk.cpp index b51c287a..c694b7fb 100644 --- a/OptiScaler/imgui/imgui_overlay_vk.cpp +++ b/OptiScaler/imgui/imgui_overlay_vk.cpp @@ -489,7 +489,7 @@ void ImGuiOverlayVk::ReInitVk(HWND InNewHwnd) if (!_isInited || !g_bInitialized) return; - spdlog::debug("ImGuiOverlayVk::ReInitVk hwnd: {0:X}", (unsigned long)InNewHwnd); + spdlog::debug("ImGuiOverlayVk::ReInitVk hwnd: {0:X}", (UINT64)InNewHwnd); ImGui_ImplVulkan_Shutdown(); ImGuiOverlayBase::Shutdown(); diff --git a/OptiScaler/rcas/RCAS_Dx12.h b/OptiScaler/rcas/RCAS_Dx12.h index 1b3e8912..1abde536 100644 --- a/OptiScaler/rcas/RCAS_Dx12.h +++ b/OptiScaler/rcas/RCAS_Dx12.h @@ -51,8 +51,8 @@ private: ID3D12Resource* _constantBuffer = nullptr; D3D12_RESOURCE_STATES _bufferState = D3D12_RESOURCE_STATE_COMMON; - uint32_t InNumThreadsX = 32; - uint32_t InNumThreadsY = 32; + UINT InNumThreadsX = 32; + UINT InNumThreadsY = 32; public: bool CreateBufferResource(ID3D12Device* InDevice, ID3D12Resource* InSource, D3D12_RESOURCE_STATES InState);