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

Corrige GraphicsAdapter

This commit is contained in:
Danilo 2024-05-19 17:52:27 -03:00
parent 7af70b394f
commit ffeb668adc
11 changed files with 195 additions and 208 deletions

@ -1,11 +1,22 @@
#include "platform-dx/adapter-dx.hpp"
#include "platform-dx/gdevicemanager-dx.hpp"
#include "platform-dx/implementations.hpp"
#include "graphics/adapter.hpp"
#include "platform-dx/displaymode-dx.hpp"
#include "platform-dx/dxheaders.hpp"
namespace xna {
static size_t getDisplayModesCount(IDXGIAdapter* adapter);
static uptr<DisplayModeCollection> createDisplayModeCollection(std::vector<DXGI_MODE_DESC> const& source);
uptr<GraphicsAdapter> IGraphicsAdapter::DefaultAdapter() {
GraphicsAdapter::GraphicsAdapter() {
impl = uNew<PlatformImplementation>();
}
GraphicsAdapter::~GraphicsAdapter() {
impl = nullptr;
}
uptr<GraphicsAdapter> GraphicsAdapter::DefaultAdapter() {
IDXGIFactory1* pFactory = nullptr;
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory))
@ -16,8 +27,8 @@ namespace xna {
if (pFactory->EnumAdapters1(0, &pAdapter) != DXGI_ERROR_NOT_FOUND) {
auto adp = uNew<GraphicsAdapter>();
adp->_index = 0;
adp->dxadapter = pAdapter;
adp->impl->_index = 0;
adp->impl->dxadapter = pAdapter;
return adp;
}
@ -28,7 +39,7 @@ namespace xna {
return nullptr;
}
void IGraphicsAdapter::Adapters(std::vector<sptr<GraphicsAdapter>>& adapters){
void GraphicsAdapter::Adapters(std::vector<sptr<GraphicsAdapter>>& adapters){
IDXGIFactory1* pFactory = nullptr;
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory))
@ -40,8 +51,8 @@ namespace xna {
for (; pFactory->EnumAdapters1(count, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++count) {
auto adp = New<GraphicsAdapter>();
adp->_index = count;
adp->dxadapter = pAdapter;
adp->impl->_index = count;
adp->impl->dxadapter = pAdapter;
adapters.push_back(adp);
}
@ -50,7 +61,7 @@ namespace xna {
pFactory = nullptr;
}
void IGraphicsAdapter::Adapters(std::vector<uptr<GraphicsAdapter>>& adapters) {
void GraphicsAdapter::Adapters(std::vector<uptr<GraphicsAdapter>>& adapters) {
IDXGIFactory1* pFactory = nullptr;
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory))
@ -62,41 +73,41 @@ namespace xna {
for (; pFactory->EnumAdapters1(count, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++count) {
auto adp = uNew<GraphicsAdapter>();
adp->_index = count;
adp->dxadapter = pAdapter;
adp->impl->_index = count;
adp->impl->dxadapter = pAdapter;
adapters.push_back(std::move(adp));
}
pFactory->Release();
pFactory = nullptr;
}
}
String GraphicsAdapter::Description() const {
if (!dxadapter) return String();
if (!impl->dxadapter) return String();
DXGI_ADAPTER_DESC1 desc;
dxadapter->GetDesc1(&desc);
impl->dxadapter->GetDesc1(&desc);
String description = XnaHToString(desc.Description);
return description;
}
Uint GraphicsAdapter::DeviceId() const {
if (!dxadapter) return 0;
if (!impl->dxadapter) return 0;
DXGI_ADAPTER_DESC1 desc;
dxadapter->GetDesc1(&desc);
impl->dxadapter->GetDesc1(&desc);
return static_cast<Uint>(desc.DeviceId);
}
String GraphicsAdapter::DeviceName() const {
if (!dxadapter) return String();
if (!impl->dxadapter) return String();
IDXGIOutput* pOutput = nullptr;
DXGI_OUTPUT_DESC outputDesc;
if (dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
if (impl->dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
pOutput->GetDesc(&outputDesc);
String deviceName = XnaHToString(outputDesc.DeviceName);
@ -110,12 +121,12 @@ namespace xna {
}
intptr_t GraphicsAdapter::MonitorHandle() const {
if (!dxadapter) return 0;
if (!impl->dxadapter) return 0;
IDXGIOutput* pOutput = nullptr;
DXGI_OUTPUT_DESC outputDesc;
if (dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
if (impl->dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
pOutput->GetDesc(&outputDesc);
pOutput->Release();
@ -128,36 +139,36 @@ namespace xna {
}
Uint GraphicsAdapter::Revision() const {
if (!dxadapter) return 0;
if (!impl->dxadapter) return 0;
DXGI_ADAPTER_DESC1 desc;
dxadapter->GetDesc1(&desc);
impl->dxadapter->GetDesc1(&desc);
return static_cast<Uint>(desc.Revision);
}
Uint GraphicsAdapter::SubSystemId() const {
if (!dxadapter) return 0;
if (!impl->dxadapter) return 0;
DXGI_ADAPTER_DESC1 desc;
dxadapter->GetDesc1(&desc);
impl->dxadapter->GetDesc1(&desc);
return static_cast<Uint>(desc.SubSysId);
}
Uint GraphicsAdapter::VendorId() const {
if (!dxadapter) return 0;
if (!impl->dxadapter) return 0;
DXGI_ADAPTER_DESC1 desc;
dxadapter->GetDesc1(&desc);
impl->dxadapter->GetDesc1(&desc);
return static_cast<Uint>(desc.VendorId);
}
uptr<DisplayModeCollection> GraphicsAdapter::SupportedDisplayModes() const {
if (!dxadapter) return nullptr;
if (!impl->dxadapter) return nullptr;
const auto totalDisplay = getDisplayModesCount(dxadapter);
const auto totalDisplay = getDisplayModesCount(impl->dxadapter);
if (totalDisplay == 0)
return nullptr;
@ -167,10 +178,10 @@ namespace xna {
std::vector<DXGI_MODE_DESC> buffer(totalDisplay);
if (dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
if (impl->dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
for (size_t f = 0; f < SURFACE_FORMAT_COUNT; ++f) {
const auto currentSurface = static_cast<SurfaceFormat>(f);
DXGI_FORMAT format = GraphicsAdapter::ConvertSurfaceToDXGIFORMAT(currentSurface);
DXGI_FORMAT format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(currentSurface);
UINT numModes = 0;
pOutput->GetDisplayModeList(format, 0, &numModes, nullptr);
@ -195,13 +206,13 @@ namespace xna {
uptr<DisplayModeCollection> GraphicsAdapter::SupportedDisplayModes(SurfaceFormat surfaceFormat) const
{
if (!dxadapter) return nullptr;
if (!impl->dxadapter) return nullptr;
IDXGIOutput* pOutput = nullptr;
UINT bufferOffset = 0;
if (dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
DXGI_FORMAT format = GraphicsAdapter::ConvertSurfaceToDXGIFORMAT(surfaceFormat);
if (impl->dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
DXGI_FORMAT format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(surfaceFormat);
UINT numModes = 0;
@ -223,11 +234,11 @@ namespace xna {
}
sptr<DisplayMode> GraphicsAdapter::CurrentDisplayMode() {
if (!_currentDisplayMode) {
if (!impl->_currentDisplayMode) {
CurrentDisplayMode(SurfaceFormat::Color, GraphicsDeviceManager::DefaultBackBufferWidth, GraphicsDeviceManager::DefaultBackBufferHeight);
}
return _currentDisplayMode;
return impl->_currentDisplayMode;
}
void GraphicsAdapter::CurrentDisplayMode(SurfaceFormat surfaceFormat, Uint width, Uint height) {
@ -237,15 +248,15 @@ namespace xna {
auto& m = modes->_displayModes[i];
if (m->_format == surfaceFormat && m->_width == width && m->_height == height) {
_currentDisplayMode = m;
impl->_currentDisplayMode = m;
}
else if(i + 1 == modes->_displayModes.size()) {
_currentDisplayMode = m;
impl->_currentDisplayMode = m;
}
}
}
bool GraphicsAdapter::GetOutput(UINT slot, IDXGIOutput*& output) {
bool GraphicsAdapter::PlatformImplementation::GetOutput(UINT slot, IDXGIOutput*& output) {
if (!dxadapter) return false;
if (dxadapter->EnumOutputs(slot, &output) != DXGI_ERROR_NOT_FOUND)
@ -263,7 +274,7 @@ namespace xna {
if (adapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
for (size_t f = 0; f < SURFACE_FORMAT_COUNT; ++f) {
const auto currentSurface = static_cast<SurfaceFormat>(f);
DXGI_FORMAT format = GraphicsAdapter::ConvertSurfaceToDXGIFORMAT(currentSurface);
DXGI_FORMAT format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(currentSurface);
UINT num = 0;
pOutput->GetDisplayModeList(format, 0, &num, nullptr);
@ -292,14 +303,14 @@ namespace xna {
description._scaling = static_cast<DisplayModeScaling>(modedesc.Scaling);
description._scanlineOrdering = static_cast<DisplayModeScanlineOrder>(modedesc.ScanlineOrdering);
if (pDisplay && pDisplay->_width == modedesc.Width && pDisplay->_height == modedesc.Height && pDisplay->_format == GraphicsAdapter::ConvertDXGIFORMATToSurface(modedesc.Format)) {
if (pDisplay && pDisplay->_width == modedesc.Width && pDisplay->_height == modedesc.Height && pDisplay->_format == GraphicsAdapter::PlatformImplementation::ConvertDXGIFORMATToSurface(modedesc.Format)) {
pDisplay->_descriptions.push_back(description);
}
else {
pDisplay = New<DisplayMode>();
pDisplay->_width = modedesc.Width;
pDisplay->_height = modedesc.Height;
pDisplay->_format = GraphicsAdapter::ConvertDXGIFORMATToSurface(modedesc.Format);
pDisplay->_format = GraphicsAdapter::PlatformImplementation::ConvertDXGIFORMATToSurface(modedesc.Format);
pDisplay->_descriptions.push_back(description);
displayList.push_back(pDisplay);
}

@ -2,11 +2,12 @@
#include "platform-dx/window-dx.hpp"
#include "platform-dx/swapchain-dx.hpp"
#include "platform-dx/rendertarget-dx.hpp"
#include "platform-dx/adapter-dx.hpp"
#include "platform-dx/blendstate-dx.hpp"
#include "platform-dx/gdeviceinfo-dx.hpp"
#include "common/color.hpp"
#include "platform-dx/gdevicemanager-dx.hpp"
#include "graphics/adapter.hpp"
#include "platform-dx/implementations.hpp"
namespace xna {
GraphicsDevice::GraphicsDevice() {
@ -86,7 +87,7 @@ namespace xna {
if FAILED(
D3D11CreateDevice(
_adapter->dxadapter,
_adapter->impl->dxadapter,
D3D_DRIVER_TYPE_UNKNOWN,
NULL,
_createDeviceFlags,

@ -3,7 +3,6 @@
#include "platform-dx/game-dx.hpp"
#include "platform-dx/window-dx.hpp"
#include "platform-dx/gdeviceinfo-dx.hpp"
#include "platform-dx/adapter-dx.hpp"
#include "platform-dx/presentparameters-dx.hpp"
namespace xna {

@ -1,6 +1,7 @@
#include "platform-dx/swapchain-dx.hpp"
#include "platform-dx/adapter-dx.hpp"
#include "platform-dx/device-dx.hpp"
#include "graphics/adapter.hpp"
#include "platform-dx/implementations.hpp"
namespace xna {
static bool internalInit(GraphicsDevice& device, HWND windowHandle, IDXGISwapChain1*& swapChain, DXGI_SWAP_CHAIN_DESC1 const& desc, DXGI_SWAP_CHAIN_FULLSCREEN_DESC const& fdesc) {
@ -13,7 +14,7 @@ namespace xna {
}
auto adapter = device.Adapter();
auto dxAdapter = adapter->dxadapter;
auto dxAdapter = adapter->impl->dxadapter;
IDXGIFactory1* dxFactory1 = nullptr;
auto hr = dxAdapter->GetParent(IID_IDXGIFactory1, (void**)&dxFactory1);
@ -47,7 +48,7 @@ namespace xna {
dxDescription.Width = static_cast<UINT>(parameters.backBufferWidth);
dxDescription.Height = static_cast<UINT>(parameters.backBufferHeight);
dxDescription.Format = GraphicsAdapter::ConvertSurfaceToDXGIFORMAT(parameters.backBufferFormat);
dxDescription.Format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(parameters.backBufferFormat);
dxDescription.SampleDesc.Count = 1;
dxDescription.SampleDesc.Quality = 0;
dxDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;

@ -1,6 +1,7 @@
#include "platform-dx/texture-dx.hpp"
#include "platform-dx/device-dx.hpp"
#include "platform-dx/adapter-dx.hpp"
#include "graphics/adapter.hpp"
#include "platform-dx/implementations.hpp"
namespace xna {
sptr<Texture2D> Texture2D::FromStream(GraphicsDevice& device, String const& fileName, xna_error_ptr_arg)
@ -111,7 +112,7 @@ namespace xna {
dxDescription.Width = static_cast<UINT>(width);
dxDescription.Height = static_cast<UINT>(height);
dxDescription.MipLevels = static_cast<UINT>(mipMap);
dxDescription.Format = GraphicsAdapter::ConvertSurfaceToDXGIFORMAT(format);
dxDescription.Format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(format);
}
void Texture2D::SetData(std::vector<Uint> const& data, size_t startIndex, size_t elementCount, xna_error_ptr_arg)

@ -4,26 +4,31 @@
#include "../default.hpp"
namespace xna {
class IGraphicsAdapter {
class GraphicsAdapter {
public:
virtual ~IGraphicsAdapter() {}
GraphicsAdapter();
~GraphicsAdapter();
virtual String Description() const = 0;
virtual Uint DeviceId() const = 0;
virtual String DeviceName() const = 0;
virtual bool IsDefaultAdapter() const = 0;
virtual intptr_t MonitorHandle() const = 0;
virtual Uint Revision() const = 0;
virtual Uint SubSystemId() const = 0;
virtual Uint VendorId() const = 0;
virtual uptr<DisplayModeCollection> SupportedDisplayModes() const = 0;
virtual uptr<DisplayModeCollection> SupportedDisplayModes(SurfaceFormat surfaceFormat) const = 0;
virtual sptr<DisplayMode> CurrentDisplayMode() = 0;
virtual void CurrentDisplayMode(SurfaceFormat surfaceFormat, Uint width, Uint height) = 0;
String Description() const;
Uint DeviceId() const;
String DeviceName() const;
bool IsDefaultAdapter() const;
intptr_t MonitorHandle() const;
Uint Revision() const;
Uint SubSystemId() const;
Uint VendorId() const;
uptr<DisplayModeCollection> SupportedDisplayModes() const;
uptr<DisplayModeCollection> SupportedDisplayModes(SurfaceFormat surfaceFormat) const;
sptr<DisplayMode> CurrentDisplayMode();
void CurrentDisplayMode(SurfaceFormat surfaceFormat, Uint width, Uint height);
static uptr<GraphicsAdapter> DefaultAdapter();
static void Adapters(std::vector<sptr<GraphicsAdapter>>& adapters);
static void Adapters(std::vector<uptr<GraphicsAdapter>>& adapters);
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl = nullptr;
};
}

@ -1,139 +0,0 @@
#ifndef XNA_PLATFORM_ADAPTER_DX_HPP
#define XNA_PLATFORM_ADAPTER_DX_HPP
#include "../graphics/adapter.hpp"
#include "displaymode-dx.hpp"
#include "dxheaders.hpp"
namespace xna {
class GraphicsAdapter : public IGraphicsAdapter {
public:
friend class IGraphicsAdapter;
GraphicsAdapter() {}
virtual ~GraphicsAdapter() override {
if (dxadapter) {
dxadapter->Release();
dxadapter = nullptr;
}
}
virtual String Description() const override;
virtual Uint DeviceId() const override;
virtual String DeviceName() const override;
virtual intptr_t MonitorHandle() const override;
virtual Uint Revision() const override;
virtual Uint SubSystemId() const override;
virtual Uint VendorId() const override;
virtual uptr<DisplayModeCollection> SupportedDisplayModes() const override;
virtual uptr<DisplayModeCollection> SupportedDisplayModes(SurfaceFormat surfaceFormat) const override;
virtual sptr<DisplayMode> CurrentDisplayMode() override;
virtual void CurrentDisplayMode(SurfaceFormat surfaceFormat, Uint width, Uint height) override;
virtual constexpr bool IsDefaultAdapter() const { return _index == 0; }
bool GetOutput(UINT slot, IDXGIOutput*& output);
public:
IDXGIAdapter1* dxadapter{ nullptr };
private:
Uint _index{ 0 };
sptr<DisplayMode> _currentDisplayMode = nullptr;
public:
static constexpr DXGI_FORMAT ConvertSurfaceToDXGIFORMAT(SurfaceFormat format)
{
switch (format)
{
case SurfaceFormat::Color://21
return DXGI_FORMAT_R8G8B8A8_UNORM;
case SurfaceFormat::Bgr565: //23
return DXGI_FORMAT_B5G6R5_UNORM;
case SurfaceFormat::Bgra5551://25
return DXGI_FORMAT_B5G5R5A1_UNORM;
case SurfaceFormat::Bgra4444://26
return DXGI_FORMAT_B4G4R4A4_UNORM;
case SurfaceFormat::Dxt1://827611204
return DXGI_FORMAT_BC1_UNORM;
case SurfaceFormat::Dxt3://861165636
return DXGI_FORMAT_BC2_UNORM;
case SurfaceFormat::Dxt5://894720068
return DXGI_FORMAT_BC3_UNORM;
case SurfaceFormat::NormalizedByte2://60
return DXGI_FORMAT_R8G8_SNORM;
case SurfaceFormat::NormalizedByte4://63
return DXGI_FORMAT_R8G8B8A8_SNORM;
case SurfaceFormat::Rgba1010102://31
return DXGI_FORMAT_R10G10B10A2_UNORM;
case SurfaceFormat::Rg32://34
return DXGI_FORMAT_R16G16_UNORM;
case SurfaceFormat::Rgba64://36
return DXGI_FORMAT_R16G16B16A16_UNORM;
case SurfaceFormat::Alpha8://28
return DXGI_FORMAT_A8_UNORM;
case SurfaceFormat::Single://114
return DXGI_FORMAT_R32_FLOAT;
case SurfaceFormat::Vector2://115
return DXGI_FORMAT_R32G32_FLOAT;
case SurfaceFormat::Vector4://116
return DXGI_FORMAT_R32G32B32A32_FLOAT;
case SurfaceFormat::HalfSingle://111
return DXGI_FORMAT_R16_FLOAT;
case SurfaceFormat::HalfVector2://112
return DXGI_FORMAT_R16G16_FLOAT;
case SurfaceFormat::HalfVector4://113
return DXGI_FORMAT_R16G16B16A16_FLOAT;
case SurfaceFormat::HdrBlendable://113
return DXGI_FORMAT_R16G16B16A16_FLOAT;
default://0
return DXGI_FORMAT_UNKNOWN;
}
}
static constexpr SurfaceFormat ConvertDXGIFORMATToSurface(DXGI_FORMAT format) {
switch (format)
{
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_B8G8R8A8_UNORM:
return SurfaceFormat::Color;
case DXGI_FORMAT_B5G6R5_UNORM:
return SurfaceFormat::Bgr565;
case DXGI_FORMAT_B5G5R5A1_UNORM:
return SurfaceFormat::Bgra5551;
case DXGI_FORMAT_B4G4R4A4_UNORM:
return SurfaceFormat::Bgra4444;
case DXGI_FORMAT_BC2_UNORM:
return SurfaceFormat::Dxt3;
case DXGI_FORMAT_BC3_UNORM:
return SurfaceFormat::Dxt5;
case DXGI_FORMAT_R8G8_SNORM:
return SurfaceFormat::NormalizedByte2;
case DXGI_FORMAT_R8G8B8A8_SNORM:
return SurfaceFormat::NormalizedByte4;
case DXGI_FORMAT_R10G10B10A2_UNORM:
return SurfaceFormat::Rgba1010102;
case DXGI_FORMAT_R16G16_UNORM:
return SurfaceFormat::Rg32;
case DXGI_FORMAT_R16G16B16A16_UNORM:
return SurfaceFormat::Rgba64;
case DXGI_FORMAT_A8_UNORM:
return SurfaceFormat::Alpha8;
case DXGI_FORMAT_R32_FLOAT:
return SurfaceFormat::Single;
case DXGI_FORMAT_R32G32_FLOAT:
return SurfaceFormat::Vector2;
case DXGI_FORMAT_R32G32B32A32_FLOAT:
return SurfaceFormat::Vector4;
case DXGI_FORMAT_R16_FLOAT:
return SurfaceFormat::HalfSingle;
case DXGI_FORMAT_R16G16_FLOAT:
return SurfaceFormat::HalfVector2;
case DXGI_FORMAT_R16G16B16A16_FLOAT:
return SurfaceFormat::HalfVector4;
default:
return SurfaceFormat::Unknown;
}
}
};
}
#endif

@ -5,9 +5,7 @@
#include "../graphics/device.hpp"
#include "../graphics/presentparams.hpp"
#include "../graphics/viewport.hpp"
#include "adapter-dx.hpp"
#include "d3d11.h"
#include "dxgi.h"
#include "dxheaders.hpp"
#include "gdeviceinfo-dx.hpp"
#include "swapchain-dx.hpp"
#include "window-dx.hpp"

@ -2,7 +2,6 @@
#define XNA_PLATFORM_GDEVICEINFOR_DX_HPP
#include "../game/gdeviceinfo.hpp"
#include "adapter-dx.hpp"
#include "window-dx.hpp"
#include "presentparameters-dx.hpp"

@ -1,6 +1,6 @@
#include "graphics/sprite.hpp"
#include "graphics/device.hpp"
#include "platform-dx/adapter-dx.hpp"
#include "graphics/adapter.hpp"
#include "platform-dx/presentparameters-dx.hpp"
#include "dxheaders.hpp"
#include "platform-dx/swapchain-dx.hpp"
@ -14,5 +14,117 @@ namespace xna {
struct SpriteBatch::PlatformImplementation {
sptr<DirectX::SpriteBatch> _dxspriteBatch = nullptr;
};
};
struct GraphicsAdapter::PlatformImplementation {
~PlatformImplementation(){
if (dxadapter) {
dxadapter->Release();
dxadapter = nullptr;
}
}
IDXGIAdapter1* dxadapter = nullptr;
private:
friend class GraphicsAdapter;
Uint _index{ 0 };
sptr<DisplayMode> _currentDisplayMode = nullptr;
public:
bool GetOutput(UINT slot, IDXGIOutput*& output);
static constexpr DXGI_FORMAT ConvertSurfaceToDXGIFORMAT(SurfaceFormat format)
{
switch (format)
{
case SurfaceFormat::Color://21
return DXGI_FORMAT_R8G8B8A8_UNORM;
case SurfaceFormat::Bgr565: //23
return DXGI_FORMAT_B5G6R5_UNORM;
case SurfaceFormat::Bgra5551://25
return DXGI_FORMAT_B5G5R5A1_UNORM;
case SurfaceFormat::Bgra4444://26
return DXGI_FORMAT_B4G4R4A4_UNORM;
case SurfaceFormat::Dxt1://827611204
return DXGI_FORMAT_BC1_UNORM;
case SurfaceFormat::Dxt3://861165636
return DXGI_FORMAT_BC2_UNORM;
case SurfaceFormat::Dxt5://894720068
return DXGI_FORMAT_BC3_UNORM;
case SurfaceFormat::NormalizedByte2://60
return DXGI_FORMAT_R8G8_SNORM;
case SurfaceFormat::NormalizedByte4://63
return DXGI_FORMAT_R8G8B8A8_SNORM;
case SurfaceFormat::Rgba1010102://31
return DXGI_FORMAT_R10G10B10A2_UNORM;
case SurfaceFormat::Rg32://34
return DXGI_FORMAT_R16G16_UNORM;
case SurfaceFormat::Rgba64://36
return DXGI_FORMAT_R16G16B16A16_UNORM;
case SurfaceFormat::Alpha8://28
return DXGI_FORMAT_A8_UNORM;
case SurfaceFormat::Single://114
return DXGI_FORMAT_R32_FLOAT;
case SurfaceFormat::Vector2://115
return DXGI_FORMAT_R32G32_FLOAT;
case SurfaceFormat::Vector4://116
return DXGI_FORMAT_R32G32B32A32_FLOAT;
case SurfaceFormat::HalfSingle://111
return DXGI_FORMAT_R16_FLOAT;
case SurfaceFormat::HalfVector2://112
return DXGI_FORMAT_R16G16_FLOAT;
case SurfaceFormat::HalfVector4://113
return DXGI_FORMAT_R16G16B16A16_FLOAT;
case SurfaceFormat::HdrBlendable://113
return DXGI_FORMAT_R16G16B16A16_FLOAT;
default://0
return DXGI_FORMAT_UNKNOWN;
}
}
static constexpr SurfaceFormat ConvertDXGIFORMATToSurface(DXGI_FORMAT format) {
switch (format)
{
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_B8G8R8A8_UNORM:
return SurfaceFormat::Color;
case DXGI_FORMAT_B5G6R5_UNORM:
return SurfaceFormat::Bgr565;
case DXGI_FORMAT_B5G5R5A1_UNORM:
return SurfaceFormat::Bgra5551;
case DXGI_FORMAT_B4G4R4A4_UNORM:
return SurfaceFormat::Bgra4444;
case DXGI_FORMAT_BC2_UNORM:
return SurfaceFormat::Dxt3;
case DXGI_FORMAT_BC3_UNORM:
return SurfaceFormat::Dxt5;
case DXGI_FORMAT_R8G8_SNORM:
return SurfaceFormat::NormalizedByte2;
case DXGI_FORMAT_R8G8B8A8_SNORM:
return SurfaceFormat::NormalizedByte4;
case DXGI_FORMAT_R10G10B10A2_UNORM:
return SurfaceFormat::Rgba1010102;
case DXGI_FORMAT_R16G16_UNORM:
return SurfaceFormat::Rg32;
case DXGI_FORMAT_R16G16B16A16_UNORM:
return SurfaceFormat::Rgba64;
case DXGI_FORMAT_A8_UNORM:
return SurfaceFormat::Alpha8;
case DXGI_FORMAT_R32_FLOAT:
return SurfaceFormat::Single;
case DXGI_FORMAT_R32G32_FLOAT:
return SurfaceFormat::Vector2;
case DXGI_FORMAT_R32G32B32A32_FLOAT:
return SurfaceFormat::Vector4;
case DXGI_FORMAT_R16_FLOAT:
return SurfaceFormat::HalfSingle;
case DXGI_FORMAT_R16G16_FLOAT:
return SurfaceFormat::HalfVector2;
case DXGI_FORMAT_R16G16B16A16_FLOAT:
return SurfaceFormat::HalfVector4;
default:
return SurfaceFormat::Unknown;
}
}
};
}

@ -1,4 +1,3 @@
#include "adapter-dx.hpp"
#include "audioengine-dx.hpp"
#include "blendstate-dx.hpp"
#include "clock-dx.hpp"