25#if defined(SK_GRAPHITE)
31#define ACQUIRE_INST_VK_PROC(name) \
32 fVk##name = reinterpret_cast<PFN_vk##name>(instProc(fBackendContext.fInstance, "vk" #name)); \
33 if (fVk##name == nullptr) { \
34 SkDebugf("Function ptr for vk%s could not be acquired\n", #name); \
38#define ACQUIRE_DEVICE_VK_PROC(name) \
39 fVk##name = reinterpret_cast<PFN_vk##name>(fVkGetDeviceProcAddr(fDevice, "vk" #name)); \
40 if (fVk##name == nullptr) { \
41 SkDebugf("Function ptr for vk%s could not be acquired\n", #name); \
47class GaneshVkTestHelper :
public VkTestHelper {
49 GaneshVkTestHelper(
bool isProtected) : VkTestHelper(isProtected) {}
51 ~GaneshVkTestHelper()
override {
58 fDirectContext.reset();
61 bool isValid()
const override {
return fDirectContext !=
nullptr; }
68 textureable, isProtected,
72 void submitAndWaitForCompletion(
bool* completionMarker)
override {
73 fDirectContext->submit();
74 while (!*completionMarker) {
75 fDirectContext->checkAsyncWorkCompletion();
79 GrDirectContext* directContext()
override {
return fDirectContext.get(); }
82 bool init()
override {
83 if (!this->setupBackendContext()) {
88 if (!fDirectContext) {
92 SkASSERT(fDirectContext->supportsProtectedContent() == fIsProtected);
102#if defined(SK_GRAPHITE)
104class GraphiteVkTestHelper :
public VkTestHelper {
106 GraphiteVkTestHelper(
bool isProtected) : VkTestHelper(isProtected) {}
108 ~GraphiteVkTestHelper()
override {
112 std::unique_ptr<skgpu::graphite::Recording> recording;
114 recording = fRecorder->snap();
118 fContext->insertRecording({ recording.get() });
127 bool isValid()
const override {
return fContext !=
nullptr && fRecorder !=
nullptr; }
131 bool isProtected)
override {
136 void submitAndWaitForCompletion(
bool* completionMarker)
override {
138 while (!*completionMarker) {
139 fContext->checkAsyncWorkCompletion();
146 bool init()
override {
147 if (!this->setupBackendContext()) {
164 fRecorder =
fContext->makeRecorder();
173 std::unique_ptr<skgpu::graphite::Context>
fContext;
174 std::unique_ptr<skgpu::graphite::Recorder> fRecorder;
181 std::unique_ptr<VkTestHelper> helper;
184#if defined(SK_GANESH)
186 helper = std::make_unique<GaneshVkTestHelper>(isProtected);
189#if defined(SK_GRAPHITE)
191 helper = std::make_unique<GraphiteVkTestHelper>(isProtected);
197 if (!helper->init()) {
204bool VkTestHelper::setupBackendContext() {
206 if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc)) {
211 fFeatures.pNext =
nullptr;
216 if (!sk_gpu_test::CreateVkBackendContext(instProc, &fBackendContext, &fExtensions,
217 &fFeatures, &fDebugCallback,
nullptr,
218 sk_gpu_test::CanPresentFn(), fIsProtected)) {
221 fDevice = fBackendContext.fDevice;
225 instProc(fBackendContext.fInstance,
"vkDestroyDebugReportCallbackEXT"));
236 ACQUIRE_DEVICE_VK_PROC(CreateImage)
237 ACQUIRE_DEVICE_VK_PROC(DestroyImage)
238 ACQUIRE_DEVICE_VK_PROC(GetImageMemoryRequirements)
239 ACQUIRE_DEVICE_VK_PROC(AllocateMemory)
240 ACQUIRE_DEVICE_VK_PROC(FreeMemory)
241 ACQUIRE_DEVICE_VK_PROC(BindImageMemory)
242 ACQUIRE_DEVICE_VK_PROC(MapMemory)
243 ACQUIRE_DEVICE_VK_PROC(UnmapMemory)
244 ACQUIRE_DEVICE_VK_PROC(FlushMappedMemoryRanges)
245 ACQUIRE_DEVICE_VK_PROC(GetImageSubresourceLayout)
249VkTestHelper::~VkTestHelper() {
250 fBackendContext.fMemoryAllocator.reset();
252 fVkDeviceWaitIdle(fDevice);
253 fVkDestroyDevice(fDevice,
nullptr);
257 fDestroyDebugCallback(fBackendContext.fInstance, fDebugCallback,
nullptr);
261 fVkDestroyInstance(fBackendContext.fInstance,
nullptr);
265 sk_gpu_test::FreeVulkanFeaturesStructs(&fFeatures);
@ kUnknown_SkPixelGeometry
#define ACQUIRE_INST_VK_PROC(name)
SK_API sk_sp< GrDirectContext > MakeVulkan(const skgpu::VulkanBackendContext &, const GrContextOptions &)
sk_sp< SkSurface > CreateProtectedSkSurface(GrDirectContext *dContext, SkISize size, bool textureable, bool isProtected, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SK_API std::unique_ptr< Context > MakeVulkan(const VulkanBackendContext &, const ContextOptions &)
bool fStoreContextRefInRecorder
ContextOptionsPriv * fOptionsPriv
void(VKAPI_PTR * PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks *pAllocator)
PFN_vkVoidFunction(VKAPI_PTR * PFN_vkGetInstanceProcAddr)(VkInstance instance, const char *pName)
@ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2