mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-02 04:29:14 +01:00
[dxvk] Use vkCmdBindVertexBuffers2 to bind buffer ranges
Potentially fixes problems with OOB access on dynamic vertex buffers.
This commit is contained in:
parent
9ba99eba93
commit
dfc0b740f8
@ -328,6 +328,19 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void cmdBindVertexBuffers2(
|
||||
uint32_t firstBinding,
|
||||
uint32_t bindingCount,
|
||||
const VkBuffer* pBuffers,
|
||||
const VkDeviceSize* pOffsets,
|
||||
const VkDeviceSize* pSizes,
|
||||
const VkDeviceSize* pStrides) {
|
||||
m_vkd->vkCmdBindVertexBuffers2EXT(m_execBuffer,
|
||||
firstBinding, bindingCount, pBuffers, pOffsets,
|
||||
pSizes, pStrides);
|
||||
}
|
||||
|
||||
|
||||
void cmdBlitImage(
|
||||
VkImage srcImage,
|
||||
VkImageLayout srcImageLayout,
|
||||
|
@ -4108,6 +4108,7 @@ namespace dxvk {
|
||||
|
||||
std::array<VkBuffer, MaxNumVertexBindings> buffers;
|
||||
std::array<VkDeviceSize, MaxNumVertexBindings> offsets;
|
||||
std::array<VkDeviceSize, MaxNumVertexBindings> lengths;
|
||||
|
||||
// Set buffer handles and offsets for active bindings
|
||||
for (uint32_t i = 0; i < m_state.gp.state.il.bindingCount(); i++) {
|
||||
@ -4118,23 +4119,30 @@ namespace dxvk {
|
||||
|
||||
buffers[i] = vbo.buffer.buffer;
|
||||
offsets[i] = vbo.buffer.offset;
|
||||
lengths[i] = vbo.buffer.range;
|
||||
|
||||
if (m_vbTracked.set(binding))
|
||||
m_cmd->trackResource<DxvkAccess::Read>(m_state.vi.vertexBuffers[binding].buffer());
|
||||
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
|
||||
buffers[i] = VK_NULL_HANDLE;
|
||||
offsets[i] = 0;
|
||||
lengths[i] = 0;
|
||||
} else {
|
||||
buffers[i] = m_common->dummyResources().bufferHandle();
|
||||
offsets[i] = 0;
|
||||
lengths[i] = VK_WHOLE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
// Vertex bindigs get remapped when compiling the
|
||||
// pipeline, so this actually does the right thing
|
||||
m_cmd->cmdBindVertexBuffers(
|
||||
0, m_state.gp.state.il.bindingCount(),
|
||||
buffers.data(), offsets.data());
|
||||
if (m_features.test(DxvkContextFeature::ExtendedDynamicState)) {
|
||||
m_cmd->cmdBindVertexBuffers2(0, m_state.gp.state.il.bindingCount(),
|
||||
buffers.data(), offsets.data(), lengths.data(), nullptr);
|
||||
} else {
|
||||
m_cmd->cmdBindVertexBuffers(0, m_state.gp.state.il.bindingCount(),
|
||||
buffers.data(), offsets.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user