1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[d3d11] Bind transform feedback buffers in SOSetTargets

This commit is contained in:
Philip Rebohle 2018-07-24 17:09:11 +02:00
parent 97d776cc00
commit 93753a5ce7
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 72 additions and 13 deletions

View File

@ -208,8 +208,10 @@ namespace dxvk {
} }
// Default SO state // Default SO state
for (uint32_t i = 0; i < D3D11_SO_STREAM_COUNT; i++) for (uint32_t i = 0; i < D3D11_SO_BUFFER_SLOT_COUNT; i++) {
m_state.so.targets[i] = nullptr; m_state.so.targets[i].buffer = nullptr;
m_state.so.targets[i].offset = 0;
}
// Default predication // Default predication
m_state.pr.predicateObject = nullptr; m_state.pr.predicateObject = nullptr;
@ -2509,17 +2511,29 @@ namespace dxvk {
*pNumRects = m_state.rs.numScissors; *pNumRects = m_state.rs.numScissors;
} }
void STDMETHODCALLTYPE D3D11DeviceContext::SOSetTargets( void STDMETHODCALLTYPE D3D11DeviceContext::SOSetTargets(
UINT NumBuffers, UINT NumBuffers,
ID3D11Buffer* const* ppSOTargets, ID3D11Buffer* const* ppSOTargets,
const UINT* pOffsets) { const UINT* pOffsets) {
// TODO implement properly, including pOffsets for (uint32_t i = 0; i < NumBuffers; i++) {
for (uint32_t i = 0; i < D3D11_SO_STREAM_COUNT; i++) { D3D11Buffer* buffer = static_cast<D3D11Buffer*>(ppSOTargets[i]);
m_state.so.targets[i] = (ppSOTargets != nullptr && i < NumBuffers) UINT offset = pOffsets != nullptr ? pOffsets[i] : 0;
? static_cast<D3D11Buffer*>(ppSOTargets[i])
: nullptr; m_state.so.targets[i].buffer = buffer;
m_state.so.targets[i].offset = offset;
}
for (uint32_t i = NumBuffers; i < D3D11_SO_BUFFER_SLOT_COUNT; i++) {
m_state.so.targets[i].buffer = nullptr;
m_state.so.targets[i].offset = 0;
}
for (uint32_t i = 0; i < D3D11_SO_BUFFER_SLOT_COUNT; i++) {
BindXfbBuffer(i,
m_state.so.targets[i].buffer.ptr(),
m_state.so.targets[i].offset);
} }
} }
@ -2528,7 +2542,7 @@ namespace dxvk {
UINT NumBuffers, UINT NumBuffers,
ID3D11Buffer** ppSOTargets) { ID3D11Buffer** ppSOTargets) {
for (uint32_t i = 0; i < NumBuffers; i++) for (uint32_t i = 0; i < NumBuffers; i++)
ppSOTargets[i] = m_state.so.targets[i].ref(); ppSOTargets[i] = m_state.so.targets[i].buffer.ref();
} }
@ -2862,7 +2876,38 @@ namespace dxvk {
}); });
} }
void D3D11DeviceContext::BindXfbBuffer(
UINT Slot,
D3D11Buffer* pBuffer,
UINT Offset) {
DxvkBufferSlice bufferSlice;
DxvkBufferSlice counterSlice;
if (pBuffer != nullptr) {
bufferSlice = pBuffer->GetBufferSlice();
counterSlice = pBuffer->GetSOCounter();
}
EmitCs([
cSlotId = Slot,
cOffset = Offset,
cBufferSlice = bufferSlice,
cCounterSlice = counterSlice
] (DxvkContext* ctx) {
if (cCounterSlice.defined() && cOffset != ~0u) {
ctx->updateBuffer(
cCounterSlice.buffer(),
cCounterSlice.offset(),
sizeof(cOffset),
&cOffset);
}
ctx->bindXfbBuffer(cSlotId, cBufferSlice, cCounterSlice);
});
}
void D3D11DeviceContext::BindConstantBuffer( void D3D11DeviceContext::BindConstantBuffer(
UINT Slot, UINT Slot,
const D3D11ConstantBufferBinding* pBufferBinding) { const D3D11ConstantBufferBinding* pBufferBinding) {
@ -3141,6 +3186,9 @@ namespace dxvk {
m_state.ia.vertexBuffers[i].offset, m_state.ia.vertexBuffers[i].offset,
m_state.ia.vertexBuffers[i].stride); m_state.ia.vertexBuffers[i].stride);
} }
for (uint32_t i = 0; i < m_state.so.targets.size(); i++)
BindXfbBuffer(i, m_state.so.targets[i].buffer.ptr(), ~0u);
RestoreConstantBuffers(DxbcProgramType::VertexShader, m_state.vs.constantBuffers); RestoreConstantBuffers(DxbcProgramType::VertexShader, m_state.vs.constantBuffers);
RestoreConstantBuffers(DxbcProgramType::HullShader, m_state.hs.constantBuffers); RestoreConstantBuffers(DxbcProgramType::HullShader, m_state.hs.constantBuffers);

View File

@ -690,6 +690,11 @@ namespace dxvk {
UINT Offset, UINT Offset,
DXGI_FORMAT Format); DXGI_FORMAT Format);
void BindXfbBuffer(
UINT Slot,
D3D11Buffer* pBuffer,
UINT Offset);
void BindConstantBuffer( void BindConstantBuffer(
UINT Slot, UINT Slot,
const D3D11ConstantBufferBinding* pBufferBinding); const D3D11ConstantBufferBinding* pBufferBinding);

View File

@ -139,10 +139,16 @@ namespace dxvk {
Com<D3D11RasterizerState> state; Com<D3D11RasterizerState> state;
}; };
struct D3D11ContextSoTarget {
Com<D3D11Buffer> buffer;
UINT offset;
};
struct D3D11ContextStateSO { struct D3D11ContextStateSO {
std::array<Com<D3D11Buffer>, D3D11_SO_STREAM_COUNT> targets; std::array<D3D11ContextSoTarget, D3D11_SO_BUFFER_SLOT_COUNT> targets;
}; };