Compare commits
1 Commits
main
...
pf/vk-chec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52b8d8cfbd |
@@ -118,6 +118,14 @@ void VulkanBufferCache::terminate() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
size_t VulkanBufferCache::getSize() const noexcept {
|
||||
size_t size = 0;
|
||||
for (int i = 0; i < MAX_POOL_COUNT; i++) {
|
||||
size += mGpuBufferPools[i].size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void VulkanBufferCache::release(VulkanGpuBuffer const* gpuBuffer) noexcept {
|
||||
assert_invariant(gpuBuffer != nullptr);
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ public:
|
||||
// This should be called while the context's VkDevice is still alive.
|
||||
void terminate() noexcept;
|
||||
|
||||
size_t getSize() const noexcept;
|
||||
|
||||
private:
|
||||
struct UnusedGpuBuffer {
|
||||
uint64_t lastAccessed;
|
||||
|
||||
@@ -158,6 +158,8 @@ struct CommandBufferPool {
|
||||
|
||||
inline bool isRecording() const { return mRecording != INVALID; }
|
||||
|
||||
size_t getSize() const noexcept { return mBuffers.size(); }
|
||||
|
||||
private:
|
||||
static constexpr int CAPACITY = FVK_MAX_COMMAND_BUFFERS;
|
||||
// int8 only goes up to 127, therefore capacity must be less than that.
|
||||
@@ -255,6 +257,17 @@ public:
|
||||
// Updates the atomic "status" variable in every extant fence.
|
||||
void updateFences();
|
||||
|
||||
struct SizeInfo {
|
||||
size_t regular;
|
||||
size_t protectedPool;
|
||||
};
|
||||
SizeInfo getSize() const noexcept {
|
||||
return {
|
||||
mPool ? mPool->getSize() : 0,
|
||||
mProtectedPool ? mProtectedPool->getSize() : 0
|
||||
};
|
||||
}
|
||||
|
||||
#if FVK_ENABLED(FVK_DEBUG_GROUP_MARKERS)
|
||||
void pushGroupMarker(char const* str, VulkanGroupMarkers::Timestamp timestamp = {});
|
||||
void popGroupMarker();
|
||||
|
||||
@@ -119,6 +119,9 @@ public:
|
||||
return mCapacity;
|
||||
}
|
||||
|
||||
uint16_t size() const { return mSize; }
|
||||
uint16_t unusedCount() const { return mUnusedCount; }
|
||||
|
||||
// A convenience method for checking if this pool can allocate sets for a given layout.
|
||||
inline bool canAllocate(DescriptorCount const& count) {
|
||||
return count == mCount;
|
||||
@@ -255,6 +258,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
VulkanDescriptorSetCache::SizeInfo getSize() const {
|
||||
VulkanDescriptorSetCache::SizeInfo info = {};
|
||||
info.poolCount = mPools.size();
|
||||
for (auto& pool : mPools) {
|
||||
info.totalSize += pool->size();
|
||||
info.totalUnusedCount += pool->unusedCount();
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private:
|
||||
VkDevice mDevice;
|
||||
std::vector<std::unique_ptr<DescriptorPool>> mPools;
|
||||
@@ -448,6 +461,10 @@ void VulkanDescriptorSetCache::manualRecycle(VulkanDescriptorSetLayout::Count co
|
||||
|
||||
void VulkanDescriptorSetCache::gc() { mStashedSets = {}; }
|
||||
|
||||
VulkanDescriptorSetCache::SizeInfo VulkanDescriptorSetCache::getSize() const noexcept {
|
||||
return mDescriptorPool->getSize();
|
||||
}
|
||||
|
||||
void VulkanDescriptorSetCache::copySet(VkDescriptorSet srcSet, VkDescriptorSet dstSet,
|
||||
fvkutils::SamplerBitmask bindings) const {
|
||||
// TODO: fix the size for better memory management
|
||||
|
||||
@@ -89,6 +89,13 @@ public:
|
||||
|
||||
void resetCachedState() noexcept { mLastBoundInfo = {}; }
|
||||
|
||||
struct SizeInfo {
|
||||
size_t poolCount;
|
||||
size_t totalSize;
|
||||
size_t totalUnusedCount;
|
||||
};
|
||||
SizeInfo getSize() const noexcept;
|
||||
|
||||
private:
|
||||
void copySet(VkDescriptorSet srcSet, VkDescriptorSet destSet,
|
||||
fvkutils::SamplerBitmask copyBindings) const;
|
||||
|
||||
@@ -49,6 +49,8 @@ public:
|
||||
fvkutils::SamplerBitmask externalSamplers,
|
||||
utils::FixedCapacityVector<std::pair<uint64_t, VkSampler>> immutableSamplers = {});
|
||||
|
||||
size_t getSize() const noexcept { return mVkLayouts.size(); }
|
||||
|
||||
private:
|
||||
VkDevice mDevice;
|
||||
fvkmemory::ResourceManager* mResourceManager;
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace bluevk;
|
||||
|
||||
@@ -445,6 +446,29 @@ void VulkanDriver::collectGarbage() {
|
||||
|
||||
mResourceManager.gc();
|
||||
|
||||
auto dsSize = mDescriptorSetCache.getSize();
|
||||
auto stageSize = mStagePool.getSize();
|
||||
auto externalSize = mExternalImageManager.getSize();
|
||||
auto commandsSize = mCommands.getSize();
|
||||
|
||||
fprintf(stderr, "Vulkan Cache Sizes:\n");
|
||||
fprintf(stderr, " Pipelines: %zu\n", mPipelineCache.getSize());
|
||||
fprintf(stderr, " Pipeline Layouts: %zu\n", mPipelineLayoutCache.getSize());
|
||||
fprintf(stderr, " Descriptor Set Layouts: %zu\n", mDescriptorSetLayoutCache.getSize());
|
||||
fprintf(stderr, " Descriptor Sets: %zu (pools: %zu, unused: %zu)\n", dsSize.totalSize, dsSize.poolCount, dsSize.totalUnusedCount);
|
||||
fprintf(stderr, " FBOs: %zu\n", mFramebufferCache.getFboCacheSize());
|
||||
fprintf(stderr, " Render Passes: %zu (refcount: %zu)\n",
|
||||
mFramebufferCache.getRenderPassCacheSize(), mFramebufferCache.getRenderPassRefCountSize());
|
||||
fprintf(stderr, " Samplers: %zu\n", mSamplerCache.getSize());
|
||||
fprintf(stderr, " Buffers: %zu\n", mBufferCache.getSize());
|
||||
fprintf(stderr, " Stages: %zu, Free Images: %zu\n", stageSize.stages, stageSize.freeImages);
|
||||
fprintf(stderr, " YCbCr Conversions: %zu\n", mYcbcrConversionCache.getSize());
|
||||
fprintf(stderr, " External Images: %zu, Set Bindings: %zu\n", externalSize.images, externalSize.setBindings);
|
||||
fprintf(stderr, " Streamed Bindings: %zu\n", mStreamedImageManager.getSize());
|
||||
fprintf(stderr, " Command Buffers: %zu (regular: %zu, protected: %zu)\n",
|
||||
commandsSize.regular + commandsSize.protectedPool, commandsSize.regular, commandsSize.protectedPool);
|
||||
fprintf(stderr, " Semaphores: %zu\n", mSemaphoreManager.getSize());
|
||||
|
||||
#if FVK_ENABLED(FVK_DEBUG_RESOURCE_LEAK)
|
||||
mResourceManager.print();
|
||||
#endif
|
||||
|
||||
@@ -85,6 +85,12 @@ public:
|
||||
// - Update the bindings that use external samplers.
|
||||
void updateSetAndLayout(fvkmemory::resource_ptr<VulkanDescriptorSet> set);
|
||||
|
||||
struct SizeInfo {
|
||||
size_t setBindings;
|
||||
size_t images;
|
||||
};
|
||||
SizeInfo getSize() const noexcept { return { mSetBindings.size(), mImages.size() }; }
|
||||
|
||||
private:
|
||||
|
||||
VulkanSamplerCache* mSamplerCache;
|
||||
|
||||
@@ -120,6 +120,10 @@ public:
|
||||
// Frees all Vulkan objects. Call this during shutdown before the device is destroyed.
|
||||
void terminate() noexcept;
|
||||
|
||||
size_t getFboCacheSize() const noexcept { return mFramebufferCache.size(); }
|
||||
size_t getRenderPassCacheSize() const noexcept { return mRenderPassCache.size(); }
|
||||
size_t getRenderPassRefCountSize() const noexcept { return mRenderPassRefCount.size(); }
|
||||
|
||||
private:
|
||||
VkDevice mDevice;
|
||||
using FboMap = tsl::robin_map<FboKey, FboVal, FboKeyHashFn, FboKeyEqualFn>;
|
||||
|
||||
@@ -136,6 +136,8 @@ public:
|
||||
void terminate() noexcept;
|
||||
void gc() noexcept;
|
||||
|
||||
size_t getSize() const noexcept { return mPipelines.size(); }
|
||||
|
||||
private:
|
||||
// PIPELINE CACHE KEY
|
||||
// ------------------
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
VkPipelineLayout getLayout(DescriptorSetLayoutArray const& descriptorSetLayouts,
|
||||
fvkmemory::resource_ptr<VulkanProgram> program);
|
||||
|
||||
size_t getSize() const noexcept { return mPipelineLayouts.size(); }
|
||||
|
||||
private:
|
||||
using Timestamp = uint64_t;
|
||||
struct PipelineLayoutCacheEntry {
|
||||
|
||||
@@ -40,6 +40,8 @@ public:
|
||||
explicit VulkanSamplerCache(VkDevice device);
|
||||
VkSampler getSampler(Params params);
|
||||
void terminate() noexcept;
|
||||
|
||||
size_t getSize() const noexcept { return mCache.size(); }
|
||||
private:
|
||||
VkDevice mDevice;
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ public:
|
||||
void terminate();
|
||||
Semaphore acquire();
|
||||
|
||||
size_t getSize() const noexcept { return mPool.size(); }
|
||||
|
||||
private:
|
||||
friend struct VulkanSemaphore;
|
||||
void recycle(VkSemaphore semaphore);
|
||||
|
||||
@@ -223,6 +223,12 @@ public:
|
||||
// resource_ptrs, as this would lead to undefined behavior.
|
||||
void terminate() noexcept;
|
||||
|
||||
struct SizeInfo {
|
||||
size_t stages;
|
||||
size_t freeImages;
|
||||
};
|
||||
SizeInfo getSize() const noexcept { return { mStages.size(), mFreeImages.size() }; }
|
||||
|
||||
private:
|
||||
VmaAllocator mAllocator;
|
||||
fvkmemory::ResourceManager* mResManager;
|
||||
|
||||
@@ -46,6 +46,8 @@ public:
|
||||
void onStreamAcquireImage(fvkmemory::resource_ptr<VulkanTexture> image,
|
||||
fvkmemory::resource_ptr<VulkanStream> stream);
|
||||
|
||||
size_t getSize() const noexcept { return mStreamedTexturesBindings.size(); }
|
||||
|
||||
private:
|
||||
struct StreamedTextureBinding {
|
||||
uint8_t binding = 0;
|
||||
|
||||
@@ -42,6 +42,8 @@ public:
|
||||
VkSamplerYcbcrConversion getConversion(Params params);
|
||||
void terminate() noexcept;
|
||||
|
||||
size_t getSize() const noexcept { return mCache.size(); }
|
||||
|
||||
private:
|
||||
VkDevice mDevice;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user