Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
|
egdaniel
2016/04/05 16:50:28
we don't usually capitalize every letter in the cl
jvanverth1
2016/04/05 18:16:49
Done.
| |
| 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 { | |
|
bsalomon
2016/04/05 14:24:43
Is this class specifically handling the window-bac
jvanverth1
2016/04/05 18:16:49
I was thinking it would be -- don't we create a wi
| |
| 20 public: | |
| 21 ~VulkanTestContext(); | |
| 22 | |
| 23 // each platform will have to implement these in its CPP file | |
| 24 VkSurfaceKHR createVkSurface(void* platformData); | |
| 25 bool canPresent(uint32_t queueFamilyIndex); | |
| 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 int getStencilBits() { return 0; } | |
| 41 int getSampleCount() { return 0; } | |
| 42 | |
| 43 bool isValid() { return SkToBool(fBackendContext.get()); } | |
| 44 | |
| 45 void resize() { | |
| 46 this->createSwapchain(0, 0); | |
| 47 } | |
| 48 | |
| 49 GrBackendContext getBackendContext() { return (GrBackendContext)fBackendCont ext.get(); } | |
| 50 | |
| 51 private: | |
| 52 VulkanTestContext(); | |
| 53 VulkanTestContext(void*, int msaaSampleCount); | |
| 54 void initializeContext(void*); | |
| 55 void destroyContext(); | |
| 56 | |
| 57 struct BackbufferInfo { | |
| 58 uint32_t fImageIndex; // image this is associated with | |
| 59 VkSemaphore fAcquireSemaphore; // we signal on this for acquisiti on of image | |
| 60 VkSemaphore fRenderSemaphore; // we wait on this for rendering t o be done | |
| 61 VkCommandBuffer fTransitionCmdBuffers[2]; // to transition layout betwee n present and render | |
| 62 VkFence fUsageFences[2]; // used to ensure this data is no longer used on GPU | |
| 63 }; | |
| 64 | |
| 65 BackbufferInfo* getAvailableBackbuffer(); | |
| 66 bool createSwapchain(uint32_t width, uint32_t height); | |
| 67 void createBuffers(); | |
| 68 void destroyBuffers(); | |
| 69 | |
| 70 GrContext* fContext; | |
| 71 SkAutoTUnref<const GrVkBackendContext> fBackendContext; | |
|
egdaniel
2016/04/05 16:50:28
use sk_sp?
jvanverth1
2016/04/05 18:16:49
I agree, but I'd like to do that as a separate cha
| |
| 72 VkSurfaceKHR fSurface; | |
| 73 VkSwapchainKHR fSwapchain; | |
| 74 uint32_t fPresentQueueIndex; | |
| 75 VkQueue fPresentQueue; | |
| 76 int fWidth; | |
| 77 int fHeight; | |
| 78 GrPixelConfig fPixelConfig; | |
| 79 | |
| 80 uint32_t fImageCount; | |
| 81 VkImage* fImages; // images in the swapchain | |
| 82 VkImageLayout* fImageLayouts; // layouts of these images when not color attachment | |
| 83 sk_sp<SkSurface>* fSurfaces; // wrapped surface for those images | |
| 84 VkCommandPool fCommandPool; | |
| 85 BackbufferInfo* fBackbuffers; | |
| 86 uint32_t fCurrentBackbufferIndex; | |
| 87 }; | |
| 88 | |
| 89 #endif // SK_VULKAN | |
| 90 | |
| 91 #endif | |
| OLD | NEW |