Skip to content

Commit

Permalink
Convert the debug markers from string to char*
Browse files Browse the repository at this point in the history
Summary: ^

Differential Revision: D50457950

fbshipit-source-id: c75ded79894e733292e7af3f9fb804f64d091cbb
  • Loading branch information
francoiscoulombe authored and facebook-github-bot committed Oct 25, 2023
1 parent abedd0f commit 1a1f1ce
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 75 deletions.
3 changes: 1 addition & 2 deletions IGLU/sentinel/CommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ void CommandBuffer::waitUntilCompleted() {
IGLU_SENTINEL_ASSERT_IF_NOT(shouldAssert_);
}

void CommandBuffer::pushDebugGroupLabel(const std::string& /*label*/,
const igl::Color& /*color*/) const {
void CommandBuffer::pushDebugGroupLabel(const char* /*label*/, const igl::Color& /*color*/) const {
IGLU_SENTINEL_ASSERT_IF_NOT(shouldAssert_);
}

Expand Down
2 changes: 1 addition & 1 deletion IGLU/sentinel/CommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CommandBuffer final : public igl::ICommandBuffer {
void present(std::shared_ptr<igl::ITexture> /*surface*/) const final;
void waitUntilScheduled() final;
void waitUntilCompleted() final;
void pushDebugGroupLabel(const std::string& /*label*/,
void pushDebugGroupLabel(const char* /*label*/,
const igl::Color& /*color*/ = igl::Color(1, 1, 1, 1)) const final;
void popDebugGroupLabel() const final;

Expand Down
2 changes: 1 addition & 1 deletion src/igl/CommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ICommandBuffer {
* When all commands for this label have been sent to the encoder, call popDebugGroupLabel()
* to pop the label off the stack.
*/
virtual void pushDebugGroupLabel(const std::string& label,
virtual void pushDebugGroupLabel(const char* IGL_NONNULL label,
const igl::Color& color = igl::Color(1, 1, 1, 1)) const = 0;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/igl/CommandEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ICommandEncoder {
* When all commands for this label have been sent to the encoder, call popDebugGroupLabel()
* to pop the label off the stack.
*/
virtual void pushDebugGroupLabel(const std::string& label,
virtual void pushDebugGroupLabel(const char* IGL_NONNULL label,
const igl::Color& color = igl::Color(1, 1, 1, 1)) const = 0;

/**
Expand All @@ -46,7 +46,7 @@ class ICommandEncoder {
* If supported by the backend GPU driver, this allows you to easily insert a label into the
* call stack of the captured frame data.
*/
virtual void insertDebugEventLabel(const std::string& label,
virtual void insertDebugEventLabel(const char* IGL_NONNULL label,
const igl::Color& color = igl::Color(1, 1, 1, 1)) const = 0;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/igl/metal/CommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CommandBuffer final : public ICommandBuffer,

void present(std::shared_ptr<ITexture> surface) const override;

void pushDebugGroupLabel(const std::string& label, const igl::Color& color) const override;
void pushDebugGroupLabel(const char* label, const igl::Color& color) const override;

void popDebugGroupLabel() const override;

Expand Down
7 changes: 3 additions & 4 deletions src/igl/metal/CommandBuffer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@
}
}

void CommandBuffer::pushDebugGroupLabel(const std::string& label,
const igl::Color& /*color*/) const {
IGL_ASSERT(!label.empty());
[value_ pushDebugGroup:[NSString stringWithUTF8String:label.c_str()] ?: @""];
void CommandBuffer::pushDebugGroupLabel(const char* label, const igl::Color& /*color*/) const {
IGL_ASSERT(label != nullptr);
[value_ pushDebugGroup:[NSString stringWithUTF8String:label] ?: @""];
}

void CommandBuffer::popDebugGroupLabel() const {
Expand Down
4 changes: 2 additions & 2 deletions src/igl/metal/ComputeCommandEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class ComputeCommandEncoder final : public IComputeCommandEncoder {
// total number of threads per grid is threadgroupCount * threadgroupSize
void dispatchThreadGroups(const Dimensions& threadgroupCount,
const Dimensions& threadgroupSize) override;
void pushDebugGroupLabel(const std::string& label, const igl::Color& color) const override;
void insertDebugEventLabel(const std::string& label, const igl::Color& color) const override;
void pushDebugGroupLabel(const char* label, const igl::Color& color) const override;
void insertDebugEventLabel(const char* label, const igl::Color& color) const override;
void popDebugGroupLabel() const override;
void bindUniform(const UniformDesc& uniformDesc, const void* data) override;
void bindTexture(size_t index, ITexture* texture) override;
Expand Down
12 changes: 6 additions & 6 deletions src/igl/metal/ComputeCommandEncoder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@
encoder_ = nil;
}

void ComputeCommandEncoder::pushDebugGroupLabel(const std::string& label,
void ComputeCommandEncoder::pushDebugGroupLabel(const char* label,
const igl::Color& /*color*/) const {
IGL_ASSERT(encoder_);
IGL_ASSERT(!label.empty());
[encoder_ pushDebugGroup:[NSString stringWithUTF8String:label.c_str()] ?: @""];
IGL_ASSERT(label != nullptr);
[encoder_ pushDebugGroup:[NSString stringWithUTF8String:label] ?: @""];
}

void ComputeCommandEncoder::insertDebugEventLabel(const std::string& label,
void ComputeCommandEncoder::insertDebugEventLabel(const char* label,
const igl::Color& /*color*/) const {
IGL_ASSERT(encoder_);
IGL_ASSERT(!label.empty());
[encoder_ insertDebugSignpost:[NSString stringWithUTF8String:label.c_str()] ?: @""];
IGL_ASSERT(label != nullptr);
[encoder_ insertDebugSignpost:[NSString stringWithUTF8String:label] ?: @""];
}

void ComputeCommandEncoder::popDebugGroupLabel() const {
Expand Down
4 changes: 2 additions & 2 deletions src/igl/metal/RenderCommandEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class RenderCommandEncoder final : public IRenderCommandEncoder {

void endEncoding() override;

void pushDebugGroupLabel(const std::string& label, const igl::Color& color) const override;
void insertDebugEventLabel(const std::string& label, const igl::Color& color) const override;
void pushDebugGroupLabel(const char* label, const igl::Color& color) const override;
void insertDebugEventLabel(const char* label, const igl::Color& color) const override;
void popDebugGroupLabel() const override;

void bindViewport(const Viewport& viewport) override;
Expand Down
12 changes: 6 additions & 6 deletions src/igl/metal/RenderCommandEncoder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@
encoder_ = nil;
}

void RenderCommandEncoder::pushDebugGroupLabel(const std::string& label,
void RenderCommandEncoder::pushDebugGroupLabel(const char* label,
const igl::Color& /*color*/) const {
IGL_ASSERT(encoder_);
IGL_ASSERT(!label.empty());
[encoder_ pushDebugGroup:[NSString stringWithUTF8String:label.c_str()] ?: @""];
IGL_ASSERT(label != nullptr);
[encoder_ pushDebugGroup:[NSString stringWithUTF8String:label] ?: @""];
}

void RenderCommandEncoder::insertDebugEventLabel(const std::string& label,
void RenderCommandEncoder::insertDebugEventLabel(const char* label,
const igl::Color& /*color*/) const {
IGL_ASSERT(encoder_);
IGL_ASSERT(!label.empty());
[encoder_ insertDebugSignpost:[NSString stringWithUTF8String:label.c_str()] ?: @""];
IGL_ASSERT(label != nullptr);
[encoder_ insertDebugSignpost:[NSString stringWithUTF8String:label] ?: @""];
}

void RenderCommandEncoder::popDebugGroupLabel() const {
Expand Down
8 changes: 4 additions & 4 deletions src/igl/opengl/CommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ void CommandBuffer::waitUntilCompleted() {
context_->finish();
}

void CommandBuffer::pushDebugGroupLabel(const std::string& label,
const igl::Color& /*color*/) const {
IGL_ASSERT(!label.empty());
void CommandBuffer::pushDebugGroupLabel(const char* label, const igl::Color& /*color*/) const {
IGL_ASSERT(label != nullptr);
if (getContext().deviceFeatures().hasInternalFeature(InternalFeatures::DebugMessage)) {
getContext().pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, label.length(), label.c_str());
std::string_view labelSV(label);
getContext().pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, labelSV.length(), labelSV.data());
} else {
IGL_LOG_ERROR_ONCE("CommandBuffer::pushDebugGroupLabel not supported in this context!\n");
}
Expand Down
2 changes: 1 addition & 1 deletion src/igl/opengl/CommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CommandBuffer final : public ICommandBuffer,

void waitUntilCompleted() override;

void pushDebugGroupLabel(const std::string& label, const igl::Color& color) const override;
void pushDebugGroupLabel(const char* label, const igl::Color& color) const override;

void popDebugGroupLabel() const override;

Expand Down
16 changes: 9 additions & 7 deletions src/igl/opengl/ComputeCommandEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,29 @@ void ComputeCommandEncoder::dispatchThreadGroups(const Dimensions& threadgroupCo
}
}

void ComputeCommandEncoder::pushDebugGroupLabel(const std::string& label,
void ComputeCommandEncoder::pushDebugGroupLabel(const char* label,
const igl::Color& /*color*/) const {
IGL_ASSERT(!label.empty());
IGL_ASSERT(label != nullptr);
if (getContext().deviceFeatures().hasInternalFeature(InternalFeatures::DebugMessage)) {
getContext().pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, label.length(), label.c_str());
std::string_view labelSV(label);
getContext().pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, labelSV.length(), labelSV.data());
} else {
IGL_LOG_ERROR_ONCE(
"ComputeCommandEncoder::pushDebugGroupLabel not supported in this context!\n");
}
}

void ComputeCommandEncoder::insertDebugEventLabel(const std::string& label,
void ComputeCommandEncoder::insertDebugEventLabel(const char* label,
const igl::Color& /*color*/) const {
IGL_ASSERT(!label.empty());
IGL_ASSERT(label != nullptr);
if (getContext().deviceFeatures().hasInternalFeature(InternalFeatures::DebugMessage)) {
std::string_view labelSV(label);
getContext().debugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_MARKER,
0,
GL_DEBUG_SEVERITY_LOW,
label.length(),
label.c_str());
labelSV.length(),
labelSV.data());
} else {
IGL_LOG_ERROR_ONCE(
"ComputeCommandEncoder::insertDebugEventLabel not supported in this context!\n");
Expand Down
4 changes: 2 additions & 2 deletions src/igl/opengl/ComputeCommandEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class ComputeCommandEncoder final : public IComputeCommandEncoder, public WithCo
const Dimensions& threadgroupSize) override;
void endEncoding() override;

void pushDebugGroupLabel(const std::string& label, const igl::Color& color) const override;
void insertDebugEventLabel(const std::string& label, const igl::Color& color) const override;
void pushDebugGroupLabel(const char* label, const igl::Color& color) const override;
void insertDebugEventLabel(const char* label, const igl::Color& color) const override;
void popDebugGroupLabel() const override;
void bindUniform(const UniformDesc& uniformDesc, const void* data) override;
void bindTexture(size_t index, ITexture* texture) override;
Expand Down
17 changes: 9 additions & 8 deletions src/igl/opengl/RenderCommandEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,30 +154,31 @@ void RenderCommandEncoder::endEncoding() {
}
}

void RenderCommandEncoder::pushDebugGroupLabel(const std::string& label,
void RenderCommandEncoder::pushDebugGroupLabel(const char* label,
const igl::Color& /*color*/) const {
IGL_ASSERT(adapter_);
IGL_ASSERT(!label.empty());

IGL_ASSERT(label != nullptr);
if (getContext().deviceFeatures().hasInternalFeature(InternalFeatures::DebugMessage)) {
getContext().pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, label.length(), label.c_str());
std::string_view labelSV(label);
getContext().pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, labelSV.length(), labelSV.data());
} else {
IGL_LOG_ERROR_ONCE(
"RenderCommandEncoder::pushDebugGroupLabel not supported in this context!\n");
}
}

void RenderCommandEncoder::insertDebugEventLabel(const std::string& label,
void RenderCommandEncoder::insertDebugEventLabel(const char* label,
const igl::Color& /*color*/) const {
IGL_ASSERT(adapter_);
IGL_ASSERT(!label.empty());
IGL_ASSERT(label != nullptr);
if (getContext().deviceFeatures().hasInternalFeature(InternalFeatures::DebugMessage)) {
std::string_view labelSV(label);
getContext().debugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_MARKER,
0,
GL_DEBUG_SEVERITY_LOW,
label.length(),
label.c_str());
labelSV.length(),
labelSV.data());
} else {
IGL_LOG_ERROR_ONCE(
"RenderCommandEncoder::insertDebugEventLabel not supported in this context!\n");
Expand Down
4 changes: 2 additions & 2 deletions src/igl/opengl/RenderCommandEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class RenderCommandEncoder final : public IRenderCommandEncoder, public WithCont
public:
void endEncoding() override;

void pushDebugGroupLabel(const std::string& label, const igl::Color& color) const override;
void insertDebugEventLabel(const std::string& label, const igl::Color& color) const override;
void pushDebugGroupLabel(const char* label, const igl::Color& color) const override;
void insertDebugEventLabel(const char* label, const igl::Color& color) const override;
void popDebugGroupLabel() const override;

void bindViewport(const Viewport& viewport) override;
Expand Down
4 changes: 2 additions & 2 deletions src/igl/tests/metal/RenderCommandEncoder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ void TearDown() override {}
auto encoder = commandBuffer_->createRenderCommandEncoder(rpDesc, framebuffer);
ASSERT_TRUE(encoder != nullptr);

encoder->pushDebugGroupLabel(label_);
encoder->pushDebugGroupLabel(label_.c_str());

encoder->insertDebugEventLabel(label_);
encoder->insertDebugEventLabel(label_.c_str());

encoder->popDebugGroupLabel();

Expand Down
5 changes: 3 additions & 2 deletions src/igl/vulkan/CommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ void CommandBuffer::present(std::shared_ptr<ITexture> surface) const {
}
}

void CommandBuffer::pushDebugGroupLabel(const std::string& label, const igl::Color& color) const {
ivkCmdBeginDebugUtilsLabel(&ctx_.vf_, wrapper_.cmdBuf_, label.c_str(), color.toFloatPtr());
void CommandBuffer::pushDebugGroupLabel(const char* label, const igl::Color& color) const {
IGL_ASSERT(label != nullptr);
ivkCmdBeginDebugUtilsLabel(&ctx_.vf_, wrapper_.cmdBuf_, label, color.toFloatPtr());
}

void CommandBuffer::popDebugGroupLabel() const {
Expand Down
2 changes: 1 addition & 1 deletion src/igl/vulkan/CommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CommandBuffer final : public ICommandBuffer,

void present(std::shared_ptr<ITexture> surface) const override;

void pushDebugGroupLabel(const std::string& label, const igl::Color& color) const override;
void pushDebugGroupLabel(const char* label, const igl::Color& color) const override;

void popDebugGroupLabel() const override;

Expand Down
15 changes: 6 additions & 9 deletions src/igl/vulkan/ComputeCommandEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,15 @@ void ComputeCommandEncoder::dispatchThreadGroups(const Dimensions& threadgroupCo
cmdBuffer_, threadgroupCount.width, threadgroupCount.height, threadgroupCount.depth);
}

void ComputeCommandEncoder::pushDebugGroupLabel(const std::string& label,
const igl::Color& color) const {
IGL_ASSERT(!label.empty());

ivkCmdBeginDebugUtilsLabel(&ctx_.vf_, cmdBuffer_, label.c_str(), color.toFloatPtr());
void ComputeCommandEncoder::pushDebugGroupLabel(const char* label, const igl::Color& color) const {
IGL_ASSERT(label != nullptr);
ivkCmdBeginDebugUtilsLabel(&ctx_.vf_, cmdBuffer_, label, color.toFloatPtr());
}

void ComputeCommandEncoder::insertDebugEventLabel(const std::string& label,
void ComputeCommandEncoder::insertDebugEventLabel(const char* label,
const igl::Color& color) const {
IGL_ASSERT(!label.empty());

ivkCmdInsertDebugUtilsLabel(&ctx_.vf_, cmdBuffer_, label.c_str(), color.toFloatPtr());
IGL_ASSERT(label != nullptr);
ivkCmdInsertDebugUtilsLabel(&ctx_.vf_, cmdBuffer_, label, color.toFloatPtr());
}

void ComputeCommandEncoder::popDebugGroupLabel() const {
Expand Down
4 changes: 2 additions & 2 deletions src/igl/vulkan/ComputeCommandEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class ComputeCommandEncoder : public IComputeCommandEncoder {
const Dimensions& threadgroupSize) override;
void endEncoding() override;

void pushDebugGroupLabel(const std::string& label, const igl::Color& color) const override;
void insertDebugEventLabel(const std::string& label, const igl::Color& color) const override;
void pushDebugGroupLabel(const char* label, const igl::Color& color) const override;
void insertDebugEventLabel(const char* label, const igl::Color& color) const override;
void popDebugGroupLabel() const override;
void bindUniform(const UniformDesc& uniformDesc, const void* data) override;
void bindTexture(size_t index, ITexture* texture) override;
Expand Down
12 changes: 6 additions & 6 deletions src/igl/vulkan/RenderCommandEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,14 @@ void RenderCommandEncoder::endEncoding() {
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
}

void RenderCommandEncoder::pushDebugGroupLabel(const std::string& label,
const igl::Color& color) const {
ivkCmdBeginDebugUtilsLabel(&ctx_.vf_, cmdBuffer_, label.c_str(), color.toFloatPtr());
void RenderCommandEncoder::pushDebugGroupLabel(const char* label, const igl::Color& color) const {
IGL_ASSERT(label != nullptr);
ivkCmdBeginDebugUtilsLabel(&ctx_.vf_, cmdBuffer_, label, color.toFloatPtr());
}

void RenderCommandEncoder::insertDebugEventLabel(const std::string& label,
const igl::Color& color) const {
ivkCmdInsertDebugUtilsLabel(&ctx_.vf_, cmdBuffer_, label.c_str(), color.toFloatPtr());
void RenderCommandEncoder::insertDebugEventLabel(const char* label, const igl::Color& color) const {
IGL_ASSERT(label != nullptr);
ivkCmdInsertDebugUtilsLabel(&ctx_.vf_, cmdBuffer_, label, color.toFloatPtr());
}

void RenderCommandEncoder::popDebugGroupLabel() const {
Expand Down
4 changes: 2 additions & 2 deletions src/igl/vulkan/RenderCommandEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class RenderCommandEncoder : public IRenderCommandEncoder {

void endEncoding() override;

void pushDebugGroupLabel(const std::string& label, const igl::Color& color) const override;
void insertDebugEventLabel(const std::string& label, const igl::Color& color) const override;
void pushDebugGroupLabel(const char* label, const igl::Color& color) const override;
void insertDebugEventLabel(const char* label, const igl::Color& color) const override;
void popDebugGroupLabel() const override;

void bindViewport(const Viewport& viewport) override;
Expand Down

0 comments on commit 1a1f1ce

Please sign in to comment.