diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/third_party/skia/include/gpu | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/skia/include/gpu')
10 files changed, 374 insertions, 178 deletions
diff --git a/chromium/third_party/skia/include/gpu/GrBackendSurface.h b/chromium/third_party/skia/include/gpu/GrBackendSurface.h index 373d23f92cc..6e52b118db2 100644 --- a/chromium/third_party/skia/include/gpu/GrBackendSurface.h +++ b/chromium/third_party/skia/include/gpu/GrBackendSurface.h @@ -8,6 +8,7 @@ #ifndef GrBackendSurface_DEFINED #define GrBackendSurface_DEFINED +#include "include/gpu/GrBackendSurfaceMutableState.h" #include "include/gpu/GrTypes.h" #include "include/gpu/gl/GrGLTypes.h" #include "include/gpu/mock/GrMockTypes.h" @@ -19,6 +20,7 @@ #include "include/gpu/dawn/GrDawnTypes.h" #endif +class GrBackendSurfaceMutableStateImpl; class GrVkImageLayout; class GrGLTextureParameters; @@ -224,7 +226,7 @@ private: class SK_API GrBackendTexture { public: // Creates an invalid backend texture. - GrBackendTexture() : fIsValid(false) {} + GrBackendTexture(); // The GrGLTextureInfo must have a valid fFormat. GrBackendTexture(int width, @@ -232,9 +234,11 @@ public: GrMipMapped, const GrGLTextureInfo& glInfo); +#ifdef SK_VULKAN GrBackendTexture(int width, int height, const GrVkImageInfo& vkInfo); +#endif #ifdef SK_METAL GrBackendTexture(int width, @@ -319,6 +323,13 @@ public: // in pointer and returns true. Otherwise returns false if the backend API is not Mock. bool getMockTextureInfo(GrMockTextureInfo*) const; + // If the client changes any of the mutable backend of the GrBackendTexture they should call + // this function to inform Skia that those values have changed. The backend API specific state + // that can be set from this function are: + // + // Vulkan: VkImageLayout and QueueFamilyIndex + void setMutableState(const GrBackendSurfaceMutableState&); + // Returns true if we are working with protected content. bool isProtected() const; @@ -333,6 +344,8 @@ public: #endif private: + friend class GrVkGpu; // for getMutableState + sk_sp<GrBackendSurfaceMutableStateImpl> getMutableState() const; #ifdef SK_GL friend class GrGLTexture; @@ -347,12 +360,10 @@ private: #ifdef SK_VULKAN friend class GrVkTexture; - friend class GrVkGpu; // for getGrVkImageLayout GrBackendTexture(int width, int height, const GrVkImageInfo& vkInfo, - sk_sp<GrVkImageLayout> layout); - sk_sp<GrVkImageLayout> getGrVkImageLayout() const; + sk_sp<GrBackendSurfaceMutableStateImpl> mutableState); #endif #ifdef SK_DIRECT3D @@ -390,12 +401,14 @@ private: #ifdef SK_DAWN GrDawnTextureInfo fDawnInfo; #endif + + sk_sp<GrBackendSurfaceMutableStateImpl> fMutableState; }; class SK_API GrBackendRenderTarget { public: // Creates an invalid backend texture. - GrBackendRenderTarget() : fIsValid(false) {} + GrBackendRenderTarget(); // The GrGLTextureInfo must have a valid fFormat. GrBackendRenderTarget(int width, @@ -412,6 +425,7 @@ public: const GrDawnRenderTargetInfo& dawnInfo); #endif +#ifdef SK_VULKAN /** Deprecated, use version that does not take stencil bits. */ GrBackendRenderTarget(int width, int height, @@ -419,6 +433,7 @@ public: int stencilBits, const GrVkImageInfo& vkInfo); GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo); +#endif #ifdef SK_METAL GrBackendRenderTarget(int width, @@ -495,6 +510,13 @@ public: // in pointer and returns true. Otherwise returns false if the backend API is not Mock. bool getMockRenderTargetInfo(GrMockRenderTargetInfo*) const; + // If the client changes any of the mutable backend of the GrBackendTexture they should call + // this function to inform Skia that those values have changed. The backend API specific state + // that can be set from this function are: + // + // Vulkan: VkImageLayout and QueueFamilyIndex + void setMutableState(const GrBackendSurfaceMutableState&); + // Returns true if we are working with protected content. bool isProtected() const; @@ -507,12 +529,15 @@ public: #endif private: - friend class GrVkGpu; // for getGrVkImageLayout - sk_sp<GrVkImageLayout> getGrVkImageLayout() const; + friend class GrVkGpu; // for getMutableState + sk_sp<GrBackendSurfaceMutableStateImpl> getMutableState() const; +#ifdef SK_VULKAN friend class GrVkRenderTarget; GrBackendRenderTarget(int width, int height, int sampleCnt, const GrVkImageInfo& vkInfo, - sk_sp<GrVkImageLayout> layout); + sk_sp<GrBackendSurfaceMutableStateImpl> mutableState); +#endif + #ifdef SK_DIRECT3D friend class GrD3DGpu; friend class GrD3DRenderTarget; @@ -550,6 +575,7 @@ private: #ifdef SK_DAWN GrDawnRenderTargetInfo fDawnInfo; #endif + sk_sp<GrBackendSurfaceMutableStateImpl> fMutableState; }; #endif diff --git a/chromium/third_party/skia/include/gpu/GrBackendSurfaceMutableState.h b/chromium/third_party/skia/include/gpu/GrBackendSurfaceMutableState.h new file mode 100644 index 00000000000..6425cb52260 --- /dev/null +++ b/chromium/third_party/skia/include/gpu/GrBackendSurfaceMutableState.h @@ -0,0 +1,66 @@ +/* + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrBackendSurfaceMutableState_DEFINED +#define GrBackendSurfaceMutableState_DEFINED + +#include "include/gpu/GrTypes.h" + +#ifdef SK_VULKAN +#include "include/private/GrVkTypesPriv.h" +#endif + +/** + * Since Skia and clients can both modify gpu textures and their connected state, Skia needs a way + * for clients to inform us if they have modifiend any of this state. In order to not need setters + * for every single API and state, we use this class to be a generic wrapper around all the mutable + * state. This class is used for calls that inform Skia of these texture/image state changes by the + * client as well as for requesting state changes to be done by Skia. The backend specific state + * that is wrapped by this class are: + * + * Vulkan: VkImageLayout and QueueFamilyIndex + */ +class GrBackendSurfaceMutableState { +public: +#ifdef SK_VULKAN + GrBackendSurfaceMutableState(VkImageLayout layout, uint32_t queueFamilyIndex) + : fVkState(layout, queueFamilyIndex) + , fBackend(GrBackend::kVulkan) {} +#endif + + GrBackendSurfaceMutableState& operator=(const GrBackendSurfaceMutableState& that) { + switch (fBackend) { + case GrBackend::kVulkan: +#ifdef SK_VULKAN + SkASSERT(that.fBackend == GrBackend::kVulkan); + fVkState = that.fVkState; +#endif + break; + + default: + (void)that; + SkUNREACHABLE; + } + fBackend = that.fBackend; + return *this; + } + +private: + friend class GrBackendSurfaceMutableStateImpl; + friend class GrVkGpu; + + union { + char fDummy; +#ifdef SK_VULKAN + GrVkSharedImageInfo fVkState; +#endif + }; + + GrBackend fBackend; +}; + +#endif diff --git a/chromium/third_party/skia/include/gpu/GrContext.h b/chromium/third_party/skia/include/gpu/GrContext.h index 9dcba2ca2f4..64137383687 100644 --- a/chromium/third_party/skia/include/gpu/GrContext.h +++ b/chromium/third_party/skia/include/gpu/GrContext.h @@ -36,7 +36,6 @@ class GrResourceProvider; class GrStrikeCache; class GrSurfaceProxy; class GrSwizzle; -class GrTextContext; class GrTextureProxy; struct GrVkBackendContext; @@ -62,7 +61,10 @@ public: /** * The Vulkan context (VkQueue, VkDevice, VkInstance) must be kept alive until the returned - * GrContext is first destroyed or abandoned. + * GrContext is destroyed. This also means that any objects created with this GrContext (e.g. + * SkSurfaces, SkImages, etc.) must also be released as they may hold refs on the GrContext. + * Once all these objects and the GrContext are released, then it is safe to delete the vulkan + * objects. */ static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext&, const GrContextOptions&); static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext&); @@ -98,6 +100,7 @@ public: ~GrContext() override; + // TODO: Remove this from public after migrating Chrome. sk_sp<GrContextThreadSafeProxy> threadSafeProxy(); /** @@ -133,7 +136,10 @@ public: * API calls may crash. * * For Vulkan, even if the device becomes lost, the VkQueue, VkDevice, or VkInstance used to - * create the GrContext must be alive before calling abandonContext. + * create the GrContext must be kept alive even after abandoning the context. Those objects must + * live for the lifetime of the GrContext object itself. The reason for this is so that + * we can continue to delete any outstanding GrBackendTextures/RenderTargets which must be + * cleaned up even in a device lost state. */ void abandonContext() override; @@ -146,6 +152,23 @@ public: bool abandoned() override; /** + * Checks if the underlying 3D API reported an out-of-memory error. If this returns true it is + * reset and will return false until another out-of-memory error is reported by the 3D API. If + * the context is abandoned then this will report false. + * + * Currently this is implemented for: + * + * OpenGL [ES] - Note that client calls to glGetError() may swallow GL_OUT_OF_MEMORY errors and + * therefore hide the error from Skia. Also, it is not advised to use this in combination with + * enabling GrContextOptions::fSkipGLErrorChecks. That option may prevent GrContext from ever + * checking the GL context for OOM. + * + * Vulkan - Reports true if VK_ERROR_OUT_OF_HOST_MEMORY or VK_ERROR_OUT_OF_DEVICE_MEMORY has + * occurred. + */ + bool oomed(); + + /** * This is similar to abandonContext() however the underlying 3D context is not yet lost and * the GrContext will cleanup all allocated resources before returning. After returning it will * assume that the underlying context may no longer be valid. @@ -296,7 +319,6 @@ public: /////////////////////////////////////////////////////////////////////////// // Misc. - /** * Inserts a list of GPU semaphores that the current GPU-backed API must wait on before * executing any more commands on the GPU. Skia will take ownership of the underlying semaphores @@ -307,82 +329,56 @@ public: bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores); /** - * Call to ensure all drawing to the context has been issued to the underlying 3D API. - */ - void flushAndSubmit() { this->flush(GrFlushInfo(), GrPrepareForExternalIORequests()); } - - /** - * Deprecated. + * Call to ensure all drawing to the context has been flushed and submitted to the underlying 3D + * API. This is equivalent to calling GrContext::flush with a default GrFlushInfo followed by + * GrContext::submit. */ - void flush() { this->flushAndSubmit(); } + void flushAndSubmit() { + this->flush(GrFlushInfo()); + this->submit(); + } /** - * Call to ensure all drawing to the context has been issued to the underlying 3D API. + * Call to ensure all drawing to the context has been flushed to underlying 3D API specific + * objects. A call to GrContext::submit is always required to ensure work is actually sent to + * the gpu. Some specific API details: + * GL: Commands are actually sent to the driver, but glFlush is never called. Thus some + * sync objects from the flush will not be valid until a submission occurs. + * + * Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command + * buffer or encoder objects. However, these objects are not sent to the gpu until a + * submission occurs. * - * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will have - * been submitted and can be waited on (it is possible Skia failed to create a subset of the - * semaphores). If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not have - * submitted any semaphores to be signaled on the GPU. Thus the client should not have the GPU - * wait on any of the semaphores passed in with the GrFlushInfo. Regardless of whether - * semaphores were submitted to the GPU or not, the client is still responsible for deleting any - * initialized semaphores. + * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be + * submitted to the gpu during the next submit call (it is possible Skia failed to create a + * subset of the semaphores). The client should not wait on these semaphores until after submit + * has been called, and must keep them alive until then. If this call returns + * GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on + * the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in with + * the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the + * client is still responsible for deleting any initialized semaphores. * Regardleess of semaphore submission the context will still be flushed. It should be * emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not * happen. It simply means there were no semaphores submitted to the GPU. A caller should only * take this as a failure if they passed in semaphores to be submitted. */ - GrSemaphoresSubmitted flush(const GrFlushInfo& info) { - return this->flush(info, GrPrepareForExternalIORequests()); - } + GrSemaphoresSubmitted flush(const GrFlushInfo& info); /** - * Call to ensure all drawing to the context has been issued to the underlying 3D API. + * Submit outstanding work to the gpu from all previously un-submitted flushes. The return + * value of the submit will indicate whether or not the submission to the GPU was successful. * - * If this call returns GrSemaphoresSubmitted::kNo, the GPU backend will not have created or - * added any semaphores to signal on the GPU. Thus the client should not have the GPU wait on - * any of the semaphores passed in with the GrFlushInfo. However, any pending commands to the - * context will still be flushed. It should be emphasized that a return value of - * GrSemaphoresSubmitted::kNo does not mean the flush did not happen. It simply means there were - * no semaphores submitted to the GPU. A caller should only take this as a failure if they - * passed in semaphores to be submitted. + * If the call returns true, all previously passed in semaphores in flush calls will have been + * submitted to the GPU and they can safely be waited on. The caller should wait on those + * semaphores or perform some other global synchronization before deleting the semaphores. * - * If the GrPrepareForExternalIORequests contains valid gpu backed SkSurfaces or SkImages, Skia - * will put the underlying backend objects into a state that is ready for external uses. See - * declaration of GrPreopareForExternalIORequests for more details. - */ - GrSemaphoresSubmitted flush(const GrFlushInfo&, const GrPrepareForExternalIORequests&); - - /** - * Deprecated. - */ - GrSemaphoresSubmitted flush(GrFlushFlags flags, int numSemaphores, - GrBackendSemaphore signalSemaphores[], - GrGpuFinishedProc finishedProc = nullptr, - GrGpuFinishedContext finishedContext = nullptr) { - GrFlushInfo info; - info.fFlags = flags; - info.fNumSemaphores = numSemaphores; - info.fSignalSemaphores = signalSemaphores; - info.fFinishedProc = finishedProc; - info.fFinishedContext = finishedContext; - return this->flush(info); - } - - /** - * Deprecated. - */ - GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores, - GrBackendSemaphore signalSemaphores[]) { - GrFlushInfo info; - info.fNumSemaphores = numSemaphores; - info.fSignalSemaphores = signalSemaphores; - return this->flush(info); - } - - /** - * Placeholder no-op submit call. + * If it returns false, then those same semaphores will not have been submitted and we will not + * try to submit them again. The caller is free to delete the semaphores at any time. + * + * If the syncCpu flag is true this function will return once the gpu has finished with all + * submitted work. */ - bool submit(bool syncToCpu = false); + bool submit(bool syncCpu = false); /** * Checks whether any asynchronous work is complete and if so calls related callbacks. @@ -472,8 +468,8 @@ public: * If possible, create a backend texture initialized to a particular color. The client should * ensure that the returned backend texture is valid. The client can pass in a finishedProc * to be notified when the data has been uploaded by the gpu and the texture can be deleted. The - * client can assume the upload work has been submitted to the gpu. The finishedProc will always - * get called even if we failed to create the GrBackendTexture. + * client is required to call GrContext::submit to send the upload work to the gpu. The + * finishedProc will always get called even if we failed to create the GrBackendTexture. * For the Vulkan backend the layout of the created VkImage will be: * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL */ @@ -490,8 +486,8 @@ public: * If possible, create a backend texture initialized to a particular color. The client should * ensure that the returned backend texture is valid. The client can pass in a finishedProc * to be notified when the data has been uploaded by the gpu and the texture can be deleted. The - * client can assume the upload work has been submitted to the gpu. The finishedProc will always - * get called even if we failed to create the GrBackendTexture. + * client is required to call GrContext::submit to send the upload work to the gpu. The + * finishedProc will always get called even if we failed to create the GrBackendTexture. * If successful, the created backend texture will be compatible with the provided * SkColorType. * For the Vulkan backend the layout of the created VkImage will be: @@ -510,9 +506,9 @@ public: * If possible, create a backend texture initialized to a particular color that is * compatible with the provided characterization. The client should ensure that the * returned backend texture is valid. The client can pass in a finishedProc to be notified when - * the data has been uploaded by the gpu and the texture can be deleted. The client can assume - * the upload work has been submitted to the gpu. The finishedProc will always get called even - * if we failed to create the GrBackendTexture. + * the data has been uploaded by the gpu and the texture can be deleted. The client is required + * to call GrContext::submit to send the upload work to the gpu. The finishedProc will always + * get called even if we failed to create the GrBackendTexture. * For the Vulkan backend the layout of the created VkImage will be: * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if texturaeble * VK_IMAGE_LAYOUT_UNDEFINED if not textureable @@ -526,11 +522,12 @@ public: * If possible, create a backend texture initialized with the provided pixmap data. The client * should ensure that the returned backend texture is valid. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to create the GrBackendTexture. + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to create the GrBackendTexture. * If successful, the created backend texture will be compatible with the provided * pixmap(s). Compatible, in this case, means that the backend format will be the result - * of calling defaultBackendFormat on the base pixmap's colortype. + * of calling defaultBackendFormat on the base pixmap's colortype. The src data can be deleted + * when this call returns. * If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired * the data for all the mipmap levels must be provided. In the mipmapped case all the * colortypes of the provided pixmaps must be the same. Additionally, all the miplevels @@ -558,8 +555,8 @@ public: * If possible, updates a backend texture to be filled to a particular color. The client should * check the return value to see if the update was successful. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to update the GrBackendTexture. + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to update the GrBackendTexture. * For the Vulkan backend after a successful update the layout of the created VkImage will be: * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL */ @@ -572,10 +569,11 @@ public: * If possible, updates a backend texture filled with the provided pixmap data. The client * should check the return value to see if the update was successful. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to create the GrBackendTexture. + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to create the GrBackendTexture. * The backend texture must be compatible with the provided pixmap(s). Compatible, in this case, - * means that the backend format is compatible with the base pixmap's colortype. + * means that the backend format is compatible with the base pixmap's colortype. The src data + * can be deleted when this call returns. * If the backend texture is mip mapped, the data for all the mipmap levels must be provided. * In the mipmapped case all the colortypes of the provided pixmaps must be the same. * Additionally, all the miplevels must be sized correctly (please see @@ -604,8 +602,8 @@ public: *If possible, create a compressed backend texture initialized to a particular color. The * client should ensure that the returned backend texture is valid. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to create the GrBackendTexture. + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to create the GrBackendTexture. * For the Vulkan backend the layout of the created VkImage will be: * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL */ @@ -629,8 +627,8 @@ public: * If possible, create a backend texture initialized with the provided raw data. The client * should ensure that the returned backend texture is valid. The client can pass in a * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be - * deleted. The client can assume the upload work has been submitted to the gpu. The - * finishedProc will always get called even if we failed to create the GrBackendTexture + * deleted. The client is required to call GrContext::submit to send the upload work to the gpu. + * The finishedProc will always get called even if we failed to create the GrBackendTexture * If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired * the data for all the mipmap levels must be provided. Additionally, all the miplevels * must be sized correctly (please see SkMipMap::ComputeLevelSize and ComputeLevelCount). @@ -653,6 +651,26 @@ public: GrGpuFinishedProc finishedProc = nullptr, GrGpuFinishedContext finishedContext = nullptr); + /** + * Updates the state of the GrBackendTexture/RenderTarget to have the passed in + * GrBackendSurfaceMutableState. All objects that wrap the backend surface (i.e. SkSurfaces and + * SkImages) will also be aware of this state change. This call does not submit the state change + * to the gpu, but requires the client to call GrContext::submit to send it to the GPU. The work + * for this call is ordered linearly with all other calls that require GrContext::submit to be + * called (e.g updateBackendTexture and flush). If finishedProc is not null then it will be + * called with finishedContext after the state transition is known to have occurred on the GPU. + * + * See GrBackendSurfaceMutableState to see what state can be set via this call. + */ + bool setBackendTextureState(const GrBackendTexture&, + const GrBackendSurfaceMutableState&, + GrGpuFinishedProc finishedProc = nullptr, + GrGpuFinishedContext finishedContext = nullptr); + bool setBackendRenderTargetState(const GrBackendRenderTarget&, + const GrBackendSurfaceMutableState&, + GrGpuFinishedProc finishedProc = nullptr, + GrGpuFinishedContext finishedContext = nullptr); + void deleteBackendTexture(GrBackendTexture); // This interface allows clients to pre-compile shaders and populate the runtime program cache. @@ -680,16 +698,14 @@ public: #endif protected: - GrContext(GrBackendApi, const GrContextOptions&, int32_t contextID = SK_InvalidGenID); + GrContext(sk_sp<GrContextThreadSafeProxy>); - bool init(sk_sp<const GrCaps>) override; + bool init() override; GrContext* asDirectContext() override { return this; } virtual GrAtlasManager* onGetAtlasManager() = 0; - sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy; - private: // fTaskGroup must appear before anything that uses it (e.g. fGpu), so that it is destroyed // after all of its users. Clients of fTaskGroup will generally want to ensure that they call diff --git a/chromium/third_party/skia/include/gpu/GrContextOptions.h b/chromium/third_party/skia/include/gpu/GrContextOptions.h index 5bdf37687c1..2f3d5b92e5e 100644 --- a/chromium/third_party/skia/include/gpu/GrContextOptions.h +++ b/chromium/third_party/skia/include/gpu/GrContextOptions.h @@ -134,16 +134,20 @@ struct SK_API GrContextOptions { /** * Below this threshold size in device space distance field fonts won't be used. Distance field - * fonts don't support hinting which is more important at smaller sizes. A negative value means - * use the default threshold. + * fonts don't support hinting which is more important at smaller sizes. */ - float fMinDistanceFieldFontSize = -1.f; + float fMinDistanceFieldFontSize = 18; /** - * Above this threshold size in device space glyphs are drawn as individual paths. A negative - * value means use the default threshold. + * Above this threshold size in device space glyphs are drawn as individual paths. */ - float fGlyphsAsPathsFontSize = -1.f; +#if defined(SK_BUILD_FOR_ANDROID) + float fGlyphsAsPathsFontSize = 384; +#elif defined(SK_BUILD_FOR_MAC) + float fGlyphsAsPathsFontSize = 256; +#else + float fGlyphsAsPathsFontSize = 324; +#endif /** * Can the glyph atlas use multiple textures. If allowed, the each texture's size is bound by @@ -258,17 +262,14 @@ struct SK_API GrContextOptions { bool fClearAllTextures = false; /** - * Include or exclude specific GPU path renderers. + * Randomly generate a (false) GL_OUT_OF_MEMORY error */ - GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault; -#endif + bool fRandomGLOOM = false; -#if SK_SUPPORT_ATLAS_TEXT /** - * Controls whether distance field glyph vertices always have 3 components even when the view - * matrix does not have perspective. + * Include or exclude specific GPU path renderers. */ - Enable fDistanceFieldGlyphVerticesAlwaysHaveW = Enable::kDefault; + GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault; #endif GrDriverBugWorkarounds fDriverBugWorkarounds; diff --git a/chromium/third_party/skia/include/gpu/GrContextThreadSafeProxy.h b/chromium/third_party/skia/include/gpu/GrContextThreadSafeProxy.h index bfd37ac77e1..ca4cb313dcd 100644 --- a/chromium/third_party/skia/include/gpu/GrContextThreadSafeProxy.h +++ b/chromium/third_party/skia/include/gpu/GrContextThreadSafeProxy.h @@ -8,11 +8,16 @@ #ifndef GrContextThreadSafeProxy_DEFINED #define GrContextThreadSafeProxy_DEFINED -#include "include/private/GrContext_Base.h" +#include "include/core/SkImageInfo.h" +#include "include/core/SkRefCnt.h" +#include "include/gpu/GrContextOptions.h" +#include "include/gpu/GrTypes.h" + +#include <atomic> class GrBackendFormat; +class GrCaps; class GrContextThreadSafeProxyPriv; -struct SkImageInfo; class SkSurfaceCharacterization; class SkSurfaceProps; @@ -20,9 +25,9 @@ class SkSurfaceProps; * Can be used to perform actions related to the generating GrContext in a thread safe manner. The * proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrContext. */ -class SK_API GrContextThreadSafeProxy : public GrContext_Base { +class SK_API GrContextThreadSafeProxy final : public SkNVRefCnt<GrContextThreadSafeProxy> { public: - ~GrContextThreadSafeProxy() override; + ~GrContextThreadSafeProxy(); /** * Create a surface characterization for a DDL that will be replayed into the GrContext @@ -73,13 +78,13 @@ public: * * The caller should check that the returned format is valid. */ - GrBackendFormat defaultBackendFormat(SkColorType ct, GrRenderable renderable) const { - return INHERITED::defaultBackendFormat(ct, renderable); - } + GrBackendFormat defaultBackendFormat(SkColorType ct, GrRenderable renderable) const; + + bool isValid() const { return nullptr != fCaps; } bool operator==(const GrContextThreadSafeProxy& that) const { // Each GrContext should only ever have a single thread-safe proxy. - SkASSERT((this == &that) == (this->contextID() == that.contextID())); + SkASSERT((this == &that) == (this->fContextID == that.fContextID)); return this == &that; } @@ -93,11 +98,21 @@ private: friend class GrContextThreadSafeProxyPriv; // for ctor and hidden methods // DDL TODO: need to add unit tests for backend & maybe options - GrContextThreadSafeProxy(GrBackendApi, const GrContextOptions&, uint32_t contextID); + GrContextThreadSafeProxy(GrBackendApi, const GrContextOptions&); + + void abandonContext(); + bool abandoned() const; - bool init(sk_sp<const GrCaps>) override; + // TODO: This should be part of the constructor but right now we have a chicken-and-egg problem + // with GrContext where we get the caps by creating a GPU which requires a context (see the + // `init` method on GrContext_Base). + void init(sk_sp<const GrCaps>); - typedef GrContext_Base INHERITED; + const GrBackendApi fBackend; + const GrContextOptions fOptions; + const uint32_t fContextID; + sk_sp<const GrCaps> fCaps; + std::atomic<bool> fAbandoned{false}; }; #endif diff --git a/chromium/third_party/skia/include/gpu/GrTypes.h b/chromium/third_party/skia/include/gpu/GrTypes.h index e7d4f7e4c8c..b6f5e6fb39a 100644 --- a/chromium/third_party/skia/include/gpu/GrTypes.h +++ b/chromium/third_party/skia/include/gpu/GrTypes.h @@ -227,13 +227,16 @@ static const uint32_t kAll_GrBackendState = 0xffffffff; enum GrFlushFlags { kNone_GrFlushFlags = 0, - // flush will wait till all submitted GPU work is finished before returning. + // Deprecated: Use syncCpu call on submit instead. kSyncCpu_GrFlushFlag = 0x1, }; typedef void* GrGpuFinishedContext; typedef void (*GrGpuFinishedProc)(GrGpuFinishedContext finishedContext); +typedef void* GrGpuSubmittedContext; +typedef void (*GrGpuSubmittedProc)(GrGpuSubmittedContext submittedContext, bool success); + /** * Struct to supply options to flush calls. * @@ -241,7 +244,8 @@ typedef void (*GrGpuFinishedProc)(GrGpuFinishedContext finishedContext); * passes in an array of fNumSemaphores GrBackendSemaphores. In general these GrBackendSemaphore's * can be either initialized or not. If they are initialized, the backend uses the passed in * semaphore. If it is not initialized, a new semaphore is created and the GrBackendSemaphore - * object is initialized with that semaphore. + * object is initialized with that semaphore. The semaphores are not sent to the GPU until the next + * GrContext::submit call is made. See the GrContext::submit for more information. * * The client will own and be responsible for deleting the underlying semaphores that are stored * and returned in initialized GrBackendSemaphore objects. The GrBackendSemaphore objects @@ -251,52 +255,40 @@ typedef void (*GrGpuFinishedProc)(GrGpuFinishedContext finishedContext); * from this flush call and all previous flush calls has finished on the GPU. If the flush call * fails due to an error and nothing ends up getting sent to the GPU, the finished proc is called * immediately. + * + * If a submittedProc is provided, the submittedProc will be called when all work from this flush + * call is submitted to the GPU. If the flush call fails due to an error and nothing will get sent + * to the GPU, the submitted proc is called immediately. It is possibly that when work is finally + * submitted, that the submission actual fails. In this case we will not reattempt to do the + * submission. Skia notifies the client of these via the success bool passed into the submittedProc. + * The submittedProc is useful to the client to know when semaphores that were sent with the flush + * have actually been submitted to the GPU so that they can be waited on (or deleted if the submit + * fails). + * Note about GL: In GL work gets sent to the driver immediately during the flush call, but we don't + * really know when the driver sends the work to the GPU. Therefore, we treat the submitted proc as + * we do in other backends. It will be called when the next GrContext::submit is called after the + * flush (or possibly during the flush if there is no work to be done for the flush). The main use + * case for the submittedProc is to know when semaphores have been sent to the GPU and even in GL + * it is required to call GrContext::submit to flush them. So a client should be able to treat all + * backend APIs the same in terms of how the submitted procs are treated. */ struct GrFlushInfo { - GrFlushFlags fFlags = kNone_GrFlushFlags; - int fNumSemaphores = 0; - GrBackendSemaphore* fSignalSemaphores = nullptr; - GrGpuFinishedProc fFinishedProc = nullptr; + GrFlushFlags fFlags = kNone_GrFlushFlags; + int fNumSemaphores = 0; + GrBackendSemaphore* fSignalSemaphores = nullptr; + GrGpuFinishedProc fFinishedProc = nullptr; GrGpuFinishedContext fFinishedContext = nullptr; + GrGpuSubmittedProc fSubmittedProc = nullptr; + GrGpuSubmittedContext fSubmittedContext = nullptr; }; /** - * Enum used as return value when flush with semaphores so the client knows whether the semaphores - * were submitted to GPU or not. + * Enum used as return value when flush with semaphores so the client knows whether the valid + * semaphores will be submitted on the next GrContext::submit call. */ enum class GrSemaphoresSubmitted : bool { kNo = false, kYes = true }; -/** - * Array of SkImages and SkSurfaces which Skia will prepare for external use when passed into a - * flush call on GrContext. All the SkImages and SkSurfaces must be GPU backed. - * - * If fPrepareSurfaceForPresent is not nullptr, then it must be an array the size of fNumSurfaces. - * Each entry in the array corresponds to the SkSurface at the same index in the fSurfaces array. If - * an entry is true, then that surface will be prepared for both external use and present. - * - * Currently this only has an effect if the backend API is Vulkan. In this case, all the underlying - * VkImages associated with the SkImages and SkSurfaces will be transitioned into the VkQueueFamily - * in which they were originally wrapped or created with. This allows a client to wrap a VkImage - * from a queue which is different from the graphics queue and then have Skia transition it back to - * that queue without needing to delete the SkImage or SkSurface. If the an SkSurface is also - * flagged to be prepared for present, then its VkImageLayout will be set to - * VK_IMAGE_LAYOUT_PRESENT_SRC_KHR if the VK_KHR_swapchain extension has been enabled for the - * GrContext and the original queue is not VK_QUEUE_FAMILY_EXTERNAL or VK_QUEUE_FAMILY_FOREIGN_EXT. - * - * If an SkSurface or SkImage is used again, it will be transitioned back to the graphics queue and - * whatever layout is needed for its use. - */ -struct GrPrepareForExternalIORequests { - int fNumImages = 0; - SkImage** fImages = nullptr; - int fNumSurfaces = 0; - SkSurface** fSurfaces = nullptr; - bool* fPrepareSurfaceForPresent = nullptr; - - bool hasRequests() const { return fNumImages || fNumSurfaces; } -}; - #endif diff --git a/chromium/third_party/skia/include/gpu/gl/GrGLInterface.h b/chromium/third_party/skia/include/gpu/gl/GrGLInterface.h index 17655bdbedb..c571314cae4 100644 --- a/chromium/third_party/skia/include/gpu/gl/GrGLInterface.h +++ b/chromium/third_party/skia/include/gpu/gl/GrGLInterface.h @@ -49,6 +49,13 @@ struct SK_API GrGLInterface : public SkRefCnt { private: typedef SkRefCnt INHERITED; +#if GR_GL_CHECK_ERROR + // This is here to avoid having our debug code that checks for a GL error after most GL calls + // accidentally swallow an OOM that should be reported. + mutable bool fOOMed = false; + bool fSuppressErrorLogging = false; +#endif + public: GrGLInterface(); @@ -57,6 +64,19 @@ public: // extensions. bool validate() const; +#if GR_GL_CHECK_ERROR + GrGLenum checkError(const char* location, const char* call) const; + bool checkAndResetOOMed() const; + void suppressErrorLogging(); +#endif + +#if GR_TEST_UTILS + GrGLInterface(const GrGLInterface& that) + : fStandard(that.fStandard) + , fExtensions(that.fExtensions) + , fFunctions(that.fFunctions) {} +#endif + // Indicates the type of GL implementation union { GrGLStandard fStandard; diff --git a/chromium/third_party/skia/include/gpu/mock/GrMockTypes.h b/chromium/third_party/skia/include/gpu/mock/GrMockTypes.h index b4c55c81d5b..897a83105eb 100644 --- a/chromium/third_party/skia/include/gpu/mock/GrMockTypes.h +++ b/chromium/third_party/skia/include/gpu/mock/GrMockTypes.h @@ -110,12 +110,12 @@ struct GrMockOptions { // GrCaps options. bool fMipMapSupport = false; bool fDrawInstancedSupport = false; - bool fTessellationSupport = false; bool fHalfFloatVertexAttributeSupport = false; uint32_t fMapBufferFlags = 0; int fMaxTextureSize = 2048; int fMaxRenderTargetSize = 2048; int fMaxVertexAttributes = 16; + int fMaxTessellationSegments = 0; ConfigOptions fConfigOptions[kGrColorTypeCnt]; ConfigOptions fCompressedOptions[SkImage::kCompressionTypeCount]; diff --git a/chromium/third_party/skia/include/gpu/vk/GrVkMemoryAllocator.h b/chromium/third_party/skia/include/gpu/vk/GrVkMemoryAllocator.h index 5102496b831..b25d5458d90 100644 --- a/chromium/third_party/skia/include/gpu/vk/GrVkMemoryAllocator.h +++ b/chromium/third_party/skia/include/gpu/vk/GrVkMemoryAllocator.h @@ -50,11 +50,43 @@ public: kGpuWritesCpuReads, }; - virtual bool allocateMemoryForImage(VkImage image, AllocationPropertyFlags flags, - GrVkBackendMemory*) = 0; + // DEPRECATED: Use and implement allocateImageMemory instead + virtual bool allocateMemoryForImage(VkImage, AllocationPropertyFlags, GrVkBackendMemory*) { + // The default implementation here is so clients can delete this virtual as the switch to + // the new one which returns a VkResult. + return false; + } + + virtual VkResult allocateImageMemory(VkImage image, AllocationPropertyFlags flags, + GrVkBackendMemory* memory) { + bool result = this->allocateMemoryForImage(image, flags, memory); + // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is + // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to + // mean something specific happened like device lost or oom. This will be removed once we + // update clients to implement this virtual. + return result ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; + } + + // DEPRECATED: Use and implement allocateBufferMemory instead + virtual bool allocateMemoryForBuffer(VkBuffer, BufferUsage, AllocationPropertyFlags, + GrVkBackendMemory*) { + // The default implementation here is so clients can delete this virtual as the switch to + // the new one which returns a VkResult. + return false; + } + + virtual VkResult allocateBufferMemory(VkBuffer buffer, + BufferUsage usage, + AllocationPropertyFlags flags, + GrVkBackendMemory* memory) { + bool result = this->allocateMemoryForBuffer(buffer, usage, flags, memory); + // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is + // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to + // mean something specific happened like device lost or oom. This will be removed once we + // update clients to implement this virtual. + return result ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; + } - virtual bool allocateMemoryForBuffer(VkBuffer buffer, BufferUsage usage, - AllocationPropertyFlags flags, GrVkBackendMemory*) = 0; // Fills out the passed in GrVkAlloc struct for the passed in GrVkBackendMemory. virtual void getAllocInfo(const GrVkBackendMemory&, GrVkAlloc*) const = 0; @@ -62,7 +94,15 @@ public: // Maps the entire allocation and returns a pointer to the start of the allocation. The // implementation may map more memory than just the allocation, but the returned pointer must // point at the start of the memory for the requested allocation. - virtual void* mapMemory(const GrVkBackendMemory&) = 0; + virtual void* mapMemory(const GrVkBackendMemory&) { return nullptr; } + virtual VkResult mapMemory(const GrVkBackendMemory& memory, void** data) { + *data = this->mapMemory(memory); + // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is + // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to + // mean something specific happened like device lost or oom. This will be removed once we + // update clients to implement this virtual. + return *data ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; + } virtual void unmapMemory(const GrVkBackendMemory&) = 0; // The following two calls are used for managing non-coherent memory. The offset is relative to @@ -70,10 +110,18 @@ public: // must make sure that the offset + size passed in is less that or equal to the allocation size. // It is the responsibility of the implementation to make sure all alignment requirements are // followed. The client should not have to deal with any sort of alignment issues. - virtual void flushMappedMemory(const GrVkBackendMemory&, VkDeviceSize offset, - VkDeviceSize size) = 0; - virtual void invalidateMappedMemory(const GrVkBackendMemory&, VkDeviceSize offset, - VkDeviceSize size)= 0; + virtual void flushMappedMemory(const GrVkBackendMemory&, VkDeviceSize, VkDeviceSize) {} + virtual VkResult flushMemory(const GrVkBackendMemory& memory, VkDeviceSize offset, + VkDeviceSize size) { + this->flushMappedMemory(memory, offset, size); + return VK_SUCCESS; + } + virtual void invalidateMappedMemory(const GrVkBackendMemory&, VkDeviceSize, VkDeviceSize) {} + virtual VkResult invalidateMemory(const GrVkBackendMemory& memory, VkDeviceSize offset, + VkDeviceSize size) { + this->invalidateMappedMemory(memory, offset, size); + return VK_SUCCESS; + } virtual void freeMemory(const GrVkBackendMemory&) = 0; diff --git a/chromium/third_party/skia/include/gpu/vk/GrVkTypes.h b/chromium/third_party/skia/include/gpu/vk/GrVkTypes.h index c7353677d5c..e869238899b 100644 --- a/chromium/third_party/skia/include/gpu/vk/GrVkTypes.h +++ b/chromium/third_party/skia/include/gpu/vk/GrVkTypes.h @@ -105,7 +105,7 @@ struct GrVkYcbcrConversionInfo { VkChromaLocation yChromaOffset, VkFilter chromaFilter, VkBool32 forceExplicitReconstruction, - uint64_t externalFormat, + int64_t externalFormat, VkFormatFeatureFlags externalFormatFeatures) : GrVkYcbcrConversionInfo(VK_FORMAT_UNDEFINED, externalFormat, ycbcrModel, ycbcrRange, xChromaOffset, yChromaOffset, chromaFilter, @@ -135,7 +135,7 @@ struct GrVkYcbcrConversionInfo { // The external format. Must be non-zero for external images, zero otherwise. // Should be compatible to be used in a VkExternalFormatANDROID struct. - uint64_t fExternalFormat; + int64_t fExternalFormat; VkSamplerYcbcrModelConversion fYcbcrModel; VkSamplerYcbcrRange fYcbcrRange; @@ -149,6 +149,12 @@ struct GrVkYcbcrConversionInfo { VkFormatFeatureFlags fFormatFeatures; }; +/* + * When wrapping a GrBackendTexture or GrBackendRendenderTarget, the fCurrentQueueFamily should + * either be VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_EXTERNAL, or VK_QUEUE_FAMILY_FOREIGN_EXT. If + * fSharingMode is VK_SHARING_MODE_EXCLUSIVE then fCurrentQueueFamily can also be the graphics + * queue index passed into Skia. + */ struct GrVkImageInfo { VkImage fImage; GrVkAlloc fAlloc; @@ -159,6 +165,7 @@ struct GrVkImageInfo { uint32_t fCurrentQueueFamily; GrProtected fProtected; GrVkYcbcrConversionInfo fYcbcrConversionInfo; + VkSharingMode fSharingMode; GrVkImageInfo() : fImage(VK_NULL_HANDLE) @@ -169,7 +176,8 @@ struct GrVkImageInfo { , fLevelCount(0) , fCurrentQueueFamily(VK_QUEUE_FAMILY_IGNORED) , fProtected(GrProtected::kNo) - , fYcbcrConversionInfo() {} + , fYcbcrConversionInfo() + , fSharingMode(VK_SHARING_MODE_EXCLUSIVE) {} GrVkImageInfo(VkImage image, GrVkAlloc alloc, @@ -179,7 +187,8 @@ struct GrVkImageInfo { uint32_t levelCount, uint32_t currentQueueFamily = VK_QUEUE_FAMILY_IGNORED, GrProtected isProtected = GrProtected::kNo, - GrVkYcbcrConversionInfo ycbcrConversionInfo = GrVkYcbcrConversionInfo()) + GrVkYcbcrConversionInfo ycbcrConversionInfo = GrVkYcbcrConversionInfo(), + VkSharingMode sharingMode = VK_SHARING_MODE_EXCLUSIVE) : fImage(image) , fAlloc(alloc) , fImageTiling(imageTiling) @@ -188,18 +197,20 @@ struct GrVkImageInfo { , fLevelCount(levelCount) , fCurrentQueueFamily(currentQueueFamily) , fProtected(isProtected) - , fYcbcrConversionInfo(ycbcrConversionInfo) {} + , fYcbcrConversionInfo(ycbcrConversionInfo) + , fSharingMode(sharingMode) {} - GrVkImageInfo(const GrVkImageInfo& info, VkImageLayout layout) + GrVkImageInfo(const GrVkImageInfo& info, VkImageLayout layout, uint32_t familyQueueIndex) : fImage(info.fImage) , fAlloc(info.fAlloc) , fImageTiling(info.fImageTiling) , fImageLayout(layout) , fFormat(info.fFormat) , fLevelCount(info.fLevelCount) - , fCurrentQueueFamily(info.fCurrentQueueFamily) + , fCurrentQueueFamily(familyQueueIndex) , fProtected(info.fProtected) - , fYcbcrConversionInfo(info.fYcbcrConversionInfo) {} + , fYcbcrConversionInfo(info.fYcbcrConversionInfo) + , fSharingMode(info.fSharingMode) {} #if GR_TEST_UTILS bool operator==(const GrVkImageInfo& that) const { @@ -207,7 +218,8 @@ struct GrVkImageInfo { fImageTiling == that.fImageTiling && fImageLayout == that.fImageLayout && fFormat == that.fFormat && fLevelCount == that.fLevelCount && fCurrentQueueFamily == that.fCurrentQueueFamily && fProtected == that.fProtected && - fYcbcrConversionInfo == that.fYcbcrConversionInfo; + fYcbcrConversionInfo == that.fYcbcrConversionInfo && + fSharingMode == that.fSharingMode; } #endif }; |