Skip to content

Commit 0ce2bd7

Browse files
committed
Removed usage of String references
1 parent 372a111 commit 0ce2bd7

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

engine/render/renderer/platform/vulkan/Texture2D.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace Siege::Vulkan
2121
{
22-
Texture2D::Texture2D(const String& name)
22+
Texture2D::Texture2D(const char* name)
2323
{
2424
LoadTexture(Constants::DEFAULT_TEXTURE_2D, Constants::DEFAULT_TEXTURE_SIZE, 16, 16);
2525

@@ -33,7 +33,7 @@ Texture2D::Texture2D(const String& name)
3333
id = INTERN_STR(name);
3434
}
3535

36-
Texture2D::Texture2D(const String& name, const String& filePath)
36+
Texture2D::Texture2D(const char* name, const char* filePath)
3737
{
3838
LoadFromFile(filePath);
3939

@@ -62,7 +62,7 @@ Texture2D& Texture2D::operator=(Texture2D&& other)
6262
return *this;
6363
}
6464

65-
void Texture2D::LoadFromFile(const String& filePath)
65+
void Texture2D::LoadFromFile(const char* filePath)
6666
{
6767
int texWidth, texHeight, texChannels;
6868

@@ -72,7 +72,7 @@ void Texture2D::LoadFromFile(const String& filePath)
7272

7373
uint64_t imageSize = texWidth * texHeight * 4;
7474

75-
uint8_t pixelPtr[imageSize];
75+
uint8_t* pixelPtr = new uint8_t[imageSize];
7676

7777
// Set the image to 0 so that we get no garbage data in the pixel array
7878
memset(pixelPtr, 0, imageSize);
@@ -102,6 +102,8 @@ void Texture2D::LoadFromFile(const String& filePath)
102102
image.CopyBuffer(stagingBuffer.buffer);
103103

104104
Buffer::DestroyBuffer(stagingBuffer);
105+
106+
delete [] pixelPtr;
105107
}
106108

107109
void Texture2D::LoadTexture(const uint8_t* pixels, size_t size, uint32_t width, uint32_t height)

engine/render/renderer/platform/vulkan/Texture2D.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ class Texture2D
4747
* default white texture
4848
* @param name the name of the texture being created
4949
*/
50-
Texture2D(const String& name);
50+
Texture2D(const char* name);
5151

5252
/**
5353
* The texture constructor used for loading a texture from file. This loads data from a given
5454
* file path and stores pixel data in the class
5555
* @param name the name of the texture
5656
* @param filePath the path of the PNG or JPG file
5757
*/
58-
Texture2D(const String& name, const String& filePath);
58+
Texture2D(const char* name, const char* filePath);
5959

6060
/**
6161
* A move constructor for the Texture2D class
@@ -108,7 +108,7 @@ class Texture2D
108108
* Loads pixel information from a PNG or JPG file located on disk
109109
* @param filePath the path of the file
110110
*/
111-
void LoadFromFile(const String& filePath);
111+
void LoadFromFile(const char* filePath);
112112

113113
/**
114114
* Loads a texture from a pixel buffer. Useful if you already have pixel info loaded into a

engine/render/renderer/platform/vulkan/utils/DebugUtilsMessenger.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ void PopulateCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo)
106106
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
107107
createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
108108
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
109-
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT |
110-
VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT;
109+
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
111110
createInfo.pfnUserCallback = debugCallback;
112111
createInfo.pUserData = nullptr; // Optional
113112
}

0 commit comments

Comments
 (0)