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
for (uint32_t i = 0; i < D3D11_SO_STREAM_COUNT; i++)
m_state.so.targets[i] = nullptr;
for (uint32_t i = 0; i < D3D11_SO_BUFFER_SLOT_COUNT; i++) {
m_state.so.targets[i].buffer = nullptr;
m_state.so.targets[i].offset = 0;
}
// Default predication
m_state.pr.predicateObject = nullptr;
@ -2515,11 +2517,23 @@ namespace dxvk {
UINT NumBuffers,
ID3D11Buffer* const* ppSOTargets,
const UINT* pOffsets) {
// TODO implement properly, including pOffsets
for (uint32_t i = 0; i < D3D11_SO_STREAM_COUNT; i++) {
m_state.so.targets[i] = (ppSOTargets != nullptr && i < NumBuffers)
? static_cast<D3D11Buffer*>(ppSOTargets[i])
: nullptr;
for (uint32_t i = 0; i < NumBuffers; i++) {
D3D11Buffer* buffer = static_cast<D3D11Buffer*>(ppSOTargets[i]);
UINT offset = pOffsets != nullptr ? pOffsets[i] : 0;
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,
ID3D11Buffer** ppSOTargets) {
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();
}
@ -2863,6 +2877,37 @@ 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(
UINT Slot,
const D3D11ConstantBufferBinding* pBufferBinding) {
@ -3142,6 +3187,9 @@ namespace dxvk {
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::HullShader, m_state.hs.constantBuffers);
RestoreConstantBuffers(DxbcProgramType::DomainShader, m_state.ds.constantBuffers);

View File

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

View File

@ -141,8 +141,14 @@ namespace dxvk {
};
struct D3D11ContextSoTarget {
Com<D3D11Buffer> buffer;
UINT offset;
};
struct D3D11ContextStateSO {
std::array<Com<D3D11Buffer>, D3D11_SO_STREAM_COUNT> targets;
std::array<D3D11ContextSoTarget, D3D11_SO_BUFFER_SLOT_COUNT> targets;
};