mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +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(
|
void cmdBlitImage(
|
||||||
VkImage srcImage,
|
VkImage srcImage,
|
||||||
VkImageLayout srcImageLayout,
|
VkImageLayout srcImageLayout,
|
||||||
|
@ -4108,6 +4108,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
std::array<VkBuffer, MaxNumVertexBindings> buffers;
|
std::array<VkBuffer, MaxNumVertexBindings> buffers;
|
||||||
std::array<VkDeviceSize, MaxNumVertexBindings> offsets;
|
std::array<VkDeviceSize, MaxNumVertexBindings> offsets;
|
||||||
|
std::array<VkDeviceSize, MaxNumVertexBindings> lengths;
|
||||||
|
|
||||||
// Set buffer handles and offsets for active bindings
|
// Set buffer handles and offsets for active bindings
|
||||||
for (uint32_t i = 0; i < m_state.gp.state.il.bindingCount(); i++) {
|
for (uint32_t i = 0; i < m_state.gp.state.il.bindingCount(); i++) {
|
||||||
@ -4118,23 +4119,30 @@ namespace dxvk {
|
|||||||
|
|
||||||
buffers[i] = vbo.buffer.buffer;
|
buffers[i] = vbo.buffer.buffer;
|
||||||
offsets[i] = vbo.buffer.offset;
|
offsets[i] = vbo.buffer.offset;
|
||||||
|
lengths[i] = vbo.buffer.range;
|
||||||
|
|
||||||
if (m_vbTracked.set(binding))
|
if (m_vbTracked.set(binding))
|
||||||
m_cmd->trackResource<DxvkAccess::Read>(m_state.vi.vertexBuffers[binding].buffer());
|
m_cmd->trackResource<DxvkAccess::Read>(m_state.vi.vertexBuffers[binding].buffer());
|
||||||
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
|
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
|
||||||
buffers[i] = VK_NULL_HANDLE;
|
buffers[i] = VK_NULL_HANDLE;
|
||||||
offsets[i] = 0;
|
offsets[i] = 0;
|
||||||
|
lengths[i] = 0;
|
||||||
} else {
|
} else {
|
||||||
buffers[i] = m_common->dummyResources().bufferHandle();
|
buffers[i] = m_common->dummyResources().bufferHandle();
|
||||||
offsets[i] = 0;
|
offsets[i] = 0;
|
||||||
|
lengths[i] = VK_WHOLE_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertex bindigs get remapped when compiling the
|
// Vertex bindigs get remapped when compiling the
|
||||||
// pipeline, so this actually does the right thing
|
// pipeline, so this actually does the right thing
|
||||||
m_cmd->cmdBindVertexBuffers(
|
if (m_features.test(DxvkContextFeature::ExtendedDynamicState)) {
|
||||||
0, m_state.gp.state.il.bindingCount(),
|
m_cmd->cmdBindVertexBuffers2(0, m_state.gp.state.il.bindingCount(),
|
||||||
buffers.data(), offsets.data());
|
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