Chromium Code Reviews| Index: tools/vulkan/VulkanTestContext.h |
| diff --git a/tools/vulkan/VulkanTestContext.h b/tools/vulkan/VulkanTestContext.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..735b5dcdf6626d4712d9a8b7bdb79eb8a1f00f46 |
| --- /dev/null |
| +++ b/tools/vulkan/VulkanTestContext.h |
| @@ -0,0 +1,91 @@ |
| + |
| +/* |
| + * Copyright 2016 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| +#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.
|
| +#define VULKANTESTCONTEXT_DEFINED |
| + |
| +#ifdef SK_VULKAN |
| + |
| +#include "GrTypes.h" |
| +#include "vk/GrVkBackendContext.h" |
| + |
| +class SkSurface; |
| +class GrContext; |
| + |
| +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
|
| +public: |
| + ~VulkanTestContext(); |
| + |
| + // each platform will have to implement these in its CPP file |
| + VkSurfaceKHR createVkSurface(void* platformData); |
| + bool canPresent(uint32_t queueFamilyIndex); |
| + |
| + static VulkanTestContext* Create(void* platformData, int msaaSampleCount) { |
| + VulkanTestContext* ctx = new VulkanTestContext(platformData, msaaSampleCount); |
| + if (!ctx->isValid()) { |
| + delete ctx; |
| + return nullptr; |
| + } |
| + return ctx; |
| + } |
| + |
| + SkSurface* getBackbufferSurface(); |
| + void swapBuffers(); |
| + |
| + bool makeCurrent() { return true; } |
| + int getStencilBits() { return 0; } |
| + int getSampleCount() { return 0; } |
| + |
| + bool isValid() { return SkToBool(fBackendContext.get()); } |
| + |
| + void resize() { |
| + this->createSwapchain(0, 0); |
| + } |
| + |
| + GrBackendContext getBackendContext() { return (GrBackendContext)fBackendContext.get(); } |
| + |
| +private: |
| + VulkanTestContext(); |
| + VulkanTestContext(void*, int msaaSampleCount); |
| + void initializeContext(void*); |
| + void destroyContext(); |
| + |
| + struct BackbufferInfo { |
| + uint32_t fImageIndex; // image this is associated with |
| + VkSemaphore fAcquireSemaphore; // we signal on this for acquisition of image |
| + VkSemaphore fRenderSemaphore; // we wait on this for rendering to be done |
| + VkCommandBuffer fTransitionCmdBuffers[2]; // to transition layout between present and render |
| + VkFence fUsageFences[2]; // used to ensure this data is no longer used on GPU |
| + }; |
| + |
| + BackbufferInfo* getAvailableBackbuffer(); |
| + bool createSwapchain(uint32_t width, uint32_t height); |
| + void createBuffers(); |
| + void destroyBuffers(); |
| + |
| + GrContext* fContext; |
| + 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
|
| + VkSurfaceKHR fSurface; |
| + VkSwapchainKHR fSwapchain; |
| + uint32_t fPresentQueueIndex; |
| + VkQueue fPresentQueue; |
| + int fWidth; |
| + int fHeight; |
| + GrPixelConfig fPixelConfig; |
| + |
| + uint32_t fImageCount; |
| + VkImage* fImages; // images in the swapchain |
| + VkImageLayout* fImageLayouts; // layouts of these images when not color attachment |
| + sk_sp<SkSurface>* fSurfaces; // wrapped surface for those images |
| + VkCommandPool fCommandPool; |
| + BackbufferInfo* fBackbuffers; |
| + uint32_t fCurrentBackbufferIndex; |
| +}; |
| + |
| +#endif // SK_VULKAN |
| + |
| +#endif |