1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Melhorias em GraphicsAdapter

This commit is contained in:
Danilo 2024-07-21 20:37:16 -03:00
parent f084bf54f9
commit fae2a4e28f
3 changed files with 16 additions and 23 deletions

View File

@ -1,6 +1,3 @@
#include "xna/graphics/adapter.hpp"
#include "xna/graphics/displaymode.hpp"
#include "xna/game/gdevicemanager.hpp"
#include "xna/xna-dx.hpp" #include "xna/xna-dx.hpp"
namespace xna { namespace xna {
@ -92,6 +89,10 @@ namespace xna {
SurfaceFormat& selectedFormat, DepthFormat& selectedDepthFormat, SurfaceFormat& selectedFormat, DepthFormat& selectedDepthFormat,
Int& selectedMultiSampleCount) const Int& selectedMultiSampleCount) const
{ {
selectedFormat = format;
selectedDepthFormat = depthFormat;
selectedMultiSampleCount = multiSampleCount;
comptr<IDXGIOutput> pOutput = nullptr; comptr<IDXGIOutput> pOutput = nullptr;
if (impl->dxAdapter->EnumOutputs(0, pOutput.GetAddressOf()) != DXGI_ERROR_NOT_FOUND){ if (impl->dxAdapter->EnumOutputs(0, pOutput.GetAddressOf()) != DXGI_ERROR_NOT_FOUND){
@ -100,14 +101,19 @@ namespace xna {
pOutput->QueryInterface(IID_IDXGIOutput1, (void**)pOutput1.GetAddressOf()); pOutput->QueryInterface(IID_IDXGIOutput1, (void**)pOutput1.GetAddressOf());
DXGI_MODE_DESC1 modeToMath{}; 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; 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); selectedFormat = DxHelpers::SurfaceFormatToXna(closestMath.Format);
selectedDepthFormat = depthFormat;
selectedMultiSampleCount = multiSampleCount;
return selectedFormat == format; return selectedFormat == format;
} }

View File

@ -73,21 +73,7 @@ namespace xna {
SurfaceFormat& selectedFormat, SurfaceFormat& selectedFormat,
DepthFormat& selectedDepthFormat, DepthFormat& selectedDepthFormat,
Int& selectedMultiSampleCount Int& selectedMultiSampleCount
) const; ) 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);
}
private: private:
String description; String description;

View File

@ -362,7 +362,8 @@ namespace xna {
static constexpr TextureAddressMode TextureAddresModeToXna(D3D11_TEXTURE_ADDRESS_MODE value) { static constexpr TextureAddressMode TextureAddresModeToXna(D3D11_TEXTURE_ADDRESS_MODE value) {
return static_cast<TextureAddressMode>(value - 1); return static_cast<TextureAddressMode>(value - 1);
} }
}; };
struct PlatformInit { struct PlatformInit {