From fae2a4e28fc77f1d270ba0bd6ff6bc06c57d577e Mon Sep 17 00:00:00 2001 From: Danilo Date: Sun, 21 Jul 2024 20:37:16 -0300 Subject: [PATCH] Melhorias em GraphicsAdapter --- framework/platform-dx/adapter.cpp | 20 +++++++++++++------- inc/xna/graphics/adapter.hpp | 16 +--------------- inc/xna/xna-dx.hpp | 3 ++- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/framework/platform-dx/adapter.cpp b/framework/platform-dx/adapter.cpp index a736e4c..0c962be 100644 --- a/framework/platform-dx/adapter.cpp +++ b/framework/platform-dx/adapter.cpp @@ -1,6 +1,3 @@ -#include "xna/graphics/adapter.hpp" -#include "xna/graphics/displaymode.hpp" -#include "xna/game/gdevicemanager.hpp" #include "xna/xna-dx.hpp" namespace xna { @@ -92,6 +89,10 @@ namespace xna { SurfaceFormat& selectedFormat, DepthFormat& selectedDepthFormat, Int& selectedMultiSampleCount) const { + selectedFormat = format; + selectedDepthFormat = depthFormat; + selectedMultiSampleCount = multiSampleCount; + comptr pOutput = nullptr; if (impl->dxAdapter->EnumOutputs(0, pOutput.GetAddressOf()) != DXGI_ERROR_NOT_FOUND){ @@ -100,14 +101,19 @@ namespace xna { pOutput->QueryInterface(IID_IDXGIOutput1, (void**)pOutput1.GetAddressOf()); DXGI_MODE_DESC1 modeToMath{}; - modeToMath.Format = DxHelpers::SurfaceFormatToDx(format); + modeToMath.Format = DxHelpers::SurfaceFormatToDx(format); + + //If pConcernedDevice is NULL, the Format member of DXGI_MODE_DESC1 cannot be DXGI_FORMAT_UNKNOWN. + if (modeToMath.Format == DXGI_FORMAT_UNKNOWN) + return false; DXGI_MODE_DESC1 closestMath; - pOutput1->FindClosestMatchingMode1(&modeToMath, &closestMath, nullptr); + const auto hresult = pOutput1->FindClosestMatchingMode1(&modeToMath, &closestMath, nullptr); + + if FAILED(hresult) + return false; selectedFormat = DxHelpers::SurfaceFormatToXna(closestMath.Format); - selectedDepthFormat = depthFormat; - selectedMultiSampleCount = multiSampleCount; return selectedFormat == format; } diff --git a/inc/xna/graphics/adapter.hpp b/inc/xna/graphics/adapter.hpp index 30c9220..55f978e 100644 --- a/inc/xna/graphics/adapter.hpp +++ b/inc/xna/graphics/adapter.hpp @@ -73,21 +73,7 @@ namespace xna { SurfaceFormat& selectedFormat, DepthFormat& selectedDepthFormat, Int& selectedMultiSampleCount - ) const; - - //Queries the adapter for support for the requested render target format. - bool QueryRenderTargetFormat( - GraphicsProfile graphicsProfile, - SurfaceFormat format, - DepthFormat depthFormat, - Int multiSampleCount, - SurfaceFormat& selectedFormat, - DepthFormat& selectedDepthFormat, - Int& selectedMultiSampleCount - ) const { - return QueryBackBufferFormat(graphicsProfile, format, depthFormat, multiSampleCount, - selectedFormat, selectedDepthFormat, selectedMultiSampleCount); - } + ) const; private: String description; diff --git a/inc/xna/xna-dx.hpp b/inc/xna/xna-dx.hpp index 7a108dc..59242bf 100644 --- a/inc/xna/xna-dx.hpp +++ b/inc/xna/xna-dx.hpp @@ -362,7 +362,8 @@ namespace xna { static constexpr TextureAddressMode TextureAddresModeToXna(D3D11_TEXTURE_ADDRESS_MODE value) { return static_cast(value - 1); - } + } + }; struct PlatformInit {