Skip to content

Commit d80d904

Browse files
bergeretCommit Bot
authored andcommitted
Reland "Add trace event to angle Program compilation API"
This reverts commit be04c04. Reason for revert: The appropriate fix for ASAN is landed here: https://chromium-review.googlesource.com/ c/angle/angle/+/2233410 Original change's description: > Revert "Add trace event to angle Program compilation API" > > This reverts commit 7685a79. > > Reason for revert: Causing TSAN failures, see issue. > > Bug: chromium:1091723 > > Original change's description: > > Add trace event to angle Program compilation API > > > > Bug: chromium:1064662 > > Change-Id: I2ee48718ff3946ab9307ba27177a02858bf436b0 > > Reviewed-on: https://chromium-review.googlesource.com/ c/angle/angle/+/2230789 > > Commit-Queue: Etienne Bergeron <[email protected]> > > Reviewed-by: Jamie Madill <[email protected]> > > [email protected],[email protected] > > Change-Id: I92148677ac53c1ff7a9bc880e0a0834a03fc92ea > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: chromium:1064662 > Reviewed-on: https://chromium-review.googlesource.com/ c/angle/angle/+/2231870 > Reviewed-by: Jamie Madill <[email protected]> > Commit-Queue: Jamie Madill <[email protected]> [email protected],[email protected] # Not skipping CQ checks because original CL landed > 1 day ago. Bug: chromium:1091723, chromium:1064662 Change-Id: I6e2ccfcb29fcddc5e0bffee43d3a737c8a6a75ea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2235915 Commit-Queue: Etienne Bergeron <[email protected]> Reviewed-by: Etienne Bergeron <[email protected]>
1 parent f56e722 commit d80d904

File tree

8 files changed

+44
-4
lines changed

8 files changed

+44
-4
lines changed

src/libANGLE/WorkerThread.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include "libANGLE/WorkerThread.h"
1212

13+
#include "libANGLE/trace.h"
14+
1315
#if (ANGLE_STD_ASYNC_WORKERS == ANGLE_ENABLED)
1416
# include <condition_variable>
1517
# include <future>
@@ -88,7 +90,7 @@ class AsyncWaitableEvent final : public WaitableEvent
8890
friend class AsyncWorkerPool;
8991
void setFuture(std::future<void> &&future);
9092

91-
// To block wait() when the task is stil in queue to be run.
93+
// To block wait() when the task is still in queue to be run.
9294
// Also to protect the concurrent accesses from both main thread and
9395
// background threads to the member fields.
9496
std::mutex mMutex;
@@ -105,6 +107,7 @@ void AsyncWaitableEvent::setFuture(std::future<void> &&future)
105107

106108
void AsyncWaitableEvent::wait()
107109
{
110+
ANGLE_TRACE_EVENT0("gpu.angle", "AsyncWaitableEvent::wait");
108111
{
109112
std::unique_lock<std::mutex> lock(mMutex);
110113
mCondition.wait(lock, [this] { return !mIsPending; });
@@ -186,7 +189,10 @@ void AsyncWorkerPool::checkToRunPendingTasks()
186189
auto closure = task.second;
187190

188191
auto future = std::async(std::launch::async, [closure, this] {
189-
(*closure)();
192+
{
193+
ANGLE_TRACE_EVENT0("gpu.angle", "AsyncWorkerPool::RunTask");
194+
(*closure)();
195+
}
190196
{
191197
std::lock_guard<std::mutex> lock(mMutex);
192198
ASSERT(mRunningThreads != 0);

src/libANGLE/renderer/ShaderImpl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "libANGLE/renderer/ShaderImpl.h"
1010

1111
#include "libANGLE/Context.h"
12+
#include "libANGLE/trace.h"
1213

1314
namespace rx
1415
{
@@ -46,6 +47,7 @@ class TranslateTask : public angle::Closure
4647

4748
void operator()() override
4849
{
50+
ANGLE_TRACE_EVENT1("gpu.angle", "TranslateTask::run", "source", mSource);
4951
const char *source = mSource.c_str();
5052
mResult = sh::Compile(mHandle, &source, 1, mOptions);
5153
}

src/libANGLE/renderer/d3d/HLSLCompiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ angle::Result HLSLCompiler::compileToBinary(d3d::Context *context,
236236
HRESULT result = S_OK;
237237

238238
{
239-
ANGLE_TRACE_EVENT0("gpu.angle", "D3DCompile");
239+
ANGLE_TRACE_EVENT1("gpu.angle", "D3DCompile", "source", hlsl);
240240
SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.D3DCompileMS");
241241
result = mD3DCompileFunc(hlsl.c_str(), hlsl.length(), gl::g_fakepath, macros, nullptr,
242242
"main", profile.c_str(), configs[i].flags, 0, &binary,
@@ -247,6 +247,7 @@ angle::Result HLSLCompiler::compileToBinary(d3d::Context *context,
247247
{
248248
std::string message = static_cast<const char *>(errorMessage->GetBufferPointer());
249249
SafeRelease(errorMessage);
250+
ANGLE_TRACE_EVENT1("gpu.angle", "D3DCompile::Error", "error", errorMessage);
250251

251252
infoLog.appendSanitized(message.c_str());
252253

src/libANGLE/renderer/d3d/ProgramD3D.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "libANGLE/renderer/d3d/ShaderExecutableD3D.h"
3030
#include "libANGLE/renderer/d3d/VertexDataManager.h"
3131
#include "libANGLE/renderer/renderer_utils.h"
32+
#include "libANGLE/trace.h"
3233

3334
using namespace angle;
3435

@@ -898,6 +899,7 @@ class ProgramD3D::LoadBinaryTask : public ProgramD3D::GetExecutableTask
898899

899900
angle::Result run() override
900901
{
902+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::LoadBinaryTask::run");
901903
if (!mDataCopySucceeded)
902904
{
903905
mInfoLog << "Failed to copy program binary data to local buffer.";
@@ -1685,6 +1687,7 @@ class ProgramD3D::GetVertexExecutableTask : public ProgramD3D::GetExecutableTask
16851687
GetVertexExecutableTask(ProgramD3D *program) : GetExecutableTask(program) {}
16861688
angle::Result run() override
16871689
{
1690+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::GetVertexExecutableTask::run");
16881691
if (!mProgram->mState.getAttachedShader(gl::ShaderType::Vertex))
16891692
{
16901693
return angle::Result::Continue;
@@ -1712,6 +1715,7 @@ class ProgramD3D::GetPixelExecutableTask : public ProgramD3D::GetExecutableTask
17121715
GetPixelExecutableTask(ProgramD3D *program) : GetExecutableTask(program) {}
17131716
angle::Result run() override
17141717
{
1718+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::GetPixelExecutableTask::run");
17151719
if (!mProgram->mState.getAttachedShader(gl::ShaderType::Fragment))
17161720
{
17171721
return angle::Result::Continue;
@@ -1747,6 +1751,7 @@ class ProgramD3D::GetGeometryExecutableTask : public ProgramD3D::GetExecutableTa
17471751

17481752
angle::Result run() override
17491753
{
1754+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::GetGeometryExecutableTask::run");
17501755
// Auto-generate the geometry shader here, if we expect to be using point rendering in
17511756
// D3D11.
17521757
if (mProgram->usesGeometryShader(mState, gl::PrimitiveMode::Points))
@@ -1768,6 +1773,7 @@ class ProgramD3D::GetComputeExecutableTask : public ProgramD3D::GetExecutableTas
17681773
GetComputeExecutableTask(ProgramD3D *program) : GetExecutableTask(program) {}
17691774
angle::Result run() override
17701775
{
1776+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::GetComputeExecutableTask::run");
17711777
mProgram->updateCachedImage2DBindLayoutFromComputeShader();
17721778
ShaderExecutableD3D *computeExecutable = nullptr;
17731779
ANGLE_TRY(mProgram->getComputeExecutableForImage2DBindLayout(this, &computeExecutable,
@@ -1806,6 +1812,7 @@ class ProgramD3D::GraphicsProgramLinkEvent final : public LinkEvent
18061812

18071813
angle::Result wait(const gl::Context *context) override
18081814
{
1815+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::GraphicsProgramLinkEvent::wait");
18091816
WaitableEvent::WaitMany(&mWaitEvents);
18101817

18111818
ANGLE_TRY(checkTask(context, mVertexTask.get()));
@@ -1906,6 +1913,7 @@ class ProgramD3D::ComputeProgramLinkEvent final : public LinkEvent
19061913

19071914
angle::Result wait(const gl::Context *context) override
19081915
{
1916+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::ComputeProgramLinkEvent::wait");
19091917
mWaitEvent->wait();
19101918

19111919
angle::Result result = mComputeTask->getResult();
@@ -1925,6 +1933,7 @@ class ProgramD3D::ComputeProgramLinkEvent final : public LinkEvent
19251933
std::unique_ptr<LinkEvent> ProgramD3D::compileProgramExecutables(const gl::Context *context,
19261934
gl::InfoLog &infoLog)
19271935
{
1936+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::compileProgramExecutables");
19281937
// Ensure the compiler is initialized to avoid race conditions.
19291938
angle::Result result = mRenderer->ensureHLSLCompilerInitialized(GetImplAs<ContextD3D>(context));
19301939
if (result != angle::Result::Continue)
@@ -1950,6 +1959,7 @@ std::unique_ptr<LinkEvent> ProgramD3D::compileProgramExecutables(const gl::Conte
19501959
std::unique_ptr<LinkEvent> ProgramD3D::compileComputeExecutable(const gl::Context *context,
19511960
gl::InfoLog &infoLog)
19521961
{
1962+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::compileComputeExecutable");
19531963
// Ensure the compiler is initialized to avoid race conditions.
19541964
angle::Result result = mRenderer->ensureHLSLCompilerInitialized(GetImplAs<ContextD3D>(context));
19551965
if (result != angle::Result::Continue)
@@ -1982,6 +1992,7 @@ angle::Result ProgramD3D::getComputeExecutableForImage2DBindLayout(
19821992
ShaderExecutableD3D **outExecutable,
19831993
gl::InfoLog *infoLog)
19841994
{
1995+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::getComputeExecutableForImage2DBindLayout");
19851996
if (mCachedComputeExecutableIndex.valid())
19861997
{
19871998
*outExecutable =
@@ -2023,6 +2034,7 @@ std::unique_ptr<LinkEvent> ProgramD3D::link(const gl::Context *context,
20232034
const gl::ProgramLinkedResources &resources,
20242035
gl::InfoLog &infoLog)
20252036
{
2037+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::link");
20262038
const auto &data = context->getState();
20272039

20282040
reset();

src/libANGLE/renderer/d3d/ShaderD3D.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "libANGLE/features.h"
1717
#include "libANGLE/renderer/d3d/ProgramD3D.h"
1818
#include "libANGLE/renderer/d3d/RendererD3D.h"
19+
#include "libANGLE/trace.h"
1920

2021
namespace rx
2122
{
@@ -36,6 +37,7 @@ class TranslateTaskD3D : public angle::Closure
3637

3738
void operator()() override
3839
{
40+
ANGLE_TRACE_EVENT1("gpu.angle", "TranslateTask::run", "source", mSource);
3941
std::vector<const char *> srcStrings;
4042
if (!mSourcePath.empty())
4143
{

src/libANGLE/renderer/gl/ProgramGL.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "libANGLE/renderer/gl/RendererGL.h"
2424
#include "libANGLE/renderer/gl/ShaderGL.h"
2525
#include "libANGLE/renderer/gl/StateManagerGL.h"
26+
#include "libANGLE/trace.h"
2627
#include "platform/FeaturesGL.h"
2728
#include "platform/PlatformMethods.h"
2829

@@ -59,6 +60,7 @@ std::unique_ptr<LinkEvent> ProgramGL::load(const gl::Context *context,
5960
gl::BinaryInputStream *stream,
6061
gl::InfoLog &infoLog)
6162
{
63+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramGL::load");
6264
preLink();
6365

6466
// Read the binary format, size and blob
@@ -135,7 +137,12 @@ class ProgramGL::LinkTask final : public angle::Closure
135137
LinkTask(LinkImplFunctor &&functor) : mLinkImplFunctor(functor), mFallbackToMainContext(false)
136138
{}
137139

138-
void operator()() override { mFallbackToMainContext = mLinkImplFunctor(mInfoLog); }
140+
void operator()() override
141+
{
142+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramGL::LinkTask::run");
143+
mFallbackToMainContext = mLinkImplFunctor(mInfoLog);
144+
}
145+
139146
bool fallbackToMainContext() { return mFallbackToMainContext; }
140147
const std::string &getInfoLog() { return mInfoLog; }
141148

@@ -159,6 +166,8 @@ class ProgramGL::LinkEventNativeParallel final : public LinkEvent
159166

160167
angle::Result wait(const gl::Context *context) override
161168
{
169+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramGL::LinkEventNativeParallel::wait");
170+
162171
GLint linkStatus = GL_FALSE;
163172
mFunctions->getProgramiv(mProgramID, GL_LINK_STATUS, &linkStatus);
164173
if (linkStatus == GL_TRUE)
@@ -196,6 +205,8 @@ class ProgramGL::LinkEventGL final : public LinkEvent
196205

197206
angle::Result wait(const gl::Context *context) override
198207
{
208+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramGL::LinkEventGL::wait");
209+
199210
mWaitableEvent->wait();
200211
return mPostLinkImplFunctor(mLinkTask->fallbackToMainContext(), mLinkTask->getInfoLog());
201212
}
@@ -212,6 +223,8 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context,
212223
const gl::ProgramLinkedResources &resources,
213224
gl::InfoLog &infoLog)
214225
{
226+
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramGL::link");
227+
215228
preLink();
216229

217230
if (mState.getAttachedShader(gl::ShaderType::Compute))

src/libANGLE/renderer/gl/ShaderGL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "libANGLE/Context.h"
1414
#include "libANGLE/renderer/gl/FunctionsGL.h"
1515
#include "libANGLE/renderer/gl/RendererGL.h"
16+
#include "libANGLE/trace.h"
1617
#include "platform/FeaturesGL.h"
1718

1819
#include <iostream>
@@ -38,6 +39,7 @@ class TranslateTaskGL : public angle::Closure
3839

3940
void operator()() override
4041
{
42+
ANGLE_TRACE_EVENT1("gpu.angle", "TranslateTaskGL::run", "source", mSource);
4143
const char *source = mSource.c_str();
4244
mResult = sh::Compile(mHandle, &source, 1, mOptions);
4345
if (mResult)

src/libANGLE/trace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@
2020
#define ANGLE_TRACE_EVENT_INSTANT0(CATEGORY, EVENT) \
2121
TRACE_EVENT_INSTANT0(ANGLEPlatformCurrent(), CATEGORY, EVENT)
2222
#define ANGLE_TRACE_EVENT0(CATEGORY, EVENT) TRACE_EVENT0(ANGLEPlatformCurrent(), CATEGORY, EVENT)
23+
#define ANGLE_TRACE_EVENT1(CATEGORY, EVENT, NAME, PARAM) \
24+
TRACE_EVENT1(ANGLEPlatformCurrent(), CATEGORY, EVENT, NAME, PARAM)
2325

2426
#endif // LIBANGLE_TRACE_H_

0 commit comments

Comments
 (0)