2017-10-11 09:51:48 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
#include "../dxgi/dxgi_object.h"
|
2017-10-11 15:32:24 +02:00
|
|
|
|
2017-11-29 07:55:44 +01:00
|
|
|
#include "d3d11_interfaces.h"
|
2017-12-06 13:16:54 +01:00
|
|
|
#include "d3d11_state.h"
|
2017-12-11 01:43:15 +01:00
|
|
|
#include "d3d11_util.h"
|
2017-10-11 09:51:48 +02:00
|
|
|
|
|
|
|
#include "../util/com/com_private_data.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
class DxgiAdapter;
|
2017-12-14 15:59:55 +01:00
|
|
|
|
|
|
|
class D3D11Buffer;
|
2017-12-29 22:20:31 +01:00
|
|
|
class D3D11Counter;
|
2017-10-11 09:51:48 +02:00
|
|
|
class D3D11DeviceContext;
|
2017-12-29 22:20:31 +01:00
|
|
|
class D3D11Predicate;
|
2017-11-29 16:23:33 +01:00
|
|
|
class D3D11PresentDevice;
|
2017-12-29 22:20:31 +01:00
|
|
|
class D3D11Query;
|
2017-12-06 18:54:01 +01:00
|
|
|
class D3D11ShaderModule;
|
2017-12-19 16:01:50 +01:00
|
|
|
class D3D11Texture1D;
|
|
|
|
class D3D11Texture2D;
|
|
|
|
class D3D11Texture3D;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-11-29 16:23:33 +01:00
|
|
|
class D3D11Device : public ComObject<ID3D11Device> {
|
2017-10-11 09:51:48 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
D3D11Device(
|
2017-11-27 15:51:53 +01:00
|
|
|
IDXGIDevicePrivate* dxgiDevice,
|
2017-10-11 15:32:24 +02:00
|
|
|
D3D_FEATURE_LEVEL featureLevel,
|
|
|
|
UINT featureFlags);
|
2017-10-11 09:51:48 +02:00
|
|
|
~D3D11Device();
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(
|
2017-10-11 15:32:24 +02:00
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject) final;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateBuffer(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_BUFFER_DESC* pDesc,
|
|
|
|
const D3D11_SUBRESOURCE_DATA* pInitialData,
|
|
|
|
ID3D11Buffer** ppBuffer) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateTexture1D(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_TEXTURE1D_DESC* pDesc,
|
|
|
|
const D3D11_SUBRESOURCE_DATA* pInitialData,
|
|
|
|
ID3D11Texture1D** ppTexture1D) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateTexture2D(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_TEXTURE2D_DESC* pDesc,
|
|
|
|
const D3D11_SUBRESOURCE_DATA* pInitialData,
|
|
|
|
ID3D11Texture2D** ppTexture2D) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateTexture3D(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_TEXTURE3D_DESC* pDesc,
|
|
|
|
const D3D11_SUBRESOURCE_DATA* pInitialData,
|
|
|
|
ID3D11Texture3D** ppTexture3D) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateShaderResourceView(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Resource* pResource,
|
|
|
|
const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc,
|
|
|
|
ID3D11ShaderResourceView** ppSRView) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateUnorderedAccessView(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Resource* pResource,
|
|
|
|
const D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc,
|
|
|
|
ID3D11UnorderedAccessView** ppUAView) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateRenderTargetView(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Resource* pResource,
|
|
|
|
const D3D11_RENDER_TARGET_VIEW_DESC* pDesc,
|
|
|
|
ID3D11RenderTargetView** ppRTView) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateDepthStencilView(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Resource* pResource,
|
|
|
|
const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc,
|
|
|
|
ID3D11DepthStencilView** ppDepthStencilView) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateInputLayout(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_INPUT_ELEMENT_DESC* pInputElementDescs,
|
|
|
|
UINT NumElements,
|
|
|
|
const void* pShaderBytecodeWithInputSignature,
|
|
|
|
SIZE_T BytecodeLength,
|
|
|
|
ID3D11InputLayout** ppInputLayout) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateVertexShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
const void* pShaderBytecode,
|
|
|
|
SIZE_T BytecodeLength,
|
|
|
|
ID3D11ClassLinkage* pClassLinkage,
|
|
|
|
ID3D11VertexShader** ppVertexShader) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateGeometryShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
const void* pShaderBytecode,
|
|
|
|
SIZE_T BytecodeLength,
|
|
|
|
ID3D11ClassLinkage* pClassLinkage,
|
|
|
|
ID3D11GeometryShader** ppGeometryShader) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateGeometryShaderWithStreamOutput(
|
2017-10-11 09:51:48 +02:00
|
|
|
const void* pShaderBytecode,
|
|
|
|
SIZE_T BytecodeLength,
|
|
|
|
const D3D11_SO_DECLARATION_ENTRY* pSODeclaration,
|
|
|
|
UINT NumEntries,
|
|
|
|
const UINT* pBufferStrides,
|
|
|
|
UINT NumStrides,
|
|
|
|
UINT RasterizedStream,
|
|
|
|
ID3D11ClassLinkage* pClassLinkage,
|
|
|
|
ID3D11GeometryShader** ppGeometryShader) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreatePixelShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
const void* pShaderBytecode,
|
|
|
|
SIZE_T BytecodeLength,
|
|
|
|
ID3D11ClassLinkage* pClassLinkage,
|
|
|
|
ID3D11PixelShader** ppPixelShader) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateHullShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
const void* pShaderBytecode,
|
|
|
|
SIZE_T BytecodeLength,
|
|
|
|
ID3D11ClassLinkage* pClassLinkage,
|
|
|
|
ID3D11HullShader** ppHullShader) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateDomainShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
const void* pShaderBytecode,
|
|
|
|
SIZE_T BytecodeLength,
|
|
|
|
ID3D11ClassLinkage* pClassLinkage,
|
|
|
|
ID3D11DomainShader** ppDomainShader) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateComputeShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
const void* pShaderBytecode,
|
|
|
|
SIZE_T BytecodeLength,
|
|
|
|
ID3D11ClassLinkage* pClassLinkage,
|
|
|
|
ID3D11ComputeShader** ppComputeShader) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateClassLinkage(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11ClassLinkage** ppLinkage) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateBlendState(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_BLEND_DESC* pBlendStateDesc,
|
|
|
|
ID3D11BlendState** ppBlendState) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateDepthStencilState(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_DEPTH_STENCIL_DESC* pDepthStencilDesc,
|
|
|
|
ID3D11DepthStencilState** ppDepthStencilState) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateRasterizerState(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_RASTERIZER_DESC* pRasterizerDesc,
|
|
|
|
ID3D11RasterizerState** ppRasterizerState) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateSamplerState(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_SAMPLER_DESC* pSamplerDesc,
|
|
|
|
ID3D11SamplerState** ppSamplerState) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateQuery(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_QUERY_DESC* pQueryDesc,
|
|
|
|
ID3D11Query** ppQuery) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreatePredicate(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_QUERY_DESC* pPredicateDesc,
|
|
|
|
ID3D11Predicate** ppPredicate) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateCounter(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_COUNTER_DESC* pCounterDesc,
|
|
|
|
ID3D11Counter** ppCounter) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CreateDeferredContext(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT ContextFlags,
|
|
|
|
ID3D11DeviceContext** ppDeferredContext) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE OpenSharedResource(
|
2017-10-11 09:51:48 +02:00
|
|
|
HANDLE hResource,
|
|
|
|
REFIID ReturnedInterface,
|
|
|
|
void** ppResource) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CheckFormatSupport(
|
2017-10-11 09:51:48 +02:00
|
|
|
DXGI_FORMAT Format,
|
|
|
|
UINT* pFormatSupport) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CheckMultisampleQualityLevels(
|
2017-10-11 09:51:48 +02:00
|
|
|
DXGI_FORMAT Format,
|
|
|
|
UINT SampleCount,
|
|
|
|
UINT* pNumQualityLevels) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE CheckCounterInfo(
|
2017-10-11 09:51:48 +02:00
|
|
|
D3D11_COUNTER_INFO* pCounterInfo) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CheckCounter(
|
2017-10-11 09:51:48 +02:00
|
|
|
const D3D11_COUNTER_DESC* pDesc,
|
|
|
|
D3D11_COUNTER_TYPE* pType,
|
|
|
|
UINT* pActiveCounters,
|
|
|
|
LPSTR szName,
|
|
|
|
UINT* pNameLength,
|
|
|
|
LPSTR szUnits,
|
|
|
|
UINT* pUnitsLength,
|
|
|
|
LPSTR szDescription,
|
|
|
|
UINT* pDescriptionLength) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE CheckFeatureSupport(
|
2017-10-11 09:51:48 +02:00
|
|
|
D3D11_FEATURE Feature,
|
|
|
|
void* pFeatureSupportData,
|
|
|
|
UINT FeatureSupportDataSize) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE GetPrivateData(
|
2017-10-11 15:32:24 +02:00
|
|
|
REFGUID Name,
|
|
|
|
UINT *pDataSize,
|
|
|
|
void *pData) final;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE SetPrivateData(
|
2017-10-11 15:32:24 +02:00
|
|
|
REFGUID Name,
|
|
|
|
UINT DataSize,
|
|
|
|
const void *pData) final;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(
|
2017-10-11 15:32:24 +02:00
|
|
|
REFGUID Name,
|
|
|
|
const IUnknown *pUnknown) final;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
D3D_FEATURE_LEVEL STDMETHODCALLTYPE GetFeatureLevel() final;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
UINT STDMETHODCALLTYPE GetCreationFlags() final;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE GetDeviceRemovedReason() final;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE GetImmediateContext(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11DeviceContext** ppImmediateContext) final;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE SetExceptionMode(UINT RaiseFlags) final;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
UINT STDMETHODCALLTYPE GetExceptionMode() final;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-11-29 16:23:33 +01:00
|
|
|
Rc<DxvkDevice> GetDXVKDevice() {
|
|
|
|
return m_dxvkDevice;
|
|
|
|
}
|
2017-10-15 21:38:09 +02:00
|
|
|
|
2017-12-14 15:59:55 +01:00
|
|
|
VkPipelineStageFlags GetEnabledShaderStages() const;
|
|
|
|
|
2017-12-20 14:54:24 +01:00
|
|
|
DxgiFormatInfo STDMETHODCALLTYPE LookupFormat(
|
2017-12-19 16:01:50 +01:00
|
|
|
DXGI_FORMAT format,
|
|
|
|
DxgiFormatMode mode) const;
|
|
|
|
|
2017-10-11 15:32:24 +02:00
|
|
|
static bool CheckFeatureLevelSupport(
|
2017-12-02 16:47:06 +01:00
|
|
|
const Rc<DxvkAdapter>& adapter,
|
|
|
|
D3D_FEATURE_LEVEL featureLevel);
|
|
|
|
|
|
|
|
static VkPhysicalDeviceFeatures GetDeviceFeatures(
|
|
|
|
const Rc<DxvkAdapter>& adapter,
|
2017-10-11 15:32:24 +02:00
|
|
|
D3D_FEATURE_LEVEL featureLevel);
|
|
|
|
|
2017-10-11 09:51:48 +02:00
|
|
|
private:
|
|
|
|
|
2017-12-04 13:47:18 +01:00
|
|
|
const Com<IDXGIDevicePrivate> m_dxgiDevice;
|
|
|
|
Com<IDXGIAdapterPrivate> m_dxgiAdapter;
|
|
|
|
const Com<D3D11PresentDevice> m_presentDevice;
|
2017-11-29 16:23:33 +01:00
|
|
|
|
2017-12-04 13:47:18 +01:00
|
|
|
const D3D_FEATURE_LEVEL m_featureLevel;
|
|
|
|
const UINT m_featureFlags;
|
2017-10-11 15:32:24 +02:00
|
|
|
|
2017-12-04 13:47:18 +01:00
|
|
|
const Rc<DxvkDevice> m_dxvkDevice;
|
|
|
|
const Rc<DxvkAdapter> m_dxvkAdapter;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-11 17:01:38 +01:00
|
|
|
D3D11DeviceContext* m_context = nullptr;
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-07 18:51:41 +01:00
|
|
|
std::mutex m_resourceInitMutex;
|
|
|
|
Rc<DxvkContext> m_resourceInitContext;
|
|
|
|
|
2017-12-11 13:03:07 +01:00
|
|
|
D3D11StateObjectSet<D3D11BlendState> m_bsStateObjects;
|
2017-12-11 01:43:15 +01:00
|
|
|
D3D11StateObjectSet<D3D11DepthStencilState> m_dsStateObjects;
|
|
|
|
D3D11StateObjectSet<D3D11RasterizerState> m_rsStateObjects;
|
2017-12-06 13:16:54 +01:00
|
|
|
|
2017-12-06 18:54:01 +01:00
|
|
|
HRESULT CreateShaderModule(
|
|
|
|
D3D11ShaderModule* pShaderModule,
|
|
|
|
const void* pShaderBytecode,
|
|
|
|
size_t BytecodeLength,
|
|
|
|
ID3D11ClassLinkage* pClassLinkage);
|
|
|
|
|
2017-12-07 18:51:41 +01:00
|
|
|
void InitBuffer(
|
2017-12-14 15:59:55 +01:00
|
|
|
D3D11Buffer* pBuffer,
|
2017-12-07 18:51:41 +01:00
|
|
|
const D3D11_SUBRESOURCE_DATA* pInitialData);
|
|
|
|
|
2017-12-08 23:13:15 +01:00
|
|
|
void InitTexture(
|
2017-12-23 17:05:07 +01:00
|
|
|
const Rc<DxvkImage>& image,
|
2017-12-08 23:13:15 +01:00
|
|
|
const D3D11_SUBRESOURCE_DATA* pInitialData);
|
|
|
|
|
2017-12-09 19:06:51 +01:00
|
|
|
HRESULT GetShaderResourceViewDescFromResource(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc);
|
|
|
|
|
|
|
|
HRESULT GetUnorderedAccessViewDescFromResource(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc);
|
|
|
|
|
|
|
|
HRESULT GetRenderTargetViewDescFromResource(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
D3D11_RENDER_TARGET_VIEW_DESC* pDesc);
|
|
|
|
|
|
|
|
HRESULT GetDepthStencilViewDescFromResource(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc);
|
|
|
|
|
2017-12-09 20:49:56 +01:00
|
|
|
VkSamplerAddressMode DecodeAddressMode(
|
|
|
|
D3D11_TEXTURE_ADDRESS_MODE mode) const;
|
|
|
|
|
2017-12-19 11:05:41 +01:00
|
|
|
HRESULT GetFormatSupportFlags(DXGI_FORMAT Format, UINT* pFlags) const;
|
|
|
|
|
2017-10-11 09:51:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|