mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementa DxHelpers
This commit is contained in:
parent
0d716d1cd6
commit
60d106588d
@ -3,6 +3,7 @@
|
|||||||
#include "graphics/adapter.hpp"
|
#include "graphics/adapter.hpp"
|
||||||
#include "platform-dx/displaymode-dx.hpp"
|
#include "platform-dx/displaymode-dx.hpp"
|
||||||
#include "platform-dx/dxheaders.hpp"
|
#include "platform-dx/dxheaders.hpp"
|
||||||
|
#include "platform-dx/dxhelpers.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
static size_t getDisplayModesCount(IDXGIAdapter* adapter);
|
static size_t getDisplayModesCount(IDXGIAdapter* adapter);
|
||||||
@ -181,7 +182,7 @@ namespace xna {
|
|||||||
if (impl->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) {
|
for (size_t f = 0; f < SURFACE_FORMAT_COUNT; ++f) {
|
||||||
const auto currentSurface = static_cast<SurfaceFormat>(f);
|
const auto currentSurface = static_cast<SurfaceFormat>(f);
|
||||||
DXGI_FORMAT format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(currentSurface);
|
DXGI_FORMAT format = DxHelpers::ConvertSurfaceToDXGIFORMAT(currentSurface);
|
||||||
|
|
||||||
UINT numModes = 0;
|
UINT numModes = 0;
|
||||||
pOutput->GetDisplayModeList(format, 0, &numModes, nullptr);
|
pOutput->GetDisplayModeList(format, 0, &numModes, nullptr);
|
||||||
@ -212,7 +213,7 @@ namespace xna {
|
|||||||
UINT bufferOffset = 0;
|
UINT bufferOffset = 0;
|
||||||
|
|
||||||
if (impl->dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
|
if (impl->dxadapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
|
||||||
DXGI_FORMAT format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(surfaceFormat);
|
DXGI_FORMAT format = DxHelpers::ConvertSurfaceToDXGIFORMAT(surfaceFormat);
|
||||||
|
|
||||||
UINT numModes = 0;
|
UINT numModes = 0;
|
||||||
|
|
||||||
@ -274,7 +275,7 @@ namespace xna {
|
|||||||
if (adapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
|
if (adapter->EnumOutputs(0, &pOutput) != DXGI_ERROR_NOT_FOUND) {
|
||||||
for (size_t f = 0; f < SURFACE_FORMAT_COUNT; ++f) {
|
for (size_t f = 0; f < SURFACE_FORMAT_COUNT; ++f) {
|
||||||
const auto currentSurface = static_cast<SurfaceFormat>(f);
|
const auto currentSurface = static_cast<SurfaceFormat>(f);
|
||||||
DXGI_FORMAT format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(currentSurface);
|
DXGI_FORMAT format = DxHelpers::ConvertSurfaceToDXGIFORMAT(currentSurface);
|
||||||
|
|
||||||
UINT num = 0;
|
UINT num = 0;
|
||||||
pOutput->GetDisplayModeList(format, 0, &num, nullptr);
|
pOutput->GetDisplayModeList(format, 0, &num, nullptr);
|
||||||
@ -303,14 +304,14 @@ namespace xna {
|
|||||||
description._scaling = static_cast<DisplayModeScaling>(modedesc.Scaling);
|
description._scaling = static_cast<DisplayModeScaling>(modedesc.Scaling);
|
||||||
description._scanlineOrdering = static_cast<DisplayModeScanlineOrder>(modedesc.ScanlineOrdering);
|
description._scanlineOrdering = static_cast<DisplayModeScanlineOrder>(modedesc.ScanlineOrdering);
|
||||||
|
|
||||||
if (pDisplay && pDisplay->_width == modedesc.Width && pDisplay->_height == modedesc.Height && pDisplay->_format == GraphicsAdapter::PlatformImplementation::ConvertDXGIFORMATToSurface(modedesc.Format)) {
|
if (pDisplay && pDisplay->_width == modedesc.Width && pDisplay->_height == modedesc.Height && pDisplay->_format == DxHelpers::ConvertDXGIFORMATToSurface(modedesc.Format)) {
|
||||||
pDisplay->_descriptions.push_back(description);
|
pDisplay->_descriptions.push_back(description);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pDisplay = New<DisplayMode>();
|
pDisplay = New<DisplayMode>();
|
||||||
pDisplay->_width = modedesc.Width;
|
pDisplay->_width = modedesc.Width;
|
||||||
pDisplay->_height = modedesc.Height;
|
pDisplay->_height = modedesc.Height;
|
||||||
pDisplay->_format = GraphicsAdapter::PlatformImplementation::ConvertDXGIFORMATToSurface(modedesc.Format);
|
pDisplay->_format = DxHelpers::ConvertDXGIFORMATToSurface(modedesc.Format);
|
||||||
pDisplay->_descriptions.push_back(description);
|
pDisplay->_descriptions.push_back(description);
|
||||||
displayList.push_back(pDisplay);
|
displayList.push_back(pDisplay);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "graphics/gresource.hpp"
|
#include "graphics/gresource.hpp"
|
||||||
#include "platform-dx/device-dx.hpp"
|
#include "platform-dx/device-dx.hpp"
|
||||||
#include "platform-dx/dxheaders.hpp"
|
#include "platform-dx/dxheaders.hpp"
|
||||||
|
#include "platform-dx/dxhelpers.hpp"
|
||||||
#include "graphics/blendstate.hpp"
|
#include "graphics/blendstate.hpp"
|
||||||
#include "platform-dx/implementations.hpp"
|
#include "platform-dx/implementations.hpp"
|
||||||
|
|
||||||
@ -72,13 +73,13 @@ namespace xna {
|
|||||||
void BlendState::RenderTargets(std::vector<BlendRenderTarget> const& value) {
|
void BlendState::RenderTargets(std::vector<BlendRenderTarget> const& value) {
|
||||||
for (size_t i = 0; i < value.size() && i < 8; ++i) {
|
for (size_t i = 0; i < value.size() && i < 8; ++i) {
|
||||||
impl->dxDescription.RenderTarget[i].BlendEnable = value[i].Enabled;
|
impl->dxDescription.RenderTarget[i].BlendEnable = value[i].Enabled;
|
||||||
impl->dxDescription.RenderTarget[i].SrcBlend = PlatformImplementation::ConvertBlend(value[i].Source);
|
impl->dxDescription.RenderTarget[i].SrcBlend = DxHelpers::ConvertBlend(value[i].Source);
|
||||||
impl->dxDescription.RenderTarget[i].DestBlend = PlatformImplementation::ConvertBlend(value[i].Destination);
|
impl->dxDescription.RenderTarget[i].DestBlend = DxHelpers::ConvertBlend(value[i].Destination);
|
||||||
impl->dxDescription.RenderTarget[i].BlendOp = PlatformImplementation::ConvertOperation(value[i].Operation);
|
impl->dxDescription.RenderTarget[i].BlendOp = DxHelpers::ConvertOperation(value[i].Operation);
|
||||||
impl->dxDescription.RenderTarget[i].SrcBlendAlpha = PlatformImplementation::ConvertBlend(value[i].SourceAlpha);
|
impl->dxDescription.RenderTarget[i].SrcBlendAlpha = DxHelpers::ConvertBlend(value[i].SourceAlpha);
|
||||||
impl->dxDescription.RenderTarget[i].DestBlendAlpha = PlatformImplementation::ConvertBlend(value[i].DestinationAlpha);
|
impl->dxDescription.RenderTarget[i].DestBlendAlpha = DxHelpers::ConvertBlend(value[i].DestinationAlpha);
|
||||||
impl->dxDescription.RenderTarget[i].BlendOpAlpha = PlatformImplementation::ConvertOperation(value[i].OperationAlpha);
|
impl->dxDescription.RenderTarget[i].BlendOpAlpha = DxHelpers::ConvertOperation(value[i].OperationAlpha);
|
||||||
impl->dxDescription.RenderTarget[i].RenderTargetWriteMask = PlatformImplementation::ConvertColorWrite(value[i].WriteMask);
|
impl->dxDescription.RenderTarget[i].RenderTargetWriteMask = DxHelpers::ConvertColorWrite(value[i].WriteMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "platform-dx/swapchain-dx.hpp"
|
#include "platform-dx/swapchain-dx.hpp"
|
||||||
#include "platform-dx/device-dx.hpp"
|
#include "platform-dx/device-dx.hpp"
|
||||||
|
#include "platform-dx/dxhelpers.hpp"
|
||||||
#include "graphics/adapter.hpp"
|
#include "graphics/adapter.hpp"
|
||||||
#include "platform-dx/implementations.hpp"
|
#include "platform-dx/implementations.hpp"
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ namespace xna {
|
|||||||
|
|
||||||
dxDescription.Width = static_cast<UINT>(parameters.backBufferWidth);
|
dxDescription.Width = static_cast<UINT>(parameters.backBufferWidth);
|
||||||
dxDescription.Height = static_cast<UINT>(parameters.backBufferHeight);
|
dxDescription.Height = static_cast<UINT>(parameters.backBufferHeight);
|
||||||
dxDescription.Format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(parameters.backBufferFormat);
|
dxDescription.Format = DxHelpers::ConvertSurfaceToDXGIFORMAT(parameters.backBufferFormat);
|
||||||
dxDescription.SampleDesc.Count = 1;
|
dxDescription.SampleDesc.Count = 1;
|
||||||
dxDescription.SampleDesc.Quality = 0;
|
dxDescription.SampleDesc.Quality = 0;
|
||||||
dxDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
dxDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "platform-dx/device-dx.hpp"
|
#include "platform-dx/device-dx.hpp"
|
||||||
#include "graphics/adapter.hpp"
|
#include "graphics/adapter.hpp"
|
||||||
#include "platform-dx/implementations.hpp"
|
#include "platform-dx/implementations.hpp"
|
||||||
|
#include "platform-dx/dxhelpers.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
sptr<Texture2D> Texture2D::FromStream(GraphicsDevice& device, String const& fileName, xna_error_ptr_arg)
|
sptr<Texture2D> Texture2D::FromStream(GraphicsDevice& device, String const& fileName, xna_error_ptr_arg)
|
||||||
@ -112,7 +113,7 @@ namespace xna {
|
|||||||
dxDescription.Width = static_cast<UINT>(width);
|
dxDescription.Width = static_cast<UINT>(width);
|
||||||
dxDescription.Height = static_cast<UINT>(height);
|
dxDescription.Height = static_cast<UINT>(height);
|
||||||
dxDescription.MipLevels = static_cast<UINT>(mipMap);
|
dxDescription.MipLevels = static_cast<UINT>(mipMap);
|
||||||
dxDescription.Format = GraphicsAdapter::PlatformImplementation::ConvertSurfaceToDXGIFORMAT(format);
|
dxDescription.Format = DxHelpers::ConvertSurfaceToDXGIFORMAT(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture2D::SetData(std::vector<Uint> const& data, size_t startIndex, size_t elementCount, xna_error_ptr_arg)
|
void Texture2D::SetData(std::vector<Uint> const& data, size_t startIndex, size_t elementCount, xna_error_ptr_arg)
|
||||||
|
165
inc/platform-dx/dxhelpers.hpp
Normal file
165
inc/platform-dx/dxhelpers.hpp
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
#include "dxheaders.hpp"
|
||||||
|
#include "graphics/blendstate.hpp"
|
||||||
|
#include "graphics/adapter.hpp"
|
||||||
|
|
||||||
|
namespace xna {
|
||||||
|
struct DxHelpers {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr D3D11_BLEND ConvertBlend(Blend blend) {
|
||||||
|
switch (blend)
|
||||||
|
{
|
||||||
|
case xna::Blend::Zero:
|
||||||
|
return D3D11_BLEND_ZERO;
|
||||||
|
case xna::Blend::One:
|
||||||
|
return D3D11_BLEND_ONE;
|
||||||
|
case xna::Blend::SourceColor:
|
||||||
|
return D3D11_BLEND_SRC_COLOR;
|
||||||
|
case xna::Blend::InverseSourceColor:
|
||||||
|
return D3D11_BLEND_INV_SRC_COLOR;
|
||||||
|
case xna::Blend::SourceAlpha:
|
||||||
|
return D3D11_BLEND_SRC_ALPHA;
|
||||||
|
case xna::Blend::InverseSourceAlpha:
|
||||||
|
return D3D11_BLEND_INV_SRC_ALPHA;
|
||||||
|
case xna::Blend::DestinationAlpha:
|
||||||
|
return D3D11_BLEND_DEST_ALPHA;
|
||||||
|
case xna::Blend::InverseDestinationAlpha:
|
||||||
|
return D3D11_BLEND_INV_DEST_ALPHA;
|
||||||
|
case xna::Blend::DestinationColor:
|
||||||
|
return D3D11_BLEND_DEST_COLOR;
|
||||||
|
case xna::Blend::InverseDestinationColor:
|
||||||
|
return D3D11_BLEND_INV_DEST_COLOR;
|
||||||
|
case xna::Blend::SourceAlphaSaturation:
|
||||||
|
return D3D11_BLEND_SRC_ALPHA_SAT;
|
||||||
|
case xna::Blend::BlendFactor:
|
||||||
|
return D3D11_BLEND_BLEND_FACTOR;
|
||||||
|
case xna::Blend::InverseBlendFactor:
|
||||||
|
return D3D11_BLEND_INV_BLEND_FACTOR;
|
||||||
|
case xna::Blend::Source1Color:
|
||||||
|
return D3D11_BLEND_SRC1_COLOR;
|
||||||
|
case xna::Blend::InverseSource1Color:
|
||||||
|
return D3D11_BLEND_INV_SRC1_COLOR;
|
||||||
|
case xna::Blend::Source1Alpha:
|
||||||
|
return D3D11_BLEND_SRC1_ALPHA;
|
||||||
|
case xna::Blend::InverseSource1Alpha:
|
||||||
|
return D3D11_BLEND_INV_SRC1_ALPHA;
|
||||||
|
default:
|
||||||
|
return D3D11_BLEND_ZERO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr D3D11_BLEND_OP ConvertOperation(BlendOperation op) {
|
||||||
|
return static_cast<D3D11_BLEND_OP>(static_cast<int>(op) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr D3D11_COLOR_WRITE_ENABLE ConvertColorWrite(ColorWriteChannels colorWrite) {
|
||||||
|
switch (colorWrite)
|
||||||
|
{
|
||||||
|
case xna::ColorWriteChannels::Red:
|
||||||
|
return D3D11_COLOR_WRITE_ENABLE_RED;
|
||||||
|
case xna::ColorWriteChannels::Green:
|
||||||
|
return D3D11_COLOR_WRITE_ENABLE_GREEN;
|
||||||
|
case xna::ColorWriteChannels::Blue:
|
||||||
|
return D3D11_COLOR_WRITE_ENABLE_BLUE;
|
||||||
|
case xna::ColorWriteChannels::Alpha:
|
||||||
|
return D3D11_COLOR_WRITE_ENABLE_ALPHA;
|
||||||
|
case xna::ColorWriteChannels::All:
|
||||||
|
return D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||||
|
default:
|
||||||
|
return D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -33,101 +33,7 @@ namespace xna {
|
|||||||
sptr<DisplayMode> _currentDisplayMode = nullptr;
|
sptr<DisplayMode> _currentDisplayMode = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool GetOutput(UINT slot, IDXGIOutput*& output);
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BlendRenderTarget {
|
struct BlendRenderTarget {
|
||||||
@ -154,71 +60,7 @@ namespace xna {
|
|||||||
ID3D11BlendState* dxBlendState = nullptr;
|
ID3D11BlendState* dxBlendState = nullptr;
|
||||||
D3D11_BLEND_DESC dxDescription{};
|
D3D11_BLEND_DESC dxDescription{};
|
||||||
float blendFactor[4]{ 1.0F, 1.0F, 1.0F, 1.0F };
|
float blendFactor[4]{ 1.0F, 1.0F, 1.0F, 1.0F };
|
||||||
UINT sampleMask{ 0xffffffff };
|
UINT sampleMask{ 0xffffffff };
|
||||||
|
|
||||||
static constexpr D3D11_BLEND ConvertBlend(Blend blend) {
|
|
||||||
switch (blend)
|
|
||||||
{
|
|
||||||
case xna::Blend::Zero:
|
|
||||||
return D3D11_BLEND_ZERO;
|
|
||||||
case xna::Blend::One:
|
|
||||||
return D3D11_BLEND_ONE;
|
|
||||||
case xna::Blend::SourceColor:
|
|
||||||
return D3D11_BLEND_SRC_COLOR;
|
|
||||||
case xna::Blend::InverseSourceColor:
|
|
||||||
return D3D11_BLEND_INV_SRC_COLOR;
|
|
||||||
case xna::Blend::SourceAlpha:
|
|
||||||
return D3D11_BLEND_SRC_ALPHA;
|
|
||||||
case xna::Blend::InverseSourceAlpha:
|
|
||||||
return D3D11_BLEND_INV_SRC_ALPHA;
|
|
||||||
case xna::Blend::DestinationAlpha:
|
|
||||||
return D3D11_BLEND_DEST_ALPHA;
|
|
||||||
case xna::Blend::InverseDestinationAlpha:
|
|
||||||
return D3D11_BLEND_INV_DEST_ALPHA;
|
|
||||||
case xna::Blend::DestinationColor:
|
|
||||||
return D3D11_BLEND_DEST_COLOR;
|
|
||||||
case xna::Blend::InverseDestinationColor:
|
|
||||||
return D3D11_BLEND_INV_DEST_COLOR;
|
|
||||||
case xna::Blend::SourceAlphaSaturation:
|
|
||||||
return D3D11_BLEND_SRC_ALPHA_SAT;
|
|
||||||
case xna::Blend::BlendFactor:
|
|
||||||
return D3D11_BLEND_BLEND_FACTOR;
|
|
||||||
case xna::Blend::InverseBlendFactor:
|
|
||||||
return D3D11_BLEND_INV_BLEND_FACTOR;
|
|
||||||
case xna::Blend::Source1Color:
|
|
||||||
return D3D11_BLEND_SRC1_COLOR;
|
|
||||||
case xna::Blend::InverseSource1Color:
|
|
||||||
return D3D11_BLEND_INV_SRC1_COLOR;
|
|
||||||
case xna::Blend::Source1Alpha:
|
|
||||||
return D3D11_BLEND_SRC1_ALPHA;
|
|
||||||
case xna::Blend::InverseSource1Alpha:
|
|
||||||
return D3D11_BLEND_INV_SRC1_ALPHA;
|
|
||||||
default:
|
|
||||||
return D3D11_BLEND_ZERO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr D3D11_BLEND_OP ConvertOperation(BlendOperation op) {
|
|
||||||
return static_cast<D3D11_BLEND_OP>(static_cast<int>(op) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr D3D11_COLOR_WRITE_ENABLE ConvertColorWrite(ColorWriteChannels colorWrite) {
|
|
||||||
switch (colorWrite)
|
|
||||||
{
|
|
||||||
case xna::ColorWriteChannels::Red:
|
|
||||||
return D3D11_COLOR_WRITE_ENABLE_RED;
|
|
||||||
case xna::ColorWriteChannels::Green:
|
|
||||||
return D3D11_COLOR_WRITE_ENABLE_GREEN;
|
|
||||||
case xna::ColorWriteChannels::Blue:
|
|
||||||
return D3D11_COLOR_WRITE_ENABLE_BLUE;
|
|
||||||
case xna::ColorWriteChannels::Alpha:
|
|
||||||
return D3D11_COLOR_WRITE_ENABLE_ALPHA;
|
|
||||||
case xna::ColorWriteChannels::All:
|
|
||||||
return D3D11_COLOR_WRITE_ENABLE_ALL;
|
|
||||||
default:
|
|
||||||
return D3D11_COLOR_WRITE_ENABLE_ALL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConstantBuffer::PlatformImplementation {
|
struct ConstantBuffer::PlatformImplementation {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user