Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Side by Side Diff: tools/vulkan/VulkanTestContext.h

Issue 1945103003: Rename VulkanViewer to Viewer, take 2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix android path Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/vulkan/Application.h ('k') | tools/vulkan/VulkanTestContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2016 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8 #ifndef VulkanTestContext_DEFINED
9 #define VulkanTestContext_DEFINED
10
11 #ifdef SK_VULKAN
12
13 #include "GrTypes.h"
14 #include "vk/GrVkBackendContext.h"
15
16 class SkSurface;
17 class GrContext;
18
19 class VulkanTestContext {
20 public:
21 ~VulkanTestContext();
22
23 // each platform will have to implement these in its CPP file
24 static VkSurfaceKHR createVkSurface(VkInstance, void* platformData);
25 static bool canPresent(VkInstance, VkPhysicalDevice, uint32_t queueFamilyInd ex);
26
27 static VulkanTestContext* Create(void* platformData, int msaaSampleCount) {
28 VulkanTestContext* ctx = new VulkanTestContext(platformData, msaaSampleC ount);
29 if (!ctx->isValid()) {
30 delete ctx;
31 return nullptr;
32 }
33 return ctx;
34 }
35
36 SkSurface* getBackbufferSurface();
37 void swapBuffers();
38
39 bool makeCurrent() { return true; }
40
41 bool isValid() { return SkToBool(fBackendContext.get()); }
42
43 void resize(uint32_t w, uint32_t h) {
44 this->createSwapchain(w, h);
45 }
46
47 GrBackendContext getBackendContext() { return (GrBackendContext)fBackendCont ext.get(); }
48
49 private:
50 VulkanTestContext();
51 VulkanTestContext(void*, int msaaSampleCount);
52 void initializeContext(void*);
53 void destroyContext();
54
55 struct BackbufferInfo {
56 uint32_t fImageIndex; // image this is associated with
57 VkSemaphore fAcquireSemaphore; // we signal on this for acquisiti on of image
58 VkSemaphore fRenderSemaphore; // we wait on this for rendering t o be done
59 VkCommandBuffer fTransitionCmdBuffers[2]; // to transition layout betwee n present and render
60 VkFence fUsageFences[2]; // used to ensure this data is no longer used on GPU
61 };
62
63 BackbufferInfo* getAvailableBackbuffer();
64 bool createSwapchain(uint32_t width, uint32_t height);
65 void createBuffers(VkFormat format);
66 void destroyBuffers();
67
68 SkAutoTUnref<const GrVkBackendContext> fBackendContext;
69
70 // simple wrapper class that exists only to initialize a pointer to NULL
71 template <typename FNPTR_TYPE> class VkPtr {
72 public:
73 VkPtr() : fPtr(NULL) {}
74 VkPtr operator=(FNPTR_TYPE ptr) { fPtr = ptr; return *this; }
75 operator FNPTR_TYPE() const { return fPtr; }
76 private:
77 FNPTR_TYPE fPtr;
78 };
79
80 // WSI interface functions
81 VkPtr<PFN_vkDestroySurfaceKHR> fDestroySurfaceKHR;
82 VkPtr<PFN_vkGetPhysicalDeviceSurfaceSupportKHR> fGetPhysicalDeviceSurfaceSup portKHR;
83 VkPtr<PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR> fGetPhysicalDeviceSurfa ceCapabilitiesKHR;
84 VkPtr<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR> fGetPhysicalDeviceSurfaceFor matsKHR;
85 VkPtr<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR> fGetPhysicalDeviceSurfa cePresentModesKHR;
86
87 VkPtr<PFN_vkCreateSwapchainKHR> fCreateSwapchainKHR;
88 VkPtr<PFN_vkDestroySwapchainKHR> fDestroySwapchainKHR;
89 VkPtr<PFN_vkGetSwapchainImagesKHR> fGetSwapchainImagesKHR;
90 VkPtr<PFN_vkAcquireNextImageKHR> fAcquireNextImageKHR;
91 VkPtr<PFN_vkQueuePresentKHR> fQueuePresentKHR;
92 VkPtr<PFN_vkCreateSharedSwapchainsKHR> fCreateSharedSwapchainsKHR;
93
94 GrContext* fContext;
95 VkSurfaceKHR fSurface;
96 VkSwapchainKHR fSwapchain;
97 uint32_t fPresentQueueIndex;
98 VkQueue fPresentQueue;
99 int fWidth;
100 int fHeight;
101 GrPixelConfig fPixelConfig;
102
103 uint32_t fImageCount;
104 VkImage* fImages; // images in the swapchain
105 VkImageLayout* fImageLayouts; // layouts of these images when not color attachment
106 sk_sp<SkSurface>* fSurfaces; // wrapped surface for those images
107 VkCommandPool fCommandPool;
108 BackbufferInfo* fBackbuffers;
109 uint32_t fCurrentBackbufferIndex;
110 };
111
112 #endif // SK_VULKAN
113
114 #endif
OLDNEW
« no previous file with comments | « tools/vulkan/Application.h ('k') | tools/vulkan/VulkanTestContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698