mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
add texture:getDebugName and buffer:getDebugName
This commit is contained in:
@@ -38,6 +38,7 @@ Buffer::Buffer(Graphics *gfx, const Settings &settings, const std::vector<DataDe
|
||||
, mapped(false)
|
||||
, mappedType(MAP_WRITE_INVALIDATE)
|
||||
, immutable(false)
|
||||
, debugName(settings.debugName)
|
||||
{
|
||||
if (size == 0 && arraylength == 0)
|
||||
throw love::Exception("Size or array length must be specified.");
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "common/config.h"
|
||||
#include "common/int.h"
|
||||
#include "common/Object.h"
|
||||
#include "common/Optional.h"
|
||||
#include "vertex.h"
|
||||
#include "Resource.h"
|
||||
|
||||
@@ -89,12 +90,13 @@ public:
|
||||
BufferUsageFlags usageFlags;
|
||||
BufferDataUsage dataUsage;
|
||||
bool zeroInitialize;
|
||||
std::string debugName;
|
||||
Optional<std::string> debugName;
|
||||
|
||||
Settings(uint32 usageflags, BufferDataUsage dataUsage)
|
||||
: usageFlags((BufferUsageFlags)usageflags)
|
||||
, dataUsage(dataUsage)
|
||||
, zeroInitialize(false)
|
||||
, debugName()
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -112,6 +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<std::string> &getDebugName() const { return debugName; }
|
||||
|
||||
void setImmutable(bool immutable) { this->immutable = immutable; };
|
||||
bool isImmutable() const { return immutable; }
|
||||
@@ -185,7 +188,7 @@ protected:
|
||||
// Usage hint. GL_[DYNAMIC, STATIC, STREAM]_DRAW.
|
||||
BufferDataUsage dataUsage;
|
||||
|
||||
std::string debugName;
|
||||
Optional<std::string> debugName;
|
||||
|
||||
bool mapped;
|
||||
MapType mappedType;
|
||||
|
||||
@@ -178,6 +178,7 @@ Texture::Texture(Graphics *gfx, const Settings &settings, const Slices *slices)
|
||||
, requestedMSAA(settings.msaa > 1 ? settings.msaa : 0)
|
||||
, samplerState()
|
||||
, graphicsMemorySize(0)
|
||||
, debugName(settings.debugName)
|
||||
{
|
||||
const auto &caps = gfx->getCapabilities();
|
||||
int requestedMipmapCount = settings.mipmapCount;
|
||||
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
bool renderTarget = false;
|
||||
bool computeWrite = false;
|
||||
OptionalBool readable;
|
||||
std::string debugName;
|
||||
Optional<std::string> debugName;
|
||||
};
|
||||
|
||||
struct Slices
|
||||
@@ -290,6 +290,8 @@ public:
|
||||
|
||||
Quad *getQuad() const;
|
||||
|
||||
const Optional<std::string>& getDebugName() const { return debugName; }
|
||||
|
||||
static int getTotalMipmapCount(int w, int h);
|
||||
static int getTotalMipmapCount(int w, int h, int d);
|
||||
|
||||
@@ -345,6 +347,8 @@ protected:
|
||||
|
||||
int64 graphicsMemorySize;
|
||||
|
||||
Optional<std::string> debugName;
|
||||
|
||||
}; // Texture
|
||||
|
||||
} // graphics
|
||||
|
||||
@@ -68,7 +68,6 @@ static GLenum getGLFormat(DataFormat format)
|
||||
|
||||
Buffer::Buffer(love::graphics::Graphics *gfx, const Settings &settings, const std::vector<DataDeclaration> &format, const void *data, size_t size, size_t arraylength)
|
||||
: love::graphics::Buffer(gfx, settings, format, size, arraylength)
|
||||
, debugName(settings.debugName)
|
||||
{
|
||||
size = getSize();
|
||||
arraylength = getArrayLength();
|
||||
@@ -165,8 +164,8 @@ bool Buffer::load(const void *initialdata)
|
||||
glTexBuffer(target, glformat, buffer);
|
||||
}
|
||||
|
||||
if (!debugName.empty())
|
||||
glObjectLabel(GL_BUFFER, buffer, -1, debugName.c_str());
|
||||
if (debugName.hasValue)
|
||||
glObjectLabel(GL_BUFFER, buffer, -1, debugName.value.c_str());
|
||||
|
||||
return (glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
@@ -81,8 +81,6 @@ private:
|
||||
|
||||
Range mappedRange;
|
||||
|
||||
std::string debugName;
|
||||
|
||||
}; // Buffer
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -227,7 +227,6 @@ Texture::Texture(love::graphics::Graphics *gfx, const Settings &settings, const
|
||||
, framebufferStatus(GL_FRAMEBUFFER_COMPLETE)
|
||||
, textureGLError(GL_NO_ERROR)
|
||||
, actualSamples(1)
|
||||
, debugName(settings.debugName)
|
||||
{
|
||||
if (data != nullptr)
|
||||
slices = *data;
|
||||
@@ -423,12 +422,12 @@ bool Texture::loadVolatile()
|
||||
|
||||
setGraphicsMemorySize(memsize);
|
||||
|
||||
if (!debugName.empty())
|
||||
if (debugName.hasValue)
|
||||
{
|
||||
if (texture)
|
||||
glObjectLabel(GL_TEXTURE, texture, -1, debugName.c_str());
|
||||
glObjectLabel(GL_TEXTURE, texture, -1, debugName.value.c_str());
|
||||
else
|
||||
glObjectLabel(GL_FRAMEBUFFER, renderbuffer, -1, debugName.c_str());
|
||||
glObjectLabel(GL_FRAMEBUFFER, renderbuffer, -1, debugName.value.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -78,9 +78,6 @@ private:
|
||||
GLenum textureGLError;
|
||||
|
||||
int actualSamples;
|
||||
|
||||
std::string debugName;
|
||||
|
||||
}; // Texture
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -58,7 +58,6 @@ static VkBufferUsageFlags getVulkanUsageFlags(BufferUsageFlags flags)
|
||||
Buffer::Buffer(love::graphics::Graphics *gfx, const Settings &settings, const std::vector<DataDeclaration> &format, const void *data, size_t size, size_t arraylength)
|
||||
: love::graphics::Buffer(gfx, settings, format, size, arraylength)
|
||||
, zeroInitialize(settings.zeroInitialize)
|
||||
, debugName(settings.debugName)
|
||||
, initialData(data)
|
||||
, vgfx(dynamic_cast<Graphics*>(gfx))
|
||||
, usageFlags(settings.usageFlags)
|
||||
@@ -109,15 +108,15 @@ bool Buffer::loadVolatile()
|
||||
else
|
||||
coherent = false;
|
||||
|
||||
if (!debugName.empty() && vgfx->getEnabledOptionalInstanceExtensions().debugInfo)
|
||||
if (debugName.hasValue && 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_IMAGE;
|
||||
nameInfo.objectType = VK_OBJECT_TYPE_BUFFER;
|
||||
nameInfo.objectHandle = (uint64_t)buffer;
|
||||
nameInfo.pObjectName = debugName.c_str();
|
||||
nameInfo.pObjectName = debugName.value.c_str();
|
||||
vkSetDebugUtilsObjectNameEXT(device, &nameInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ private:
|
||||
BufferUsageFlags usageFlags;
|
||||
Range mappedRange;
|
||||
bool coherent;
|
||||
std::string debugName;
|
||||
};
|
||||
|
||||
} // vulkan
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace vulkan
|
||||
Texture::Texture(love::graphics::Graphics *gfx, const Settings &settings, const Slices *data)
|
||||
: love::graphics::Texture(gfx, settings, data)
|
||||
, vgfx(dynamic_cast<Graphics*>(gfx))
|
||||
, debugName(settings.debugName)
|
||||
, slices(settings.type)
|
||||
, imageAspect(0)
|
||||
{
|
||||
@@ -202,7 +201,7 @@ bool Texture::loadVolatile()
|
||||
|
||||
setGraphicsMemorySize(memsize);
|
||||
|
||||
if (!debugName.empty())
|
||||
if (debugName.hasValue)
|
||||
{
|
||||
if (vgfx->getEnabledOptionalInstanceExtensions().debugInfo)
|
||||
{
|
||||
@@ -210,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.c_str();
|
||||
nameInfo.pObjectName = debugName.value.c_str();
|
||||
vkSetDebugUtilsObjectNameEXT(device, &nameInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,6 @@ private:
|
||||
Slices slices;
|
||||
int layerCount = 0;
|
||||
VkSampleCountFlagBits msaaSamples = VK_SAMPLE_COUNT_1_BIT;
|
||||
std::string debugName;
|
||||
};
|
||||
|
||||
} // vulkan
|
||||
|
||||
@@ -413,6 +413,17 @@ static int w_Buffer_isBufferType(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
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
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg w_Buffer_functions[] =
|
||||
{
|
||||
{ "setArrayData", w_Buffer_setArrayData },
|
||||
@@ -422,6 +433,7 @@ static const luaL_Reg w_Buffer_functions[] =
|
||||
{ "getSize", w_Buffer_getSize },
|
||||
{ "getFormat", w_Buffer_getFormat },
|
||||
{ "isBufferType", w_Buffer_isBufferType },
|
||||
{ "getDebugName", w_Buffer_getDebugName },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -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 = luaL_checkstring(L, -1);
|
||||
s.debugName.set(luaL_checkstring(L, -1));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
|
||||
@@ -474,6 +474,17 @@ int w_Texture_renderTo(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg w_Texture_functions[] =
|
||||
{
|
||||
{ "getTextureType", w_Texture_getTextureType },
|
||||
@@ -506,6 +517,7 @@ const luaL_Reg w_Texture_functions[] =
|
||||
{ "generateMipmaps", w_Texture_generateMipmaps },
|
||||
{ "replacePixels", w_Texture_replacePixels },
|
||||
{ "renderTo", w_Texture_renderTo },
|
||||
{ "getDebugName", w_Texture_getDebugName },
|
||||
|
||||
// Deprecated
|
||||
{ "newImageData", w_Texture_newImageData },
|
||||
|
||||
Reference in New Issue
Block a user