From c8da51775951f2301f8507016d1177ace2892171 Mon Sep 17 00:00:00 2001 From: niki Date: Thu, 14 Dec 2023 00:42:19 +0100 Subject: [PATCH] don't use optional for debugName --- src/modules/graphics/Buffer.h | 6 +++--- src/modules/graphics/Texture.h | 6 +++--- src/modules/graphics/opengl/Buffer.cpp | 4 ++-- src/modules/graphics/opengl/Texture.cpp | 6 +++--- src/modules/graphics/vulkan/Buffer.cpp | 4 ++-- src/modules/graphics/vulkan/Texture.cpp | 4 ++-- src/modules/graphics/wrap_Buffer.cpp | 8 ++++---- src/modules/graphics/wrap_Graphics.cpp | 2 +- src/modules/graphics/wrap_Texture.cpp | 8 ++++---- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/modules/graphics/Buffer.h b/src/modules/graphics/Buffer.h index 165490d1e..1afa6c6b1 100644 --- a/src/modules/graphics/Buffer.h +++ b/src/modules/graphics/Buffer.h @@ -90,7 +90,7 @@ public: BufferUsageFlags usageFlags; BufferDataUsage dataUsage; bool zeroInitialize; - Optional debugName; + std::string debugName; Settings(uint32 usageflags, BufferDataUsage dataUsage) : usageFlags((BufferUsageFlags)usageflags) @@ -114,7 +114,7 @@ public: const DataMember &getDataMember(int index) const { return dataMembers[index]; } size_t getMemberOffset(int index) const { return dataMembers[index].offset; } int getDataMemberIndex(const std::string &name) const; - const Optional &getDebugName() const { return debugName; } + const std::string &getDebugName() const { return debugName; } void setImmutable(bool immutable) { this->immutable = immutable; }; bool isImmutable() const { return immutable; } @@ -188,7 +188,7 @@ protected: // Usage hint. GL_[DYNAMIC, STATIC, STREAM]_DRAW. BufferDataUsage dataUsage; - Optional debugName; + std::string debugName; bool mapped; MapType mappedType; diff --git a/src/modules/graphics/Texture.h b/src/modules/graphics/Texture.h index 618fded5d..b9d156c95 100644 --- a/src/modules/graphics/Texture.h +++ b/src/modules/graphics/Texture.h @@ -195,7 +195,7 @@ public: bool renderTarget = false; bool computeWrite = false; OptionalBool readable; - Optional debugName; + std::string debugName; }; struct Slices @@ -290,7 +290,7 @@ public: Quad *getQuad() const; - const Optional &getDebugName() const { return debugName; } + const std::string &getDebugName() const { return debugName; } static int getTotalMipmapCount(int w, int h); static int getTotalMipmapCount(int w, int h, int d); @@ -347,7 +347,7 @@ protected: int64 graphicsMemorySize; - Optional debugName; + std::string debugName; }; // Texture diff --git a/src/modules/graphics/opengl/Buffer.cpp b/src/modules/graphics/opengl/Buffer.cpp index ff6a9a4fc..be437d3ec 100644 --- a/src/modules/graphics/opengl/Buffer.cpp +++ b/src/modules/graphics/opengl/Buffer.cpp @@ -164,8 +164,8 @@ bool Buffer::load(const void *initialdata) glTexBuffer(target, glformat, buffer); } - if (debugName.hasValue) - glObjectLabel(GL_BUFFER, buffer, -1, debugName.value.c_str()); + if (!debugName.empty()) + glObjectLabel(GL_BUFFER, buffer, -1, debugName.c_str()); return (glGetError() == GL_NO_ERROR); } diff --git a/src/modules/graphics/opengl/Texture.cpp b/src/modules/graphics/opengl/Texture.cpp index 1c8ad1bc9..9343a9f68 100644 --- a/src/modules/graphics/opengl/Texture.cpp +++ b/src/modules/graphics/opengl/Texture.cpp @@ -422,12 +422,12 @@ bool Texture::loadVolatile() setGraphicsMemorySize(memsize); - if (debugName.hasValue) + if (!debugName.empty()) { if (texture) - glObjectLabel(GL_TEXTURE, texture, -1, debugName.value.c_str()); + glObjectLabel(GL_TEXTURE, texture, -1, debugName.c_str()); else - glObjectLabel(GL_FRAMEBUFFER, renderbuffer, -1, debugName.value.c_str()); + glObjectLabel(GL_FRAMEBUFFER, renderbuffer, -1, debugName.c_str()); } return true; diff --git a/src/modules/graphics/vulkan/Buffer.cpp b/src/modules/graphics/vulkan/Buffer.cpp index 1d5681858..48c89deac 100644 --- a/src/modules/graphics/vulkan/Buffer.cpp +++ b/src/modules/graphics/vulkan/Buffer.cpp @@ -108,7 +108,7 @@ bool Buffer::loadVolatile() else coherent = false; - if (debugName.hasValue && vgfx->getEnabledOptionalInstanceExtensions().debugInfo) + if (!debugName.empty() && vgfx->getEnabledOptionalInstanceExtensions().debugInfo) { auto device = vgfx->getDevice(); @@ -116,7 +116,7 @@ bool Buffer::loadVolatile() nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; nameInfo.objectType = VK_OBJECT_TYPE_BUFFER; nameInfo.objectHandle = (uint64_t)buffer; - nameInfo.pObjectName = debugName.value.c_str(); + nameInfo.pObjectName = debugName.c_str(); vkSetDebugUtilsObjectNameEXT(device, &nameInfo); } diff --git a/src/modules/graphics/vulkan/Texture.cpp b/src/modules/graphics/vulkan/Texture.cpp index 0ace94e1f..7a02b0224 100644 --- a/src/modules/graphics/vulkan/Texture.cpp +++ b/src/modules/graphics/vulkan/Texture.cpp @@ -201,7 +201,7 @@ bool Texture::loadVolatile() setGraphicsMemorySize(memsize); - if (debugName.hasValue) + if (!debugName.empty()) { if (vgfx->getEnabledOptionalInstanceExtensions().debugInfo) { @@ -209,7 +209,7 @@ bool Texture::loadVolatile() nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; nameInfo.objectType = VK_OBJECT_TYPE_IMAGE; nameInfo.objectHandle = (uint64_t)textureImage; - nameInfo.pObjectName = debugName.value.c_str(); + nameInfo.pObjectName = debugName.c_str(); vkSetDebugUtilsObjectNameEXT(device, &nameInfo); } } diff --git a/src/modules/graphics/wrap_Buffer.cpp b/src/modules/graphics/wrap_Buffer.cpp index cd23bfc6c..e020c1ae4 100644 --- a/src/modules/graphics/wrap_Buffer.cpp +++ b/src/modules/graphics/wrap_Buffer.cpp @@ -416,11 +416,11 @@ static int w_Buffer_isBufferType(lua_State *L) static int w_Buffer_getDebugName(lua_State *L) { Buffer *t = luax_checkbuffer(L, 1); - const Optional &debugName = t->getDebugName(); - if (debugName.hasValue) - luax_pushstring(L, debugName.value); - else + const std::string &debugName = t->getDebugName(); + if (debugName.empty()) lua_pushnil(L); + else + luax_pushstring(L, debugName); return 1; } diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index bae7d29a9..bc92aa97e 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -741,7 +741,7 @@ static void luax_checktexturesettings(lua_State *L, int idx, bool opt, bool chec lua_getfield(L, idx, Texture::getConstant(Texture::SETTING_DEBUGNAME)); if (!lua_isnoneornil(L, -1)) { - s.debugName.set(luaL_checkstring(L, -1)); + s.debugName = luaL_checkstring(L, -1); } lua_pop(L, 1); diff --git a/src/modules/graphics/wrap_Texture.cpp b/src/modules/graphics/wrap_Texture.cpp index 965bdbc13..8198d9a57 100644 --- a/src/modules/graphics/wrap_Texture.cpp +++ b/src/modules/graphics/wrap_Texture.cpp @@ -477,11 +477,11 @@ int w_Texture_renderTo(lua_State *L) static int w_Texture_getDebugName(lua_State *L) { Texture *t = luax_checktexture(L, 1); - const Optional &debugName = t->getDebugName(); - if (debugName.hasValue) - luax_pushstring(L, debugName.value); - else + const std::string &debugName = t->getDebugName(); + if (debugName.empty()) lua_pushnil(L); + else + luax_pushstring(L, debugName); return 1; }