2018-01-23 09:23:31 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-19 03:19:13 +01:00
|
|
|
#include "d3d11_buffer.h"
|
2018-01-23 12:03:26 +01:00
|
|
|
#include "d3d11_cmdlist.h"
|
2018-01-23 09:23:31 +01:00
|
|
|
#include "d3d11_context.h"
|
2018-03-19 03:19:13 +01:00
|
|
|
#include "d3d11_texture.h"
|
2018-01-23 09:23:31 +01:00
|
|
|
|
2018-03-25 13:24:03 +02:00
|
|
|
#include <vector>
|
2018-03-19 11:49:48 +01:00
|
|
|
|
2018-01-23 09:23:31 +01:00
|
|
|
namespace dxvk {
|
|
|
|
|
2018-03-19 03:19:13 +01:00
|
|
|
struct D3D11DeferredContextMapEntry {
|
2022-02-10 14:23:53 +01:00
|
|
|
D3D11DeferredContextMapEntry() { }
|
|
|
|
D3D11DeferredContextMapEntry(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
UINT Subresource,
|
|
|
|
D3D11_RESOURCE_DIMENSION ResourceType,
|
|
|
|
const D3D11_MAPPED_SUBRESOURCE& MappedResource)
|
|
|
|
: Resource(pResource, Subresource, ResourceType),
|
|
|
|
MapInfo(MappedResource) { }
|
|
|
|
|
|
|
|
D3D11ResourceRef Resource;
|
|
|
|
D3D11_MAPPED_SUBRESOURCE MapInfo;
|
2018-03-19 03:19:13 +01:00
|
|
|
};
|
|
|
|
|
2018-01-23 09:23:31 +01:00
|
|
|
class D3D11DeferredContext : public D3D11DeviceContext {
|
2022-02-06 18:20:31 +01:00
|
|
|
friend class D3D11DeviceContext;
|
2018-01-23 09:23:31 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
D3D11DeferredContext(
|
2018-04-28 14:17:52 +02:00
|
|
|
D3D11Device* pParent,
|
|
|
|
const Rc<DxvkDevice>& Device,
|
|
|
|
UINT ContextFlags);
|
2018-01-23 09:23:31 +01:00
|
|
|
|
2018-10-17 16:52:46 +02:00
|
|
|
D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType();
|
2018-01-23 09:23:31 +01:00
|
|
|
|
2018-10-17 16:52:46 +02:00
|
|
|
UINT STDMETHODCALLTYPE GetContextFlags();
|
2018-01-23 09:23:31 +01:00
|
|
|
|
2018-06-08 12:29:24 +02:00
|
|
|
HRESULT STDMETHODCALLTYPE GetData(
|
2019-11-02 13:06:44 +01:00
|
|
|
ID3D11Asynchronous* pAsync,
|
|
|
|
void* pData,
|
|
|
|
UINT DataSize,
|
|
|
|
UINT GetDataFlags);
|
2018-06-08 12:29:24 +02:00
|
|
|
|
2019-11-02 13:06:44 +01:00
|
|
|
void STDMETHODCALLTYPE Begin(
|
|
|
|
ID3D11Asynchronous* pAsync);
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE End(
|
|
|
|
ID3D11Asynchronous* pAsync);
|
|
|
|
|
2018-10-17 16:52:46 +02:00
|
|
|
void STDMETHODCALLTYPE Flush();
|
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-23 09:23:31 +01:00
|
|
|
void STDMETHODCALLTYPE ExecuteCommandList(
|
2019-09-16 13:12:13 +02:00
|
|
|
ID3D11CommandList* pCommandList,
|
|
|
|
BOOL RestoreContextState);
|
2018-01-23 09:23:31 +01:00
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE FinishCommandList(
|
2019-09-16 13:12:13 +02:00
|
|
|
BOOL RestoreDeferredContextState,
|
|
|
|
ID3D11CommandList** ppCommandList);
|
2018-01-23 09:23:31 +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-23 09:23:31 +01:00
|
|
|
|
|
|
|
void STDMETHODCALLTYPE Unmap(
|
|
|
|
ID3D11Resource* pResource,
|
2018-10-17 16:52:46 +02:00
|
|
|
UINT Subresource);
|
2018-01-23 09:23:31 +01:00
|
|
|
|
2022-02-06 18:20:31 +01:00
|
|
|
void STDMETHODCALLTYPE UpdateSubresource(
|
|
|
|
ID3D11Resource* pDstResource,
|
|
|
|
UINT DstSubresource,
|
|
|
|
const D3D11_BOX* pDstBox,
|
|
|
|
const void* pSrcData,
|
|
|
|
UINT SrcRowPitch,
|
|
|
|
UINT SrcDepthPitch);
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE UpdateSubresource1(
|
|
|
|
ID3D11Resource* pDstResource,
|
|
|
|
UINT DstSubresource,
|
|
|
|
const D3D11_BOX* pDstBox,
|
|
|
|
const void* pSrcData,
|
|
|
|
UINT SrcRowPitch,
|
|
|
|
UINT SrcDepthPitch,
|
|
|
|
UINT CopyFlags);
|
|
|
|
|
2019-05-03 16:41:44 +02:00
|
|
|
void STDMETHODCALLTYPE SwapDeviceContextState(
|
|
|
|
ID3DDeviceContextState* pState,
|
|
|
|
ID3DDeviceContextState** ppPreviousState);
|
|
|
|
|
2018-01-23 09:23:31 +01:00
|
|
|
private:
|
|
|
|
|
|
|
|
const UINT m_contextFlags;
|
|
|
|
|
2018-03-19 03:19:13 +01:00
|
|
|
// Command list that we're recording
|
2018-01-23 12:03:26 +01:00
|
|
|
Com<D3D11CommandList> m_commandList;
|
|
|
|
|
2018-03-19 03:19:13 +01:00
|
|
|
// Info about currently mapped (sub)resources. Using a vector
|
|
|
|
// here is reasonable since there will usually only be a small
|
|
|
|
// number of mapped resources per command list.
|
|
|
|
std::vector<D3D11DeferredContextMapEntry> m_mappedResources;
|
|
|
|
|
2019-11-02 13:06:44 +01:00
|
|
|
// Begun and ended queries, will also be stored in command list
|
|
|
|
std::vector<Com<D3D11Query, false>> m_queriesBegun;
|
|
|
|
|
2018-03-19 03:19:13 +01:00
|
|
|
HRESULT MapBuffer(
|
2018-03-25 13:24:03 +02:00
|
|
|
ID3D11Resource* pResource,
|
2022-02-10 14:23:53 +01:00
|
|
|
D3D11_MAPPED_SUBRESOURCE* pMappedResource);
|
2018-03-19 03:19:13 +01:00
|
|
|
|
|
|
|
HRESULT MapImage(
|
2018-03-25 13:24:03 +02:00
|
|
|
ID3D11Resource* pResource,
|
|
|
|
UINT Subresource,
|
2022-02-10 14:23:53 +01:00
|
|
|
D3D11_MAPPED_SUBRESOURCE* pMappedResource);
|
2022-02-06 18:20:31 +01:00
|
|
|
|
|
|
|
void UpdateMappedBuffer(
|
|
|
|
D3D11Buffer* pDstBuffer,
|
|
|
|
UINT Offset,
|
|
|
|
UINT Length,
|
|
|
|
const void* pSrcData,
|
|
|
|
UINT CopyFlags);
|
|
|
|
|
2019-11-02 13:06:44 +01:00
|
|
|
void FinalizeQueries();
|
|
|
|
|
2018-01-23 12:03:26 +01:00
|
|
|
Com<D3D11CommandList> CreateCommandList();
|
|
|
|
|
2019-05-19 13:21:08 +02:00
|
|
|
void EmitCsChunk(DxvkCsChunkRef&& chunk);
|
2018-11-20 10:44:04 +01:00
|
|
|
|
2022-02-09 02:54:32 +01:00
|
|
|
void TrackTextureSequenceNumber(
|
2022-02-10 14:23:53 +01:00
|
|
|
D3D11CommonTexture* pResource,
|
|
|
|
UINT Subresource);
|
2022-02-09 02:54:32 +01:00
|
|
|
|
|
|
|
void TrackBufferSequenceNumber(
|
2022-02-10 14:23:53 +01:00
|
|
|
D3D11Buffer* pResource);
|
|
|
|
|
|
|
|
D3D11DeferredContextMapEntry* FindMapEntry(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
UINT Subresource);
|
|
|
|
|
|
|
|
void AddMapEntry(
|
|
|
|
ID3D11Resource* pResource,
|
|
|
|
UINT Subresource,
|
|
|
|
D3D11_RESOURCE_DIMENSION ResourceType,
|
|
|
|
const D3D11_MAPPED_SUBRESOURCE& MapInfo);
|
2022-02-09 02:54:32 +01:00
|
|
|
|
2018-11-20 10:44:04 +01:00
|
|
|
static DxvkCsChunkFlags GetCsChunkFlags(
|
|
|
|
D3D11Device* pDevice);
|
2018-01-23 09:23:31 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-03-19 11:49:48 +01:00
|
|
|
}
|