[Vulkan] Buffers typically aren't aligned.

This commit is contained in:
DrChat 2018-02-15 17:05:54 -06:00
parent abd21e5034
commit 30e0a258e4
1 changed files with 8 additions and 8 deletions

View File

@ -297,11 +297,11 @@ std::pair<VkBuffer, VkDeviceSize> BufferCache::UploadIndexBuffer(
// TODO(benvanik): memcpy then use compute shaders to swap? // TODO(benvanik): memcpy then use compute shaders to swap?
if (format == IndexFormat::kInt16) { if (format == IndexFormat::kInt16) {
// Endian::k8in16, swap half-words. // Endian::k8in16, swap half-words.
xe::copy_and_swap_16_aligned(transient_buffer_->host_base() + offset, xe::copy_and_swap_16_unaligned(transient_buffer_->host_base() + offset,
source_ptr, source_length / 2); source_ptr, source_length / 2);
} else if (format == IndexFormat::kInt32) { } else if (format == IndexFormat::kInt32) {
// Endian::k8in32, swap words. // Endian::k8in32, swap words.
xe::copy_and_swap_32_aligned(transient_buffer_->host_base() + offset, xe::copy_and_swap_32_unaligned(transient_buffer_->host_base() + offset,
source_ptr, source_length / 4); source_ptr, source_length / 4);
} }
@ -348,11 +348,11 @@ std::pair<VkBuffer, VkDeviceSize> BufferCache::UploadVertexBuffer(
// TODO(benvanik): memcpy then use compute shaders to swap? // TODO(benvanik): memcpy then use compute shaders to swap?
if (endian == Endian::k8in32) { if (endian == Endian::k8in32) {
// Endian::k8in32, swap words. // Endian::k8in32, swap words.
xe::copy_and_swap_32_aligned(transient_buffer_->host_base() + offset, xe::copy_and_swap_32_unaligned(transient_buffer_->host_base() + offset,
source_ptr, source_length / 4); source_ptr, source_length / 4);
} else if (endian == Endian::k16in32) { } else if (endian == Endian::k16in32) {
xe::copy_and_swap_16_in_32_aligned(transient_buffer_->host_base() + offset, xe::copy_and_swap_16_in_32_unaligned(
source_ptr, source_length / 4); transient_buffer_->host_base() + offset, source_ptr, source_length / 4);
} else { } else {
assert_always(); assert_always();
} }