1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05: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:
Philip Rebohle 2018-04-12 15:36:01 +02:00
parent adb1789571
commit 3405b89494
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
7 changed files with 73 additions and 53 deletions

View File

@ -173,7 +173,7 @@ namespace dxvk {
}
DxgiFormatInfo STDMETHODCALLTYPE DxgiAdapter::LookupFormat(
DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE DxgiAdapter::LookupFormat(
DXGI_FORMAT format,
DxgiFormatMode mode) {
// 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));
return DxgiFormatInfo();
return DXGI_VK_FORMAT_INFO();
}
@ -247,7 +247,7 @@ namespace dxvk {
void DxgiAdapter::AddColorFormatTypeless(
DXGI_FORMAT srcFormat,
VkFormat dstFormat) {
DxgiFormatInfo formatPair;
DXGI_VK_FORMAT_INFO formatPair;
formatPair.format = dstFormat;
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
formatPair.swizzle = {
@ -255,7 +255,7 @@ namespace dxvk {
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));
}
@ -264,11 +264,11 @@ namespace dxvk {
DXGI_FORMAT srcFormat,
VkFormat dstFormat,
VkComponentMapping swizzle) {
DxgiFormatInfo formatPair;
DXGI_VK_FORMAT_INFO formatPair;
formatPair.format = dstFormat;
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
formatPair.swizzle = swizzle;
formatPair.flags = DxgiFormatFlags();
formatPair.flags = 0;
m_colorFormats.insert(std::make_pair(srcFormat, formatPair));
}
@ -276,7 +276,7 @@ namespace dxvk {
void DxgiAdapter::AddDepthFormatTypeless(
DXGI_FORMAT srcFormat,
VkFormat dstFormat) {
DxgiFormatInfo formatPair;
DXGI_VK_FORMAT_INFO formatPair;
formatPair.format = dstFormat;
formatPair.aspect = 0;
formatPair.swizzle = {
@ -284,7 +284,7 @@ namespace dxvk {
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));
}
@ -293,7 +293,7 @@ namespace dxvk {
DXGI_FORMAT srcFormat,
VkFormat dstFormat,
VkImageAspectFlags srvAspect) {
DxgiFormatInfo formatPair;
DXGI_VK_FORMAT_INFO formatPair;
formatPair.format = dstFormat;
formatPair.aspect = srvAspect;
formatPair.swizzle = {
@ -301,7 +301,7 @@ namespace dxvk {
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));
}

View File

@ -54,7 +54,7 @@ namespace dxvk {
const VkPhysicalDeviceFeatures* pFeatures,
IDXGIVkDevice** ppDevice) final;
DxgiFormatInfo STDMETHODCALLTYPE LookupFormat(
DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE LookupFormat(
DXGI_FORMAT format,
DxgiFormatMode mode) final;
@ -72,7 +72,7 @@ namespace dxvk {
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>;
Com<DxgiFactory> m_factory;

9
src/dxgi/dxgi_format.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "dxgi_format.h"
#include <array>
namespace dxvk {
};

47
src/dxgi/dxgi_format.h Normal file
View 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,
};
};

View File

@ -2,6 +2,7 @@
#include "../dxvk/dxvk_include.h"
#include "dxgi_format.h"
#include "dxgi_include.h"
namespace dxvk {
@ -10,44 +11,6 @@ namespace dxvk {
class DxvkBuffer;
class DxvkDevice;
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
* \returns Vulkan format pair
*/
virtual dxvk::DxgiFormatInfo STDMETHODCALLTYPE LookupFormat(
virtual dxvk::DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE LookupFormat(
DXGI_FORMAT format,
dxvk::DxgiFormatMode mode) = 0;
};

View File

@ -325,7 +325,7 @@ namespace dxvk {
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;
}

View File

@ -8,6 +8,7 @@ dxgi_src = [
'dxgi_device.cpp',
'dxgi_enums.cpp',
'dxgi_factory.cpp',
'dxgi_format.cpp',
'dxgi_main.cpp',
'dxgi_output.cpp',
'dxgi_presenter.cpp',