Hash :
c0d806b4
Author :
Date :
2025-02-10T23:01:33
CL: OpenCL support for ANGLE Capture/Replay Implementation of OpenCL Capture/Replay tool in ANGLE. Brief notes about the change: - Most meaningful changes for the capture process are made in src/libANGLE/capture/ - Most meaningful changes for replay are made in util/capture/ and src/tests/perf_tests/ - Many autogenerated files are changed/added to allow the capture of OpenCL objects & calls - The following applications were captured/replayed: benchmark_model, GeekBench Compute, GeekBench ML, AI-Benchmark, various OCL CTS tests - End2end test added to capture_tests. CapturedTestCL.MultiFrameCL/ES3_Vulkan Bug: angleproject:383841335 Change-Id: I55fdaa6cd6c7ba740aaa2351e4d29050059d6d1d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6102105 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
//
// Copyright 2022 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// frame_capture_utils.h:
// ANGLE Frame capture common classes.
//
#ifndef COMMON_FRAME_CAPTURE_UTILS_H_
#define COMMON_FRAME_CAPTURE_UTILS_H_
#include "common/frame_capture_utils_autogen.h"
#include "common/gl_enum_utils_autogen.h"
namespace angle
{
namespace
{
template <typename ParamValueType>
struct ParamValueTrait
{
static_assert(sizeof(ParamValueType) == 0, "invalid ParamValueType");
};
template <>
struct ParamValueTrait<gl::FramebufferID>
{
static constexpr const char *name = "framebufferPacked";
static const ParamType typeID = ParamType::TFramebufferID;
};
template <>
struct ParamValueTrait<gl::BufferID>
{
static constexpr const char *name = "bufferPacked";
static const ParamType typeID = ParamType::TBufferID;
};
template <>
struct ParamValueTrait<gl::RenderbufferID>
{
static constexpr const char *name = "renderbufferPacked";
static const ParamType typeID = ParamType::TRenderbufferID;
};
template <>
struct ParamValueTrait<gl::TextureID>
{
static constexpr const char *name = "texturePacked";
static const ParamType typeID = ParamType::TTextureID;
};
template <>
struct ParamValueTrait<gl::ShaderProgramID>
{
static constexpr const char *name = "programPacked";
static const ParamType typeID = ParamType::TShaderProgramID;
};
} // namespace
using ParamData = std::vector<std::vector<uint8_t>>;
struct ParamCapture : angle::NonCopyable
{
ParamCapture();
ParamCapture(const char *nameIn, ParamType typeIn);
~ParamCapture();
ParamCapture(ParamCapture &&other);
ParamCapture &operator=(ParamCapture &&other);
std::string name;
ParamType type;
ParamValue value;
gl::GLESEnum enumGroup; // only used for param type GLenum, GLboolean and GLbitfield
gl::BigGLEnum bigGLEnum; // only used for param type GLenum, GLboolean and GLbitfield
ParamData data;
int dataNElements = 0;
int arrayClientPointerIndex = -1;
size_t readBufferSizeBytes = 0;
uint32_t uniqueID = 0;
static uint32_t nextID;
};
using Captures = std::vector<ParamCapture>;
class ParamBuffer final : angle::NonCopyable
{
public:
ParamBuffer();
~ParamBuffer();
ParamBuffer(ParamBuffer &&other);
ParamBuffer &operator=(ParamBuffer &&other);
template <typename T>
void addValueParam(const char *paramName, ParamType paramType, T paramValue);
template <typename T>
void setValueParamAtIndex(const char *paramName, ParamType paramType, T paramValue, int index);
template <typename T>
void addEnumParam(const char *paramName,
gl::GLESEnum enumGroup,
ParamType paramType,
T paramValue);
template <typename T>
void addEnumParam(const char *paramName,
gl::BigGLEnum enumGroup,
ParamType paramType,
T paramValue);
template <typename T>
void addUnnamedParam(ParamType paramType, T paramValue);
ParamCapture &getParam(const char *paramName, ParamType paramType, int index);
const ParamCapture &getParam(const char *paramName, ParamType paramType, int index) const;
ParamCapture &getParamFlexName(const char *paramName1,
const char *paramName2,
ParamType paramType,
int index);
const ParamCapture &getParamFlexName(const char *paramName1,
const char *paramName2,
ParamType paramType,
int index) const;
const ParamCapture &getReturnValue() const { return mReturnValueCapture; }
void addParam(ParamCapture &¶m);
void addReturnValue(ParamCapture &&returnValue);
bool hasClientArrayData() const { return mClientArrayDataParam != -1; }
ParamCapture &getClientArrayPointerParameter();
size_t getReadBufferSize() const { return mReadBufferSize; }
bool empty() const { return mParamCaptures.empty(); }
const std::vector<ParamCapture> &getParamCaptures() const { return mParamCaptures; }
const char *getNextParamName();
private:
std::vector<ParamCapture> mParamCaptures;
ParamCapture mReturnValueCapture;
int mClientArrayDataParam = -1;
size_t mReadBufferSize = 0;
};
struct CallCapture
{
CallCapture(EntryPoint entryPointIn, ParamBuffer &¶msIn);
CallCapture(const std::string &customFunctionNameIn, ParamBuffer &¶msIn);
~CallCapture();
CallCapture(CallCapture &&other);
CallCapture &operator=(CallCapture &&other);
const char *name() const;
EntryPoint entryPoint;
std::string customFunctionName;
ParamBuffer params;
bool isActive = true;
gl::ContextID contextID;
bool isSyncPoint = false;
};
template <typename T>
void ParamBuffer::addValueParam(const char *paramName, ParamType paramType, T paramValue)
{
ParamCapture capture(paramName, paramType);
InitParamValue(paramType, paramValue, &capture.value);
mParamCaptures.emplace_back(std::move(capture));
}
template <typename T>
void ParamBuffer::setValueParamAtIndex(const char *paramName,
ParamType paramType,
T paramValue,
int index)
{
ASSERT(mParamCaptures.size() > static_cast<size_t>(index));
ParamCapture capture(paramName, paramType);
InitParamValue(paramType, paramValue, &capture.value);
mParamCaptures[index] = std::move(capture);
}
template <typename T>
void ParamBuffer::addEnumParam(const char *paramName,
gl::GLESEnum enumGroup,
ParamType paramType,
T paramValue)
{
ParamCapture capture(paramName, paramType);
InitParamValue(paramType, paramValue, &capture.value);
capture.enumGroup = enumGroup;
mParamCaptures.emplace_back(std::move(capture));
}
template <typename T>
void ParamBuffer::addEnumParam(const char *paramName,
gl::BigGLEnum enumGroup,
ParamType paramType,
T paramValue)
{
ParamCapture capture(paramName, paramType);
InitParamValue(paramType, paramValue, &capture.value);
capture.bigGLEnum = enumGroup;
mParamCaptures.emplace_back(std::move(capture));
}
template <typename T>
void ParamBuffer::addUnnamedParam(ParamType paramType, T paramValue)
{
addValueParam(getNextParamName(), paramType, paramValue);
}
template <ParamType ParamT, typename T>
void WriteParamValueReplay(std::ostream &os, const CallCapture &call, T value);
template <>
void WriteParamValueReplay<ParamType::TGLboolean>(std::ostream &os,
const CallCapture &call,
GLboolean value);
template <>
void WriteParamValueReplay<ParamType::TGLbooleanPointer>(std::ostream &os,
const CallCapture &call,
GLboolean *value);
template <>
void WriteParamValueReplay<ParamType::TvoidConstPointer>(std::ostream &os,
const CallCapture &call,
const void *value);
template <>
void WriteParamValueReplay<ParamType::TvoidPointer>(std::ostream &os,
const CallCapture &call,
void *value);
template <>
void WriteParamValueReplay<ParamType::TGLfloatConstPointer>(std::ostream &os,
const CallCapture &call,
const GLfloat *value);
template <>
void WriteParamValueReplay<ParamType::TGLintConstPointer>(std::ostream &os,
const CallCapture &call,
const GLint *value);
template <>
void WriteParamValueReplay<ParamType::TGLsizeiPointer>(std::ostream &os,
const CallCapture &call,
GLsizei *value);
template <>
void WriteParamValueReplay<ParamType::TGLuintPointer>(std::ostream &os,
const CallCapture &call,
GLuint *value);
template <>
void WriteParamValueReplay<ParamType::TGLuintConstPointer>(std::ostream &os,
const CallCapture &call,
const GLuint *value);
template <>
void WriteParamValueReplay<ParamType::TGLDEBUGPROCKHR>(std::ostream &os,
const CallCapture &call,
GLDEBUGPROCKHR value);
template <>
void WriteParamValueReplay<ParamType::TGLDEBUGPROC>(std::ostream &os,
const CallCapture &call,
GLDEBUGPROC value);
template <>
void WriteParamValueReplay<ParamType::TBufferID>(std::ostream &os,
const CallCapture &call,
gl::BufferID value);
template <>
void WriteParamValueReplay<ParamType::TFenceNVID>(std::ostream &os,
const CallCapture &call,
gl::FenceNVID value);
template <>
void WriteParamValueReplay<ParamType::TFramebufferID>(std::ostream &os,
const CallCapture &call,
gl::FramebufferID value);
template <>
void WriteParamValueReplay<ParamType::TMemoryObjectID>(std::ostream &os,
const CallCapture &call,
gl::MemoryObjectID value);
template <>
void WriteParamValueReplay<ParamType::TProgramPipelineID>(std::ostream &os,
const CallCapture &call,
gl::ProgramPipelineID value);
template <>
void WriteParamValueReplay<ParamType::TQueryID>(std::ostream &os,
const CallCapture &call,
gl::QueryID value);
template <>
void WriteParamValueReplay<ParamType::TRenderbufferID>(std::ostream &os,
const CallCapture &call,
gl::RenderbufferID value);
template <>
void WriteParamValueReplay<ParamType::TSamplerID>(std::ostream &os,
const CallCapture &call,
gl::SamplerID value);
template <>
void WriteParamValueReplay<ParamType::TSemaphoreID>(std::ostream &os,
const CallCapture &call,
gl::SemaphoreID value);
template <>
void WriteParamValueReplay<ParamType::TShaderProgramID>(std::ostream &os,
const CallCapture &call,
gl::ShaderProgramID value);
template <>
void WriteParamValueReplay<ParamType::TTextureID>(std::ostream &os,
const CallCapture &call,
gl::TextureID value);
template <>
void WriteParamValueReplay<ParamType::TTransformFeedbackID>(std::ostream &os,
const CallCapture &call,
gl::TransformFeedbackID value);
template <>
void WriteParamValueReplay<ParamType::TVertexArrayID>(std::ostream &os,
const CallCapture &call,
gl::VertexArrayID value);
template <>
void WriteParamValueReplay<ParamType::TUniformLocation>(std::ostream &os,
const CallCapture &call,
gl::UniformLocation value);
template <>
void WriteParamValueReplay<ParamType::TUniformBlockIndex>(std::ostream &os,
const CallCapture &call,
gl::UniformBlockIndex value);
template <>
void WriteParamValueReplay<ParamType::TSyncID>(std::ostream &os,
const CallCapture &call,
gl::SyncID value);
template <>
void WriteParamValueReplay<ParamType::TGLubyte>(std::ostream &os,
const CallCapture &call,
GLubyte value);
template <>
void WriteParamValueReplay<ParamType::TContextID>(std::ostream &os,
const CallCapture &call,
gl::ContextID value);
template <>
void WriteParamValueReplay<ParamType::Tegl_DisplayPointer>(std::ostream &os,
const CallCapture &call,
egl::Display *value);
template <>
void WriteParamValueReplay<ParamType::TImageID>(std::ostream &os,
const CallCapture &call,
egl::ImageID value);
template <>
void WriteParamValueReplay<ParamType::TSurfaceID>(std::ostream &os,
const CallCapture &call,
egl::SurfaceID value);
template <>
void WriteParamValueReplay<ParamType::TEGLDEBUGPROCKHR>(std::ostream &os,
const CallCapture &call,
EGLDEBUGPROCKHR value);
template <>
void WriteParamValueReplay<ParamType::TEGLGetBlobFuncANDROID>(std::ostream &os,
const CallCapture &call,
EGLGetBlobFuncANDROID value);
template <>
void WriteParamValueReplay<ParamType::TEGLSetBlobFuncANDROID>(std::ostream &os,
const CallCapture &call,
EGLSetBlobFuncANDROID value);
template <>
void WriteParamValueReplay<ParamType::TEGLClientBuffer>(std::ostream &os,
const CallCapture &call,
EGLClientBuffer value);
template <>
void WriteParamValueReplay<ParamType::TEGLAttribPointer>(std::ostream &os,
const CallCapture &call,
EGLAttrib *value);
template <>
void WriteParamValueReplay<ParamType::TEGLAttribConstPointer>(std::ostream &os,
const CallCapture &call,
const EGLAttrib *value);
template <>
void WriteParamValueReplay<ParamType::TEGLintPointer>(std::ostream &os,
const CallCapture &call,
EGLint *value);
template <>
void WriteParamValueReplay<ParamType::TEGLintConstPointer>(std::ostream &os,
const CallCapture &call,
const EGLint *value);
template <>
void WriteParamValueReplay<ParamType::Tegl_ConfigPointer>(std::ostream &os,
const CallCapture &call,
egl::Config *value);
template <>
void WriteParamValueReplay<ParamType::Tegl_SyncID>(std::ostream &os,
const CallCapture &call,
egl::SyncID value);
template <>
void WriteParamValueReplay<ParamType::TEGLTime>(std::ostream &os,
const CallCapture &call,
EGLTime value);
template <>
void WriteParamValueReplay<ParamType::TEGLTimeKHR>(std::ostream &os,
const CallCapture &call,
EGLTimeKHR value);
template <>
void WriteParamValueReplay<ParamType::TGLGETBLOBPROCANGLE>(std::ostream &os,
const CallCapture &call,
GLGETBLOBPROCANGLE value);
template <>
void WriteParamValueReplay<ParamType::TGLSETBLOBPROCANGLE>(std::ostream &os,
const CallCapture &call,
GLSETBLOBPROCANGLE value);
template <>
void WriteParamValueReplay<ParamType::TcharConstPointer>(std::ostream &os,
const CallCapture &call,
const char *value);
template <>
void WriteParamValueReplay<ParamType::Tsize_tPointer>(std::ostream &os,
const CallCapture &call,
size_t *value);
template <>
void WriteParamValueReplay<ParamType::Tsize_tConstPointer>(std::ostream &os,
const CallCapture &call,
size_t const *value);
template <>
void WriteParamValueReplay<ParamType::TcharConstPointerPointer>(std::ostream &os,
const CallCapture &call,
const char **value);
template <>
void WriteParamValueReplay<ParamType::TcharUnsignedConstPointerPointer>(
std::ostream &os,
const CallCapture &call,
const unsigned char **value);
#ifdef ANGLE_ENABLE_CL
template <>
void WriteParamValueReplay<ParamType::Tcl_platform_idPointer>(std::ostream &os,
const CallCapture &call,
cl_platform_id *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_uintPointer>(std::ostream &os,
const CallCapture &call,
cl_uint *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_device_idPointer>(std::ostream &os,
const CallCapture &call,
cl_device_id *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_context_propertiesConstPointer>(
std::ostream &os,
const CallCapture &call,
cl_context_properties const *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_eventPointer>(std::ostream &os,
const CallCapture &call,
cl_event *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_eventConstPointer>(std::ostream &os,
const CallCapture &call,
cl_event const *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_device_idConstPointer>(std::ostream &os,
const CallCapture &call,
cl_device_id const *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_image_formatPointer>(std::ostream &os,
const CallCapture &call,
cl_image_format *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_intPointer>(std::ostream &os,
const CallCapture &call,
cl_int *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_queue_propertiesConstPointer>(
std::ostream &os,
const CallCapture &call,
const cl_queue_properties *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_command_queue_propertiesPointer>(
std::ostream &os,
const CallCapture &call,
const cl_command_queue_properties *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_device_partition_propertyConstPointer>(
std::ostream &os,
const CallCapture &call,
const cl_device_partition_property *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_programConstPointer>(std::ostream &os,
const CallCapture &call,
const cl_program *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_pipe_propertiesConstPointer>(
std::ostream &os,
const CallCapture &call,
const cl_pipe_properties *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_ulongPointer>(std::ostream &os,
const CallCapture &call,
cl_ulong *value);
template <>
void WriteParamValueReplay<ParamType::Tcl_callback_func_type>(std::ostream &os,
const CallCapture &call,
cl_callback_func_type value);
template <>
void WriteParamValueReplay<ParamType::Tcl_context_destructor_func_type>(
std::ostream &os,
const CallCapture &call,
cl_context_destructor_func_type value);
template <>
void WriteParamValueReplay<ParamType::Tcl_context_func_type>(std::ostream &os,
const CallCapture &call,
cl_context_func_type value);
template <>
void WriteParamValueReplay<ParamType::Tcl_mem_destructor_func_type>(
std::ostream &os,
const CallCapture &call,
cl_mem_destructor_func_type value);
template <>
void WriteParamValueReplay<ParamType::Tcl_program_func_type>(std::ostream &os,
const CallCapture &call,
cl_program_func_type value);
template <>
void WriteParamValueReplay<ParamType::Tcl_svm_free_callback_func_type>(
std::ostream &os,
const CallCapture &call,
cl_svm_free_callback_func_type value);
template <>
void WriteParamValueReplay<ParamType::Tcl_void_func_type>(std::ostream &os,
const CallCapture &call,
cl_void_func_type value);
template <ParamType ParamT>
void WriteParamValueReplay(std::ostream &os, const CallCapture &call, cl::BitField value)
{
os << value.get();
}
#endif
// General fallback for any unspecific type.
template <ParamType ParamT, typename T>
void WriteParamValueReplay(std::ostream &os, const CallCapture &call, T value)
{
os << value;
}
struct FmtPointerIndex
{
FmtPointerIndex(const void *ptrIn) : ptr(ptrIn) {}
const void *ptr;
};
inline std::ostream &operator<<(std::ostream &os, const FmtPointerIndex &fmt)
{
os << reinterpret_cast<uintptr_t>(fmt.ptr) << "ul";
return os;
}
template <typename ParamValueType>
bool FindResourceIDsInCall(const CallCapture &call, std::vector<ParamValueType> &idsOut);
} // namespace angle
#endif // COMMON_FRAME_CAPTURE_UTILS_H_