Skip to content

Commit

Permalink
don't use optional for debugName
Browse files Browse the repository at this point in the history
  • Loading branch information
nikeinikei committed Dec 13, 2023
1 parent 364b5c3 commit c8da517
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/modules/graphics/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Buffer : public love::Object, public Resource
BufferUsageFlags usageFlags;
BufferDataUsage dataUsage;
bool zeroInitialize;
Optional<std::string> debugName;
std::string debugName;

Settings(uint32 usageflags, BufferDataUsage dataUsage)
: usageFlags((BufferUsageFlags)usageflags)
Expand All @@ -114,7 +114,7 @@ class Buffer : public love::Object, public Resource
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<std::string> &getDebugName() const { return debugName; }
const std::string &getDebugName() const { return debugName; }

void setImmutable(bool immutable) { this->immutable = immutable; };
bool isImmutable() const { return immutable; }
Expand Down Expand Up @@ -188,7 +188,7 @@ class Buffer : public love::Object, public Resource
// Usage hint. GL_[DYNAMIC, STATIC, STREAM]_DRAW.
BufferDataUsage dataUsage;

Optional<std::string> debugName;
std::string debugName;

bool mapped;
MapType mappedType;
Expand Down
6 changes: 3 additions & 3 deletions src/modules/graphics/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Texture : public Drawable, public Resource
bool renderTarget = false;
bool computeWrite = false;
OptionalBool readable;
Optional<std::string> debugName;
std::string debugName;
};

struct Slices
Expand Down Expand Up @@ -290,7 +290,7 @@ class Texture : public Drawable, public Resource

Quad *getQuad() const;

const Optional<std::string> &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);
Expand Down Expand Up @@ -347,7 +347,7 @@ class Texture : public Drawable, public Resource

int64 graphicsMemorySize;

Optional<std::string> debugName;
std::string debugName;

}; // Texture

Expand Down
4 changes: 2 additions & 2 deletions src/modules/graphics/opengl/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/graphics/opengl/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/graphics/vulkan/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ bool Buffer::loadVolatile()
else
coherent = false;

if (debugName.hasValue && vgfx->getEnabledOptionalInstanceExtensions().debugInfo)
if (!debugName.empty() && vgfx->getEnabledOptionalInstanceExtensions().debugInfo)
{
auto device = vgfx->getDevice();

VkDebugUtilsObjectNameInfoEXT nameInfo{};
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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/modules/graphics/vulkan/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@ bool Texture::loadVolatile()

setGraphicsMemorySize(memsize);

if (debugName.hasValue)
if (!debugName.empty())
{
if (vgfx->getEnabledOptionalInstanceExtensions().debugInfo)
{
VkDebugUtilsObjectNameInfoEXT nameInfo{};
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);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/modules/graphics/wrap_Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> &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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/graphics/wrap_Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions src/modules/graphics/wrap_Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> &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;
}

Expand Down

0 comments on commit c8da517

Please sign in to comment.