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

Implementa QueryBackBufferFormat

This commit is contained in:
Danilo 2024-07-20 23:44:10 -03:00
parent 8ffbabc2d1
commit f084bf54f9
3 changed files with 53 additions and 8 deletions

View File

@ -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<IDXGIOutput> pOutput = nullptr;
if (impl->dxAdapter->EnumOutputs(0, pOutput.GetAddressOf()) != DXGI_ERROR_NOT_FOUND){
comptr<IDXGIOutput1> 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<DisplayModeCollection> getSupportedDisplayModes(comptr<IDXGIAdapter1>& dxAdapter) {

View File

@ -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
};

View File

@ -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<DisplayMode> currentDisplayMode{ nullptr };
sptr<DisplayModeCollection> supportedDisplayModes{ nullptr };
inline static bool useNullDevice = false;
inline static bool useReferenceDevice = false;
GraphicsAdapter();
public: