Making memory API less error prone; fixes buffer/constant uploads.
This commit is contained in:
@@ -1019,9 +1019,8 @@ bool CommandProcessor::ExecutePacketType3_EVENT_WRITE_EXT(RingBuffer* reader,
|
||||
1, // max z
|
||||
};
|
||||
assert_true(endianness == Endian::k8in16);
|
||||
xe::copy_and_swap_16_aligned(
|
||||
reinterpret_cast<uint16_t*>(memory_->TranslatePhysical(address)), extents,
|
||||
xe::countof(extents));
|
||||
xe::copy_and_swap_16_aligned(memory_->TranslatePhysical(address), extents,
|
||||
xe::countof(extents));
|
||||
trace_writer_.WriteMemoryWrite(CpuToGpu(address), sizeof(extents));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1410,7 +1410,7 @@ GL4CommandProcessor::UpdateStatus GL4CommandProcessor::PopulateVertexBuffers() {
|
||||
// as we copy and only if it differs from the previous value committing
|
||||
// it (and if it matches just discard and reuse).
|
||||
xe::copy_and_swap_32_aligned(
|
||||
reinterpret_cast<uint32_t*>(allocation.host_ptr),
|
||||
allocation.host_ptr,
|
||||
memory_->TranslatePhysical<const uint32_t*>(fetch->address << 2),
|
||||
valid_range / 4);
|
||||
|
||||
|
||||
@@ -662,19 +662,13 @@ void TextureSwap(Endian endianness, void* dest, const void* src,
|
||||
size_t length) {
|
||||
switch (endianness) {
|
||||
case Endian::k8in16:
|
||||
xe::copy_and_swap_16_aligned(reinterpret_cast<uint16_t*>(dest),
|
||||
reinterpret_cast<const uint16_t*>(src),
|
||||
length / 2);
|
||||
xe::copy_and_swap_16_aligned(dest, src, length / 2);
|
||||
break;
|
||||
case Endian::k8in32:
|
||||
xe::copy_and_swap_32_aligned(reinterpret_cast<uint32_t*>(dest),
|
||||
reinterpret_cast<const uint32_t*>(src),
|
||||
length / 4);
|
||||
xe::copy_and_swap_32_aligned(dest, src, length / 4);
|
||||
break;
|
||||
case Endian::k16in32: // Swap high and low 16 bits within a 32 bit word
|
||||
xe::copy_and_swap_16_in_32_aligned(reinterpret_cast<uint32_t*>(dest),
|
||||
reinterpret_cast<const uint32_t*>(src),
|
||||
length);
|
||||
xe::copy_and_swap_16_in_32_aligned(dest, src, length);
|
||||
break;
|
||||
default:
|
||||
case Endian::kUnspecified:
|
||||
|
||||
@@ -290,13 +290,13 @@ std::pair<VkBuffer, VkDeviceSize> BufferCache::UploadIndexBuffer(
|
||||
if (format == IndexFormat::kInt16) {
|
||||
// Endian::k8in16, swap half-words.
|
||||
xe::copy_and_swap_16_aligned(
|
||||
reinterpret_cast<uint16_t*>(transient_buffer_data_) + offset,
|
||||
reinterpret_cast<const uint16_t*>(source_ptr), source_length / 2);
|
||||
reinterpret_cast<uint8_t*>(transient_buffer_data_) + offset, source_ptr,
|
||||
source_length / 2);
|
||||
} else if (format == IndexFormat::kInt32) {
|
||||
// Endian::k8in32, swap words.
|
||||
xe::copy_and_swap_32_aligned(
|
||||
reinterpret_cast<uint32_t*>(transient_buffer_data_) + offset,
|
||||
reinterpret_cast<const uint32_t*>(source_ptr), source_length / 4);
|
||||
reinterpret_cast<uint8_t*>(transient_buffer_data_) + offset, source_ptr,
|
||||
source_length / 4);
|
||||
}
|
||||
|
||||
return {transient_index_buffer_, offset};
|
||||
@@ -317,8 +317,8 @@ std::pair<VkBuffer, VkDeviceSize> BufferCache::UploadVertexBuffer(
|
||||
// TODO(benvanik): memcpy then use compute shaders to swap?
|
||||
// Endian::k8in32, swap words.
|
||||
xe::copy_and_swap_32_aligned(
|
||||
reinterpret_cast<uint32_t*>(transient_buffer_data_) + offset,
|
||||
reinterpret_cast<const uint32_t*>(source_ptr), source_length / 4);
|
||||
reinterpret_cast<uint8_t*>(transient_buffer_data_) + offset, source_ptr,
|
||||
source_length / 4);
|
||||
|
||||
return {transient_vertex_buffer_, offset};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user