Fix Render Info
* Fixed and redone the process to obtain render information from a viewport * Some stats, such as material changes are too difficult to guess on Vulkan, were removed. * Separated visible and shadow stats, which causes confusion. * Texture, buffer and general video memory can be queried now. * Fixed the performance metrics too.
This commit is contained in:
parent
ecf9ea740e
commit
6c55d2aad2
34 changed files with 391 additions and 279 deletions
|
|
@ -1398,12 +1398,15 @@ Error RenderingDeviceVulkan::_buffer_allocate(Buffer *p_buffer, uint32_t p_size,
|
|||
p_buffer->buffer_info.range = p_size;
|
||||
p_buffer->usage = p_usage;
|
||||
|
||||
buffer_memory += p_size;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error RenderingDeviceVulkan::_buffer_free(Buffer *p_buffer) {
|
||||
ERR_FAIL_COND_V(p_buffer->size == 0, ERR_INVALID_PARAMETER);
|
||||
|
||||
buffer_memory -= p_buffer->size;
|
||||
vmaDestroyBuffer(allocator, p_buffer->buffer, p_buffer->allocation);
|
||||
p_buffer->buffer = VK_NULL_HANDLE;
|
||||
p_buffer->allocation = nullptr;
|
||||
|
|
@ -1896,7 +1899,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
|
|||
|
||||
VkResult err = vmaCreateImage(allocator, &image_create_info, &allocInfo, &texture.image, &texture.allocation, &texture.allocation_info);
|
||||
ERR_FAIL_COND_V_MSG(err, RID(), "vmaCreateImage failed with error " + itos(err) + ".");
|
||||
|
||||
image_memory += texture.allocation_info.size;
|
||||
texture.type = p_format.texture_type;
|
||||
texture.format = p_format.format;
|
||||
texture.width = image_create_info.extent.width;
|
||||
|
|
@ -8121,6 +8124,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) {
|
|||
vkDestroyImageView(device, texture->view, nullptr);
|
||||
if (texture->owner.is_null()) {
|
||||
//actually owns the image and the allocation too
|
||||
image_memory -= texture->allocation_info.size;
|
||||
vmaDestroyImage(allocator, texture->image, texture->allocation);
|
||||
}
|
||||
frames[p_frame].textures_to_dispose_of.pop_front();
|
||||
|
|
@ -8144,10 +8148,16 @@ uint32_t RenderingDeviceVulkan::get_frame_delay() const {
|
|||
return frame_count;
|
||||
}
|
||||
|
||||
uint64_t RenderingDeviceVulkan::get_memory_usage() const {
|
||||
VmaStats stats;
|
||||
vmaCalculateStats(allocator, &stats);
|
||||
return stats.total.usedBytes;
|
||||
uint64_t RenderingDeviceVulkan::get_memory_usage(MemoryType p_type) const {
|
||||
if (p_type == MEMORY_BUFFERS) {
|
||||
return buffer_memory;
|
||||
} else if (p_type == MEMORY_TEXTURES) {
|
||||
return image_memory;
|
||||
} else {
|
||||
VmaStats stats;
|
||||
vmaCalculateStats(allocator, &stats);
|
||||
return stats.total.usedBytes;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingDeviceVulkan::_flush(bool p_current_frame) {
|
||||
|
|
|
|||
|
|
@ -1005,6 +1005,9 @@ class RenderingDeviceVulkan : public RenderingDevice {
|
|||
|
||||
VulkanContext *context = nullptr;
|
||||
|
||||
uint64_t image_memory = 0;
|
||||
uint64_t buffer_memory = 0;
|
||||
|
||||
void _free_internal(RID p_id);
|
||||
void _flush(bool p_current_frame);
|
||||
|
||||
|
|
@ -1191,7 +1194,7 @@ public:
|
|||
|
||||
virtual RenderingDevice *create_local_device();
|
||||
|
||||
virtual uint64_t get_memory_usage() const;
|
||||
virtual uint64_t get_memory_usage(MemoryType p_type) const;
|
||||
|
||||
virtual void set_resource_name(RID p_id, const String p_name);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue