Use thin3d's push pool in the draw engine too.

This commit is contained in:
Henrik Rydgård 2023-03-15 00:02:57 +01:00
parent 23fe57e774
commit 9fcd6d6612
4 changed files with 9 additions and 10 deletions

View File

@ -349,9 +349,11 @@ void VulkanPushPool::NextBlock(VkDeviceSize allocationSize) {
curBlockIndex_++;
while (curBlockIndex_ < blocks_.size()) {
Block &block = blocks_[curBlockIndex_];
if (block.frameIndex == curFrameIndex) {
// Grab the first matching block, or unused block (frameIndex == -1).
if ((block.frameIndex == curFrameIndex || block.frameIndex == -1) && block.size >= allocationSize) {
_assert_(block.used == 0);
block.used = allocationSize;
block.frameIndex = curFrameIndex;
return;
}
curBlockIndex_++;

View File

@ -981,7 +981,7 @@ VKContext::VKContext(VulkanContext *vulkan)
// 200 textures per frame was not enough for the UI.
dp.maxSets = 4096;
VkBufferUsageFlags usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
VkBufferUsageFlags usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
push_ = new VulkanPushPool(vulkan_, "pushBuffer", 1024 * 1024, usage);
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
@ -1770,7 +1770,8 @@ uint64_t VKContext::GetNativeObject(NativeObject obj, void *srcObject) {
return (uint64_t)curFramebuffer_->GetFB()->GetRTView();
case NativeObject::THIN3D_PIPELINE_LAYOUT:
return (uint64_t)pipelineLayout_;
case NativeObject::PUSH_POOL:
return (uint64_t)push_;
default:
Crash();
return 0;

View File

@ -252,6 +252,7 @@ enum class NativeObject {
NULL_IMAGEVIEW,
NULL_IMAGEVIEW_ARRAY,
THIN3D_PIPELINE_LAYOUT,
PUSH_POOL,
};
enum FBChannel {

View File

@ -173,7 +173,7 @@ void DrawEngineVulkan::InitDeviceObjects() {
// the null texture. This should be cleaned up...
}
pushUBO = new VulkanPushPool(vulkan, "pushUBO", 4 * 1024 * 1024, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
pushUBO = (VulkanPushPool *)draw_->GetNativeObject(Draw::NativeObject::PUSH_POOL);
pushVertex = new VulkanPushPool(vulkan, "pushVertex", 2 * 1024 * 1024, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
pushIndex = new VulkanPushPool(vulkan, "pushIndex", 1 * 1024 * 1024, VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
@ -252,11 +252,6 @@ void DrawEngineVulkan::DestroyDeviceObjects() {
delete pushIndex;
pushIndex = nullptr;
}
if (pushUBO) {
pushUBO->Destroy();
delete pushUBO;
pushUBO = nullptr;
}
if (samplerSecondaryNearest_ != VK_NULL_HANDLE)
vulkan->Delete().QueueDeleteSampler(samplerSecondaryNearest_);
@ -297,7 +292,7 @@ void DrawEngineVulkan::BeginFrame() {
lastPipeline_ = nullptr;
pushUBO->BeginFrame();
// pushUBO is the thin3d push pool, don't need to BeginFrame again.
pushVertex->BeginFrame();
pushIndex->BeginFrame();