Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
GPUTarget Struct Reference
Inheritance diagram for GPUTarget:
Target

Public Member Functions

 GPUTarget (const Config &c)
 
 ~GPUTarget () override
 
void onSetup () override
 
void endTiming () override
 
void submitWorkAndSyncCPU () override
 
bool needsFrameTiming (int *maxFrameLag) const override
 
bool init (SkImageInfo info, Benchmark *bench) override
 
void dumpStats () override
 
- Public Member Functions inherited from Target
 Target (const Config &c)
 
virtual ~Target ()
 
void setup ()
 
virtual SkCanvasbeginTiming (SkCanvas *canvas)
 
virtual bool capturePixels (SkBitmap *bmp)
 
SkCanvasgetCanvas () const
 

Public Attributes

ContextInfo contextInfo
 
std::unique_ptr< GrContextFactoryfactory
 
- Public Attributes inherited from Target
const Config config
 
sk_sp< SkSurfacesurface
 

Detailed Description

Definition at line 244 of file nanobench.cpp.

Constructor & Destructor Documentation

◆ GPUTarget()

GPUTarget::GPUTarget ( const Config c)
inlineexplicit

Definition at line 245 of file nanobench.cpp.

245: Target(c) {}

◆ ~GPUTarget()

GPUTarget::~GPUTarget ( )
inlineoverride

Definition at line 249 of file nanobench.cpp.

249 {
250 // For Vulkan we need to release all our refs to the GrContext before destroy the vulkan
251 // context which happens at the end of this destructor. Thus we need to release the surface
252 // here which holds a ref to the GrContext.
253 surface.reset();
254 }
void reset(T *ptr=nullptr)
Definition SkRefCnt.h:310
sk_sp< SkSurface > surface
Definition nanobench.h:41

Member Function Documentation

◆ dumpStats()

void GPUTarget::dumpStats ( )
inlineoverridevirtual

Writes gathered stats using SkDebugf.

Reimplemented from Target.

Definition at line 300 of file nanobench.cpp.

300 {
301 auto context = this->contextInfo.directContext();
302
303 context->priv().printCacheStats();
304 context->priv().printGpuStats();
305 context->priv().printContextStats();
306 }
GrDirectContextPriv priv()
GrDirectContext * directContext() const
ContextInfo contextInfo

◆ endTiming()

void GPUTarget::endTiming ( )
inlineoverridevirtual

Called after a benchmark is drawn, but before the clock timer is stopped.

Reimplemented from Target.

Definition at line 259 of file nanobench.cpp.

259 {
260 if (this->contextInfo.testContext()) {
262 }
263 }
TestContext * testContext() const
void flushAndWaitOnSync(GrDirectContext *context)

◆ init()

bool GPUTarget::init ( SkImageInfo  info,
Benchmark bench 
)
inlineoverridevirtual

Called once per target, during program initialization. Returns false if initialization fails.

Reimplemented from Target.

Definition at line 277 of file nanobench.cpp.

277 {
279 bench->modifyGrContextOptions(&options);
280 this->factory = std::make_unique<GrContextFactory>(options);
281 SkSurfaceProps props(this->config.surfaceFlags, kRGB_H_SkPixelGeometry);
283 this->factory->get(this->config.ctxType, this->config.ctxOverrides),
285 info,
286 this->config.samples,
287 &props);
288 this->contextInfo =
289 this->factory->getContextInfo(this->config.ctxType, this->config.ctxOverrides);
290 if (!this->surface) {
291 return false;
292 }
293 if (!this->contextInfo.testContext()->fenceSyncSupport()) {
294 SkDebugf("WARNING: GL context for config \"%s\" does not support fence sync. "
295 "Timings might not be accurate.\n", this->config.name.c_str());
296 }
297 return true;
298 }
const char * options
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void bench(NanoJSONResultsWriter *log, const char *name, int bytes)
@ kRGB_H_SkPixelGeometry
bool fenceSyncSupport() const
Definition TestContext.h:35
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
GrContextOptions grContextOpts
std::unique_ptr< GrContextFactory > factory
const Config config
Definition nanobench.h:40

◆ needsFrameTiming()

bool GPUTarget::needsFrameTiming ( int frameLag) const
inlineoverridevirtual

CPU-like targets can just be timed, but GPU-like targets need to pay attention to frame boundaries or other similar details.

Reimplemented from Target.

Definition at line 270 of file nanobench.cpp.

270 {
271 if (!this->contextInfo.testContext()->getMaxGpuFrameLag(maxFrameLag)) {
272 // Frame lag is unknown.
273 *maxFrameLag = FLAGS_gpuFrameLag;
274 }
275 return true;
276 }
bool getMaxGpuFrameLag(int *maxFrameLag) const
Definition TestContext.h:40

◆ onSetup()

void GPUTarget::onSetup ( )
inlineoverridevirtual

Reimplemented from Target.

Definition at line 256 of file nanobench.cpp.

256 {
258 }

◆ submitWorkAndSyncCPU()

void GPUTarget::submitWorkAndSyncCPU ( )
inlineoverridevirtual

Called between benchmarks (or between calibration and measured runs) to make sure all pending work in drivers / threads is complete.

Reimplemented from Target.

Definition at line 264 of file nanobench.cpp.

264 {
265 if (this->contextInfo.testContext()) {
267 }
268 }
void flushAndSyncCpu(GrDirectContext *)

Member Data Documentation

◆ contextInfo

ContextInfo GPUTarget::contextInfo

Definition at line 246 of file nanobench.cpp.

◆ factory

std::unique_ptr<GrContextFactory> GPUTarget::factory

Definition at line 247 of file nanobench.cpp.


The documentation for this struct was generated from the following file: