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

[dxvk] Bind dummy resource for unbound vertex and index buffers

Allows GTA V to run, although heavy rendering artifacts remain.
This commit is contained in:
Philip Rebohle 2018-02-01 13:29:57 +01:00
parent 0791c8ca4c
commit d4a0581f8f
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 46 additions and 3 deletions

View File

@ -1185,8 +1185,12 @@ namespace dxvk {
m_flags.clr(DxvkContextFlag::GpDirtyPipelineState);
for (uint32_t i = 0; i < m_state.gp.state.ilBindingCount; i++) {
const uint32_t binding = m_state.gp.state.ilBindings[i].binding;
m_state.gp.state.ilBindings[i].stride
= m_state.vi.vertexStrides[m_state.gp.state.ilBindings[i].binding];
= (m_state.vi.bindingMask & (1u << binding)) != 0
? m_state.vi.vertexStrides[binding]
: 0;
}
for (uint32_t i = m_state.gp.state.ilBindingCount; i < MaxNumVertexBindings; i++)
@ -1399,6 +1403,10 @@ namespace dxvk {
m_state.vi.indexType);
m_cmd->trackResource(
physicalSlice.resource());
} else {
m_cmd->cmdBindIndexBuffer(
m_device->dummyBufferHandle(),
0, VK_INDEX_TYPE_UINT32);
}
}
}
@ -1408,6 +1416,8 @@ namespace dxvk {
if (m_flags.test(DxvkContextFlag::GpDirtyVertexBuffers)) {
m_flags.clr(DxvkContextFlag::GpDirtyVertexBuffers);
uint32_t bindingMask = 0;
for (uint32_t i = 0; i < m_state.gp.state.ilBindingCount; i++) {
const uint32_t binding = m_state.gp.state.ilBindings[i].binding;
@ -1419,8 +1429,20 @@ namespace dxvk {
m_cmd->cmdBindVertexBuffers(binding, 1, &handle, &offset);
m_cmd->trackResource(vbo.resource());
bindingMask |= 1u << binding;
} else {
const VkBuffer handle = m_device->dummyBufferHandle();
const VkDeviceSize offset = 0;
m_cmd->cmdBindVertexBuffers(binding, 1, &handle, &offset);
}
}
if (m_state.vi.bindingMask != bindingMask) {
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
m_state.vi.bindingMask = bindingMask;
}
}
}

View File

@ -38,7 +38,8 @@ namespace dxvk {
struct DxvkVertexInputState {
DxvkBufferSlice indexBuffer;
VkIndexType indexType = VK_INDEX_TYPE_UINT32;
VkIndexType indexType = VK_INDEX_TYPE_UINT32;
uint32_t bindingMask = 0;
std::array<DxvkBufferSlice,
DxvkLimits::MaxNumVertexBindings> vertexBuffers;

View File

@ -275,6 +275,14 @@ namespace dxvk {
const Rc<DxvkSurface>& surface,
const DxvkSwapchainProperties& properties);
/**
* \brief Dummy buffer handle
* \returns Use for unbound vertex buffers.
*/
VkBuffer dummyBufferHandle() const {
return m_unboundResources.bufferHandle();
}
/**
* \brief Dummy buffer descriptor
* \returns Descriptor that points to a dummy buffer

View File

@ -20,10 +20,22 @@ namespace dxvk {
DxvkUnboundResources(DxvkDevice* dev);
~DxvkUnboundResources();
/**
* \brief Dummy buffer handle
*
* Returns a handle to a buffer filled
* with zeroes. Use for unbound vertex
* and index buffers.
* \returns Dummy buffer handle
*/
VkBuffer bufferHandle() const {
return m_buffer->slice().handle();
}
/**
* \brief Dummy buffer descriptor
*
* Points to a tiny buffer with undefined
* Points to a small buffer with undefined
* values. Do not access this buffer.
* \returns Dummy buffer descriptor
*/