1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[d3d11] Allocate predicate buffer per query

Allows us to get rid of the D3D11 counter buffer class.
This commit is contained in:
Philip Rebohle 2019-10-26 17:41:59 +02:00
parent 09f507c284
commit e967c52ff7
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 26 additions and 35 deletions

View File

@ -44,8 +44,6 @@ namespace dxvk {
m_initializer = new D3D11Initializer(this);
m_context = new D3D11ImmediateContext(this, m_dxvkDevice);
m_d3d10Device = new D3D10Device(this, m_context);
m_predicates = CreatePredicateBuffer();
}
@ -1968,21 +1966,6 @@ namespace dxvk {
}
Rc<D3D11CounterBuffer> D3D11Device::CreatePredicateBuffer() {
DxvkBufferCreateInfo predCounterInfo;
predCounterInfo.size = 4096 * sizeof(uint32_t);
predCounterInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT
| VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT;
predCounterInfo.stages = VK_PIPELINE_STAGE_TRANSFER_BIT
| VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT;
predCounterInfo.access = VK_ACCESS_TRANSFER_WRITE_BIT
| VK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXT;
return new D3D11CounterBuffer(m_dxvkDevice,
predCounterInfo, sizeof(uint32_t));
}
HRESULT D3D11Device::CreateShaderModule(
D3D11CommonShader* pShaderModule,
DxvkShaderKey ShaderKey,

View File

@ -425,10 +425,6 @@ namespace dxvk {
return m_d3d10Device;
}
DxvkBufferSlice AllocPredicateSlice () { return m_predicates ->AllocSlice(); }
void FreePredicateSlice (const DxvkBufferSlice& Slice) { m_predicates ->FreeSlice(Slice); }
static bool CheckFeatureLevelSupport(
const Rc<DxvkAdapter>& adapter,
D3D_FEATURE_LEVEL featureLevel);
@ -457,8 +453,6 @@ namespace dxvk {
D3D11ImmediateContext* m_context = nullptr;
D3D10Device* m_d3d10Device = nullptr;
Rc<D3D11CounterBuffer> m_predicates;
D3D11StateObjectSet<D3D11BlendState> m_bsStateObjects;
D3D11StateObjectSet<D3D11DepthStencilState> m_dsStateObjects;
D3D11StateObjectSet<D3D11RasterizerState> m_rsStateObjects;
@ -466,8 +460,6 @@ namespace dxvk {
D3D11ShaderModuleSet m_shaderModules;
D3D11CommandListAllocator m_commandListAllocator;
Rc<D3D11CounterBuffer> CreatePredicateBuffer();
HRESULT CreateShaderModule(
D3D11CommonShader* pShaderModule,
DxvkShaderKey ShaderKey,

View File

@ -80,8 +80,7 @@ namespace dxvk {
D3D11Query::~D3D11Query() {
if (m_predicate.defined())
m_device->FreePredicateSlice(m_predicate);
}
@ -221,8 +220,8 @@ namespace dxvk {
ctx->endQuery(m_query[0]);
}
if (unlikely(m_predicate.defined()))
ctx->writePredicate(m_predicate, m_query[0]);
if (unlikely(m_predicate != nullptr))
ctx->writePredicate(DxvkBufferSlice(m_predicate), m_query[0]);
m_state = D3D11_VK_QUERY_ENDED;
}
@ -331,12 +330,12 @@ namespace dxvk {
if (unlikely(m_state != D3D11_VK_QUERY_ENDED))
return DxvkBufferSlice();
if (unlikely(!m_predicate.defined())) {
m_predicate = m_device->AllocPredicateSlice();
ctx->writePredicate(m_predicate, m_query[0]);
if (unlikely(m_predicate != nullptr)) {
m_predicate = CreatePredicateBuffer();
ctx->writePredicate(DxvkBufferSlice(m_predicate), m_query[0]);
}
return m_predicate;
return DxvkBufferSlice(m_predicate);
}
@ -357,4 +356,19 @@ namespace dxvk {
return S_OK;
}
Rc<DxvkBuffer> D3D11Query::CreatePredicateBuffer() {
Rc<DxvkDevice> device = m_device->GetDXVKDevice();
DxvkBufferCreateInfo info;
info.size = sizeof(uint32_t);
info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT
| VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT;
info.stages = VK_PIPELINE_STAGE_TRANSFER_BIT
| VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT;
info.access = VK_ACCESS_TRANSFER_WRITE_BIT
| VK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXT;
return device->createBuffer(info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
}
}

View File

@ -92,8 +92,8 @@ namespace dxvk {
std::array<Rc<DxvkGpuQuery>, MaxGpuQueries> m_query;
std::array<Rc<DxvkGpuEvent>, MaxGpuEvents> m_event;
sync::Spinlock m_predicateLock;
DxvkBufferSlice m_predicate;
sync::Spinlock m_predicateLock;
Rc<DxvkBuffer> m_predicate;
D3D10Query m_d3d10;
@ -102,6 +102,8 @@ namespace dxvk {
UINT64 GetTimestampQueryFrequency() const;
Rc<DxvkBuffer> CreatePredicateBuffer();
};
}