1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 19:54:19 +01:00

[dxgi] Add methods to retrieve original format mappings

This commit is contained in:
Philip Rebohle 2019-03-26 17:17:32 +01:00
parent b3ea1b02eb
commit 6c2f16fce8
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 65 additions and 20 deletions

View File

@ -853,26 +853,16 @@ namespace dxvk {
DXGI_VK_FORMAT_INFO DXGIVkFormatTable::GetFormatInfo(
DXGI_FORMAT Format,
DXGI_VK_FORMAT_MODE Mode) const {
const DXGI_VK_FORMAT_MAPPING* mapping = GetFormatMapping(Format);
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: GetFormatInfo: Internal error");
return DXGI_VK_FORMAT_INFO();
return GetFormatInfoFromMapping(
GetFormatMapping(Format), Mode);
}
DXGI_VK_FORMAT_INFO DXGIVkFormatTable::GetPackedFormatInfo(
DXGI_FORMAT Format,
DXGI_VK_FORMAT_MODE Mode) const {
return GetFormatInfoFromMapping(
GetPackedFormatMapping(Format), Mode);
}
@ -890,6 +880,30 @@ namespace dxvk {
}
DXGI_VK_FORMAT_INFO DXGIVkFormatTable::GetFormatInfoFromMapping(
const DXGI_VK_FORMAT_MAPPING* pMapping,
DXGI_VK_FORMAT_MODE Mode) const {
switch (Mode) {
case DXGI_VK_FORMAT_MODE_ANY:
return pMapping->FormatColor != VK_FORMAT_UNDEFINED
? DXGI_VK_FORMAT_INFO { pMapping->FormatColor, pMapping->AspectColor, pMapping->Swizzle }
: DXGI_VK_FORMAT_INFO { pMapping->FormatDepth, pMapping->AspectDepth };
case DXGI_VK_FORMAT_MODE_COLOR:
return { pMapping->FormatColor, pMapping->AspectColor, pMapping->Swizzle };
case DXGI_VK_FORMAT_MODE_DEPTH:
return { pMapping->FormatDepth, pMapping->AspectDepth };
case DXGI_VK_FORMAT_MODE_RAW:
return { pMapping->FormatRaw, pMapping->AspectColor };
}
Logger::err("DXGI: GetFormatInfoFromMapping: Internal error");
return DXGI_VK_FORMAT_INFO();
}
const DXGI_VK_FORMAT_MAPPING* DXGIVkFormatTable::GetFormatMapping(
DXGI_FORMAT Format) const {
const size_t formatId = size_t(Format);
@ -900,6 +914,16 @@ namespace dxvk {
}
const DXGI_VK_FORMAT_MAPPING* DXGIVkFormatTable::GetPackedFormatMapping(
DXGI_FORMAT Format) const {
const size_t formatId = size_t(Format);
return formatId < g_dxgiFormats.size()
? &g_dxgiFormats[formatId]
: &g_dxgiFormats[0];
}
bool DXGIVkFormatTable::CheckImageFormatSupport(
const Rc<DxvkAdapter>& Adapter,
VkFormat Format,

View File

@ -114,6 +114,20 @@ namespace dxvk {
DXGI_FORMAT Format,
DXGI_VK_FORMAT_MODE Mode) const;
/**
* \brief Retrieves original info for a given DXGI format
*
* Doesn't perform any format adjustment, so this
* can be used to determine the packed data format
* of a DXGI format for things like data uploads.
* \param [in] Format The DXGI format to look up
* \param [in] Mode the format lookup mode
* \returns Format info
*/
DXGI_VK_FORMAT_INFO GetPackedFormatInfo(
DXGI_FORMAT Format,
DXGI_VK_FORMAT_MODE Mode) const;
/**
* \brief Retrieves a format family
*
@ -129,10 +143,17 @@ namespace dxvk {
std::array<DXGI_VK_FORMAT_MAPPING, 133> m_dxgiFormats;
std::array<DXGI_VK_FORMAT_FAMILY, 133> m_dxgiFamilies;
DXGI_VK_FORMAT_INFO GetFormatInfoFromMapping(
const DXGI_VK_FORMAT_MAPPING* pMapping,
DXGI_VK_FORMAT_MODE Mode) const;
const DXGI_VK_FORMAT_MAPPING* GetFormatMapping(
DXGI_FORMAT Format) const;
const DXGI_VK_FORMAT_MAPPING* GetPackedFormatMapping(
DXGI_FORMAT Format) const;
bool CheckImageFormatSupport(
const Rc<DxvkAdapter>& Adapter,
VkFormat Format,