1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-05 01:24:14 +01:00

[dxgi] Implement DxgiSurfaceFactory

This commit is contained in:
Philip Rebohle 2022-10-27 19:36:56 +02:00
parent 1754b73ade
commit 3a9e975a71
4 changed files with 90 additions and 0 deletions

View File

@ -3,6 +3,7 @@ d3d11_res = wrc_generator.process('version.rc')
dxgi_common_src = [
'../dxgi/dxgi_format.cpp',
'../dxgi/dxgi_monitor.cpp',
'../dxgi/dxgi_surface.cpp',
'../dxgi/dxgi_swapchain.cpp',
]

45
src/dxgi/dxgi_surface.cpp Normal file
View File

@ -0,0 +1,45 @@
#include "dxgi_surface.h"
#include "../wsi/wsi_window.h"
namespace dxvk {
DxgiSurfaceFactory::DxgiSurfaceFactory(PFN_vkGetInstanceProcAddr vulkanLoaderProc, HWND hWnd)
: m_vkGetInstanceProcAddr(vulkanLoaderProc), m_window(hWnd) {
}
DxgiSurfaceFactory::~DxgiSurfaceFactory() {
}
HRESULT STDMETHODCALLTYPE DxgiSurfaceFactory::QueryInterface(
REFIID riid,
void** ppvObject) {
if (ppvObject == nullptr)
return E_POINTER;
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(IDXGIVkSurfaceFactory)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("DxgiSurfaceFactory::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
return E_NOINTERFACE;
}
VkResult STDMETHODCALLTYPE DxgiSurfaceFactory::CreateSurface(
VkInstance Instance,
VkPhysicalDevice Adapter,
VkSurfaceKHR* pSurface) {
return wsi::createSurface(m_window, m_vkGetInstanceProcAddr, Instance, pSurface);
}
}

43
src/dxgi/dxgi_surface.h Normal file
View File

@ -0,0 +1,43 @@
#pragma once
#include "../util/com/com_object.h"
#include "../vulkan/vulkan_loader.h"
#include "dxgi_interfaces.h"
namespace dxvk {
/**
* \brief Surface factory
*
* Provides a way to transparently create a
* Vulkan surface for a given platform window.
*/
class DxgiSurfaceFactory : public ComObject<IDXGIVkSurfaceFactory> {
public:
DxgiSurfaceFactory(
PFN_vkGetInstanceProcAddr vulkanLoaderProc,
HWND hWnd);
~DxgiSurfaceFactory();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
VkResult STDMETHODCALLTYPE CreateSurface(
VkInstance Instance,
VkPhysicalDevice Adapter,
VkSurfaceKHR* pSurface);
private:
PFN_vkGetInstanceProcAddr m_vkGetInstanceProcAddr;
HWND m_window;
};
}

View File

@ -9,6 +9,7 @@ dxgi_src = [
'dxgi_monitor.cpp',
'dxgi_options.cpp',
'dxgi_output.cpp',
'dxgi_surface.cpp',
'dxgi_swapchain.cpp',
]