Remove std::string from VulkanTexture

This commit is contained in:
Henrik Rydgård
2022-12-01 11:58:16 +01:00
parent c05ec8b520
commit 40ae99073b
4 changed files with 19 additions and 23 deletions
+9 -3
View File
@@ -5,9 +5,15 @@
#include "Common/GPU/Vulkan/VulkanAlloc.h"
#include "Common/GPU/Vulkan/VulkanImage.h"
#include "Common/GPU/Vulkan/VulkanMemory.h"
#include "Common/StringUtils.h"
using namespace PPSSPP_VK;
VulkanTexture::VulkanTexture(VulkanContext *vulkan, const char *tag)
: vulkan_(vulkan) {
truncate_cpy(tag_, tag);
}
void VulkanTexture::Wipe() {
if (view_ != VK_NULL_HANDLE) {
vulkan_->Delete().QueueDeleteImageView(view_);
@@ -80,7 +86,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int depth, i
VkResult res = vmaCreateImage(vulkan_->Allocator(), &image_create_info, &allocCreateInfo, &image_, &allocation_, &allocInfo);
// Apply the tag
vulkan_->SetDebugName(image_, VK_OBJECT_TYPE_IMAGE, tag_.c_str());
vulkan_->SetDebugName(image_, VK_OBJECT_TYPE_IMAGE, tag_);
// Write a command to transition the image to the requested layout, if it's not already that layout.
if (initialLayout != VK_IMAGE_LAYOUT_UNDEFINED && initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED) {
@@ -123,14 +129,14 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int depth, i
_assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS);
return false;
}
vulkan_->SetDebugName(view_, VK_OBJECT_TYPE_IMAGE_VIEW, tag_.c_str());
vulkan_->SetDebugName(view_, VK_OBJECT_TYPE_IMAGE_VIEW, tag_);
// Additionally, create an array view, but only if it's a 2D texture.
if (view_info.viewType == VK_IMAGE_VIEW_TYPE_2D) {
view_info.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
res = vkCreateImageView(vulkan_->GetDevice(), &view_info, NULL, &arrayView_);
_assert_(res == VK_SUCCESS);
vulkan_->SetDebugName(arrayView_, VK_OBJECT_TYPE_IMAGE_VIEW, tag_.c_str());
vulkan_->SetDebugName(arrayView_, VK_OBJECT_TYPE_IMAGE_VIEW, tag_);
}
return true;
+4 -9
View File
@@ -1,6 +1,5 @@
#pragma once
#include <string>
#include "VulkanLoader.h"
class VulkanContext;
@@ -12,9 +11,7 @@ VK_DEFINE_HANDLE(VmaAllocation);
// ALWAYS use an allocator when calling CreateDirect.
class VulkanTexture {
public:
VulkanTexture(VulkanContext *vulkan)
: vulkan_(vulkan) {
}
VulkanTexture(VulkanContext *vulkan, const char *tag);
~VulkanTexture() {
Destroy();
}
@@ -37,12 +34,10 @@ public:
void Destroy();
void SetTag(const char *tag) {
tag_ = tag;
}
const std::string &Tag() const {
const char *Tag() const {
return tag_;
}
void Touch() {}
// Used in image copies, etc.
@@ -74,5 +69,5 @@ private:
int16_t depth_ = 1;
VkFormat format_ = VK_FORMAT_UNDEFINED;
std::string tag_;
char tag_[64];
};
+2 -6
View File
@@ -652,8 +652,7 @@ static inline VkSamplerAddressMode AddressModeToVulkan(Draw::TextureAddressMode
VulkanTexture *VKContext::GetNullTexture() {
if (!nullTexture_) {
VkCommandBuffer cmdInit = renderManager_.GetInitCmd();
nullTexture_ = new VulkanTexture(vulkan_);
nullTexture_->SetTag("Null");
nullTexture_ = new VulkanTexture(vulkan_, "Null");
int w = 8;
int h = 8;
nullTexture_->CreateDirect(cmdInit, w, h, 1, 1, VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
@@ -737,10 +736,7 @@ bool VKTexture::Create(VkCommandBuffer cmd, VulkanPushBuffer *push, const Textur
width_ = desc.width;
height_ = desc.height;
depth_ = desc.depth;
vkTex_ = new VulkanTexture(vulkan_);
if (desc.tag) {
vkTex_->SetTag(desc.tag);
}
vkTex_ = new VulkanTexture(vulkan_, desc.tag);
VkFormat vulkanFormat = DataFormatToVulkan(format_);
int bpp = GetBpp(vulkanFormat);
int bytesPerPixel = bpp / 8;