2017-10-11 03:09:04 +02:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include "dxgi_adapter.h"
|
2018-03-28 18:58:53 +02:00
|
|
|
#include "dxgi_device.h"
|
2017-12-04 11:33:04 +01:00
|
|
|
#include "dxgi_enums.h"
|
2017-10-11 03:09:04 +02:00
|
|
|
#include "dxgi_factory.h"
|
|
|
|
#include "dxgi_output.h"
|
|
|
|
|
2017-12-04 11:33:04 +01:00
|
|
|
#include "../dxvk/vulkan/dxvk_vulkan_names.h"
|
|
|
|
|
2017-10-11 03:09:04 +02:00
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
DxgiAdapter::DxgiAdapter(
|
|
|
|
DxgiFactory* factory,
|
|
|
|
const Rc<DxvkAdapter>& adapter)
|
|
|
|
: m_factory (factory),
|
|
|
|
m_adapter (adapter) {
|
2017-12-04 11:33:04 +01:00
|
|
|
SetupFormatTable();
|
2017-10-11 03:09:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DxgiAdapter::~DxgiAdapter() {
|
2017-11-26 14:01:41 +01:00
|
|
|
|
2017-10-11 03:09:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 21:24:52 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiAdapter::QueryInterface(REFIID riid, void** ppvObject) {
|
2018-04-02 12:52:02 +02:00
|
|
|
*ppvObject = nullptr;
|
|
|
|
|
|
|
|
if (riid == __uuidof(IUnknown)
|
|
|
|
|| riid == __uuidof(IDXGIObject)
|
|
|
|
|| riid == __uuidof(IDXGIAdapter)
|
|
|
|
|| riid == __uuidof(IDXGIAdapter1)
|
|
|
|
|| riid == __uuidof(IDXGIVkAdapter)) {
|
|
|
|
*ppvObject = ref(this);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2017-10-11 03:09:04 +02:00
|
|
|
|
|
|
|
Logger::warn("DxgiAdapter::QueryInterface: Unknown interface query");
|
2018-03-12 12:05:43 +01:00
|
|
|
Logger::warn(str::format(riid));
|
2017-10-11 03:09:04 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 21:24:52 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiAdapter::GetParent(REFIID riid, void** ppParent) {
|
2017-10-11 03:09:04 +02:00
|
|
|
return m_factory->QueryInterface(riid, ppParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiAdapter::CheckInterfaceSupport(
|
2018-04-12 13:38:22 +02:00
|
|
|
REFGUID InterfaceName,
|
|
|
|
LARGE_INTEGER* pUMDVersion) {
|
2017-10-11 03:09:04 +02:00
|
|
|
Logger::err("DxgiAdapter::CheckInterfaceSupport: No D3D10 support");
|
|
|
|
return DXGI_ERROR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiAdapter::EnumOutputs(
|
2018-04-12 13:38:22 +02:00
|
|
|
UINT Output,
|
|
|
|
IDXGIOutput** ppOutput) {
|
2018-04-02 12:04:20 +02:00
|
|
|
InitReturnPtr(ppOutput);
|
|
|
|
|
2017-10-11 03:09:04 +02:00
|
|
|
if (ppOutput == nullptr)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
2018-04-12 01:48:57 +02:00
|
|
|
if (Output > 0) {
|
|
|
|
*ppOutput = nullptr;
|
2017-10-11 03:09:04 +02:00
|
|
|
return DXGI_ERROR_NOT_FOUND;
|
2018-04-12 01:48:57 +02:00
|
|
|
}
|
2017-10-11 03:09:04 +02:00
|
|
|
|
2018-04-12 01:48:57 +02:00
|
|
|
// TODO support multiple monitors
|
|
|
|
HMONITOR monitor = ::MonitorFromPoint({ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
*ppOutput = ref(new DxgiOutput(this, monitor));
|
2017-10-11 03:09:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiAdapter::GetDesc(DXGI_ADAPTER_DESC* pDesc) {
|
2018-03-26 07:38:37 +02:00
|
|
|
if (pDesc == nullptr)
|
2018-03-28 11:56:58 +02:00
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
2018-03-26 07:38:37 +02:00
|
|
|
|
2017-11-26 16:12:11 +01:00
|
|
|
DXGI_ADAPTER_DESC1 desc1;
|
|
|
|
HRESULT hr = this->GetDesc1(&desc1);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) {
|
2017-11-26 16:18:32 +01:00
|
|
|
std::memcpy(
|
|
|
|
pDesc->Description,
|
|
|
|
desc1.Description,
|
|
|
|
sizeof(pDesc->Description));
|
|
|
|
|
2017-11-26 16:12:11 +01:00
|
|
|
pDesc->VendorId = desc1.VendorId;
|
|
|
|
pDesc->DeviceId = desc1.DeviceId;
|
|
|
|
pDesc->SubSysId = desc1.SubSysId;
|
|
|
|
pDesc->Revision = desc1.Revision;
|
|
|
|
pDesc->DedicatedVideoMemory = desc1.DedicatedVideoMemory;
|
|
|
|
pDesc->DedicatedSystemMemory = desc1.DedicatedSystemMemory;
|
|
|
|
pDesc->SharedSystemMemory = desc1.SharedSystemMemory;
|
|
|
|
pDesc->AdapterLuid = desc1.AdapterLuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiAdapter::GetDesc1(DXGI_ADAPTER_DESC1* pDesc) {
|
2017-10-11 03:09:04 +02:00
|
|
|
if (pDesc == nullptr)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
2018-03-17 00:40:26 +01:00
|
|
|
auto deviceProp = m_adapter->deviceProperties();
|
|
|
|
auto memoryProp = m_adapter->memoryProperties();
|
|
|
|
|
2018-03-28 21:24:52 +02:00
|
|
|
// Custom Vendor ID
|
2018-03-17 00:40:26 +01:00
|
|
|
const std::string customVendorID = env::getEnvVar(L"DXVK_CUSTOM_VENDOR_ID");
|
|
|
|
const std::string customDeviceID = env::getEnvVar(L"DXVK_CUSTOM_DEVICE_ID");
|
|
|
|
|
|
|
|
if (!customVendorID.empty()) {
|
|
|
|
Logger::info("Using Custom PCI Vendor ID " + customVendorID + " instead of " + str::format(std::hex, deviceProp.vendorID));
|
|
|
|
deviceProp.vendorID = std::stoul(customVendorID, nullptr, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!customDeviceID.empty()) {
|
|
|
|
Logger::info("Using Custom PCI Device ID " + customDeviceID + " instead of " + str::format(std::hex, deviceProp.deviceID));
|
|
|
|
deviceProp.deviceID = std::stoul(customDeviceID, nullptr, 16);
|
|
|
|
}
|
2017-10-11 03:09:04 +02:00
|
|
|
|
|
|
|
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
2018-04-02 18:49:03 +02:00
|
|
|
std::mbstowcs(pDesc->Description, deviceProp.deviceName, std::size(pDesc->Description) - 1);
|
2017-10-11 03:09:04 +02:00
|
|
|
|
|
|
|
VkDeviceSize deviceMemory = 0;
|
|
|
|
VkDeviceSize sharedMemory = 0;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < memoryProp.memoryHeapCount; i++) {
|
|
|
|
VkMemoryHeap heap = memoryProp.memoryHeaps[i];
|
|
|
|
|
|
|
|
if (heap.flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
|
|
|
|
deviceMemory += heap.size;
|
|
|
|
else
|
|
|
|
sharedMemory += heap.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDesc->VendorId = deviceProp.vendorID;
|
|
|
|
pDesc->DeviceId = deviceProp.deviceID;
|
|
|
|
pDesc->SubSysId = 0;
|
|
|
|
pDesc->Revision = 0;
|
|
|
|
pDesc->DedicatedVideoMemory = deviceMemory;
|
|
|
|
pDesc->DedicatedSystemMemory = 0;
|
|
|
|
pDesc->SharedSystemMemory = sharedMemory;
|
|
|
|
pDesc->AdapterLuid = LUID { 0, 0 }; // TODO implement
|
2017-11-26 16:12:11 +01:00
|
|
|
pDesc->Flags = 0;
|
2017-10-11 03:09:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-10-11 15:31:36 +02:00
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
Rc<DxvkAdapter> STDMETHODCALLTYPE DxgiAdapter::GetDXVKAdapter() {
|
2017-10-11 15:31:36 +02:00
|
|
|
return m_adapter;
|
|
|
|
}
|
|
|
|
|
2017-12-04 11:33:04 +01:00
|
|
|
|
2018-03-28 18:58:53 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE DxgiAdapter::CreateDevice(
|
2018-03-28 21:24:52 +02:00
|
|
|
IDXGIObject* pContainer,
|
2018-03-28 18:58:53 +02:00
|
|
|
const VkPhysicalDeviceFeatures* pFeatures,
|
2018-03-28 21:24:52 +02:00
|
|
|
IDXGIVkDevice** ppDevice) {
|
2018-04-02 12:04:20 +02:00
|
|
|
InitReturnPtr(ppDevice);
|
|
|
|
|
2018-03-28 18:58:53 +02:00
|
|
|
try {
|
2018-03-28 21:24:52 +02:00
|
|
|
*ppDevice = new dxvk::DxgiDevice(pContainer, this, pFeatures);
|
2018-03-28 18:58:53 +02:00
|
|
|
return S_OK;
|
|
|
|
} catch (const dxvk::DxvkError& e) {
|
|
|
|
dxvk::Logger::err(e.message());
|
|
|
|
return DXGI_ERROR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-12 15:36:01 +02:00
|
|
|
DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE DxgiAdapter::LookupFormat(
|
2018-04-12 13:38:22 +02:00
|
|
|
DXGI_FORMAT format,
|
|
|
|
DxgiFormatMode mode) {
|
2017-12-19 14:47:35 +01:00
|
|
|
// If the mode is 'Any', probe color formats first
|
|
|
|
if (mode != DxgiFormatMode::Depth) {
|
|
|
|
auto color = m_colorFormats.find(format);
|
|
|
|
|
2018-01-17 05:34:51 +01:00
|
|
|
if (color != m_colorFormats.end())
|
2017-12-19 14:47:35 +01:00
|
|
|
return color->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode != DxgiFormatMode::Color) {
|
|
|
|
auto depth = m_depthFormats.find(format);
|
|
|
|
if (depth != m_depthFormats.end())
|
|
|
|
return depth->second;
|
|
|
|
}
|
2017-12-04 11:33:04 +01:00
|
|
|
|
2017-12-20 14:54:24 +01:00
|
|
|
Logger::err(str::format("DxgiAdapter: No format mapping for ", format));
|
2018-04-12 15:36:01 +02:00
|
|
|
return DXGI_VK_FORMAT_INFO();
|
2017-12-04 11:33:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-13 18:56:15 +01:00
|
|
|
HRESULT DxgiAdapter::GetOutputFromMonitor(
|
2018-04-12 13:38:22 +02:00
|
|
|
HMONITOR Monitor,
|
|
|
|
IDXGIOutput** ppOutput) {
|
2018-03-28 11:56:58 +02:00
|
|
|
if (ppOutput == nullptr)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
2018-01-13 18:56:15 +01:00
|
|
|
|
2018-03-28 11:56:58 +02:00
|
|
|
for (uint32_t i = 0; SUCCEEDED(EnumOutputs(i, ppOutput)); i++) {
|
2018-01-13 18:56:15 +01:00
|
|
|
DXGI_OUTPUT_DESC outputDesc;
|
2018-03-28 11:56:58 +02:00
|
|
|
(*ppOutput)->GetDesc(&outputDesc);
|
2018-01-13 18:56:15 +01:00
|
|
|
|
2018-03-28 11:56:58 +02:00
|
|
|
if (outputDesc.Monitor == Monitor)
|
2018-01-13 18:56:15 +01:00
|
|
|
return S_OK;
|
2018-03-28 11:56:58 +02:00
|
|
|
|
|
|
|
(*ppOutput)->Release();
|
|
|
|
(*ppOutput) = nullptr;
|
2018-01-13 18:56:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// No such output found
|
|
|
|
return DXGI_ERROR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-12 13:38:22 +02:00
|
|
|
HRESULT DxgiAdapter::GetOutputData(
|
|
|
|
HMONITOR Monitor,
|
|
|
|
DXGI_VK_OUTPUT_DATA* pOutputData) {
|
|
|
|
std::lock_guard<std::mutex> lock(m_outputMutex);
|
|
|
|
|
|
|
|
auto entry = m_outputData.find(Monitor);
|
|
|
|
if (entry == m_outputData.end())
|
|
|
|
return DXGI_ERROR_NOT_FOUND;
|
|
|
|
|
|
|
|
if (pOutputData == nullptr)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
*pOutputData = entry->second;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT DxgiAdapter::SetOutputData(
|
|
|
|
HMONITOR Monitor,
|
|
|
|
const DXGI_VK_OUTPUT_DATA* pOutputData) {
|
|
|
|
std::lock_guard<std::mutex> lock(m_outputMutex);
|
|
|
|
|
|
|
|
m_outputData.insert_or_assign(Monitor, *pOutputData);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
void DxgiAdapter::AddColorFormatTypeless(
|
2017-12-09 14:41:37 +01:00
|
|
|
DXGI_FORMAT srcFormat,
|
|
|
|
VkFormat dstFormat) {
|
2018-04-12 15:36:01 +02:00
|
|
|
DXGI_VK_FORMAT_INFO formatPair;
|
2017-12-20 14:54:24 +01:00
|
|
|
formatPair.format = dstFormat;
|
|
|
|
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
|
|
formatPair.swizzle = {
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
2018-01-28 18:06:08 +01:00
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY };
|
2018-04-12 15:36:01 +02:00
|
|
|
formatPair.flags = DXGI_VK_FORMAT_TYPELESS;
|
2017-12-20 14:54:24 +01:00
|
|
|
m_colorFormats.insert(std::make_pair(srcFormat, formatPair));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DxgiAdapter::AddColorFormat(
|
|
|
|
DXGI_FORMAT srcFormat,
|
|
|
|
VkFormat dstFormat,
|
|
|
|
VkComponentMapping swizzle) {
|
2018-04-12 15:36:01 +02:00
|
|
|
DXGI_VK_FORMAT_INFO formatPair;
|
2017-12-20 14:54:24 +01:00
|
|
|
formatPair.format = dstFormat;
|
|
|
|
formatPair.aspect = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
|
|
formatPair.swizzle = swizzle;
|
2018-04-12 15:36:01 +02:00
|
|
|
formatPair.flags = 0;
|
2017-12-19 14:47:35 +01:00
|
|
|
m_colorFormats.insert(std::make_pair(srcFormat, formatPair));
|
2017-12-09 14:41:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
void DxgiAdapter::AddDepthFormatTypeless(
|
|
|
|
DXGI_FORMAT srcFormat,
|
|
|
|
VkFormat dstFormat) {
|
2018-04-12 15:36:01 +02:00
|
|
|
DXGI_VK_FORMAT_INFO formatPair;
|
2018-01-28 18:06:08 +01:00
|
|
|
formatPair.format = dstFormat;
|
|
|
|
formatPair.aspect = 0;
|
|
|
|
formatPair.swizzle = {
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY };
|
2018-04-12 15:36:01 +02:00
|
|
|
formatPair.flags = DXGI_VK_FORMAT_TYPELESS;
|
2018-01-28 18:06:08 +01:00
|
|
|
m_depthFormats.insert(std::make_pair(srcFormat, formatPair));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-19 14:47:35 +01:00
|
|
|
void DxgiAdapter::AddDepthFormat(
|
2017-12-04 11:33:04 +01:00
|
|
|
DXGI_FORMAT srcFormat,
|
2017-12-20 14:54:24 +01:00
|
|
|
VkFormat dstFormat,
|
|
|
|
VkImageAspectFlags srvAspect) {
|
2018-04-12 15:36:01 +02:00
|
|
|
DXGI_VK_FORMAT_INFO formatPair;
|
2017-12-20 14:54:24 +01:00
|
|
|
formatPair.format = dstFormat;
|
|
|
|
formatPair.aspect = srvAspect;
|
|
|
|
formatPair.swizzle = {
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
2018-01-28 18:06:08 +01:00
|
|
|
VK_COMPONENT_SWIZZLE_IDENTITY };
|
2018-04-12 15:36:01 +02:00
|
|
|
formatPair.flags = 0;
|
2017-12-19 14:47:35 +01:00
|
|
|
m_depthFormats.insert(std::make_pair(srcFormat, formatPair));
|
2017-12-04 11:33:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DxgiAdapter::SetupFormatTable() {
|
2017-12-19 14:47:35 +01:00
|
|
|
/***********************************************************************************/
|
|
|
|
/* C O L O R F O R M A T S */
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
|
|
|
|
2018-03-08 16:23:44 +01:00
|
|
|
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);
|
2018-01-28 18:06:08 +01:00
|
|
|
|
|
|
|
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,
|
2018-01-17 01:13:46 +01:00
|
|
|
{ VK_COMPONENT_SWIZZLE_ZERO, VK_COMPONENT_SWIZZLE_ZERO,
|
|
|
|
VK_COMPONENT_SWIZZLE_ZERO, VK_COMPONENT_SWIZZLE_R });
|
2017-12-19 14:47:35 +01:00
|
|
|
|
|
|
|
// AddColorFormat(DXGI_FORMAT_R1_UNORM, VK_FORMAT_UNDEFINED);
|
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
AddColorFormat (DXGI_FORMAT_R9G9B9E5_SHAREDEXP, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32);
|
2018-03-01 10:45:46 +01:00
|
|
|
|
|
|
|
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 });
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-04-08 15:19:26 +02:00
|
|
|
AddColorFormat (DXGI_FORMAT_B5G6R5_UNORM, VK_FORMAT_R5G6B5_UNORM_PACK16);
|
|
|
|
AddColorFormat (DXGI_FORMAT_B5G5R5A1_UNORM, VK_FORMAT_A1R5G5B5_UNORM_PACK16);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-10 19:47:38 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
AddColorFormatTypeless(DXGI_FORMAT_B8G8R8X8_TYPELESS, VK_FORMAT_B8G8R8A8_UNORM);
|
2017-12-20 14:54:24 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
AddColorFormat(DXGI_FORMAT_B8G8R8X8_UNORM, VK_FORMAT_B8G8R8A8_UNORM,
|
2017-12-20 14:54:24 +01:00
|
|
|
{ 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 });
|
|
|
|
|
2017-12-19 14:47:35 +01:00
|
|
|
// AddColorFormat(DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, VK_FORMAT_UNDEFINED);
|
|
|
|
|
2018-04-08 15:19:26 +02:00
|
|
|
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 });
|
2018-02-23 08:22:40 +01:00
|
|
|
|
2017-12-19 14:47:35 +01:00
|
|
|
/***********************************************************************************/
|
|
|
|
/* B L O C K F O R M A T S */
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
|
|
|
/***********************************************************************************/
|
|
|
|
/* D E P T H F O R M A T S */
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
2018-01-28 18:06:08 +01:00
|
|
|
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);
|
2017-12-19 14:47:35 +01:00
|
|
|
|
|
|
|
// Vulkan implementations are not required to support 24-bit depth buffers natively
|
2018-03-22 11:09:23 +01:00
|
|
|
// 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);
|
2017-12-04 11:33:04 +01:00
|
|
|
}
|
|
|
|
|
2017-10-11 03:09:04 +02:00
|
|
|
}
|