mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Very minor VulkanImage optimization
This commit is contained in:
parent
d426ccf178
commit
b32c0b461a
3 changed files with 19 additions and 3 deletions
|
@ -47,6 +47,20 @@ struct TinySet {
|
|||
slowLookup_->push_back(t);
|
||||
return *slowLookup_->back();
|
||||
}
|
||||
void reserve(size_t size) {
|
||||
if (size < MaxFastSize) {
|
||||
return;
|
||||
}
|
||||
if (slowLookup_) {
|
||||
if (size < MaxFastSize + slowLookup_->capacity()) {
|
||||
return;
|
||||
}
|
||||
slowLookup_->reserve(size - MaxFastSize);
|
||||
} else {
|
||||
slowLookup_ = new std::vector<T>();
|
||||
slowLookup_->reserve(size - MaxFastSize);
|
||||
}
|
||||
}
|
||||
void append(const TinySet<T, MaxFastSize> &other) {
|
||||
size_t otherSize = other.size();
|
||||
if (size() + otherSize <= MaxFastSize) {
|
||||
|
|
|
@ -168,10 +168,12 @@ bool VulkanTexture::CreateDirect(int w, int h, int depth, int numMips, VkFormat
|
|||
}
|
||||
|
||||
void VulkanTexture::CopyBufferToMipLevel(VkCommandBuffer cmd, TextureCopyBatch *copyBatch, int mip, int mipWidth, int mipHeight, int depthLayer, VkBuffer buffer, uint32_t offset, size_t rowLength) {
|
||||
VkBufferImageCopy copy_region{};
|
||||
VkBufferImageCopy ©_region = copyBatch->copies.push_uninitialized();
|
||||
copy_region.bufferOffset = offset;
|
||||
copy_region.bufferRowLength = (uint32_t)rowLength;
|
||||
copy_region.bufferImageHeight = 0; // 2D
|
||||
copy_region.imageOffset.x = 0;
|
||||
copy_region.imageOffset.y = 0;
|
||||
copy_region.imageOffset.z = depthLayer;
|
||||
copy_region.imageExtent.width = mipWidth;
|
||||
copy_region.imageExtent.height = mipHeight;
|
||||
|
@ -190,7 +192,6 @@ void VulkanTexture::CopyBufferToMipLevel(VkCommandBuffer cmd, TextureCopyBatch *
|
|||
FinishCopyBatch(cmd, copyBatch);
|
||||
copyBatch->buffer = buffer;
|
||||
}
|
||||
copyBatch->copies.push_back(copy_region);
|
||||
}
|
||||
|
||||
void VulkanTexture::FinishCopyBatch(VkCommandBuffer cmd, TextureCopyBatch *copyBatch) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include "VulkanLoader.h"
|
||||
#include "Common/Data/Collections/FastVec.h"
|
||||
|
||||
class VulkanContext;
|
||||
class VulkanDeviceAllocator;
|
||||
|
@ -11,7 +12,7 @@ VK_DEFINE_HANDLE(VmaAllocation);
|
|||
class VulkanBarrierBatch;
|
||||
|
||||
struct TextureCopyBatch {
|
||||
std::vector<VkBufferImageCopy> copies;
|
||||
FastVec<VkBufferImageCopy> copies;
|
||||
VkBuffer buffer = VK_NULL_HANDLE;
|
||||
void reserve(size_t mips) { copies.reserve(mips); }
|
||||
bool empty() const { return copies.empty(); }
|
||||
|
|
Loading…
Add table
Reference in a new issue