[dxvk] Introduce DxvkContextType

This commit is contained in:
Philip Rebohle 2022-06-21 23:17:26 +02:00
parent 8dde72da06
commit ab0c15ea54
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
13 changed files with 26 additions and 13 deletions

View File

@ -13,7 +13,7 @@ namespace dxvk {
D3D11Device* pParent,
const Rc<DxvkDevice>& Device)
: D3D11DeviceContext(pParent, Device, DxvkCsChunkFlag::SingleUse),
m_csThread(Device, Device->createContext()),
m_csThread(Device, Device->createContext(DxvkContextType::Primary)),
m_maxImplicitDiscardSize(pParent->GetOptions()->maxImplicitDiscardSize),
m_videoContext(this, Device) {
EmitCs([

View File

@ -9,7 +9,7 @@ namespace dxvk {
D3D11Device* pParent)
: m_parent(pParent),
m_device(pParent->GetDXVKDevice()),
m_context(m_device->createContext()) {
m_context(m_device->createContext(DxvkContextType::Supplementary)) {
m_context->beginRecording(
m_device->createCommandList());
}

View File

@ -21,7 +21,7 @@ namespace dxvk {
m_window (hWnd),
m_desc (*pDesc),
m_device (pDevice->GetDXVKDevice()),
m_context (m_device->createContext()),
m_context (m_device->createContext(DxvkContextType::Supplementary)),
m_frameLatencyCap(pDevice->GetOptions()->maxFrameLatency) {
CreateFrameLatencyEvent();

View File

@ -49,7 +49,7 @@ namespace dxvk {
, m_d3d9Options ( dxvkDevice, pParent->GetInstance()->config() )
, m_multithread ( BehaviorFlags & D3DCREATE_MULTITHREADED )
, m_isSWVP ( (BehaviorFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING) ? true : false )
, m_csThread ( dxvkDevice, dxvkDevice->createContext() )
, m_csThread ( dxvkDevice, dxvkDevice->createContext(DxvkContextType::Primary) )
, m_csChunk ( AllocCsChunk() ) {
// If we can SWVP, then we use an extended constant set
// as SWVP has many more slots available than HWVP.

View File

@ -10,7 +10,7 @@
namespace dxvk {
D3D9FormatHelper::D3D9FormatHelper(const Rc<DxvkDevice>& device)
: m_device(device), m_context(m_device->createContext()) {
: m_device(device), m_context(m_device->createContext(DxvkContextType::Supplementary)) {
m_context->beginRecording(
m_device->createCommandList());

View File

@ -6,7 +6,7 @@ namespace dxvk {
D3D9Initializer::D3D9Initializer(
const Rc<DxvkDevice>& Device)
: m_device(Device), m_context(m_device->createContext()) {
: m_device(Device), m_context(m_device->createContext(DxvkContextType::Supplementary)) {
m_context->beginRecording(
m_device->createCommandList());
}

View File

@ -190,7 +190,7 @@ namespace dxvk {
const D3DDISPLAYMODEEX* pFullscreenDisplayMode)
: D3D9SwapChainExBase(pDevice)
, m_device (pDevice->GetDXVKDevice())
, m_context (m_device->createContext())
, m_context (m_device->createContext(DxvkContextType::Supplementary))
, m_frameLatencyCap (pDevice->GetOptions()->maxFrameLatency)
, m_frameLatencySignal(new sync::Fence(m_frameId))
, m_dialog (pDevice->GetOptions()->enableDialogMode) {

View File

@ -7,8 +7,9 @@
namespace dxvk {
DxvkContext::DxvkContext(const Rc<DxvkDevice>& device)
DxvkContext::DxvkContext(const Rc<DxvkDevice>& device, DxvkContextType type)
: m_device (device),
m_type (type),
m_common (&device->m_objects),
m_sdmaAcquires(DxvkCmdBuffer::SdmaBuffer),
m_sdmaBarriers(DxvkCmdBuffer::SdmaBuffer),

View File

@ -22,7 +22,7 @@ namespace dxvk {
constexpr static VkDeviceSize StagingBufferSize = 4ull << 20;
public:
DxvkContext(const Rc<DxvkDevice>& device);
DxvkContext(const Rc<DxvkDevice>& device, DxvkContextType type);
~DxvkContext();
/**
@ -1038,6 +1038,7 @@ namespace dxvk {
private:
Rc<DxvkDevice> m_device;
DxvkContextType m_type;
DxvkObjects* m_common;
Rc<DxvkCommandList> m_cmd;

View File

@ -8,6 +8,16 @@ namespace dxvk {
class DxvkDevice;
/**
* \brief DXVK context type
*
* Used as a hint to optimize certain usage patterns.
*/
enum class DxvkContextType : uint32_t {
Primary = 0,
Supplementary = 1,
};
/**
* \brief Descriptor info
*

View File

@ -94,8 +94,8 @@ namespace dxvk {
}
Rc<DxvkContext> DxvkDevice::createContext() {
return new DxvkContext(this);
Rc<DxvkContext> DxvkDevice::createContext(DxvkContextType type) {
return new DxvkContext(this, type);
}

View File

@ -244,9 +244,10 @@ namespace dxvk {
*
* Creates a context object that can
* be used to record command buffers.
* \param [in] type Context type
* \returns The context object
*/
Rc<DxvkContext> createContext();
Rc<DxvkContext> createContext(DxvkContextType type);
/**
* \brief Creates a GPU event

View File

@ -21,7 +21,7 @@ namespace dxvk {
void DxvkUnboundResources::clearResources(DxvkDevice* dev) {
const Rc<DxvkContext> ctx = dev->createContext();
const Rc<DxvkContext> ctx = dev->createContext(DxvkContextType::Supplementary);
ctx->beginRecording(dev->createCommandList());
this->clearBuffer(ctx, m_buffer);