Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
skiatest::graphite::MtlTestContext Class Reference

#include <GraphiteMtlTestContext.h>

Inheritance diagram for skiatest::graphite::MtlTestContext:
skiatest::graphite::GraphiteTestContext

Public Member Functions

 ~MtlTestContext () override
 
skgpu::BackendApi backend () override
 
skgpu::ContextType contextType () override
 
std::unique_ptr< skgpu::graphite::ContextmakeContext (const TestOptions &) override
 
const skgpu::graphite::MtlBackendContextgetBackendContext () const
 
- Public Member Functions inherited from skiatest::graphite::GraphiteTestContext
 GraphiteTestContext (const GraphiteTestContext &)=delete
 
GraphiteTestContextoperator= (const GraphiteTestContext &)=delete
 
virtual ~GraphiteTestContext ()
 
virtual skgpu::BackendApi backend ()=0
 
virtual skgpu::ContextType contextType ()=0
 
virtual std::unique_ptr< skgpu::graphite::ContextmakeContext (const TestOptions &)=0
 
bool getMaxGpuFrameLag (int *maxFrameLag) const
 
void submitRecordingAndWaitOnSync (skgpu::graphite::Context *, skgpu::graphite::Recording *)
 
virtual void tick ()
 
void syncedSubmit (skgpu::graphite::Context *)
 

Static Public Member Functions

static std::unique_ptr< GraphiteTestContextMake ()
 

Protected Member Functions

 MtlTestContext (const skgpu::graphite::MtlBackendContext &mtl)
 
- Protected Member Functions inherited from skiatest::graphite::GraphiteTestContext
 GraphiteTestContext ()
 

Protected Attributes

skgpu::graphite::MtlBackendContext fMtl
 
- Protected Attributes inherited from skiatest::graphite::GraphiteTestContext
sk_sp< sk_gpu_test::FlushFinishTrackerfFinishTrackers [kMaxFrameLag - 1]
 
int fCurrentFlushIdx = 0
 

Additional Inherited Members

- Static Protected Attributes inherited from skiatest::graphite::GraphiteTestContext
static constexpr int kMaxFrameLag = 3
 

Detailed Description

Definition at line 17 of file GraphiteMtlTestContext.h.

Constructor & Destructor Documentation

◆ ~MtlTestContext()

skiatest::graphite::MtlTestContext::~MtlTestContext ( )
inlineoverride

Definition at line 19 of file GraphiteMtlTestContext.h.

19{}

◆ MtlTestContext()

skiatest::graphite::MtlTestContext::MtlTestContext ( const skgpu::graphite::MtlBackendContext mtl)
inlineprotected

Definition at line 34 of file GraphiteMtlTestContext.h.

34: fMtl(mtl) {}
skgpu::graphite::MtlBackendContext fMtl

Member Function Documentation

◆ backend()

skgpu::BackendApi skiatest::graphite::MtlTestContext::backend ( )
inlineoverridevirtual

◆ contextType()

skgpu::ContextType skiatest::graphite::MtlTestContext::contextType ( )
overridevirtual

Implements skiatest::graphite::GraphiteTestContext.

Definition at line 53 of file GraphiteMtlTestContext.mm.

53 {
55}

◆ getBackendContext()

const skgpu::graphite::MtlBackendContext & skiatest::graphite::MtlTestContext::getBackendContext ( ) const
inline

Definition at line 29 of file GraphiteMtlTestContext.h.

29 {
30 return fMtl;
31 }

◆ Make()

std::unique_ptr< GraphiteTestContext > skiatest::graphite::MtlTestContext::Make ( )
static

Definition at line 22 of file GraphiteMtlTestContext.mm.

22 {
23 sk_cfp<id<MTLDevice>> device;
24#ifdef SK_BUILD_FOR_MAC
25 sk_cfp<NSArray<id <MTLDevice>>*> availableDevices(MTLCopyAllDevices());
26 // Choose the non-integrated CPU if available
27 for (id<MTLDevice> dev in availableDevices.get()) {
28 if (!dev.isLowPower) {
29 // This retain is necessary because when the NSArray goes away it will delete the
30 // device entry otherwise.
31 device.retain(dev);
32 break;
33 }
34 if (dev.isRemovable) {
35 device.retain(dev);
36 break;
37 }
38 }
39 if (!device) {
40 device.reset(MTLCreateSystemDefaultDevice());
41 }
42#else
43 device.reset(MTLCreateSystemDefaultDevice());
44#endif
45
46 skgpu::graphite::MtlBackendContext backendContext = {};
47 backendContext.fDevice.retain(device.get());
48 backendContext.fQueue.reset([*device newCommandQueue]);
49
50 return std::unique_ptr<GraphiteTestContext>(new MtlTestContext(backendContext));
51}
MtlTestContext(const skgpu::graphite::MtlBackendContext &mtl)
VkDevice device
Definition: main.cc:53

◆ makeContext()

std::unique_ptr< skgpu::graphite::Context > skiatest::graphite::MtlTestContext::makeContext ( const TestOptions options)
overridevirtual

Implements skiatest::graphite::GraphiteTestContext.

Definition at line 57 of file GraphiteMtlTestContext.mm.

57 {
58 SkASSERT(!options.fNeverYieldToWebGPU);
59 skgpu::graphite::ContextOptions revisedContextOptions(options.fContextOptions);
60 skgpu::graphite::ContextOptionsPriv contextOptionsPriv;
61 if (!options.fContextOptions.fOptionsPriv) {
62 revisedContextOptions.fOptionsPriv = &contextOptionsPriv;
63 }
64 // Needed to make synchronous readPixels work
65 revisedContextOptions.fOptionsPriv->fStoreContextRefInRecorder = true;
66
67 return skgpu::graphite::ContextFactory::MakeMetal(fMtl, revisedContextOptions);
68}
const char * options
#define SkASSERT(cond)
Definition: SkAssert.h:116
SK_API std::unique_ptr< Context > MakeMetal(const MtlBackendContext &, const ContextOptions &)

Member Data Documentation

◆ fMtl

skgpu::graphite::MtlBackendContext skiatest::graphite::MtlTestContext::fMtl
protected

Definition at line 36 of file GraphiteMtlTestContext.h.


The documentation for this class was generated from the following files: