Skip to content

Commit

Permalink
fix debug markers when implemented with systrace
Browse files Browse the repository at this point in the history
when debug markers are implemented with systrace, begin/end can is not
guaranteed to happen in the same C++ scope, so we can't really use 
other scoped systraces.
  • Loading branch information
pixelflinger committed Sep 5, 2024
1 parent 1b4afba commit 8c91b1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 8 additions & 2 deletions filament/backend/src/CommandStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@
#include <utils/CallStack.h>
#endif

#include <utils/compiler.h>
#include <utils/Log.h>
#include <utils/ostream.h>
#include <utils/Profiler.h>
#include <utils/Systrace.h>

#include <cstddef>
#include <functional>
#include <string>
#include <utility>

#ifdef __ANDROID__
#include <sys/system_properties.h>
Expand Down Expand Up @@ -74,8 +79,8 @@ CommandStream::CommandStream(Driver& driver, CircularBuffer& buffer) noexcept
}

void CommandStream::execute(void* buffer) {
SYSTRACE_CALL();
SYSTRACE_CONTEXT();
// NOTE: we can't use SYSTRACE_CALL() or similar here because, execute() below, also
// uses systrace BEGIN/END and the END is not guaranteed to be happening in this scope.

Profiler profiler;

Expand All @@ -100,6 +105,7 @@ void CommandStream::execute(void* buffer) {
// we want to remove all this when tracing is completely disabled
profiler.stop();
UTILS_UNUSED Profiler::Counters const counters = profiler.readCounters();
SYSTRACE_CONTEXT();
SYSTRACE_VALUE32("GLThread (I)", counters.getInstructions());
SYSTRACE_VALUE32("GLThread (C)", counters.getCpuCycles());
SYSTRACE_VALUE32("GLThread (CPI x10)", counters.getCPI() * 10);
Expand Down
5 changes: 1 addition & 4 deletions filament/src/fg/FrameGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,11 @@ FrameGraph& FrameGraph::compile() noexcept {

void FrameGraph::execute(backend::DriverApi& driver) noexcept {

SYSTRACE_CALL();

bool const useProtectedMemory = mMode == Mode::PROTECTED;
auto const& passNodes = mPassNodes;
auto& resourceAllocator = mResourceAllocator;

SYSTRACE_NAME("FrameGraph");
driver.pushGroupMarker("FrameGraph");

auto first = passNodes.begin();
Expand All @@ -211,7 +210,6 @@ void FrameGraph::execute(backend::DriverApi& driver) noexcept {
assert_invariant(!node->isCulled());

SYSTRACE_NAME(node->getName());

driver.pushGroupMarker(node->getName());

// devirtualize resourcesList
Expand All @@ -229,7 +227,6 @@ void FrameGraph::execute(backend::DriverApi& driver) noexcept {
assert_invariant(resource->last == node);
resource->destroy(resourceAllocator);
}

driver.popGroupMarker();
}
driver.popGroupMarker();
Expand Down

0 comments on commit 8c91b1b

Please sign in to comment.