diff --git a/framework/platform-dx/adapter.cpp b/framework/platform-dx/adapter.cpp index d74932b..a736e4c 100644 --- a/framework/platform-dx/adapter.cpp +++ b/framework/platform-dx/adapter.cpp @@ -86,6 +86,35 @@ namespace xna { } } + bool GraphicsAdapter::QueryBackBufferFormat( + GraphicsProfile graphicsProfile, SurfaceFormat format, + DepthFormat depthFormat, Int multiSampleCount, + SurfaceFormat& selectedFormat, DepthFormat& selectedDepthFormat, + Int& selectedMultiSampleCount) const + { + comptr pOutput = nullptr; + + if (impl->dxAdapter->EnumOutputs(0, pOutput.GetAddressOf()) != DXGI_ERROR_NOT_FOUND){ + comptr pOutput1 = nullptr; + + pOutput->QueryInterface(IID_IDXGIOutput1, (void**)pOutput1.GetAddressOf()); + + DXGI_MODE_DESC1 modeToMath{}; + modeToMath.Format = DxHelpers::SurfaceFormatToDx(format); + + DXGI_MODE_DESC1 closestMath; + pOutput1->FindClosestMatchingMode1(&modeToMath, &closestMath, nullptr); + + selectedFormat = DxHelpers::SurfaceFormatToXna(closestMath.Format); + selectedDepthFormat = depthFormat; + selectedMultiSampleCount = multiSampleCount; + + return selectedFormat == format; + } + + return false; + } + //INTERNAL FUNCTIONS sptr getSupportedDisplayModes(comptr& dxAdapter) { diff --git a/inc/xna/enumerations.hpp b/inc/xna/enumerations.hpp index bb007e0..17f1471 100644 --- a/inc/xna/enumerations.hpp +++ b/inc/xna/enumerations.hpp @@ -255,8 +255,12 @@ namespace xna { None, }; + //Identifies the set of supported devices for the game based on device capabilities. enum class GraphicsProfile { + //Use a limited set of graphic features and capabilities, allowing the game to support the widest variety of devices, including all Windows-based computers. Reach, + //Use the largest available set of graphic features and capabilities to target devices, + //such as an Xbox 360 console and a Windows-based computer, that have more enhanced graphic capabilities. HiDef }; diff --git a/inc/xna/graphics/adapter.hpp b/inc/xna/graphics/adapter.hpp index b44d678..30c9220 100644 --- a/inc/xna/graphics/adapter.hpp +++ b/inc/xna/graphics/adapter.hpp @@ -48,11 +48,21 @@ namespace xna { //Retrieves a value used to identify the manufacturer. constexpr Uint VendorId() const { return vendorId; } + + //Gets or sets a NULL device. + static bool UseNullDevice() { return useNullDevice; } + //Gets or sets a NULL device. + static void UseNullDevice(bool value) { useNullDevice = value; } + + //Gets or sets a reference device. + constexpr static bool UseReferenceDevice() { return useReferenceDevice; } + //Gets or sets a reference device. + constexpr static void UseReferenceDevice(bool value) { useReferenceDevice = value; } //Tests to see if the adapter supports the requested profile. bool IsProfileSupported(GraphicsProfile graphicsProfile) { - return false; - } + return true; + } //Queries the adapter for support for the requested back buffer format. bool QueryBackBufferFormat( @@ -63,9 +73,7 @@ namespace xna { SurfaceFormat& selectedFormat, DepthFormat& selectedDepthFormat, Int& selectedMultiSampleCount - ) { - return false; - } + ) const; //Queries the adapter for support for the requested render target format. bool QueryRenderTargetFormat( @@ -75,9 +83,10 @@ namespace xna { Int multiSampleCount, SurfaceFormat& selectedFormat, DepthFormat& selectedDepthFormat, - int& selectedMultiSampleCount - ) { - return false; + Int& selectedMultiSampleCount + ) const { + return QueryBackBufferFormat(graphicsProfile, format, depthFormat, multiSampleCount, + selectedFormat, selectedDepthFormat, selectedMultiSampleCount); } private: @@ -92,6 +101,9 @@ namespace xna { sptr currentDisplayMode{ nullptr }; sptr supportedDisplayModes{ nullptr }; + inline static bool useNullDevice = false; + inline static bool useReferenceDevice = false; + GraphicsAdapter(); public: