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

[d3d9] Don't rebind user's vertex buffer/indices in DrawPrimitive[Indexed]UP

D3D9 doesn't do this, it instead sets them to NULL so we can simplify this logic a fair bit.

Found via a Wine test.
This commit is contained in:
Joshua Ashton 2020-02-28 21:37:00 +00:00
parent 3587bcdb9f
commit 722520a9f7
2 changed files with 16 additions and 24 deletions

View File

@ -2302,7 +2302,7 @@ namespace dxvk {
UINT VertexStreamZeroStride) {
D3D9DeviceLock lock = LockDevice();
PrepareDraw(PrimitiveType, true);
PrepareDraw(PrimitiveType);
auto drawInfo = GenerateDrawInfo(PrimitiveType, PrimitiveCount, 0);
@ -2326,9 +2326,12 @@ namespace dxvk {
ctx->draw(
drawInfo.vertexCount, drawInfo.instanceCount,
0, 0);
ctx->bindVertexBuffer(0, DxvkBufferSlice(), 0);
});
m_flags.set(D3D9DeviceFlag::UpDirtiedVertices);
m_state.vertexBuffers[0].vertexBuffer = nullptr;
m_state.vertexBuffers[0].offset = 0;
m_state.vertexBuffers[0].stride = 0;
return D3D_OK;
}
@ -2345,7 +2348,7 @@ namespace dxvk {
UINT VertexStreamZeroStride) {
D3D9DeviceLock lock = LockDevice();
PrepareDraw(PrimitiveType, true);
PrepareDraw(PrimitiveType);
auto drawInfo = GenerateDrawInfo(PrimitiveType, PrimitiveCount, 0);
@ -2382,10 +2385,15 @@ namespace dxvk {
drawInfo.vertexCount, drawInfo.instanceCount,
0,
0, 0);
ctx->bindVertexBuffer(0, DxvkBufferSlice(), 0);
ctx->bindIndexBuffer(DxvkBufferSlice(), VK_INDEX_TYPE_UINT32);
});
m_flags.set(D3D9DeviceFlag::UpDirtiedVertices);
m_flags.set(D3D9DeviceFlag::UpDirtiedIndices);
m_state.vertexBuffers[0].vertexBuffer = nullptr;
m_state.vertexBuffers[0].offset = 0;
m_state.vertexBuffers[0].stride = 0;
m_state.indices = nullptr;
return D3D_OK;
}
@ -2415,7 +2423,7 @@ namespace dxvk {
D3D9CommonBuffer* dst = static_cast<D3D9VertexBuffer*>(pDestBuffer)->GetCommonBuffer();
D3D9VertexDecl* decl = static_cast<D3D9VertexDecl*> (pVertexDecl);
PrepareDraw(D3DPT_FORCE_DWORD, false);
PrepareDraw(D3DPT_FORCE_DWORD);
if (decl == nullptr) {
DWORD FVF = dst->Desc()->FVF;
@ -5425,7 +5433,7 @@ namespace dxvk {
}
void D3D9DeviceEx::PrepareDraw(D3DPRIMITIVETYPE PrimitiveType, bool up) {
void D3D9DeviceEx::PrepareDraw(D3DPRIMITIVETYPE PrimitiveType) {
if (unlikely(m_activeHazards != 0)) {
EmitCs([](DxvkContext* ctx) {
ctx->emitRenderTargetReadbackBarrier();
@ -5488,20 +5496,6 @@ namespace dxvk {
else if (m_lastPointMode != 0)
UpdatePointMode<false>();
if (!up && m_flags.test(D3D9DeviceFlag::UpDirtiedVertices)) {
m_flags.clr(D3D9DeviceFlag::UpDirtiedVertices);
if (m_state.vertexBuffers[0].vertexBuffer != nullptr)
BindVertexBuffer(0,
m_state.vertexBuffers[0].vertexBuffer.ptr(),
m_state.vertexBuffers[0].offset,
m_state.vertexBuffers[0].stride);
}
if (!up && m_flags.test(D3D9DeviceFlag::UpDirtiedIndices)) {
m_flags.clr(D3D9DeviceFlag::UpDirtiedIndices);
BindIndices();
}
if (likely(UseProgrammableVS())) {
if (unlikely(m_flags.test(D3D9DeviceFlag::DirtyProgVertexShader))) {
m_flags.set(D3D9DeviceFlag::DirtyInputLayout);

View File

@ -68,8 +68,6 @@ namespace dxvk {
DirtyFFPixelData,
DirtyProgVertexShader,
DirtySharedPixelShaderData,
UpDirtiedVertices,
UpDirtiedIndices,
ValidSampleMask,
DirtyDepthBounds,
DirtyPointScale,
@ -837,7 +835,7 @@ namespace dxvk {
uint32_t GetInstanceCount() const;
void PrepareDraw(D3DPRIMITIVETYPE PrimitiveType, bool up = false);
void PrepareDraw(D3DPRIMITIVETYPE PrimitiveType);
template <DxsoProgramType ShaderStage>
void BindShader(