• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2025 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // trace_fixture_cl.h:
7 //   OpenCL-specific code for the ANGLE trace replays.
8 //
9 
10 #ifndef ANGLE_TRACE_FIXTURE_CL_H_
11 #define ANGLE_TRACE_FIXTURE_CL_H_
12 
13 #include <CL/cl.h>
14 
15 #include <EGL/egl.h>
16 #include <EGL/eglext.h>
17 #include <math.h>
18 #include <stddef.h>
19 #include <stdint.h>
20 
21 #include "trace_interface.h"
22 #include "traces_export.h"
23 
24 #include "trace_egl_loader_autogen.h"
25 #include "trace_gles_loader_autogen.h"
26 
27 #if defined(__cplusplus)
28 #    include <cstdio>
29 #    include <cstring>
30 #    include <limits>
31 #    include <unordered_map>
32 #    include <vector>
33 
34 extern "C" {
35 
36 // Functions implemented by traces.
37 // "not exported" tag is a hack to get around trace interpreter codegen -_-
38 /* not exported */ void SetupReplay();
39 /* not exported */ void ReplayFrame(uint32_t frameIndex);
40 /* not exported */ void ResetReplay();
41 /* not exported */ void FinishReplay();
42 /* not exported */ void SetupFirstFrame();
43 
44 ANGLE_REPLAY_EXPORT void SetupEntryPoints(angle::TraceCallbacks *traceCallbacks,
45                                           angle::TraceFunctions **traceFunctions);
46 #endif  // defined(__cplusplus)
47 
48 extern uint8_t *gBinaryData;
49 extern uint8_t *gReadBuffer;
50 
51 extern cl_platform_id *clPlatformsMap;
52 extern cl_device_id *clDevicesMap;
53 extern cl_context *clContextsMap;
54 extern cl_command_queue *clCommandQueuesMap;
55 extern cl_mem *clMemMap;
56 extern cl_event *clEventsMap;
57 extern cl_program *clProgramsMap;
58 extern cl_kernel *clKernelsMap;
59 extern cl_sampler *clSamplerMap;
60 extern void **clVoidMap;
61 
62 extern std::vector<cl_platform_id> temporaryPlatformsList;
63 extern std::vector<cl_device_id> temporaryDevicesList;
64 extern std::vector<cl_kernel> temporaryKernelsList;
65 extern std::vector<cl_mem> temporaryBuffersList;
66 extern std::vector<cl_program> temporaryProgramsList;
67 extern std::vector<cl_event> temporaryEventsList;
68 extern cl_image_desc temporaryImageDesc;
69 extern std::vector<cl_context_properties> temporaryContextProps;
70 extern std::vector<const char *> temporaryCharPointerList;
71 extern std::vector<const void *> temporaryVoidPtrList;
72 extern std::vector<const unsigned char *> temporaryUnsignedCharPointerList;
73 extern void *temporaryVoidPtr;
74 
75 void InitializeReplayCL(const char *binaryDataFileName,
76                         size_t maxClientArraySize,
77                         size_t readBufferSize,
78                         uint32_t maxCLPlatform,
79                         uint32_t maxCLDevices,
80                         uint32_t maxCLContexts,
81                         uint32_t maxCLCommandQueues,
82                         uint32_t maxCLMem,
83                         uint32_t maxCLEvents,
84                         uint32_t maxCLPrograms,
85                         uint32_t maxCLKernels,
86                         uint32_t maxCLSamplers,
87                         uint32_t maxCLVoidPointer);
88 
89 void UpdateCLContextPropertiesNoPlatform(size_t propSize, const cl_context_properties *propData);
90 void UpdateCLContextPropertiesWithPlatform(size_t propSize,
91                                            const cl_context_properties *propData,
92                                            size_t platformIdxInProps,
93                                            size_t platformIdxInMap);
94 
95 #if defined(__cplusplus)
96 }       // extern "C"
97 #endif  // defined(__cplusplus)
98 
99 #endif  // ANGLE_TRACE_FIXTURE_CL_H_
100