2018-01-20 13:22:44 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-11-26 00:46:39 +00: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 21:37:30 +02:00
|
|
|
#include "d3d11_context.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;
|
2023-01-14 14:31:26 +01:00
|
|
|
|
2022-08-03 16:33:54 +02:00
|
|
|
class D3D11ImmediateContext : public D3D11CommonContext<D3D11ImmediateContext> {
|
2022-08-04 18:40:07 +02:00
|
|
|
friend class D3D11CommonContext<D3D11ImmediateContext>;
|
2019-11-02 16:32:55 +01:00
|
|
|
friend class D3D11SwapChain;
|
2021-05-07 15:02:52 +02:00
|
|
|
friend class D3D11VideoContext;
|
2023-08-23 14:50:42 +01:00
|
|
|
friend class D3D11DXGIKeyedMutex;
|
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-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 20:34:34 +03: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
|
|
|
|
2023-03-16 16:40:12 +01:00
|
|
|
void Acquire11on12Resource(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
VkImageLayout SrcLayout);
|
|
|
|
|
|
|
|
void Release11on12Resource(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
VkImageLayout DstLayout);
|
|
|
|
|
2022-02-09 02:58:21 +01:00
|
|
|
void SynchronizeCsThread(
|
|
|
|
uint64_t SequenceNumber);
|
2022-08-24 12:14:43 +02:00
|
|
|
|
2023-11-15 16:51:30 +01:00
|
|
|
D3D10Multithread& GetMultithread() {
|
|
|
|
return m_multithread;
|
|
|
|
}
|
|
|
|
|
2022-08-24 12:14:43 +02:00
|
|
|
D3D10DeviceLock LockContext() {
|
|
|
|
return m_multithread.AcquireLock();
|
|
|
|
}
|
|
|
|
|
2024-09-29 14:36:10 +02:00
|
|
|
void EmitCsChunkExternal(
|
|
|
|
DxvkCsChunkRef&& Chunk,
|
|
|
|
bool Synchronize);
|
|
|
|
|
2024-10-01 23:34:42 +02:00
|
|
|
template<typename Fn>
|
|
|
|
void InjectCsCommand(
|
|
|
|
Fn&& Command) {
|
|
|
|
auto chunk = AllocCsChunk();
|
|
|
|
chunk->push(std::move(Command));
|
|
|
|
|
|
|
|
EmitCsChunkExternal(std::move(chunk), false);
|
|
|
|
}
|
|
|
|
|
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;
|
2018-06-04 23:31:49 +02:00
|
|
|
|
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
|
|
|
|
2023-01-14 14:31:26 +01:00
|
|
|
Rc<sync::CallbackFence> m_submissionFence;
|
|
|
|
uint64_t m_submissionId = 0ull;
|
2023-03-16 13:15:35 +01:00
|
|
|
DxvkSubmitStatus m_submitStatus;
|
2023-01-14 14:30:30 +01:00
|
|
|
|
2023-01-14 14:31:26 +01:00
|
|
|
uint64_t m_flushSeqNum = 0ull;
|
|
|
|
GpuFlushTracker m_flushTracker;
|
2023-01-14 14:30:30 +01:00
|
|
|
|
2023-01-14 14:31:26 +01:00
|
|
|
D3D10Multithread m_multithread;
|
|
|
|
D3D11VideoContext m_videoContext;
|
2022-09-16 10:08:40 +00:00
|
|
|
|
|
|
|
Com<D3D11DeviceContextState, false> m_stateObject;
|
2019-05-03 16:41:44 +02:00
|
|
|
|
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-09-05 01:56:54 +02:00
|
|
|
void ReadbackImageBuffer(
|
|
|
|
D3D11CommonTexture* pResource,
|
|
|
|
UINT Subresource);
|
|
|
|
|
2022-09-05 05:35:16 +02:00
|
|
|
void UpdateDirtyImageRegion(
|
|
|
|
D3D11CommonTexture* pResource,
|
|
|
|
UINT Subresource,
|
|
|
|
const D3D11_COMMON_TEXTURE_REGION* pRegion);
|
|
|
|
|
2022-02-06 18:20:31 +01:00
|
|
|
void UpdateMappedBuffer(
|
2023-01-14 14:31:26 +01:00
|
|
|
D3D11Buffer* pDstBuffer,
|
|
|
|
UINT Offset,
|
|
|
|
UINT Length,
|
|
|
|
const void* pSrcData,
|
|
|
|
UINT CopyFlags);
|
2022-02-06 18:20:31 +01:00
|
|
|
|
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(
|
2023-01-14 14:31:26 +01:00
|
|
|
const Rc<DxvkResource>& Resource,
|
|
|
|
uint64_t SequenceNumber,
|
|
|
|
D3D11_MAP MapType,
|
|
|
|
UINT MapFlags);
|
2018-03-10 23:32:15 +01:00
|
|
|
|
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();
|
|
|
|
|
2023-01-14 14:30:30 +01:00
|
|
|
uint64_t GetPendingCsChunks();
|
|
|
|
|
2023-01-14 14:31:26 +01:00
|
|
|
void ConsiderFlush(
|
|
|
|
GpuFlushType FlushType);
|
|
|
|
|
|
|
|
void ExecuteFlush(
|
|
|
|
GpuFlushType FlushType,
|
2023-03-16 13:15:35 +01:00
|
|
|
HANDLE hEvent,
|
|
|
|
BOOL Synchronize);
|
2020-03-19 23:29:32 +01:00
|
|
|
|
2018-01-20 13:22:44 +01:00
|
|
|
};
|
|
|
|
|
2018-07-15 19:45:40 +02:00
|
|
|
}
|