mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[d3d11] Allocate xfb counter buffer per buffer
Same idea as with UAV counters, allows for more efficient updates.
This commit is contained in:
parent
191c9644af
commit
09f507c284
@ -76,13 +76,12 @@ namespace dxvk {
|
||||
|
||||
// For Stream Output buffers we need a counter
|
||||
if (pDesc->BindFlags & D3D11_BIND_STREAM_OUTPUT)
|
||||
m_soCounter = m_device->AllocXfbCounterSlice();
|
||||
m_soCounter = CreateSoCounterBuffer();
|
||||
}
|
||||
|
||||
|
||||
D3D11Buffer::~D3D11Buffer() {
|
||||
if (m_soCounter.defined())
|
||||
m_device->FreeXfbCounterSlice(m_soCounter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -257,6 +256,27 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
Rc<DxvkBuffer> D3D11Buffer::CreateSoCounterBuffer() {
|
||||
Rc<DxvkDevice> device = m_device->GetDXVKDevice();
|
||||
|
||||
DxvkBufferCreateInfo info;
|
||||
info.size = sizeof(D3D11SOCounter);
|
||||
info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT
|
||||
| VK_BUFFER_USAGE_TRANSFER_SRC_BIT
|
||||
| VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT
|
||||
| VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT;
|
||||
info.stages = VK_PIPELINE_STAGE_TRANSFER_BIT
|
||||
| VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
|
||||
| VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT;
|
||||
info.access = VK_ACCESS_TRANSFER_READ_BIT
|
||||
| VK_ACCESS_TRANSFER_WRITE_BIT
|
||||
| VK_ACCESS_INDIRECT_COMMAND_READ_BIT
|
||||
| VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT
|
||||
| VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT;
|
||||
return device->createBuffer(info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
}
|
||||
|
||||
|
||||
D3D11Buffer* GetCommonBuffer(ID3D11Resource* pResource) {
|
||||
D3D11_RESOURCE_DIMENSION dimension = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
||||
pResource->GetType(&dimension);
|
||||
|
@ -92,7 +92,9 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
DxvkBufferSlice GetSOCounter() {
|
||||
return m_soCounter;
|
||||
return m_soCounter != nullptr
|
||||
? DxvkBufferSlice(m_soCounter)
|
||||
: DxvkBufferSlice();
|
||||
}
|
||||
|
||||
DxvkBufferSliceHandle AllocSlice() {
|
||||
@ -127,7 +129,7 @@ namespace dxvk {
|
||||
const D3D11_BUFFER_DESC m_desc;
|
||||
|
||||
Rc<DxvkBuffer> m_buffer;
|
||||
DxvkBufferSlice m_soCounter;
|
||||
Rc<DxvkBuffer> m_soCounter;
|
||||
DxvkBufferSliceHandle m_mapped;
|
||||
|
||||
D3D11DXGIResource m_resource;
|
||||
@ -139,6 +141,8 @@ namespace dxvk {
|
||||
|
||||
VkMemoryPropertyFlags GetMemoryFlags() const;
|
||||
|
||||
Rc<DxvkBuffer> CreateSoCounterBuffer();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -45,7 +45,6 @@ namespace dxvk {
|
||||
m_context = new D3D11ImmediateContext(this, m_dxvkDevice);
|
||||
m_d3d10Device = new D3D10Device(this, m_context);
|
||||
|
||||
m_xfbCounters = CreateXFBCounterBuffer();
|
||||
m_predicates = CreatePredicateBuffer();
|
||||
}
|
||||
|
||||
@ -1969,27 +1968,6 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
Rc<D3D11CounterBuffer> D3D11Device::CreateXFBCounterBuffer() {
|
||||
DxvkBufferCreateInfo xfbCounterInfo;
|
||||
xfbCounterInfo.size = 4096 * sizeof(D3D11SOCounter);
|
||||
xfbCounterInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT
|
||||
| VK_BUFFER_USAGE_TRANSFER_SRC_BIT
|
||||
| VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT
|
||||
| VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT;
|
||||
xfbCounterInfo.stages = VK_PIPELINE_STAGE_TRANSFER_BIT
|
||||
| VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
|
||||
| VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT;
|
||||
xfbCounterInfo.access = VK_ACCESS_TRANSFER_READ_BIT
|
||||
| VK_ACCESS_TRANSFER_WRITE_BIT
|
||||
| VK_ACCESS_INDIRECT_COMMAND_READ_BIT
|
||||
| VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT
|
||||
| VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT;
|
||||
|
||||
return new D3D11CounterBuffer(m_dxvkDevice,
|
||||
xfbCounterInfo, sizeof(D3D11SOCounter));
|
||||
}
|
||||
|
||||
|
||||
Rc<D3D11CounterBuffer> D3D11Device::CreatePredicateBuffer() {
|
||||
DxvkBufferCreateInfo predCounterInfo;
|
||||
predCounterInfo.size = 4096 * sizeof(uint32_t);
|
||||
|
@ -425,10 +425,8 @@ namespace dxvk {
|
||||
return m_d3d10Device;
|
||||
}
|
||||
|
||||
DxvkBufferSlice AllocXfbCounterSlice() { return m_xfbCounters->AllocSlice(); }
|
||||
DxvkBufferSlice AllocPredicateSlice () { return m_predicates ->AllocSlice(); }
|
||||
|
||||
void FreeXfbCounterSlice(const DxvkBufferSlice& Slice) { m_xfbCounters->FreeSlice(Slice); }
|
||||
void FreePredicateSlice (const DxvkBufferSlice& Slice) { m_predicates ->FreeSlice(Slice); }
|
||||
|
||||
static bool CheckFeatureLevelSupport(
|
||||
@ -459,7 +457,6 @@ namespace dxvk {
|
||||
D3D11ImmediateContext* m_context = nullptr;
|
||||
D3D10Device* m_d3d10Device = nullptr;
|
||||
|
||||
Rc<D3D11CounterBuffer> m_xfbCounters;
|
||||
Rc<D3D11CounterBuffer> m_predicates;
|
||||
|
||||
D3D11StateObjectSet<D3D11BlendState> m_bsStateObjects;
|
||||
@ -469,7 +466,6 @@ namespace dxvk {
|
||||
D3D11ShaderModuleSet m_shaderModules;
|
||||
D3D11CommandListAllocator m_commandListAllocator;
|
||||
|
||||
Rc<D3D11CounterBuffer> CreateXFBCounterBuffer();
|
||||
Rc<D3D11CounterBuffer> CreatePredicateBuffer();
|
||||
|
||||
HRESULT CreateShaderModule(
|
||||
|
Loading…
x
Reference in New Issue
Block a user