mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxgi] Rename and move DXGI format lookup related structures
This is part of a major refactoring process regarding DXGI->Vulkan format conversions. Since we don't patch format lookup tables any longer, we can create a global lookup table.
This commit is contained in:
parent
adb1789571
commit
3405b89494
@ -173,7 +173,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxgiFormatInfo STDMETHODCALLTYPE DxgiAdapter::LookupFormat(
|
DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE DxgiAdapter::LookupFormat(
|
||||||
DXGI_FORMAT format,
|
DXGI_FORMAT format,
|
||||||
DxgiFormatMode mode) {
|
DxgiFormatMode mode) {
|
||||||
// If the mode is 'Any', probe color formats first
|
// If the mode is 'Any', probe color formats first
|
||||||
@ -191,7 +191,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger::err(str::format("DxgiAdapter: No format mapping for ", format));
|
Logger::err(str::format("DxgiAdapter: No format mapping for ", format));
|
||||||
return DxgiFormatInfo();
|
return DXGI_VK_FORMAT_INFO();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ namespace dxvk {
|
|||||||
void DxgiAdapter::AddColorFormatTypeless(
|
void DxgiAdapter::AddColorFormatTypeless(
|
||||||
DXGI_FORMAT srcFormat,
|
DXGI_FORMAT srcFormat,
|
||||||
VkFormat dstFormat) {
|
VkFormat dstFormat) {
|
||||||
DxgiFormatInfo formatPair;
|
DXGI_VK_FORMAT_INFO formatPair;
|
||||||
formatPair.format = dstFormat;
|
formatPair.format = dstFormat;
|
||||||
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
|
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
formatPair.swizzle = {
|
formatPair.swizzle = {
|
||||||
@ -255,7 +255,7 @@ namespace dxvk {
|
|||||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY };
|
VK_COMPONENT_SWIZZLE_IDENTITY };
|
||||||
formatPair.flags = DxgiFormatFlag::Typeless;
|
formatPair.flags = DXGI_VK_FORMAT_TYPELESS;
|
||||||
m_colorFormats.insert(std::make_pair(srcFormat, formatPair));
|
m_colorFormats.insert(std::make_pair(srcFormat, formatPair));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,11 +264,11 @@ namespace dxvk {
|
|||||||
DXGI_FORMAT srcFormat,
|
DXGI_FORMAT srcFormat,
|
||||||
VkFormat dstFormat,
|
VkFormat dstFormat,
|
||||||
VkComponentMapping swizzle) {
|
VkComponentMapping swizzle) {
|
||||||
DxgiFormatInfo formatPair;
|
DXGI_VK_FORMAT_INFO formatPair;
|
||||||
formatPair.format = dstFormat;
|
formatPair.format = dstFormat;
|
||||||
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
|
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
formatPair.swizzle = swizzle;
|
formatPair.swizzle = swizzle;
|
||||||
formatPair.flags = DxgiFormatFlags();
|
formatPair.flags = 0;
|
||||||
m_colorFormats.insert(std::make_pair(srcFormat, formatPair));
|
m_colorFormats.insert(std::make_pair(srcFormat, formatPair));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ namespace dxvk {
|
|||||||
void DxgiAdapter::AddDepthFormatTypeless(
|
void DxgiAdapter::AddDepthFormatTypeless(
|
||||||
DXGI_FORMAT srcFormat,
|
DXGI_FORMAT srcFormat,
|
||||||
VkFormat dstFormat) {
|
VkFormat dstFormat) {
|
||||||
DxgiFormatInfo formatPair;
|
DXGI_VK_FORMAT_INFO formatPair;
|
||||||
formatPair.format = dstFormat;
|
formatPair.format = dstFormat;
|
||||||
formatPair.aspect = 0;
|
formatPair.aspect = 0;
|
||||||
formatPair.swizzle = {
|
formatPair.swizzle = {
|
||||||
@ -284,7 +284,7 @@ namespace dxvk {
|
|||||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY };
|
VK_COMPONENT_SWIZZLE_IDENTITY };
|
||||||
formatPair.flags = DxgiFormatFlag::Typeless;
|
formatPair.flags = DXGI_VK_FORMAT_TYPELESS;
|
||||||
m_depthFormats.insert(std::make_pair(srcFormat, formatPair));
|
m_depthFormats.insert(std::make_pair(srcFormat, formatPair));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ namespace dxvk {
|
|||||||
DXGI_FORMAT srcFormat,
|
DXGI_FORMAT srcFormat,
|
||||||
VkFormat dstFormat,
|
VkFormat dstFormat,
|
||||||
VkImageAspectFlags srvAspect) {
|
VkImageAspectFlags srvAspect) {
|
||||||
DxgiFormatInfo formatPair;
|
DXGI_VK_FORMAT_INFO formatPair;
|
||||||
formatPair.format = dstFormat;
|
formatPair.format = dstFormat;
|
||||||
formatPair.aspect = srvAspect;
|
formatPair.aspect = srvAspect;
|
||||||
formatPair.swizzle = {
|
formatPair.swizzle = {
|
||||||
@ -301,7 +301,7 @@ namespace dxvk {
|
|||||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
VK_COMPONENT_SWIZZLE_IDENTITY };
|
VK_COMPONENT_SWIZZLE_IDENTITY };
|
||||||
formatPair.flags = DxgiFormatFlags();
|
formatPair.flags = 0;
|
||||||
m_depthFormats.insert(std::make_pair(srcFormat, formatPair));
|
m_depthFormats.insert(std::make_pair(srcFormat, formatPair));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ namespace dxvk {
|
|||||||
const VkPhysicalDeviceFeatures* pFeatures,
|
const VkPhysicalDeviceFeatures* pFeatures,
|
||||||
IDXGIVkDevice** ppDevice) final;
|
IDXGIVkDevice** ppDevice) final;
|
||||||
|
|
||||||
DxgiFormatInfo STDMETHODCALLTYPE LookupFormat(
|
DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE LookupFormat(
|
||||||
DXGI_FORMAT format,
|
DXGI_FORMAT format,
|
||||||
DxgiFormatMode mode) final;
|
DxgiFormatMode mode) final;
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
using FormatMap = std::unordered_map<DXGI_FORMAT, DxgiFormatInfo>;
|
using FormatMap = std::unordered_map<DXGI_FORMAT, DXGI_VK_FORMAT_INFO>;
|
||||||
using OutputMap = std::unordered_map<HMONITOR, DXGI_VK_OUTPUT_DATA>;
|
using OutputMap = std::unordered_map<HMONITOR, DXGI_VK_OUTPUT_DATA>;
|
||||||
|
|
||||||
Com<DxgiFactory> m_factory;
|
Com<DxgiFactory> m_factory;
|
||||||
|
9
src/dxgi/dxgi_format.cpp
Normal file
9
src/dxgi/dxgi_format.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "dxgi_format.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
namespace dxvk {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
47
src/dxgi/dxgi_format.h
Normal file
47
src/dxgi/dxgi_format.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dxgi_include.h"
|
||||||
|
|
||||||
|
#include "../dxvk/dxvk_include.h"
|
||||||
|
|
||||||
|
namespace dxvk {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Format information
|
||||||
|
*/
|
||||||
|
enum DXGI_VK_FORMAT_FLAGS : uint32_t {
|
||||||
|
DXGI_VK_FORMAT_TYPELESS = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Format info
|
||||||
|
*
|
||||||
|
* Stores a Vulkan image format for a given
|
||||||
|
* DXGI format and some additional information
|
||||||
|
* on how resources with the particular format
|
||||||
|
* are supposed to be used.
|
||||||
|
*/
|
||||||
|
struct DXGI_VK_FORMAT_INFO {
|
||||||
|
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||||
|
VkImageAspectFlags aspect = 0;
|
||||||
|
VkComponentMapping swizzle = {
|
||||||
|
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
|
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY };
|
||||||
|
UINT flags = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Format lookup mode
|
||||||
|
*
|
||||||
|
* When looking up an image format, additional information
|
||||||
|
* might be needed on how the image is going to be used.
|
||||||
|
* 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,
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "../dxvk/dxvk_include.h"
|
#include "../dxvk/dxvk_include.h"
|
||||||
|
|
||||||
|
#include "dxgi_format.h"
|
||||||
#include "dxgi_include.h"
|
#include "dxgi_include.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
@ -10,44 +11,6 @@ namespace dxvk {
|
|||||||
class DxvkBuffer;
|
class DxvkBuffer;
|
||||||
class DxvkDevice;
|
class DxvkDevice;
|
||||||
class DxvkImage;
|
class DxvkImage;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Format information
|
|
||||||
*/
|
|
||||||
enum class DxgiFormatFlag {
|
|
||||||
Typeless = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
using DxgiFormatFlags = Flags<DxgiFormatFlag>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Format info
|
|
||||||
*
|
|
||||||
* Stores a Vulkan image format for a given
|
|
||||||
* DXGI format and some additional information
|
|
||||||
* on how resources with the particular format
|
|
||||||
* are supposed to be used.
|
|
||||||
*/
|
|
||||||
struct DxgiFormatInfo {
|
|
||||||
VkFormat format;
|
|
||||||
VkImageAspectFlags aspect;
|
|
||||||
VkComponentMapping swizzle;
|
|
||||||
DxgiFormatFlags flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Format lookup mode
|
|
||||||
*
|
|
||||||
* When looking up an image format, additional information
|
|
||||||
* might be needed on how the image is going to be used.
|
|
||||||
* 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,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,7 +68,7 @@ IDXGIVkAdapter : public IDXGIAdapter1 {
|
|||||||
* \param [in] mode Format lookup mode
|
* \param [in] mode Format lookup mode
|
||||||
* \returns Vulkan format pair
|
* \returns Vulkan format pair
|
||||||
*/
|
*/
|
||||||
virtual dxvk::DxgiFormatInfo STDMETHODCALLTYPE LookupFormat(
|
virtual dxvk::DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE LookupFormat(
|
||||||
DXGI_FORMAT format,
|
DXGI_FORMAT format,
|
||||||
dxvk::DxgiFormatMode mode) = 0;
|
dxvk::DxgiFormatMode mode) = 0;
|
||||||
};
|
};
|
||||||
|
@ -325,7 +325,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
uint32_t DxgiOutput::GetFormatBpp(DXGI_FORMAT Format) const {
|
uint32_t DxgiOutput::GetFormatBpp(DXGI_FORMAT Format) const {
|
||||||
DxgiFormatInfo formatInfo = m_adapter->LookupFormat(Format, DxgiFormatMode::Any);
|
DXGI_VK_FORMAT_INFO formatInfo = m_adapter->LookupFormat(Format, DxgiFormatMode::Any);
|
||||||
return imageFormatInfo(formatInfo.format)->elementSize * 8;
|
return imageFormatInfo(formatInfo.format)->elementSize * 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ dxgi_src = [
|
|||||||
'dxgi_device.cpp',
|
'dxgi_device.cpp',
|
||||||
'dxgi_enums.cpp',
|
'dxgi_enums.cpp',
|
||||||
'dxgi_factory.cpp',
|
'dxgi_factory.cpp',
|
||||||
|
'dxgi_format.cpp',
|
||||||
'dxgi_main.cpp',
|
'dxgi_main.cpp',
|
||||||
'dxgi_output.cpp',
|
'dxgi_output.cpp',
|
||||||
'dxgi_presenter.cpp',
|
'dxgi_presenter.cpp',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user