mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 20:52:10 +01:00
[dxgi] Added static format mapping table
This commit is contained in:
parent
3405b89494
commit
db541d188f
@ -876,16 +876,16 @@ namespace dxvk {
|
||||
const D3D11CommonTexture* dstTextureInfo = GetCommonTexture(pDstResource);
|
||||
const D3D11CommonTexture* srcTextureInfo = GetCommonTexture(pSrcResource);
|
||||
|
||||
const DxgiFormatInfo dstFormatInfo = m_parent->LookupFormat(dstDesc.Format, DxgiFormatMode::Any);
|
||||
const DxgiFormatInfo srcFormatInfo = m_parent->LookupFormat(srcDesc.Format, DxgiFormatMode::Any);
|
||||
const DXGI_VK_FORMAT_INFO dstFormatInfo = m_parent->LookupFormat(dstDesc.Format, DXGI_VK_FORMAT_MODE_ANY);
|
||||
const DXGI_VK_FORMAT_INFO srcFormatInfo = m_parent->LookupFormat(srcDesc.Format, DXGI_VK_FORMAT_MODE_ANY);
|
||||
|
||||
const VkImageSubresource dstSubresource =
|
||||
dstTextureInfo->GetSubresourceFromIndex(
|
||||
dstFormatInfo.aspect, DstSubresource);
|
||||
dstFormatInfo.Aspect, DstSubresource);
|
||||
|
||||
const VkImageSubresource srcSubresource =
|
||||
srcTextureInfo->GetSubresourceFromIndex(
|
||||
srcFormatInfo.aspect, SrcSubresource);
|
||||
srcFormatInfo.Aspect, SrcSubresource);
|
||||
|
||||
const VkImageSubresourceLayers dstSubresourceLayers = {
|
||||
dstSubresource.aspectMask,
|
||||
@ -911,7 +911,7 @@ namespace dxvk {
|
||||
});
|
||||
} else {
|
||||
const VkFormat format = m_parent->LookupFormat(
|
||||
Format, DxgiFormatMode::Any).format;
|
||||
Format, DXGI_VK_FORMAT_MODE_ANY).Format;
|
||||
|
||||
EmitCs([
|
||||
cDstImage = dstTextureInfo->GetImage(),
|
||||
|
@ -323,7 +323,7 @@ namespace dxvk {
|
||||
} else {
|
||||
// Typed buffer view - must use an uncompressed color format
|
||||
viewInfo.format = m_dxgiAdapter->LookupFormat(
|
||||
desc.Format, DxgiFormatMode::Color).format;
|
||||
desc.Format, DXGI_VK_FORMAT_MODE_COLOR).Format;
|
||||
|
||||
const DxvkFormatInfo* formatInfo = imageFormatInfo(viewInfo.format);
|
||||
viewInfo.rangeOffset = formatInfo->elementSize * bufInfo.FirstElement;
|
||||
@ -359,13 +359,13 @@ namespace dxvk {
|
||||
// Fill in the view info. The view type depends solely
|
||||
// on the view dimension field in the view description,
|
||||
// not on the resource type.
|
||||
const DxgiFormatInfo formatInfo = m_dxgiAdapter
|
||||
const DXGI_VK_FORMAT_INFO formatInfo = m_dxgiAdapter
|
||||
->LookupFormat(desc.Format, textureInfo->GetFormatMode());
|
||||
|
||||
DxvkImageViewCreateInfo viewInfo;
|
||||
viewInfo.format = formatInfo.format;
|
||||
viewInfo.aspect = formatInfo.aspect;
|
||||
viewInfo.swizzle = formatInfo.swizzle;
|
||||
viewInfo.format = formatInfo.Format;
|
||||
viewInfo.aspect = formatInfo.Aspect;
|
||||
viewInfo.swizzle = formatInfo.Swizzle;
|
||||
|
||||
switch (desc.ViewDimension) {
|
||||
case D3D11_SRV_DIMENSION_TEXTURE1D:
|
||||
@ -512,7 +512,7 @@ namespace dxvk {
|
||||
} else {
|
||||
// Typed buffer view - must use an uncompressed color format
|
||||
viewInfo.format = m_dxgiAdapter->LookupFormat(
|
||||
desc.Format, DxgiFormatMode::Color).format;
|
||||
desc.Format, DXGI_VK_FORMAT_MODE_COLOR).Format;
|
||||
|
||||
const DxvkFormatInfo* formatInfo = imageFormatInfo(viewInfo.format);
|
||||
viewInfo.rangeOffset = formatInfo->elementSize * desc.Buffer.FirstElement;
|
||||
@ -556,13 +556,13 @@ namespace dxvk {
|
||||
// Fill in the view info. The view type depends solely
|
||||
// on the view dimension field in the view description,
|
||||
// not on the resource type.
|
||||
const DxgiFormatInfo formatInfo = m_dxgiAdapter
|
||||
const DXGI_VK_FORMAT_INFO formatInfo = m_dxgiAdapter
|
||||
->LookupFormat(desc.Format, textureInfo->GetFormatMode());
|
||||
|
||||
DxvkImageViewCreateInfo viewInfo;
|
||||
viewInfo.format = formatInfo.format;
|
||||
viewInfo.aspect = formatInfo.aspect;
|
||||
viewInfo.swizzle = formatInfo.swizzle;
|
||||
viewInfo.format = formatInfo.Format;
|
||||
viewInfo.aspect = formatInfo.Aspect;
|
||||
viewInfo.swizzle = formatInfo.Swizzle;
|
||||
|
||||
switch (desc.ViewDimension) {
|
||||
case D3D11_UAV_DIMENSION_TEXTURE1D:
|
||||
@ -672,7 +672,7 @@ namespace dxvk {
|
||||
|
||||
// Fill in Vulkan image view info
|
||||
DxvkImageViewCreateInfo viewInfo;
|
||||
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DxgiFormatMode::Color).format;
|
||||
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DXGI_VK_FORMAT_MODE_COLOR).Format;
|
||||
viewInfo.aspect = imageFormatInfo(viewInfo.format)->aspectMask;
|
||||
|
||||
switch (desc.ViewDimension) {
|
||||
@ -790,7 +790,7 @@ namespace dxvk {
|
||||
|
||||
// Fill in Vulkan image view info
|
||||
DxvkImageViewCreateInfo viewInfo;
|
||||
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DxgiFormatMode::Depth).format;
|
||||
viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DXGI_VK_FORMAT_MODE_DEPTH).Format;
|
||||
viewInfo.aspect = imageFormatInfo(viewInfo.format)->aspectMask;
|
||||
|
||||
switch (desc.ViewDimension) {
|
||||
@ -903,7 +903,7 @@ namespace dxvk {
|
||||
attrib.location = entry->registerId;
|
||||
attrib.binding = pInputElementDescs[i].InputSlot;
|
||||
attrib.format = m_dxgiAdapter->LookupFormat(
|
||||
pInputElementDescs[i].Format, DxgiFormatMode::Color).format;
|
||||
pInputElementDescs[i].Format, DXGI_VK_FORMAT_MODE_COLOR).Format;
|
||||
attrib.offset = pInputElementDescs[i].AlignedByteOffset;
|
||||
|
||||
// The application may choose to let the implementation
|
||||
@ -1407,7 +1407,7 @@ namespace dxvk {
|
||||
|
||||
// We need to check whether the format is
|
||||
VkFormat format = m_dxgiAdapter->LookupFormat(
|
||||
Format, DxgiFormatMode::Any).format;
|
||||
Format, DXGI_VK_FORMAT_MODE_ANY).Format;
|
||||
|
||||
if (format == VK_FORMAT_UNDEFINED) {
|
||||
Logger::err(str::format("D3D11: Unsupported format: ", Format));
|
||||
@ -1625,9 +1625,9 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
DxgiFormatInfo STDMETHODCALLTYPE D3D11Device::LookupFormat(
|
||||
DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE D3D11Device::LookupFormat(
|
||||
DXGI_FORMAT format,
|
||||
DxgiFormatMode mode) const {
|
||||
DXGI_VK_FORMAT_MODE mode) const {
|
||||
return m_dxgiAdapter->LookupFormat(format, mode);
|
||||
}
|
||||
|
||||
@ -1871,7 +1871,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
HRESULT D3D11Device::GetFormatSupportFlags(DXGI_FORMAT Format, UINT* pFlags1, UINT* pFlags2) const {
|
||||
const VkFormat fmt = m_dxgiAdapter->LookupFormat(Format, DxgiFormatMode::Any).format;
|
||||
const VkFormat fmt = m_dxgiAdapter->LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY).Format;
|
||||
const VkFormatProperties fmtInfo = m_dxvkAdapter->formatProperties(fmt);
|
||||
if (fmt == VK_FORMAT_UNDEFINED)
|
||||
return E_FAIL;
|
||||
|
@ -320,9 +320,9 @@ namespace dxvk {
|
||||
|
||||
VkPipelineStageFlags GetEnabledShaderStages() const;
|
||||
|
||||
DxgiFormatInfo STDMETHODCALLTYPE LookupFormat(
|
||||
DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE LookupFormat(
|
||||
DXGI_FORMAT format,
|
||||
DxgiFormatMode mode) const;
|
||||
DXGI_VK_FORMAT_MODE mode) const;
|
||||
|
||||
bool TestOption(D3D11Option Option) const {
|
||||
return m_d3d11Options.test(Option);
|
||||
|
@ -8,11 +8,11 @@ namespace dxvk {
|
||||
const D3D11_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D11_RESOURCE_DIMENSION Dimension)
|
||||
: m_device(pDevice), m_desc(*pDesc) {
|
||||
DxgiFormatInfo formatInfo = m_device->LookupFormat(m_desc.Format, GetFormatMode());
|
||||
DXGI_VK_FORMAT_INFO formatInfo = m_device->LookupFormat(m_desc.Format, GetFormatMode());
|
||||
|
||||
DxvkImageCreateInfo imageInfo;
|
||||
imageInfo.type = GetImageTypeFromResourceDim(Dimension);
|
||||
imageInfo.format = formatInfo.format;
|
||||
imageInfo.format = formatInfo.Format;
|
||||
imageInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
|
||||
imageInfo.sampleCount = VK_SAMPLE_COUNT_1_BIT;
|
||||
imageInfo.extent.width = m_desc.Width;
|
||||
@ -137,14 +137,14 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
DxgiFormatMode D3D11CommonTexture::GetFormatMode() const {
|
||||
DXGI_VK_FORMAT_MODE D3D11CommonTexture::GetFormatMode() const {
|
||||
if (m_desc.BindFlags & D3D11_BIND_RENDER_TARGET)
|
||||
return DxgiFormatMode::Color;
|
||||
return DXGI_VK_FORMAT_MODE_COLOR;
|
||||
|
||||
if (m_desc.BindFlags & D3D11_BIND_DEPTH_STENCIL)
|
||||
return DxgiFormatMode::Depth;
|
||||
return DXGI_VK_FORMAT_MODE_DEPTH;
|
||||
|
||||
return DxgiFormatMode::Any;
|
||||
return DXGI_VK_FORMAT_MODE_ANY;
|
||||
}
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ namespace dxvk {
|
||||
|
||||
Rc<DxvkBuffer> D3D11CommonTexture::CreateMappedBuffer() const {
|
||||
const DxvkFormatInfo* formatInfo = imageFormatInfo(
|
||||
m_device->LookupFormat(m_desc.Format, GetFormatMode()).format);
|
||||
m_device->LookupFormat(m_desc.Format, GetFormatMode()).Format);
|
||||
|
||||
const VkExtent3D blockCount = util::computeBlockCount(
|
||||
VkExtent3D { m_desc.Width, m_desc.Height, m_desc.Depth },
|
||||
|
@ -140,7 +140,7 @@ namespace dxvk {
|
||||
* be used as a color image or a depth image.
|
||||
* \returns Format mode
|
||||
*/
|
||||
DxgiFormatMode GetFormatMode() const;
|
||||
DXGI_VK_FORMAT_MODE GetFormatMode() const;
|
||||
|
||||
/**
|
||||
* \brief Retrieves parent D3D11 device
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "dxgi_device.h"
|
||||
#include "dxgi_enums.h"
|
||||
#include "dxgi_factory.h"
|
||||
#include "dxgi_format.h"
|
||||
#include "dxgi_output.h"
|
||||
|
||||
#include "../dxvk/vulkan/dxvk_vulkan_names.h"
|
||||
@ -16,7 +17,7 @@ namespace dxvk {
|
||||
const Rc<DxvkAdapter>& adapter)
|
||||
: m_factory (factory),
|
||||
m_adapter (adapter) {
|
||||
SetupFormatTable();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -174,24 +175,9 @@ namespace dxvk {
|
||||
|
||||
|
||||
DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE DxgiAdapter::LookupFormat(
|
||||
DXGI_FORMAT format,
|
||||
DxgiFormatMode mode) {
|
||||
// If the mode is 'Any', probe color formats first
|
||||
if (mode != DxgiFormatMode::Depth) {
|
||||
auto color = m_colorFormats.find(format);
|
||||
|
||||
if (color != m_colorFormats.end())
|
||||
return color->second;
|
||||
}
|
||||
|
||||
if (mode != DxgiFormatMode::Color) {
|
||||
auto depth = m_depthFormats.find(format);
|
||||
if (depth != m_depthFormats.end())
|
||||
return depth->second;
|
||||
}
|
||||
|
||||
Logger::err(str::format("DxgiAdapter: No format mapping for ", format));
|
||||
return DXGI_VK_FORMAT_INFO();
|
||||
DXGI_FORMAT Format,
|
||||
DXGI_VK_FORMAT_MODE Mode) {
|
||||
return GetDXGIFormatInfo(Format, Mode);
|
||||
}
|
||||
|
||||
|
||||
@ -243,230 +229,4 @@ namespace dxvk {
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
void DxgiAdapter::AddColorFormatTypeless(
|
||||
DXGI_FORMAT srcFormat,
|
||||
VkFormat dstFormat) {
|
||||
DXGI_VK_FORMAT_INFO formatPair;
|
||||
formatPair.format = dstFormat;
|
||||
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
formatPair.swizzle = {
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY };
|
||||
formatPair.flags = DXGI_VK_FORMAT_TYPELESS;
|
||||
m_colorFormats.insert(std::make_pair(srcFormat, formatPair));
|
||||
}
|
||||
|
||||
|
||||
void DxgiAdapter::AddColorFormat(
|
||||
DXGI_FORMAT srcFormat,
|
||||
VkFormat dstFormat,
|
||||
VkComponentMapping swizzle) {
|
||||
DXGI_VK_FORMAT_INFO formatPair;
|
||||
formatPair.format = dstFormat;
|
||||
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
formatPair.swizzle = swizzle;
|
||||
formatPair.flags = 0;
|
||||
m_colorFormats.insert(std::make_pair(srcFormat, formatPair));
|
||||
}
|
||||
|
||||
|
||||
void DxgiAdapter::AddDepthFormatTypeless(
|
||||
DXGI_FORMAT srcFormat,
|
||||
VkFormat dstFormat) {
|
||||
DXGI_VK_FORMAT_INFO formatPair;
|
||||
formatPair.format = dstFormat;
|
||||
formatPair.aspect = 0;
|
||||
formatPair.swizzle = {
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY };
|
||||
formatPair.flags = DXGI_VK_FORMAT_TYPELESS;
|
||||
m_depthFormats.insert(std::make_pair(srcFormat, formatPair));
|
||||
}
|
||||
|
||||
|
||||
void DxgiAdapter::AddDepthFormat(
|
||||
DXGI_FORMAT srcFormat,
|
||||
VkFormat dstFormat,
|
||||
VkImageAspectFlags srvAspect) {
|
||||
DXGI_VK_FORMAT_INFO formatPair;
|
||||
formatPair.format = dstFormat;
|
||||
formatPair.aspect = srvAspect;
|
||||
formatPair.swizzle = {
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY };
|
||||
formatPair.flags = 0;
|
||||
m_depthFormats.insert(std::make_pair(srcFormat, formatPair));
|
||||
}
|
||||
|
||||
|
||||
void DxgiAdapter::SetupFormatTable() {
|
||||
/***********************************************************************************/
|
||||
/* C O L O R F O R M A T S */
|
||||
AddColorFormat (DXGI_FORMAT_UNKNOWN, VK_FORMAT_UNDEFINED);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R32G32B32A32_TYPELESS, VK_FORMAT_R32G32B32A32_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT);
|
||||
AddColorFormat (DXGI_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_SINT);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R32G32B32_TYPELESS, VK_FORMAT_R32G32B32_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT);
|
||||
AddColorFormat (DXGI_FORMAT_R32G32B32_UINT, VK_FORMAT_R32G32B32_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R32G32B32_SINT, VK_FORMAT_R32G32B32_SINT);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R16G16B16A16_TYPELESS, VK_FORMAT_R16G16B16A16_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16B16A16_FLOAT, VK_FORMAT_R16G16B16A16_SFLOAT);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16B16A16_UNORM, VK_FORMAT_R16G16B16A16_UNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16B16A16_UINT, VK_FORMAT_R16G16B16A16_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16B16A16_SNORM, VK_FORMAT_R16G16B16A16_SNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SINT);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R32G32_TYPELESS, VK_FORMAT_R32G32_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT);
|
||||
AddColorFormat (DXGI_FORMAT_R32G32_UINT, VK_FORMAT_R32G32_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R32G32_SINT, VK_FORMAT_R32G32_SINT);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R10G10B10A2_TYPELESS, VK_FORMAT_A2B10G10R10_UINT_PACK32);
|
||||
AddColorFormat (DXGI_FORMAT_R10G10B10A2_UINT, VK_FORMAT_A2B10G10R10_UINT_PACK32);
|
||||
AddColorFormat (DXGI_FORMAT_R10G10B10A2_UNORM, VK_FORMAT_A2B10G10R10_UNORM_PACK32);
|
||||
|
||||
AddColorFormat (DXGI_FORMAT_R11G11B10_FLOAT, VK_FORMAT_B10G11R11_UFLOAT_PACK32);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R8G8B8A8_TYPELESS, VK_FORMAT_R8G8B8A8_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, VK_FORMAT_R8G8B8A8_SRGB);
|
||||
AddColorFormat (DXGI_FORMAT_R8G8B8A8_UINT, VK_FORMAT_R8G8B8A8_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_SNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R8G8B8A8_SINT, VK_FORMAT_R8G8B8A8_SINT);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R16G16_TYPELESS, VK_FORMAT_R16G16_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16_FLOAT, VK_FORMAT_R16G16_SFLOAT);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16_UNORM, VK_FORMAT_R16G16_UNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16_UINT, VK_FORMAT_R16G16_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16_SNORM, VK_FORMAT_R16G16_SNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R16G16_SINT, VK_FORMAT_R16G16_SINT);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R32_TYPELESS, VK_FORMAT_R32_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R32_FLOAT, VK_FORMAT_R32_SFLOAT);
|
||||
AddColorFormat (DXGI_FORMAT_R32_UINT, VK_FORMAT_R32_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R32_SINT, VK_FORMAT_R32_SINT);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R8G8_TYPELESS, VK_FORMAT_R8G8_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8_UNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R8G8_UINT, VK_FORMAT_R8G8_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R8G8_SNORM, VK_FORMAT_R8G8_SNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R8G8_SINT, VK_FORMAT_R8G8_SINT);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R16_TYPELESS, VK_FORMAT_R16_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R16_FLOAT, VK_FORMAT_R16_SFLOAT);
|
||||
AddColorFormat (DXGI_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R16_UINT, VK_FORMAT_R16_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R16_SNORM, VK_FORMAT_R16_SNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R16_SINT, VK_FORMAT_R16_SINT);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_R8_TYPELESS, VK_FORMAT_R8_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R8_UNORM, VK_FORMAT_R8_UNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R8_UINT, VK_FORMAT_R8_UINT);
|
||||
AddColorFormat (DXGI_FORMAT_R8_SNORM, VK_FORMAT_R8_SNORM);
|
||||
AddColorFormat (DXGI_FORMAT_R8_SINT, VK_FORMAT_R8_SINT);
|
||||
|
||||
AddColorFormat (DXGI_FORMAT_A8_UNORM, VK_FORMAT_R8_UNORM,
|
||||
{ VK_COMPONENT_SWIZZLE_ZERO, VK_COMPONENT_SWIZZLE_ZERO,
|
||||
VK_COMPONENT_SWIZZLE_ZERO, VK_COMPONENT_SWIZZLE_R });
|
||||
|
||||
// AddColorFormat(DXGI_FORMAT_R1_UNORM, VK_FORMAT_UNDEFINED);
|
||||
|
||||
AddColorFormat (DXGI_FORMAT_R9G9B9E5_SHAREDEXP, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32);
|
||||
|
||||
AddColorFormat (DXGI_FORMAT_R8G8_B8G8_UNORM, VK_FORMAT_B8G8R8G8_422_UNORM_KHR,
|
||||
{ VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_G,
|
||||
VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_ONE });
|
||||
|
||||
AddColorFormat (DXGI_FORMAT_G8R8_G8B8_UNORM, VK_FORMAT_G8B8G8R8_422_UNORM_KHR,
|
||||
{ VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_G,
|
||||
VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_ONE });
|
||||
|
||||
AddColorFormat (DXGI_FORMAT_B5G6R5_UNORM, VK_FORMAT_R5G6B5_UNORM_PACK16);
|
||||
AddColorFormat (DXGI_FORMAT_B5G5R5A1_UNORM, VK_FORMAT_A1R5G5B5_UNORM_PACK16);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_B8G8R8A8_TYPELESS, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
AddColorFormat (DXGI_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
AddColorFormat (DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, VK_FORMAT_B8G8R8A8_SRGB);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_B8G8R8X8_TYPELESS, VK_FORMAT_B8G8R8A8_UNORM);
|
||||
|
||||
AddColorFormat(DXGI_FORMAT_B8G8R8X8_UNORM, VK_FORMAT_B8G8R8A8_UNORM,
|
||||
{ VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G,
|
||||
VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ONE });
|
||||
|
||||
AddColorFormat(DXGI_FORMAT_B8G8R8X8_UNORM_SRGB, VK_FORMAT_B8G8R8A8_SRGB,
|
||||
{ VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G,
|
||||
VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ONE });
|
||||
|
||||
// AddColorFormat(DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, VK_FORMAT_UNDEFINED);
|
||||
|
||||
AddColorFormat (DXGI_FORMAT_B4G4R4A4_UNORM, VK_FORMAT_B4G4R4A4_UNORM_PACK16,
|
||||
{ VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R,
|
||||
VK_COMPONENT_SWIZZLE_A, VK_COMPONENT_SWIZZLE_B });
|
||||
|
||||
/***********************************************************************************/
|
||||
/* B L O C K F O R M A T S */
|
||||
AddColorFormatTypeless(DXGI_FORMAT_BC1_TYPELESS, VK_FORMAT_BC1_RGBA_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC1_UNORM, VK_FORMAT_BC1_RGBA_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC1_UNORM_SRGB, VK_FORMAT_BC1_RGBA_SRGB_BLOCK);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_BC2_TYPELESS, VK_FORMAT_BC2_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC2_UNORM, VK_FORMAT_BC2_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC2_UNORM_SRGB, VK_FORMAT_BC2_SRGB_BLOCK);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_BC3_TYPELESS, VK_FORMAT_BC3_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC3_UNORM, VK_FORMAT_BC3_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC3_UNORM_SRGB, VK_FORMAT_BC3_SRGB_BLOCK);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_BC4_TYPELESS, VK_FORMAT_BC4_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC4_UNORM, VK_FORMAT_BC4_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC4_SNORM, VK_FORMAT_BC4_SNORM_BLOCK);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_BC5_TYPELESS, VK_FORMAT_BC5_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC5_UNORM, VK_FORMAT_BC5_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC5_SNORM, VK_FORMAT_BC5_SNORM_BLOCK);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_BC6H_TYPELESS, VK_FORMAT_BC6H_UFLOAT_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC6H_UF16, VK_FORMAT_BC6H_UFLOAT_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC6H_SF16, VK_FORMAT_BC6H_SFLOAT_BLOCK);
|
||||
|
||||
AddColorFormatTypeless(DXGI_FORMAT_BC7_TYPELESS, VK_FORMAT_BC7_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC7_UNORM, VK_FORMAT_BC7_UNORM_BLOCK);
|
||||
AddColorFormat (DXGI_FORMAT_BC7_UNORM_SRGB, VK_FORMAT_BC7_SRGB_BLOCK);
|
||||
|
||||
/***********************************************************************************/
|
||||
/* D E P T H F O R M A T S */
|
||||
AddDepthFormatTypeless(DXGI_FORMAT_R16_TYPELESS, VK_FORMAT_D16_UNORM);
|
||||
AddDepthFormat (DXGI_FORMAT_D16_UNORM, VK_FORMAT_D16_UNORM, 0);
|
||||
AddDepthFormat (DXGI_FORMAT_R16_UNORM, VK_FORMAT_D16_UNORM, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
|
||||
AddDepthFormatTypeless(DXGI_FORMAT_R32_TYPELESS, VK_FORMAT_D32_SFLOAT);
|
||||
AddDepthFormat (DXGI_FORMAT_D32_FLOAT, VK_FORMAT_D32_SFLOAT, 0);
|
||||
AddDepthFormat (DXGI_FORMAT_R32_FLOAT, VK_FORMAT_D32_SFLOAT, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
|
||||
AddDepthFormatTypeless(DXGI_FORMAT_R32G8X24_TYPELESS, VK_FORMAT_D32_SFLOAT_S8_UINT);
|
||||
AddDepthFormat (DXGI_FORMAT_D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, 0);
|
||||
AddDepthFormat (DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
AddDepthFormat (DXGI_FORMAT_X32_TYPELESS_G8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
|
||||
// Vulkan implementations are not required to support 24-bit depth buffers natively
|
||||
// and support is generally worse than for 32-bit depth buffers, so we won't use them
|
||||
AddDepthFormatTypeless(DXGI_FORMAT_R24G8_TYPELESS, VK_FORMAT_D32_SFLOAT_S8_UINT);
|
||||
AddDepthFormat (DXGI_FORMAT_R24_UNORM_X8_TYPELESS, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
AddDepthFormat (DXGI_FORMAT_X24_TYPELESS_G8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
AddDepthFormat (DXGI_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ namespace dxvk {
|
||||
IDXGIVkDevice** ppDevice) final;
|
||||
|
||||
DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE LookupFormat(
|
||||
DXGI_FORMAT format,
|
||||
DxgiFormatMode mode) final;
|
||||
DXGI_FORMAT Format,
|
||||
DXGI_VK_FORMAT_MODE Mode) final;
|
||||
|
||||
HRESULT GetOutputFromMonitor(
|
||||
HMONITOR Monitor,
|
||||
@ -72,40 +72,14 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
using FormatMap = std::unordered_map<DXGI_FORMAT, DXGI_VK_FORMAT_INFO>;
|
||||
using OutputMap = std::unordered_map<HMONITOR, DXGI_VK_OUTPUT_DATA>;
|
||||
|
||||
Com<DxgiFactory> m_factory;
|
||||
Rc<DxvkAdapter> m_adapter;
|
||||
|
||||
FormatMap m_colorFormats;
|
||||
FormatMap m_depthFormats;
|
||||
|
||||
std::mutex m_outputMutex;
|
||||
OutputMap m_outputData;
|
||||
|
||||
void AddColorFormatTypeless(
|
||||
DXGI_FORMAT srcFormat,
|
||||
VkFormat dstFormat);
|
||||
|
||||
void AddColorFormat(
|
||||
DXGI_FORMAT srcFormat,
|
||||
VkFormat dstFormat,
|
||||
VkComponentMapping swizzle = {
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY });
|
||||
|
||||
void AddDepthFormatTypeless(
|
||||
DXGI_FORMAT srcFormat,
|
||||
VkFormat dstFormat);
|
||||
|
||||
void AddDepthFormat(
|
||||
DXGI_FORMAT srcFormat,
|
||||
VkFormat dstFormat,
|
||||
VkImageAspectFlags srvAspect);
|
||||
|
||||
void SetupFormatTable();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,563 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
std::array<DXGI_VK_FORMAT_MAPPING, 133> g_dxgiFormats = {{
|
||||
// DXGI_FORMAT_UNKNOWN
|
||||
{ },
|
||||
// DXGI_FORMAT_R32G32B32A32_TYPELESS
|
||||
{ VK_FORMAT_R32G32B32A32_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32B32A32_UINT },
|
||||
// DXGI_FORMAT_R32G32B32A32_FLOAT
|
||||
{ VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32B32A32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32G32B32A32_UINT
|
||||
{ VK_FORMAT_R32G32B32A32_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32B32A32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32G32B32A32_SINT
|
||||
{ VK_FORMAT_R32G32B32A32_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32B32A32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32G32B32_TYPELESS
|
||||
{ VK_FORMAT_R32G32B32_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32B32_UINT },
|
||||
// DXGI_FORMAT_R32G32B32_FLOAT
|
||||
{ VK_FORMAT_R32G32B32_SFLOAT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32B32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32G32B32_UINT
|
||||
{ VK_FORMAT_R32G32B32_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32B32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32G32B32_SINT
|
||||
{ VK_FORMAT_R32G32B32_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32B32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16B16A16_TYPELESS
|
||||
{ VK_FORMAT_R16G16B16A16_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16B16A16_UINT },
|
||||
// DXGI_FORMAT_R16G16B16A16_FLOAT
|
||||
{ VK_FORMAT_R16G16B16A16_SFLOAT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16B16A16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16B16A16_UNORM
|
||||
{ VK_FORMAT_R16G16B16A16_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16B16A16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16B16A16_UINT
|
||||
{ VK_FORMAT_R16G16B16A16_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16B16A16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16B16A16_SNORM
|
||||
{ VK_FORMAT_R16G16B16A16_SNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16B16A16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16B16A16_SINT
|
||||
{ VK_FORMAT_R16G16B16A16_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16B16A16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32G32_TYPELESS
|
||||
{ VK_FORMAT_R32G32_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32_UINT },
|
||||
// DXGI_FORMAT_R32G32_FLOAT
|
||||
{ VK_FORMAT_R32G32_SFLOAT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32G32_UINT
|
||||
{ VK_FORMAT_R32G32_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32G32_SINT
|
||||
{ VK_FORMAT_R32G32_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32G32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32G8X24_TYPELESS
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_D32_FLOAT_S8X24_UINT
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
0, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT },
|
||||
// DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
0, VK_IMAGE_ASPECT_DEPTH_BIT },
|
||||
// DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
0, VK_IMAGE_ASPECT_STENCIL_BIT },
|
||||
// DXGI_FORMAT_R10G10B10A2_TYPELESS
|
||||
{ VK_FORMAT_A2B10G10R10_UINT_PACK32,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_A2B10G10R10_UINT_PACK32 },
|
||||
// DXGI_FORMAT_R10G10B10A2_UNORM
|
||||
{ VK_FORMAT_A2B10G10R10_UNORM_PACK32,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_A2B10G10R10_UINT_PACK32,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R10G10B10A2_UINT
|
||||
{ VK_FORMAT_A2B10G10R10_UINT_PACK32,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_A2B10G10R10_UINT_PACK32,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R11G11B10_FLOAT
|
||||
{ VK_FORMAT_B10G11R11_UFLOAT_PACK32,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8G8B8A8_TYPELESS
|
||||
{ VK_FORMAT_R8G8B8A8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8B8A8_UINT },
|
||||
// DXGI_FORMAT_R8G8B8A8_UNORM
|
||||
{ VK_FORMAT_R8G8B8A8_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8B8A8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
|
||||
{ VK_FORMAT_R8G8B8A8_SRGB,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8B8A8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8G8B8A8_UINT
|
||||
{ VK_FORMAT_R8G8B8A8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8B8A8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8G8B8A8_SNORM
|
||||
{ VK_FORMAT_R8G8B8A8_SNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8B8A8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8G8B8A8_SINT
|
||||
{ VK_FORMAT_R8G8B8A8_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8B8A8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16_TYPELESS
|
||||
{ VK_FORMAT_R16G16_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16_UINT },
|
||||
// DXGI_FORMAT_R16G16_FLOAT
|
||||
{ VK_FORMAT_R16G16_SFLOAT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16_UNORM
|
||||
{ VK_FORMAT_R16G16_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16_UINT
|
||||
{ VK_FORMAT_R16G16_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16_SNORM
|
||||
{ VK_FORMAT_R16G16_SNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16G16_SINT
|
||||
{ VK_FORMAT_R16G16_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16G16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32_TYPELESS
|
||||
{ VK_FORMAT_R32_UINT,
|
||||
VK_FORMAT_D32_SFLOAT,
|
||||
VK_FORMAT_R32_UINT },
|
||||
// DXGI_FORMAT_D32_FLOAT
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D32_SFLOAT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
0, VK_IMAGE_ASPECT_DEPTH_BIT },
|
||||
// DXGI_FORMAT_R32_FLOAT
|
||||
{ VK_FORMAT_R32_SFLOAT,
|
||||
VK_FORMAT_D32_SFLOAT,
|
||||
VK_FORMAT_R32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT },
|
||||
// DXGI_FORMAT_R32_UINT
|
||||
{ VK_FORMAT_R32_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R32_SINT
|
||||
{ VK_FORMAT_R32_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R32_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R24G8_TYPELESS
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_D24_UNORM_S8_UINT
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
0, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT },
|
||||
// DXGI_FORMAT_R24_UNORM_X8_TYPELESS
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
0, VK_IMAGE_ASPECT_DEPTH_BIT },
|
||||
// DXGI_FORMAT_X24_TYPELESS_G8_UINT
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
0, VK_IMAGE_ASPECT_STENCIL_BIT },
|
||||
// DXGI_FORMAT_R8G8_TYPELESS
|
||||
{ VK_FORMAT_R8G8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8_UINT },
|
||||
// DXGI_FORMAT_R8G8_UNORM
|
||||
{ VK_FORMAT_R8G8_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8G8_UINT
|
||||
{ VK_FORMAT_R8G8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8G8_SNORM
|
||||
{ VK_FORMAT_R8G8_SNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8G8_SINT
|
||||
{ VK_FORMAT_R8G8_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8G8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16_TYPELESS
|
||||
{ VK_FORMAT_R16_UINT,
|
||||
VK_FORMAT_D16_UNORM,
|
||||
VK_FORMAT_R16_UINT },
|
||||
// DXGI_FORMAT_R16_FLOAT
|
||||
{ VK_FORMAT_R16_SFLOAT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_D16_UNORM
|
||||
{ VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_D16_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
0, VK_IMAGE_ASPECT_DEPTH_BIT },
|
||||
// DXGI_FORMAT_R16_UNORM
|
||||
{ VK_FORMAT_R16_UNORM,
|
||||
VK_FORMAT_D16_UNORM,
|
||||
VK_FORMAT_R16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT },
|
||||
// DXGI_FORMAT_R16_UINT
|
||||
{ VK_FORMAT_R16_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16_SNORM
|
||||
{ VK_FORMAT_R16_SNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R16_SINT
|
||||
{ VK_FORMAT_R16_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R16_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8_TYPELESS
|
||||
{ VK_FORMAT_R8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8_UINT },
|
||||
// DXGI_FORMAT_R8_UNORM
|
||||
{ VK_FORMAT_R8_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8_UINT
|
||||
{ VK_FORMAT_R8_UINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8_SNORM
|
||||
{ VK_FORMAT_R8_SNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8_SINT
|
||||
{ VK_FORMAT_R8_SINT,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_R8_UINT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_A8_UNORM
|
||||
{ VK_FORMAT_R8_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, 0,
|
||||
{ VK_COMPONENT_SWIZZLE_ZERO, VK_COMPONENT_SWIZZLE_ZERO,
|
||||
VK_COMPONENT_SWIZZLE_ZERO, VK_COMPONENT_SWIZZLE_R }},
|
||||
// DXGI_FORMAT_R1_UNORM
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_R9G9B9E5_SHAREDEXP
|
||||
{ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_R8G8_B8G8_UNORM
|
||||
{ VK_FORMAT_B8G8R8G8_422_UNORM_KHR,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, 0,
|
||||
{ VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_G,
|
||||
VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_ONE }},
|
||||
// DXGI_FORMAT_G8R8_G8B8_UNORM
|
||||
{ VK_FORMAT_G8B8G8R8_422_UNORM_KHR,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, 0,
|
||||
{ VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_G,
|
||||
VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_ONE }},
|
||||
// DXGI_FORMAT_BC1_TYPELESS
|
||||
{ VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_BC1_UNORM
|
||||
{ VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC1_UNORM_SRGB
|
||||
{ VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC2_TYPELESS
|
||||
{ VK_FORMAT_BC2_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_BC2_UNORM
|
||||
{ VK_FORMAT_BC2_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC2_UNORM_SRGB
|
||||
{ VK_FORMAT_BC2_SRGB_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC3_TYPELESS
|
||||
{ VK_FORMAT_BC3_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_BC3_UNORM
|
||||
{ VK_FORMAT_BC3_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC3_UNORM_SRGB
|
||||
{ VK_FORMAT_BC3_SRGB_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC4_TYPELESS
|
||||
{ VK_FORMAT_BC4_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_BC4_UNORM
|
||||
{ VK_FORMAT_BC4_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC4_SNORM
|
||||
{ VK_FORMAT_BC4_SNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC5_TYPELESS
|
||||
{ VK_FORMAT_BC5_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_BC5_UNORM
|
||||
{ VK_FORMAT_BC5_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC5_SNORM
|
||||
{ VK_FORMAT_BC5_SNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_B5G6R5_UNORM
|
||||
{ VK_FORMAT_R5G6B5_UNORM_PACK16,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_B5G5R5A1_UNORM
|
||||
{ VK_FORMAT_A1R5G5B5_UNORM_PACK16,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_B8G8R8A8_UNORM
|
||||
{ VK_FORMAT_B8G8R8A8_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_B8G8R8X8_UNORM
|
||||
{ VK_FORMAT_B8G8R8A8_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, 0,
|
||||
{ VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G,
|
||||
VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ONE }},
|
||||
// DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_B8G8R8A8_TYPELESS
|
||||
{ VK_FORMAT_B8G8R8A8_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
|
||||
{ VK_FORMAT_B8G8R8A8_SRGB,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_B8G8R8X8_TYPELESS
|
||||
{ VK_FORMAT_B8G8R8A8_UNORM,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
|
||||
{ VK_FORMAT_B8G8R8A8_SRGB,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, 0,
|
||||
{ VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G,
|
||||
VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ONE }},
|
||||
// DXGI_FORMAT_BC6H_TYPELESS
|
||||
{ VK_FORMAT_BC6H_UFLOAT_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_BC6H_UF16
|
||||
{ VK_FORMAT_BC6H_UFLOAT_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC6H_SF16
|
||||
{ VK_FORMAT_BC6H_SFLOAT_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC7_TYPELESS
|
||||
{ VK_FORMAT_BC7_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED },
|
||||
// DXGI_FORMAT_BC7_UNORM
|
||||
{ VK_FORMAT_BC7_UNORM_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_BC7_UNORM_SRGB
|
||||
{ VK_FORMAT_BC7_SRGB_BLOCK,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT },
|
||||
// DXGI_FORMAT_AYUV
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_Y410
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_Y416
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_NV12
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_P010
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_P016
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_420_OPAQUE
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_YUY2
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_Y210
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_Y216
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_NV11
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_AI44
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_IA44
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_P8
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_A8P8
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_B4G4R4A4_UNORM
|
||||
{ VK_FORMAT_B4G4R4A4_UNORM_PACK16,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_FORMAT_UNDEFINED,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, 0,
|
||||
{ VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R,
|
||||
VK_COMPONENT_SWIZZLE_A, VK_COMPONENT_SWIZZLE_B }},
|
||||
// DXGI_FORMAT_P208
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_V208
|
||||
{ }, // Unsupported
|
||||
// DXGI_FORMAT_V408
|
||||
{ }, // Unsupported
|
||||
}};
|
||||
|
||||
|
||||
DXGI_VK_FORMAT_INFO GetDXGIFormatInfo(
|
||||
DXGI_FORMAT Format,
|
||||
DXGI_VK_FORMAT_MODE Mode) {
|
||||
const size_t formatId = size_t(Format);
|
||||
|
||||
const DXGI_VK_FORMAT_MAPPING& mapping
|
||||
= formatId < g_dxgiFormats.size()
|
||||
? g_dxgiFormats[formatId]
|
||||
: g_dxgiFormats[0];
|
||||
|
||||
switch (Mode) {
|
||||
case DXGI_VK_FORMAT_MODE_ANY:
|
||||
return mapping.FormatColor != VK_FORMAT_UNDEFINED
|
||||
? DXGI_VK_FORMAT_INFO { mapping.FormatColor, mapping.AspectColor, mapping.Swizzle }
|
||||
: DXGI_VK_FORMAT_INFO { mapping.FormatDepth, mapping.AspectDepth };
|
||||
|
||||
case DXGI_VK_FORMAT_MODE_COLOR:
|
||||
return { mapping.FormatColor, mapping.AspectColor, mapping.Swizzle };
|
||||
|
||||
case DXGI_VK_FORMAT_MODE_DEPTH:
|
||||
return { mapping.FormatDepth, mapping.AspectDepth };
|
||||
|
||||
case DXGI_VK_FORMAT_MODE_RAW:
|
||||
return { mapping.FormatRaw, mapping.AspectColor };
|
||||
}
|
||||
|
||||
Logger::err("DXGI: GetDXGIFormatInfo: Internal error");
|
||||
return DXGI_VK_FORMAT_INFO();
|
||||
}
|
||||
|
||||
};
|
@ -7,10 +7,19 @@
|
||||
namespace dxvk {
|
||||
|
||||
/**
|
||||
* \brief Format information
|
||||
* \brief Format mapping
|
||||
*
|
||||
* Maps a DXGI format to a set of Vulkan formats.
|
||||
*/
|
||||
enum DXGI_VK_FORMAT_FLAGS : uint32_t {
|
||||
DXGI_VK_FORMAT_TYPELESS = 0,
|
||||
struct DXGI_VK_FORMAT_MAPPING {
|
||||
VkFormat FormatColor = VK_FORMAT_UNDEFINED; ///< Corresponding color format
|
||||
VkFormat FormatDepth = VK_FORMAT_UNDEFINED; ///< Corresponding depth format
|
||||
VkFormat FormatRaw = VK_FORMAT_UNDEFINED; ///< Bit-compatible integer format
|
||||
VkImageAspectFlags AspectColor = 0; ///< Defined aspects for the color format
|
||||
VkImageAspectFlags AspectDepth = 0; ///< Defined aspects for the depth format
|
||||
VkComponentMapping Swizzle = { ///< Color component swizzle
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY };
|
||||
};
|
||||
|
||||
/**
|
||||
@ -22,12 +31,11 @@ namespace dxvk {
|
||||
* are supposed to be used.
|
||||
*/
|
||||
struct DXGI_VK_FORMAT_INFO {
|
||||
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||
VkImageAspectFlags aspect = 0;
|
||||
VkComponentMapping swizzle = {
|
||||
VkFormat Format = VK_FORMAT_UNDEFINED; ///< Corresponding color format
|
||||
VkImageAspectFlags Aspect = 0; ///< Defined image aspect mask
|
||||
VkComponentMapping Swizzle = { ///< Component swizzle
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY };
|
||||
UINT flags = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -38,10 +46,22 @@ namespace dxvk {
|
||||
* This is used to properly map typeless formats and color
|
||||
* formats to depth formats if they are used on depth images.
|
||||
*/
|
||||
enum class DxgiFormatMode : uint32_t {
|
||||
Any = 0,
|
||||
Color = 1,
|
||||
Depth = 2,
|
||||
enum DXGI_VK_FORMAT_MODE {
|
||||
DXGI_VK_FORMAT_MODE_ANY = 0, ///< Color first, then depth
|
||||
DXGI_VK_FORMAT_MODE_COLOR = 1, ///< Color only
|
||||
DXGI_VK_FORMAT_MODE_DEPTH = 2, ///< Depth only
|
||||
DXGI_VK_FORMAT_MODE_RAW = 3, ///< Unsigned integer format
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Retrieves info for a given DXGI format
|
||||
*
|
||||
* \param [in] Format The DXGI format to look up
|
||||
* \param [in] Mode the format lookup mode
|
||||
* \returns Format info
|
||||
*/
|
||||
DXGI_VK_FORMAT_INFO GetDXGIFormatInfo(
|
||||
DXGI_FORMAT Format,
|
||||
DXGI_VK_FORMAT_MODE Mode);
|
||||
|
||||
};
|
@ -70,7 +70,7 @@ IDXGIVkAdapter : public IDXGIAdapter1 {
|
||||
*/
|
||||
virtual dxvk::DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE LookupFormat(
|
||||
DXGI_FORMAT format,
|
||||
dxvk::DxgiFormatMode mode) = 0;
|
||||
dxvk::DXGI_VK_FORMAT_MODE mode) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -325,8 +325,8 @@ namespace dxvk {
|
||||
|
||||
|
||||
uint32_t DxgiOutput::GetFormatBpp(DXGI_FORMAT Format) const {
|
||||
DXGI_VK_FORMAT_INFO formatInfo = m_adapter->LookupFormat(Format, DxgiFormatMode::Any);
|
||||
return imageFormatInfo(formatInfo.format)->elementSize * 8;
|
||||
DXGI_VK_FORMAT_INFO formatInfo = m_adapter->LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY);
|
||||
return imageFormatInfo(formatInfo.Format)->elementSize * 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user