2018-01-20 12:22:44 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-06-04 22:31:49 +01:00
|
|
|
#include <chrono>
|
|
|
|
|
2018-01-20 12:22:44 +00:00
|
|
|
#include "d3d11_context.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2018-03-14 13:40:09 +00:00
|
|
|
class D3D11Buffer;
|
|
|
|
class D3D11CommonTexture;
|
|
|
|
|
2018-01-20 12:22:44 +00:00
|
|
|
class D3D11ImmediateContext : public D3D11DeviceContext {
|
2018-06-04 22:31:49 +01:00
|
|
|
constexpr static uint32_t MinFlushIntervalUs = 2500;
|
|
|
|
constexpr static uint32_t MaxPendingSubmits = 2;
|
2018-01-20 12:22:44 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
D3D11ImmediateContext(
|
2018-04-28 13:17:52 +01:00
|
|
|
D3D11Device* pParent,
|
|
|
|
const Rc<DxvkDevice>& Device);
|
2018-01-20 12:22:44 +00:00
|
|
|
~D3D11ImmediateContext();
|
|
|
|
|
|
|
|
ULONG STDMETHODCALLTYPE AddRef() final;
|
|
|
|
|
|
|
|
ULONG STDMETHODCALLTYPE Release() final;
|
|
|
|
|
|
|
|
D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType() final;
|
|
|
|
|
|
|
|
UINT STDMETHODCALLTYPE GetContextFlags() final;
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE Flush() final;
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE ExecuteCommandList(
|
|
|
|
ID3D11CommandList* pCommandList,
|
2018-03-06 17:34:34 +00:00
|
|
|
BOOL RestoreContextState) final;
|
2018-01-20 12:22:44 +00:00
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE FinishCommandList(
|
2018-03-06 17:34:34 +00:00
|
|
|
BOOL RestoreDeferredContextState,
|
2018-01-20 12:22:44 +00:00
|
|
|
ID3D11CommandList **ppCommandList) final;
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE Map(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
UINT Subresource,
|
|
|
|
D3D11_MAP MapType,
|
|
|
|
UINT MapFlags,
|
|
|
|
D3D11_MAPPED_SUBRESOURCE* pMappedResource) final;
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE Unmap(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
UINT Subresource) final;
|
|
|
|
|
2018-03-17 13:09:16 +00:00
|
|
|
void STDMETHODCALLTYPE OMSetRenderTargets(
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11RenderTargetView* const* ppRenderTargetViews,
|
|
|
|
ID3D11DepthStencilView* pDepthStencilView) final;
|
|
|
|
|
2018-01-21 17:04:22 +00:00
|
|
|
void SynchronizeCsThread();
|
2018-01-20 12:22:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2018-01-20 22:12:03 +00:00
|
|
|
DxvkCsThread m_csThread;
|
2018-03-22 11:58:26 +00:00
|
|
|
bool m_csIsBusy = false;
|
2018-06-04 22:31:49 +01:00
|
|
|
|
|
|
|
std::chrono::high_resolution_clock::time_point m_lastFlush
|
|
|
|
= std::chrono::high_resolution_clock::now();
|
2018-01-20 22:12:03 +00:00
|
|
|
|
2018-03-14 13:40:09 +00:00
|
|
|
HRESULT MapBuffer(
|
|
|
|
D3D11Buffer* pResource,
|
|
|
|
D3D11_MAP MapType,
|
|
|
|
UINT MapFlags,
|
|
|
|
D3D11_MAPPED_SUBRESOURCE* pMappedResource);
|
|
|
|
|
|
|
|
HRESULT MapImage(
|
|
|
|
D3D11CommonTexture* pResource,
|
|
|
|
UINT Subresource,
|
|
|
|
D3D11_MAP MapType,
|
|
|
|
UINT MapFlags,
|
|
|
|
D3D11_MAPPED_SUBRESOURCE* pMappedResource);
|
|
|
|
|
|
|
|
void UnmapImage(
|
|
|
|
D3D11CommonTexture* pResource,
|
|
|
|
UINT Subresource);
|
|
|
|
|
2018-01-21 17:04:22 +00:00
|
|
|
void SynchronizeDevice();
|
2018-01-21 01:57:36 +00:00
|
|
|
|
2018-03-10 22:32:15 +00:00
|
|
|
bool WaitForResource(
|
|
|
|
const Rc<DxvkResource>& Resource,
|
|
|
|
UINT MapFlags);
|
|
|
|
|
2018-01-23 11:03:26 +00:00
|
|
|
void EmitCsChunk(Rc<DxvkCsChunk>&& chunk) final;
|
2018-06-04 22:31:49 +01:00
|
|
|
|
|
|
|
void FlushImplicit();
|
2018-01-20 21:52:18 +00:00
|
|
|
|
2018-01-20 12:22:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|