#pragma once #include #include "dxgi_object.h" #include "dxgi_interfaces.h" namespace dxvk { template class DxgiResource : public DxgiObject { public: DxgiResource( IDXGIDevicePrivate* pDevice, UINT usage) : m_device (pDevice), m_usageFlags(usage) { } HRESULT GetDevice(REFIID riid, void** ppDevice) { return m_device->QueryInterface(riid, ppDevice); } HRESULT STDMETHODCALLTYPE GetSharedHandle(HANDLE *pSharedHandle) { Logger::err("DxgiResource::GetSharedHandle: Not implemented"); return DXGI_ERROR_UNSUPPORTED; } HRESULT STDMETHODCALLTYPE GetUsage(DXGI_USAGE *pUsage) { if (pUsage == nullptr) return DXGI_ERROR_INVALID_CALL; *pUsage = m_usageFlags; return S_OK; } HRESULT STDMETHODCALLTYPE SetEvictionPriority(UINT EvictionPriority) { m_evictionPriority = EvictionPriority; return S_OK; } HRESULT STDMETHODCALLTYPE GetEvictionPriority(UINT *pEvictionPriority) { if (pEvictionPriority == nullptr) return DXGI_ERROR_INVALID_CALL; *pEvictionPriority = m_evictionPriority; return S_OK; } private: Com m_device; UINT m_evictionPriority = DXGI_RESOURCE_PRIORITY_NORMAL; UINT m_usageFlags = 0; }; /** * \brief Image resource * * Stores a DXVK image and provides a method to retrieve * it. D3D textures will be backed by an image resource. */ class DxgiImageResource : public DxgiResource { using Base = DxgiResource; public: DxgiImageResource( IDXGIDevicePrivate* pDevice, const dxvk::DxvkImageCreateInfo* pCreateInfo, VkMemoryPropertyFlags memoryFlags, UINT usageFlags); ~DxgiImageResource(); HRESULT QueryInterface( REFIID riid, void **ppvObject) final; HRESULT GetParent( REFIID riid, void **ppParent) final; Rc GetDXVKImage() final; void SetResourceLayer( IUnknown* pLayer) final; private: Rc m_image; IUnknown* m_layer = nullptr; }; /** * \brief Buffer resource * * Stores a DXVK buffer and provides a method to retrieve * it. D3D buffers will be backed by a buffer resource. */ class DxgiBufferResource : public DxgiResource { using Base = DxgiResource; public: DxgiBufferResource( IDXGIDevicePrivate* pDevice, const dxvk::DxvkBufferCreateInfo* pCreateInfo, VkMemoryPropertyFlags memoryFlags, UINT usageFlags); ~DxgiBufferResource(); HRESULT QueryInterface( REFIID riid, void **ppvObject) final; HRESULT GetParent( REFIID riid, void **ppParent) final; Rc GetDXVKBuffer() final; void SetResourceLayer( IUnknown* pLayer) final; private: Rc m_buffer; IUnknown* m_layer = nullptr; }; } extern "C" { DLLEXPORT HRESULT __stdcall DXGICreateImageResourcePrivate( IDXGIDevicePrivate* pDevice, const dxvk::DxvkImageCreateInfo* pCreateInfo, VkMemoryPropertyFlags memoryFlags, UINT usageFlags, IDXGIImageResourcePrivate** ppResource); DLLEXPORT HRESULT __stdcall DXGICreateBufferResourcePrivate( IDXGIDevicePrivate* pDevice, const dxvk::DxvkBufferCreateInfo* pCreateInfo, VkMemoryPropertyFlags memoryFlags, UINT usageFlags, IDXGIBufferResourcePrivate** ppResource); }