mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
implement #1992
add debugname to settings table for texture and buffer, which can be used for debugging in e.g. RenderDoc.
This commit is contained in:
@@ -89,6 +89,7 @@ public:
|
|||||||
BufferUsageFlags usageFlags;
|
BufferUsageFlags usageFlags;
|
||||||
BufferDataUsage dataUsage;
|
BufferDataUsage dataUsage;
|
||||||
bool zeroInitialize;
|
bool zeroInitialize;
|
||||||
|
std::string debugName;
|
||||||
|
|
||||||
Settings(uint32 usageflags, BufferDataUsage dataUsage)
|
Settings(uint32 usageflags, BufferDataUsage dataUsage)
|
||||||
: usageFlags((BufferUsageFlags)usageflags)
|
: usageFlags((BufferUsageFlags)usageflags)
|
||||||
@@ -184,6 +185,8 @@ protected:
|
|||||||
// Usage hint. GL_[DYNAMIC, STATIC, STREAM]_DRAW.
|
// Usage hint. GL_[DYNAMIC, STATIC, STREAM]_DRAW.
|
||||||
BufferDataUsage dataUsage;
|
BufferDataUsage dataUsage;
|
||||||
|
|
||||||
|
std::string debugName;
|
||||||
|
|
||||||
bool mapped;
|
bool mapped;
|
||||||
MapType mappedType;
|
MapType mappedType;
|
||||||
bool immutable;
|
bool immutable;
|
||||||
|
|||||||
@@ -975,6 +975,7 @@ static StringMap<Texture::SettingType, Texture::SETTING_MAX_ENUM>::Entry setting
|
|||||||
{ "canvas", Texture::SETTING_RENDER_TARGET },
|
{ "canvas", Texture::SETTING_RENDER_TARGET },
|
||||||
{ "computewrite", Texture::SETTING_COMPUTE_WRITE },
|
{ "computewrite", Texture::SETTING_COMPUTE_WRITE },
|
||||||
{ "readable", Texture::SETTING_READABLE },
|
{ "readable", Texture::SETTING_READABLE },
|
||||||
|
{ "debugname", Texture::SETTING_DEBUGNAME },
|
||||||
};
|
};
|
||||||
|
|
||||||
static StringMap<Texture::SettingType, Texture::SETTING_MAX_ENUM> settingTypes(settingTypeEntries, sizeof(settingTypeEntries));
|
static StringMap<Texture::SettingType, Texture::SETTING_MAX_ENUM> settingTypes(settingTypeEntries, sizeof(settingTypeEntries));
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ public:
|
|||||||
SETTING_RENDER_TARGET,
|
SETTING_RENDER_TARGET,
|
||||||
SETTING_COMPUTE_WRITE,
|
SETTING_COMPUTE_WRITE,
|
||||||
SETTING_READABLE,
|
SETTING_READABLE,
|
||||||
|
SETTING_DEBUGNAME,
|
||||||
SETTING_MAX_ENUM
|
SETTING_MAX_ENUM
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -194,6 +195,7 @@ public:
|
|||||||
bool renderTarget = false;
|
bool renderTarget = false;
|
||||||
bool computeWrite = false;
|
bool computeWrite = false;
|
||||||
OptionalBool readable;
|
OptionalBool readable;
|
||||||
|
std::string debugName;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Slices
|
struct Slices
|
||||||
|
|||||||
@@ -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)
|
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)
|
: love::graphics::Buffer(gfx, settings, format, size, arraylength)
|
||||||
|
, debugName(settings.debugName)
|
||||||
{
|
{
|
||||||
size = getSize();
|
size = getSize();
|
||||||
arraylength = getArrayLength();
|
arraylength = getArrayLength();
|
||||||
@@ -164,6 +165,9 @@ bool Buffer::load(const void *initialdata)
|
|||||||
glTexBuffer(target, glformat, buffer);
|
glTexBuffer(target, glformat, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!debugName.empty())
|
||||||
|
glObjectLabel(GL_BUFFER, buffer, -1, debugName.c_str());
|
||||||
|
|
||||||
return (glGetError() == GL_NO_ERROR);
|
return (glGetError() == GL_NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ private:
|
|||||||
|
|
||||||
Range mappedRange;
|
Range mappedRange;
|
||||||
|
|
||||||
|
std::string debugName;
|
||||||
|
|
||||||
}; // Buffer
|
}; // Buffer
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ Texture::Texture(love::graphics::Graphics *gfx, const Settings &settings, const
|
|||||||
, framebufferStatus(GL_FRAMEBUFFER_COMPLETE)
|
, framebufferStatus(GL_FRAMEBUFFER_COMPLETE)
|
||||||
, textureGLError(GL_NO_ERROR)
|
, textureGLError(GL_NO_ERROR)
|
||||||
, actualSamples(1)
|
, actualSamples(1)
|
||||||
|
, debugName(settings.debugName)
|
||||||
{
|
{
|
||||||
if (data != nullptr)
|
if (data != nullptr)
|
||||||
slices = *data;
|
slices = *data;
|
||||||
@@ -422,6 +423,14 @@ bool Texture::loadVolatile()
|
|||||||
|
|
||||||
setGraphicsMemorySize(memsize);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ private:
|
|||||||
|
|
||||||
int actualSamples;
|
int actualSamples;
|
||||||
|
|
||||||
|
std::string debugName;
|
||||||
|
|
||||||
}; // Texture
|
}; // Texture
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
|
|||||||
@@ -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)
|
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)
|
: love::graphics::Buffer(gfx, settings, format, size, arraylength)
|
||||||
, zeroInitialize(settings.zeroInitialize)
|
, zeroInitialize(settings.zeroInitialize)
|
||||||
|
, debugName(settings.debugName)
|
||||||
, initialData(data)
|
, initialData(data)
|
||||||
, vgfx(dynamic_cast<Graphics*>(gfx))
|
, vgfx(dynamic_cast<Graphics*>(gfx))
|
||||||
, usageFlags(settings.usageFlags)
|
, usageFlags(settings.usageFlags)
|
||||||
@@ -108,6 +109,18 @@ bool Buffer::loadVolatile()
|
|||||||
else
|
else
|
||||||
coherent = false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ private:
|
|||||||
BufferUsageFlags usageFlags;
|
BufferUsageFlags usageFlags;
|
||||||
Range mappedRange;
|
Range mappedRange;
|
||||||
bool coherent;
|
bool coherent;
|
||||||
|
std::string debugName;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // vulkan
|
} // vulkan
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ static void checkOptionalInstanceExtensions(OptionalInstanceExtensions& ext)
|
|||||||
{
|
{
|
||||||
if (strcmp(extension.extensionName, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == 0)
|
if (strcmp(extension.extensionName, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == 0)
|
||||||
ext.physicalDeviceProperties2 = true;
|
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)
|
if (optionalInstanceExtensions.physicalDeviceProperties2)
|
||||||
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
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();
|
size_t additional_extension_count = extensions.size();
|
||||||
extensions.resize(additional_extension_count + count);
|
extensions.resize(additional_extension_count + count);
|
||||||
@@ -1399,6 +1403,11 @@ const OptionalDeviceExtensions &Graphics::getEnabledOptionalDeviceExtensions() c
|
|||||||
return optionalDeviceExtensions;
|
return optionalDeviceExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const OptionalInstanceExtensions& Graphics::getEnabledOptionalInstanceExtensions() const
|
||||||
|
{
|
||||||
|
return optionalInstanceExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
bool Graphics::checkValidationSupport()
|
bool Graphics::checkValidationSupport()
|
||||||
{
|
{
|
||||||
uint32_t layerCount;
|
uint32_t layerCount;
|
||||||
|
|||||||
@@ -144,6 +144,9 @@ struct OptionalInstanceExtensions
|
|||||||
{
|
{
|
||||||
// VK_KHR_get_physical_device_properties2
|
// VK_KHR_get_physical_device_properties2
|
||||||
bool physicalDeviceProperties2 = false;
|
bool physicalDeviceProperties2 = false;
|
||||||
|
|
||||||
|
// VK_EXT_debug_info
|
||||||
|
bool debugInfo = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OptionalDeviceExtensions
|
struct OptionalDeviceExtensions
|
||||||
@@ -318,6 +321,7 @@ public:
|
|||||||
void setComputeShader(Shader *computeShader);
|
void setComputeShader(Shader *computeShader);
|
||||||
graphics::Shader::BuiltinUniformData getCurrentBuiltinUniformData();
|
graphics::Shader::BuiltinUniformData getCurrentBuiltinUniformData();
|
||||||
const OptionalDeviceExtensions &getEnabledOptionalDeviceExtensions() const;
|
const OptionalDeviceExtensions &getEnabledOptionalDeviceExtensions() const;
|
||||||
|
const OptionalInstanceExtensions& getEnabledOptionalInstanceExtensions() const;
|
||||||
VkSampleCountFlagBits getMsaaCount(int requestedMsaa) const;
|
VkSampleCountFlagBits getMsaaCount(int requestedMsaa) const;
|
||||||
void setVsync(int vsync);
|
void setVsync(int vsync);
|
||||||
int getVsync() const;
|
int getVsync() const;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace vulkan
|
|||||||
Texture::Texture(love::graphics::Graphics *gfx, const Settings &settings, const Slices *data)
|
Texture::Texture(love::graphics::Graphics *gfx, const Settings &settings, const Slices *data)
|
||||||
: love::graphics::Texture(gfx, settings, data)
|
: love::graphics::Texture(gfx, settings, data)
|
||||||
, vgfx(dynamic_cast<Graphics*>(gfx))
|
, vgfx(dynamic_cast<Graphics*>(gfx))
|
||||||
|
, debugName(settings.debugName)
|
||||||
, slices(settings.type)
|
, slices(settings.type)
|
||||||
, imageAspect(0)
|
, imageAspect(0)
|
||||||
{
|
{
|
||||||
@@ -201,6 +202,19 @@ bool Texture::loadVolatile()
|
|||||||
|
|
||||||
setGraphicsMemorySize(memsize);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ private:
|
|||||||
Slices slices;
|
Slices slices;
|
||||||
int layerCount = 0;
|
int layerCount = 0;
|
||||||
VkSampleCountFlagBits msaaSamples = VK_SAMPLE_COUNT_1_BIT;
|
VkSampleCountFlagBits msaaSamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
std::string debugName;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // vulkan
|
} // vulkan
|
||||||
|
|||||||
@@ -738,6 +738,13 @@ static void luax_checktexturesettings(lua_State *L, int idx, bool opt, bool chec
|
|||||||
if (!forceRenderTarget.hasValue)
|
if (!forceRenderTarget.hasValue)
|
||||||
s.renderTarget = luax_boolflag(L, idx, Texture::getConstant(Texture::SETTING_RENDER_TARGET), s.renderTarget);
|
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));
|
lua_getfield(L, idx, Texture::getConstant(Texture::SETTING_FORMAT));
|
||||||
if (!lua_isnoneornil(L, -1))
|
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");
|
lua_getfield(L, idx, "usage");
|
||||||
settings.dataUsage = luax_optdatausage(L, -1, settings.dataUsage);
|
settings.dataUsage = luax_optdatausage(L, -1, settings.dataUsage);
|
||||||
|
|
||||||
|
lua_getfield(L, idx, "debugname");
|
||||||
|
settings.debugName = luax_checkstring(L, -1);
|
||||||
|
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user