2018-01-20 13:22:44 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-11-26 01:46:39 +01:00
|
|
|
#include "../util/util_time.h"
|
2018-06-04 23:31:49 +02:00
|
|
|
|
2021-08-02 19:10:48 +02:00
|
|
|
#include "../util/sync/sync_signal.h"
|
2020-03-19 23:29:32 +01:00
|
|
|
|
2022-08-03 16:33:54 +02:00
|
|
|
#include "d3d11_context_common.h"
|
2019-05-03 16:41:44 +02:00
|
|
|
#include "d3d11_state_object.h"
|
2021-05-06 17:44:30 +02:00
|
|
|
#include "d3d11_video.h"
|
2018-01-20 13:22:44 +01:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2018-03-14 14:40:09 +01:00
|
|
|
class D3D11Buffer;
|
|
|
|
class D3D11CommonTexture;
|
|
|
|
|
2022-08-03 16:33:54 +02:00
|
|
|
class D3D11ImmediateContext : public D3D11CommonContext<D3D11ImmediateContext> {
|
|
|
|
template<typename T>
|
|
|
|
friend class D3D11CommonContext;
|
2019-11-02 16:32:55 +01:00
|
|
|
friend class D3D11SwapChain;
|
2021-05-07 15:02:52 +02:00
|
|
|
friend class D3D11VideoContext;
|
2018-01-20 13:22:44 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
D3D11ImmediateContext(
|
2018-04-28 14:17:52 +02:00
|
|
|
D3D11Device* pParent,
|
|
|
|
const Rc<DxvkDevice>& Device);
|
2018-01-20 13:22:44 +01:00
|
|
|
~D3D11ImmediateContext();
|
|
|
|
|
2021-05-06 17:44:30 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
|
|
|
|
2018-10-17 16:52:46 +02:00
|
|
|
D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType();
|
2018-01-20 13:22:44 +01:00
|
|
|
|
2018-10-17 16:52:46 +02:00
|
|
|
UINT STDMETHODCALLTYPE GetContextFlags();
|
2018-01-20 13:22:44 +01:00
|
|
|
|
2018-06-08 12:29:24 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE GetData(
|
2019-11-02 13:10:59 +01:00
|
|
|
ID3D11Asynchronous* pAsync,
|
|
|
|
void* pData,
|
|
|
|
UINT DataSize,
|
|
|
|
UINT GetDataFlags);
|
2018-06-08 12:29:24 +02:00
|
|
|
|
2019-11-02 13:10:59 +01:00
|
|
|
void STDMETHODCALLTYPE Begin(
|
|
|
|
ID3D11Asynchronous* pAsync);
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE End(
|
|
|
|
ID3D11Asynchronous* pAsync);
|
2019-05-09 16:38:07 +02:00
|
|
|
|
2018-10-17 16:52:46 +02:00
|
|
|
void STDMETHODCALLTYPE Flush();
|
2018-01-20 13:22:44 +01:00
|
|
|
|
2019-09-16 13:12:13 +02:00
|
|
|
void STDMETHODCALLTYPE Flush1(
|
|
|
|
D3D11_CONTEXT_TYPE ContextType,
|
|
|
|
HANDLE hEvent);
|
|
|
|
|
2019-09-16 13:17:00 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE Signal(
|
|
|
|
ID3D11Fence* pFence,
|
|
|
|
UINT64 Value);
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE Wait(
|
|
|
|
ID3D11Fence* pFence,
|
|
|
|
UINT64 Value);
|
|
|
|
|
2018-01-20 13:22:44 +01:00
|
|
|
void STDMETHODCALLTYPE ExecuteCommandList(
|
|
|
|
ID3D11CommandList* pCommandList,
|
2018-10-17 16:52:46 +02:00
|
|
|
BOOL RestoreContextState);
|
2018-01-20 13:22:44 +01:00
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE FinishCommandList(
|
2018-03-06 18:34:34 +01:00
|
|
|
BOOL RestoreDeferredContextState,
|
2018-10-17 16:52:46 +02:00
|
|
|
ID3D11CommandList **ppCommandList);
|
2018-01-20 13:22:44 +01:00
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE Map(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
UINT Subresource,
|
|
|
|
D3D11_MAP MapType,
|
|
|
|
UINT MapFlags,
|
2018-10-17 16:52:46 +02:00
|
|
|
D3D11_MAPPED_SUBRESOURCE* pMappedResource);
|
2018-01-20 13:22:44 +01:00
|
|
|
|
|
|
|
void STDMETHODCALLTYPE Unmap(
|
|
|
|
ID3D11Resource* pResource,
|
2018-10-17 16:52:46 +02:00
|
|
|
UINT Subresource);
|
2019-05-09 13:04:07 +02:00
|
|
|
|
2019-05-03 16:41:44 +02:00
|
|
|
void STDMETHODCALLTYPE SwapDeviceContextState(
|
2022-02-09 02:58:21 +01:00
|
|
|
ID3DDeviceContextState* pState,
|
|
|
|
ID3DDeviceContextState** ppPreviousState);
|
2019-05-03 16:41:44 +02:00
|
|
|
|
2022-02-09 02:58:21 +01:00
|
|
|
void SynchronizeCsThread(
|
|
|
|
uint64_t SequenceNumber);
|
2018-01-20 13:22:44 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2022-02-09 02:54:32 +01:00
|
|
|
DxvkCsThread m_csThread;
|
|
|
|
uint64_t m_csSeqNum = 0ull;
|
|
|
|
bool m_csIsBusy = false;
|
2018-06-04 23:31:49 +02:00
|
|
|
|
2021-08-02 19:10:48 +02:00
|
|
|
Rc<sync::CallbackFence> m_eventSignal;
|
2022-02-09 02:54:32 +01:00
|
|
|
uint64_t m_eventCount = 0ull;
|
2022-02-10 04:34:50 +01:00
|
|
|
uint32_t m_mappedImageCount = 0u;
|
2022-02-09 02:54:32 +01:00
|
|
|
|
2022-02-14 04:11:36 +01:00
|
|
|
VkDeviceSize m_maxImplicitDiscardSize = 0ull;
|
2020-03-19 23:29:32 +01:00
|
|
|
|
2019-11-26 01:46:39 +01:00
|
|
|
dxvk::high_resolution_clock::time_point m_lastFlush
|
|
|
|
= dxvk::high_resolution_clock::now();
|
2018-01-20 23:12:03 +01:00
|
|
|
|
2021-05-06 17:44:30 +02:00
|
|
|
D3D11VideoContext m_videoContext;
|
2019-05-03 16:41:44 +02:00
|
|
|
Com<D3D11DeviceContextState> m_stateObject;
|
|
|
|
|
2018-03-14 14:40:09 +01: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);
|
|
|
|
|
2022-02-06 18:20:31 +01:00
|
|
|
void UpdateMappedBuffer(
|
|
|
|
D3D11Buffer* pDstBuffer,
|
|
|
|
UINT Offset,
|
|
|
|
UINT Length,
|
|
|
|
const void* pSrcData,
|
|
|
|
UINT CopyFlags);
|
|
|
|
|
2018-01-21 18:04:22 +01:00
|
|
|
void SynchronizeDevice();
|
2022-06-22 00:39:36 +02:00
|
|
|
|
|
|
|
void EndFrame();
|
2018-01-21 02:57:36 +01:00
|
|
|
|
2018-03-10 23:32:15 +01:00
|
|
|
bool WaitForResource(
|
|
|
|
const Rc<DxvkResource>& Resource,
|
2022-02-09 02:58:21 +01:00
|
|
|
uint64_t SequenceNumber,
|
2019-09-19 20:28:22 +02:00
|
|
|
D3D11_MAP MapType,
|
2018-03-10 23:32:15 +01:00
|
|
|
UINT MapFlags);
|
|
|
|
|
2019-05-19 13:21:08 +02:00
|
|
|
void EmitCsChunk(DxvkCsChunkRef&& chunk);
|
|
|
|
|
2022-02-09 02:54:32 +01:00
|
|
|
void TrackTextureSequenceNumber(
|
|
|
|
D3D11CommonTexture* pResource,
|
|
|
|
UINT Subresource);
|
|
|
|
|
|
|
|
void TrackBufferSequenceNumber(
|
|
|
|
D3D11Buffer* pResource);
|
|
|
|
|
2022-02-18 14:14:18 +01:00
|
|
|
uint64_t GetCurrentSequenceNumber();
|
|
|
|
|
2018-10-17 17:22:52 +02:00
|
|
|
void FlushImplicit(BOOL StrongHint);
|
2020-03-19 23:29:32 +01:00
|
|
|
|
|
|
|
void SignalEvent(HANDLE hEvent);
|
2018-01-20 22:52:18 +01:00
|
|
|
|
2018-01-20 13:22:44 +01:00
|
|
|
};
|
|
|
|
|
2018-07-15 19:45:40 +02:00
|
|
|
}
|