diff options
author | Greg Daniel <egdaniel@google.com> | 2018-10-03 13:10:43 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-10-03 13:30:30 +0000 |
commit | 55aea84baa53f2d7e7e876b09fd590f046ff9ab9 (patch) | |
tree | cf82b96aec596370b1220b8bdb3bc4e3ebaf8d2e | |
parent | 8d5da42a204f5701279410fdfbfd2b24950b11f9 (diff) | |
download | skqp-55aea84baa53f2d7e7e876b09fd590f046ff9ab9.tar.gz |
Reland "Always include public/include headers for vulkan and just guard src files with SK_VULKAN."
This reverts commit 684b506f3589ecc78eebe8d92082be31a5fbe348.
Reason for revert: Chrome change has landed to fix broken chrome roll.
Original change's description:
> Revert "Always include public/include headers for vulkan and just guard src files with SK_VULKAN."
>
> This reverts commit 6e2d607334cc57c22e3a52179743763828ea84b2.
>
> Reason for revert: chrome roll
>
> Original change's description:
> > Always include public/include headers for vulkan and just guard src files with SK_VULKAN.
> >
> > This should allow a client to build a skia library that doesn't use vulkan but still
> > has all the public headers defined so that they don't have to build two versions of
> > their code.
> >
> > Bug: chromium:862144
> > Change-Id: I0eecbe0bc48123619f217e2cf318eb9a8c77ccb2
> > Reviewed-on: https://skia-review.googlesource.com/158661
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,cblume@chromium.org
>
> Change-Id: I76ae6f435333755fa5d546fc1e5999a324b4fd05
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:862144
> Reviewed-on: https://skia-review.googlesource.com/c/159000
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>
TBR=egdaniel@google.com,mtklein@google.com,bsalomon@google.com,cblume@chromium.org
Change-Id: Id019b428f880efbd7ead8dee4178c6190469a290
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:862144
Reviewed-on: https://skia-review.googlesource.com/c/159145
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
-rw-r--r-- | BUILD.gn | 2 | ||||
-rw-r--r-- | include/gpu/GrBackendSemaphore.h | 13 | ||||
-rw-r--r-- | include/gpu/GrBackendSurface.h | 27 | ||||
-rw-r--r-- | include/gpu/GrContext.h | 2 | ||||
-rw-r--r-- | include/gpu/vk/GrVkDefines.h | 4 | ||||
-rw-r--r-- | src/gpu/GrBackendSurface.cpp | 49 | ||||
-rw-r--r-- | src/gpu/GrDirectContext.cpp | 11 |
7 files changed, 52 insertions, 56 deletions
@@ -1362,8 +1362,8 @@ if (skia_enable_tools) { deps += [ "//third_party/angle2" ] sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ] } + public_include_dirs += [ "third_party/vulkan" ] if (skia_use_vulkan) { - public_include_dirs += [ "third_party/vulkan" ] sources += [ "tools/gpu/vk/VkTestContext.cpp" ] sources += [ "tools/gpu/vk/VkTestUtils.cpp" ] if (defined(skia_moltenvk_path) && skia_moltenvk_path != "") { diff --git a/include/gpu/GrBackendSemaphore.h b/include/gpu/GrBackendSemaphore.h index 5c41532cb9..828cdcb17a 100644 --- a/include/gpu/GrBackendSemaphore.h +++ b/include/gpu/GrBackendSemaphore.h @@ -11,10 +11,7 @@ #include "GrTypes.h" #include "gl/GrGLTypes.h" - -#ifdef SK_VULKAN #include "vk/GrVkTypes.h" -#endif /** * Wrapper class for passing into and receiving data from Ganesh about a backend semaphore object. @@ -31,13 +28,15 @@ public: fIsInitialized = true; } -#ifdef SK_VULKAN void initVulkan(VkSemaphore semaphore) { fBackend = kVulkan_GrBackend; fVkSemaphore = semaphore; +#ifdef SK_VULKAN fIsInitialized = true; - } +#else + fIsInitialized = false; #endif + } bool isInitialized() const { return fIsInitialized; } @@ -48,22 +47,18 @@ public: return fGLSync; } -#ifdef SK_VULKAN VkSemaphore vkSemaphore() const { if (!fIsInitialized || kVulkan_GrBackend != fBackend) { return VK_NULL_HANDLE; } return fVkSemaphore; } -#endif private: GrBackend fBackend; union { GrGLsync fGLSync; -#ifdef SK_VULKAN VkSemaphore fVkSemaphore; -#endif }; bool fIsInitialized; }; diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h index 8caebb8f1e..e0db0a4282 100644 --- a/include/gpu/GrBackendSurface.h +++ b/include/gpu/GrBackendSurface.h @@ -11,13 +11,10 @@ #include "GrTypes.h" #include "gl/GrGLTypes.h" #include "mock/GrMockTypes.h" - -#ifdef SK_VULKAN #include "vk/GrVkTypes.h" #include "../private/GrVkTypesPriv.h" class GrVkImageLayout; -#endif #ifdef SK_METAL #include "mtl/GrMtlTypes.h" @@ -50,11 +47,9 @@ public: return GrBackendFormat(format, target); } -#ifdef SK_VULKAN static GrBackendFormat MakeVk(VkFormat format) { return GrBackendFormat(format); } -#endif #ifdef SK_METAL static GrBackendFormat MakeMtl(GrMTLPixelFormat format) { @@ -73,11 +68,9 @@ public: const GrGLenum* getGLFormat() const; const GrGLenum* getGLTarget() const; -#ifdef SK_VULKAN // If the backend API is Vulkan, this returns a pointer to a VkFormat. Otherwise // it returns nullptr const VkFormat* getVkFormat() const; -#endif #ifdef SK_METAL // If the backend API is Metal, this returns a pointer to a GrMTLPixelFormat. Otherwise @@ -95,9 +88,7 @@ public: private: GrBackendFormat(GrGLenum format, GrGLenum target); -#ifdef SK_VULKAN GrBackendFormat(const VkFormat vkFormat); -#endif #ifdef SK_METAL GrBackendFormat(const GrMTLPixelFormat mtlFormat); @@ -113,9 +104,7 @@ private: GrGLenum fTarget; // GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL or GL_TEXTURE_RECTANGLE GrGLenum fFormat; // the sized, internal format of the GL resource } fGL; -#ifdef SK_VULKAN VkFormat fVkFormat; -#endif #ifdef SK_METAL GrMTLPixelFormat fMtlFormat; #endif @@ -134,11 +123,9 @@ public: GrMipMapped, const GrGLTextureInfo& glInfo); -#ifdef SK_VULKAN GrBackendTexture(int width, int height, const GrVkImageInfo& vkInfo); -#endif #ifdef SK_METAL GrBackendTexture(int width, @@ -167,7 +154,6 @@ public: // pointer and returns true. Otherwise returns false if the backend API is not GL. bool getGLTextureInfo(GrGLTextureInfo*) const; -#ifdef SK_VULKAN // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed // in pointer and returns true. This snapshot will set the fImageLayout to the current layout // state. Otherwise returns false if the backend API is not Vulkan. @@ -176,7 +162,6 @@ public: // Anytime the client changes the VkImageLayout of the VkImage captured by this // GrBackendTexture, they must call this function to notify Skia of the changed layout. void setVkImageLayout(VkImageLayout); -#endif #ifdef SK_METAL // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed @@ -218,11 +203,11 @@ private: GrPixelConfig config() const { return fConfig; } -#ifdef SK_VULKAN // Requires friending of GrVkGpu (done above already) sk_sp<GrVkImageLayout> getGrVkImageLayout() const; friend class GrVkTexture; +#ifdef SK_VULKAN GrBackendTexture(int width, int height, const GrVkImageInfo& vkInfo, @@ -241,9 +226,7 @@ private: union { GrGLTextureInfo fGLInfo; -#ifdef SK_VULKAN GrVkBackendSurfaceInfo fVkInfo; -#endif #ifdef SK_METAL GrMtlTextureInfo fMtlInfo; #endif @@ -263,7 +246,6 @@ public: int stencilBits, const GrGLFramebufferInfo& glInfo); -#ifdef SK_VULKAN /** Deprecated, use version that does not take stencil bits. */ GrBackendRenderTarget(int width, int height, @@ -271,7 +253,6 @@ public: int stencilBits, const GrVkImageInfo& vkInfo); GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo); -#endif #ifdef SK_METAL GrBackendRenderTarget(int width, @@ -301,7 +282,6 @@ public: // in pointer and returns true. Otherwise returns false if the backend API is not GL. bool getGLFramebufferInfo(GrGLFramebufferInfo*) const; -#ifdef SK_VULKAN // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed // in pointer and returns true. This snapshot will set the fImageLayout to the current layout // state. Otherwise returns false if the backend API is not Vulkan. @@ -310,7 +290,6 @@ public: // Anytime the client changes the VkImageLayout of the VkImage captured by this // GrBackendRenderTarget, they must call this function to notify Skia of the changed layout. void setVkImageLayout(VkImageLayout); -#endif #ifdef SK_METAL // If the backend API is Metal, copies a snapshot of the GrMtlTextureInfo struct into the passed @@ -348,14 +327,12 @@ private: friend class GrMtlGpu; GrPixelConfig config() const { return fConfig; } -#ifdef SK_VULKAN // Requires friending of GrVkGpu (done above already) sk_sp<GrVkImageLayout> getGrVkImageLayout() const; friend class GrVkRenderTarget; GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo, sk_sp<GrVkImageLayout> layout); -#endif // Free and release and resources being held by the GrBackendTexture. void cleanup(); @@ -372,9 +349,7 @@ private: union { GrGLFramebufferInfo fGLInfo; -#ifdef SK_VULKAN GrVkBackendSurfaceInfo fVkInfo; -#endif #ifdef SK_METAL GrMtlTextureInfo fMtlInfo; #endif diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index a85a6d5503..6258c504db 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -63,10 +63,8 @@ public: static sk_sp<GrContext> MakeGL(const GrContextOptions&); static sk_sp<GrContext> MakeGL(); -#ifdef SK_VULKAN static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext&, const GrContextOptions&); static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext&); -#endif #ifdef SK_METAL /** diff --git a/include/gpu/vk/GrVkDefines.h b/include/gpu/vk/GrVkDefines.h index d30615ea1e..e8bb63b120 100644 --- a/include/gpu/vk/GrVkDefines.h +++ b/include/gpu/vk/GrVkDefines.h @@ -11,12 +11,8 @@ #include "SkTypes.h" -#ifdef SK_VULKAN - #ifndef VULKAN_H_ #include "../../../third_party/vulkan/SkiaVulkan.h" #endif #endif - -#endif diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp index 7e10cb20a2..0e6df50c1e 100644 --- a/src/gpu/GrBackendSurface.cpp +++ b/src/gpu/GrBackendSurface.cpp @@ -39,10 +39,13 @@ const GrGLenum* GrBackendFormat::getGLTarget() const { return nullptr; } -#ifdef SK_VULKAN GrBackendFormat::GrBackendFormat(VkFormat vkFormat) : fBackend(kVulkan_GrBackend) +#ifdef SK_VULKAN , fValid(true) +#else + ,fValid(false) +#endif , fVkFormat(vkFormat) { } @@ -52,7 +55,6 @@ const VkFormat* GrBackendFormat::getVkFormat() const { } return nullptr; } -#endif #ifdef SK_METAL GrBackendFormat::GrBackendFormat(GrMTLPixelFormat mtlFormat) @@ -82,13 +84,17 @@ const GrPixelConfig* GrBackendFormat::getMockFormat() const { return nullptr; } -#ifdef SK_VULKAN GrBackendTexture::GrBackendTexture(int width, int height, const GrVkImageInfo& vkInfo) +#ifdef SK_VULKAN : GrBackendTexture(width, height, vkInfo, sk_sp<GrVkImageLayout>(new GrVkImageLayout(vkInfo.fImageLayout))) {} +#else + : fIsValid(false) {} +#endif +#ifdef SK_VULKAN GrBackendTexture::GrBackendTexture(int width, int height, const GrVkImageInfo& vkInfo, @@ -173,11 +179,11 @@ GrBackendTexture& GrBackendTexture::operator=(const GrBackendTexture& that) { case kOpenGL_GrBackend: fGLInfo = that.fGLInfo; break; -#ifdef SK_VULKAN case kVulkan_GrBackend: +#ifdef SK_VULKAN fVkInfo.assign(that.fVkInfo, this->isValid()); - break; #endif + break; #ifdef SK_METAL case kMetal_GrBackend: fMtlInfo = that.fMtlInfo; @@ -193,28 +199,39 @@ GrBackendTexture& GrBackendTexture::operator=(const GrBackendTexture& that) { return *this; } -#ifdef SK_VULKAN bool GrBackendTexture::getVkImageInfo(GrVkImageInfo* outInfo) const { +#ifdef SK_VULKAN if (this->isValid() && kVulkan_GrBackend == fBackend) { *outInfo = fVkInfo.snapImageInfo(); return true; } +#endif return false; } void GrBackendTexture::setVkImageLayout(VkImageLayout layout) { +#ifdef SK_VULKAN if (this->isValid() && kVulkan_GrBackend == fBackend) { fVkInfo.setImageLayout(layout); } +#endif } +// We need a stubbed version of GrVkImageLayout for non vulkan builds +#ifndef SK_VULKAN +class GrVkImageLayout : public SkRefCnt { + GrVkImageLayout(VkImageLayout layout) {} +}; +#endif + sk_sp<GrVkImageLayout> GrBackendTexture::getGrVkImageLayout() const { +#ifdef SK_VULKAN if (this->isValid() && kVulkan_GrBackend == fBackend) { return fVkInfo.getGrVkImageLayout(); } +#endif return nullptr; } -#endif #ifdef SK_METAL bool GrBackendTexture::getMtlTextureInfo(GrMtlTextureInfo* outInfo) const { @@ -284,7 +301,6 @@ bool GrBackendTexture::TestingOnly_Equals(const GrBackendTexture& t0, const GrBa //////////////////////////////////////////////////////////////////////////////////////////////////// -#ifdef SK_VULKAN GrBackendRenderTarget::GrBackendRenderTarget(int width, int height, int sampleCnt, @@ -299,9 +315,14 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo) +#ifdef SK_VULKAN : GrBackendRenderTarget(width, height, sampleCnt, vkInfo, sk_sp<GrVkImageLayout>(new GrVkImageLayout(vkInfo.fImageLayout))) {} +#else + : fIsValid(false) {} +#endif +#ifdef SK_VULKAN GrBackendRenderTarget::GrBackendRenderTarget(int width, int height, int sampleCnt, @@ -392,11 +413,11 @@ GrBackendRenderTarget& GrBackendRenderTarget::operator=(const GrBackendRenderTar case kOpenGL_GrBackend: fGLInfo = that.fGLInfo; break; -#ifdef SK_VULKAN case kVulkan_GrBackend: +#ifdef SK_VULKAN fVkInfo.assign(that.fVkInfo, this->isValid()); - break; #endif + break; #ifdef SK_METAL case kMetal_GrBackend: fMtlInfo = that.fMtlInfo; @@ -412,28 +433,32 @@ GrBackendRenderTarget& GrBackendRenderTarget::operator=(const GrBackendRenderTar return *this; } -#ifdef SK_VULKAN bool GrBackendRenderTarget::getVkImageInfo(GrVkImageInfo* outInfo) const { +#ifdef SK_VULKAN if (this->isValid() && kVulkan_GrBackend == fBackend) { *outInfo = fVkInfo.snapImageInfo(); return true; } +#endif return false; } void GrBackendRenderTarget::setVkImageLayout(VkImageLayout layout) { +#ifdef SK_VULKAN if (this->isValid() && kVulkan_GrBackend == fBackend) { fVkInfo.setImageLayout(layout); } +#endif } sk_sp<GrVkImageLayout> GrBackendRenderTarget::getGrVkImageLayout() const { +#ifdef SK_VULKAN if (this->isValid() && kVulkan_GrBackend == fBackend) { return fVkInfo.getGrVkImageLayout(); } +#endif return nullptr; } -#endif #ifdef SK_METAL bool GrBackendRenderTarget::getMtlTextureInfo(GrMtlTextureInfo* outInfo) const { diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp index 14133cd31e..59b984caa3 100644 --- a/src/gpu/GrDirectContext.cpp +++ b/src/gpu/GrDirectContext.cpp @@ -147,14 +147,19 @@ sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions, return context; } -#ifdef SK_VULKAN sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext) { +#ifdef SK_VULKAN GrContextOptions defaultOptions; return MakeVulkan(backendContext, defaultOptions); +#else + return nullptr; +#endif } sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext, const GrContextOptions& options) { +#ifdef SK_VULKAN + GrContextOptions defaultOptions; sk_sp<GrContext> context(new GrDirectContext(kVulkan_GrBackend)); context->fGpu = GrVkGpu::Make(backendContext, options, context.get()); @@ -167,8 +172,10 @@ sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext, return nullptr; } return context; -} +#else + return nullptr; #endif +} #ifdef SK_METAL sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue) { |