add debugname to settings table for texture and buffer,
which can be used for debugging in e.g. RenderDoc.
This commit is contained in:
niki
2023-12-13 14:28:34 +01:00
parent 8951635abc
commit a5d7ba1589
14 changed files with 76 additions and 0 deletions
+3
View File
@@ -89,6 +89,7 @@ public:
BufferUsageFlags usageFlags;
BufferDataUsage dataUsage;
bool zeroInitialize;
std::string debugName;
Settings(uint32 usageflags, BufferDataUsage dataUsage)
: usageFlags((BufferUsageFlags)usageflags)
@@ -184,6 +185,8 @@ protected:
// Usage hint. GL_[DYNAMIC, STATIC, STREAM]_DRAW.
BufferDataUsage dataUsage;
std::string debugName;
bool mapped;
MapType mappedType;
bool immutable;
+1
View File
@@ -975,6 +975,7 @@ static StringMap<Texture::SettingType, Texture::SETTING_MAX_ENUM>::Entry setting
{ "canvas", Texture::SETTING_RENDER_TARGET },
{ "computewrite", Texture::SETTING_COMPUTE_WRITE },
{ "readable", Texture::SETTING_READABLE },
{ "debugname", Texture::SETTING_DEBUGNAME },
};
static StringMap<Texture::SettingType, Texture::SETTING_MAX_ENUM> settingTypes(settingTypeEntries, sizeof(settingTypeEntries));
+2
View File
@@ -175,6 +175,7 @@ public:
SETTING_RENDER_TARGET,
SETTING_COMPUTE_WRITE,
SETTING_READABLE,
SETTING_DEBUGNAME,
SETTING_MAX_ENUM
};
@@ -194,6 +195,7 @@ public:
bool renderTarget = false;
bool computeWrite = false;
OptionalBool readable;
std::string debugName;
};
struct Slices
+4
View File
@@ -68,6 +68,7 @@ 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();
@@ -164,6 +165,9 @@ bool Buffer::load(const void *initialdata)
glTexBuffer(target, glformat, buffer);
}
if (!debugName.empty())
glObjectLabel(GL_BUFFER, buffer, -1, debugName.c_str());
return (glGetError() == GL_NO_ERROR);
}
+2
View File
@@ -81,6 +81,8 @@ private:
Range mappedRange;
std::string debugName;
}; // Buffer
} // opengl
+9
View File
@@ -227,6 +227,7 @@ 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;
@@ -422,6 +423,14 @@ bool Texture::loadVolatile()
setGraphicsMemorySize(memsize);
if (!debugName.empty())
{
if (texture)
glObjectLabel(GL_TEXTURE, texture, -1, debugName.c_str());
else
glObjectLabel(GL_FRAMEBUFFER, renderbuffer, -1, debugName.c_str());
}
return true;
}
+2
View File
@@ -79,6 +79,8 @@ private:
int actualSamples;
std::string debugName;
}; // Texture
} // opengl
+13
View File
@@ -58,6 +58,7 @@ 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)
@@ -108,6 +109,18 @@ bool Buffer::loadVolatile()
else
coherent = false;
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_IMAGE;
nameInfo.objectHandle = (uint64_t)buffer;
nameInfo.pObjectName = debugName.c_str();
vkSetDebugUtilsObjectNameEXT(device, &nameInfo);
}
return true;
}
+1
View File
@@ -71,6 +71,7 @@ private:
BufferUsageFlags usageFlags;
Range mappedRange;
bool coherent;
std::string debugName;
};
} // vulkan
+9
View File
@@ -89,6 +89,8 @@ static void checkOptionalInstanceExtensions(OptionalInstanceExtensions& ext)
{
if (strcmp(extension.extensionName, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == 0)
ext.physicalDeviceProperties2 = true;
if (strcmp(extension.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0)
ext.debugInfo = true;
}
}
@@ -127,6 +129,8 @@ Graphics::Graphics()
if (optionalInstanceExtensions.physicalDeviceProperties2)
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
if (optionalInstanceExtensions.debugInfo)
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
size_t additional_extension_count = extensions.size();
extensions.resize(additional_extension_count + count);
@@ -1399,6 +1403,11 @@ const OptionalDeviceExtensions &Graphics::getEnabledOptionalDeviceExtensions() c
return optionalDeviceExtensions;
}
const OptionalInstanceExtensions& Graphics::getEnabledOptionalInstanceExtensions() const
{
return optionalInstanceExtensions;
}
bool Graphics::checkValidationSupport()
{
uint32_t layerCount;
+4
View File
@@ -144,6 +144,9 @@ struct OptionalInstanceExtensions
{
// VK_KHR_get_physical_device_properties2
bool physicalDeviceProperties2 = false;
// VK_EXT_debug_info
bool debugInfo = false;
};
struct OptionalDeviceExtensions
@@ -318,6 +321,7 @@ public:
void setComputeShader(Shader *computeShader);
graphics::Shader::BuiltinUniformData getCurrentBuiltinUniformData();
const OptionalDeviceExtensions &getEnabledOptionalDeviceExtensions() const;
const OptionalInstanceExtensions& getEnabledOptionalInstanceExtensions() const;
VkSampleCountFlagBits getMsaaCount(int requestedMsaa) const;
void setVsync(int vsync);
int getVsync() const;
+14
View File
@@ -34,6 +34,7 @@ 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)
{
@@ -201,6 +202,19 @@ bool Texture::loadVolatile()
setGraphicsMemorySize(memsize);
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.c_str();
vkSetDebugUtilsObjectNameEXT(device, &nameInfo);
}
}
return true;
}
+1
View File
@@ -85,6 +85,7 @@ private:
Slices slices;
int layerCount = 0;
VkSampleCountFlagBits msaaSamples = VK_SAMPLE_COUNT_1_BIT;
std::string debugName;
};
} // vulkan
+11
View File
@@ -738,6 +738,13 @@ static void luax_checktexturesettings(lua_State *L, int idx, bool opt, bool chec
if (!forceRenderTarget.hasValue)
s.renderTarget = luax_boolflag(L, idx, Texture::getConstant(Texture::SETTING_RENDER_TARGET), s.renderTarget);
lua_getfield(L, idx, Texture::getConstant(Texture::SETTING_DEBUGNAME));
if (!lua_isnoneornil(L, -1))
{
s.debugName = luaL_checkstring(L, -1);
}
lua_pop(L, 1);
lua_getfield(L, idx, Texture::getConstant(Texture::SETTING_FORMAT));
if (!lua_isnoneornil(L, -1))
{
@@ -1569,6 +1576,10 @@ static void luax_optbuffersettings(lua_State *L, int idx, Buffer::Settings &sett
lua_getfield(L, idx, "usage");
settings.dataUsage = luax_optdatausage(L, -1, settings.dataUsage);
lua_getfield(L, idx, "debugname");
settings.debugName = luax_checkstring(L, -1);
lua_pop(L, 1);
}