1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-27 04:54:15 +01:00

[dxvk,d3d11] Fix draw buffer tracking for DrawAuto

Not like anybody uses this feature, but we need to both check for
hazards and make sure the SO counter actually gets tracked. Use
the existing draw buffer mechanism for this.
This commit is contained in:
Philip Rebohle 2025-02-16 13:53:46 +01:00 committed by Philip Rebohle
parent d37a13847a
commit 07f7ccdc96
3 changed files with 27 additions and 13 deletions

View File

@ -1009,10 +1009,22 @@ namespace dxvk {
if (!ctrBuf.defined())
return;
EmitCs([=] (DxvkContext* ctx) {
ctx->drawIndirectXfb(ctrBuf,
// We bind the SO counter as an indirect count buffer,
// so reset any tracking we may have been doing here.
m_state.id.reset();
EmitCs([=] (DxvkContext* ctx) mutable {
ctx->bindDrawBuffers(DxvkBufferSlice(),
Forwarder::move(ctrBuf));
ctx->drawIndirectXfb(0u,
vtxBuf.buffer()->getXfbVertexStride(),
vtxBuf.offset());
// Reset draw buffer right away so we don't
// keep the SO counter alive indefinitely
ctx->bindDrawBuffers(DxvkBufferSlice(),
DxvkBufferSlice());
});
}

View File

@ -1052,17 +1052,19 @@ namespace dxvk {
void DxvkContext::drawIndirectXfb(
const DxvkBufferSlice& counterBuffer,
VkDeviceSize counterOffset,
uint32_t counterDivisor,
uint32_t counterBias) {
if (this->commitGraphicsState<false, false>()) {
auto physSlice = counterBuffer.getSliceHandle();
if (this->commitGraphicsState<false, true>()) {
auto physSlice = m_state.id.cntBuffer.getSliceHandle();
m_cmd->cmdDrawIndirectVertexCount(1, 0,
physSlice.handle,
physSlice.offset,
counterBias,
counterDivisor);
physSlice.handle, physSlice.offset + counterOffset,
counterBias, counterDivisor);
// The count will generally be written from streamout
if (likely(m_state.id.cntBuffer.buffer()->hasGfxStores()))
accessDrawCountBuffer(counterOffset);
}
}

View File

@ -832,14 +832,14 @@ namespace dxvk {
uint32_t stride);
/**
* \brief Transform feddback draw call
* \param [in] counterBuffer Xfb counter buffer
* \brief Transform feedback draw call
*
* \param [in] counterOffset Draw count offset
* \param [in] counterDivisor Vertex stride
* \param [in] counterBias Counter bias
*/
void drawIndirectXfb(
const DxvkBufferSlice& counterBuffer,
VkDeviceSize counterOffset,
uint32_t counterDivisor,
uint32_t counterBias);