Revert "Add flush() to SkImage."
This reverts commit d0503a72ac
.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Add flush() to SkImage.
>
> This allows a client to ensure all uses of a texture-backed image have
> been flushed.
>
> Does nothing if the image isn't texture-backed.
>
> The implementation adds support for triggering a flush if any of a set
> of proxies are used rather than just a single proxy.
>
> Change-Id: I358882d9737e63c6e69b924c0767f49b8f8f36ec
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212405
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: Ie376bf4225307f45b8fb3eb4a63bf84702365797
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212884
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
d0503a72ac
commit
693bc2bae5
@ -726,23 +726,6 @@ public:
|
||||
*/
|
||||
bool isValid(GrContext* context) const;
|
||||
|
||||
/** Flushes any pending uses of texture-backed images in the GPU backend. If the image is not
|
||||
texture-backed (including promise texture images) or if the the GrContext does not
|
||||
have the same context ID as the context backing the image then this is a no-op.
|
||||
|
||||
If the image was not used in any non-culled draws recorded on the passed GrContext then
|
||||
this is a no-op unless the GrFlushInfo contains semaphores, a finish proc, or uses
|
||||
kSyncCpu_GrFlushFlag. Those are respected even when the image has not been used.
|
||||
|
||||
@param context the context on which to flush pending usages of the image.
|
||||
@param info flush options
|
||||
@return one of: GrSemaphoresSubmitted::kYes, GrSemaphoresSubmitted::kNo
|
||||
*/
|
||||
GrSemaphoresSubmitted flush(GrContext* context, const GrFlushInfo& flushInfo);
|
||||
|
||||
/** Version of flush() that uses a default GrFlushInfo. */
|
||||
void flush(GrContext*);
|
||||
|
||||
/** Retrieves the back-end texture. If SkImage has no back-end texture, an invalid
|
||||
object is returned. Call GrBackendTexture::isValid to determine if the result
|
||||
is valid.
|
||||
|
@ -264,7 +264,7 @@ GrSemaphoresSubmitted GrContext::flush(const GrFlushInfo& info) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
return this->drawingManager()->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
return this->drawingManager()->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
info);
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,12 @@
|
||||
#include "src/image/SkImage_Base.h"
|
||||
#include "src/image/SkImage_Gpu.h"
|
||||
|
||||
#define ASSERT_OWNED_PROXY(P) \
|
||||
#define ASSERT_OWNED_PROXY_PRIV(P) \
|
||||
SkASSERT(!(P) || !((P)->peekTexture()) || (P)->peekTexture()->getContext() == fContext)
|
||||
#define ASSERT_SINGLE_OWNER \
|
||||
#define ASSERT_SINGLE_OWNER_PRIV \
|
||||
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fContext->singleOwner());)
|
||||
#define RETURN_VALUE_IF_ABANDONED(value) if (fContext->abandoned()) { return (value); }
|
||||
#define RETURN_IF_ABANDONED RETURN_VALUE_IF_ABANDONED(void)
|
||||
#define RETURN_IF_ABANDONED_PRIV if (fContext->abandoned()) { return; }
|
||||
#define RETURN_FALSE_IF_ABANDONED_PRIV if (fContext->abandoned()) { return false; }
|
||||
|
||||
sk_sp<const GrCaps> GrContextPriv::refCaps() const {
|
||||
return fContext->refCaps();
|
||||
@ -103,7 +103,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithF
|
||||
sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackendTexture& tex,
|
||||
GrSurfaceOrigin origin,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
|
||||
sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendTexture(
|
||||
tex, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
|
||||
@ -122,7 +122,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContex
|
||||
const SkSurfaceProps* props,
|
||||
ReleaseProc releaseProc,
|
||||
ReleaseContext releaseCtx) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
SkASSERT(sampleCnt > 0);
|
||||
|
||||
sk_sp<GrTextureProxy> proxy(this->proxyProvider()->wrapRenderableBackendTexture(
|
||||
@ -143,7 +143,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetC
|
||||
const SkSurfaceProps* surfaceProps,
|
||||
ReleaseProc releaseProc,
|
||||
ReleaseContext releaseCtx) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
|
||||
sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendRenderTarget(
|
||||
backendRT, origin, releaseProc, releaseCtx);
|
||||
@ -162,7 +162,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRend
|
||||
int sampleCnt,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* props) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
SkASSERT(sampleCnt > 0);
|
||||
sk_sp<GrSurfaceProxy> proxy(
|
||||
this->proxyProvider()->wrapBackendTextureAsRenderTarget(tex, origin, sampleCnt));
|
||||
@ -177,7 +177,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRend
|
||||
|
||||
sk_sp<GrRenderTargetContext> GrContextPriv::makeVulkanSecondaryCBRenderTargetContext(
|
||||
const SkImageInfo& imageInfo, const GrVkDrawableInfo& vkInfo, const SkSurfaceProps* props) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
sk_sp<GrSurfaceProxy> proxy(
|
||||
this->proxyProvider()->wrapVulkanSecondaryCBAsRenderTarget(imageInfo, vkInfo));
|
||||
if (!proxy) {
|
||||
@ -189,22 +189,23 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeVulkanSecondaryCBRenderTargetCon
|
||||
props);
|
||||
}
|
||||
|
||||
GrSemaphoresSubmitted GrContextPriv::flushSurfaces(GrSurfaceProxy* proxies[], int numProxies,
|
||||
const GrFlushInfo& info) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_VALUE_IF_ABANDONED(GrSemaphoresSubmitted::kNo)
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrContextPriv", "flushSurfaces", fContext);
|
||||
SkASSERT(numProxies >= 0);
|
||||
SkASSERT(!numProxies || proxies);
|
||||
for (int i = 0; i < numProxies; ++i) {
|
||||
SkASSERT(proxies[i]);
|
||||
ASSERT_OWNED_PROXY(proxies[i]);
|
||||
}
|
||||
return fContext->drawingManager()->flushSurfaces(
|
||||
proxies, numProxies, SkSurface::BackendSurfaceAccess::kNoAccess, info);
|
||||
void GrContextPriv::flush(GrSurfaceProxy* proxy) {
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
RETURN_IF_ABANDONED_PRIV
|
||||
ASSERT_OWNED_PROXY_PRIV(proxy);
|
||||
|
||||
fContext->drawingManager()->flush(proxy, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
GrFlushInfo());
|
||||
}
|
||||
|
||||
void GrContextPriv::flushSurface(GrSurfaceProxy* proxy) { this->flushSurfaces(&proxy, 1, {}); }
|
||||
void GrContextPriv::flushSurface(GrSurfaceProxy* proxy) {
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
RETURN_IF_ABANDONED_PRIV
|
||||
SkASSERT(proxy);
|
||||
ASSERT_OWNED_PROXY_PRIV(proxy);
|
||||
fContext->drawingManager()->flushSurface(proxy,
|
||||
SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
|
||||
}
|
||||
|
||||
static bool valid_premul_color_type(GrColorType ct) {
|
||||
switch (ct) {
|
||||
@ -276,11 +277,11 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, int left, int top,
|
||||
int height, GrColorType dstColorType,
|
||||
SkColorSpace* dstColorSpace, void* buffer, size_t rowBytes,
|
||||
uint32_t pixelOpsFlags) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_VALUE_IF_ABANDONED(false)
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
RETURN_FALSE_IF_ABANDONED_PRIV
|
||||
SkASSERT(src);
|
||||
SkASSERT(buffer);
|
||||
ASSERT_OWNED_PROXY(src->asSurfaceProxy());
|
||||
ASSERT_OWNED_PROXY_PRIV(src->asSurfaceProxy());
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrContextPriv", "readSurfacePixels", fContext);
|
||||
|
||||
GrSurfaceProxy* srcProxy = src->asSurfaceProxy();
|
||||
@ -430,7 +431,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, int left, int top,
|
||||
sk_bzero(buffer, tempPixmap.computeByteSize());
|
||||
}
|
||||
|
||||
this->flushSurface(srcProxy);
|
||||
this->flush(srcProxy);
|
||||
|
||||
if (!fContext->fGpu->readPixels(srcSurface, left, top, width, height, allowedColorType, buffer,
|
||||
rowBytes)) {
|
||||
@ -460,11 +461,11 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, int left, int top,
|
||||
int height, GrColorType srcColorType,
|
||||
SkColorSpace* srcColorSpace, const void* buffer,
|
||||
size_t rowBytes, uint32_t pixelOpsFlags) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_VALUE_IF_ABANDONED(false)
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
RETURN_FALSE_IF_ABANDONED_PRIV
|
||||
SkASSERT(dst);
|
||||
SkASSERT(buffer);
|
||||
ASSERT_OWNED_PROXY(dst->asSurfaceProxy());
|
||||
ASSERT_OWNED_PROXY_PRIV(dst->asSurfaceProxy());
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrContextPriv", "writeSurfacePixels", fContext);
|
||||
|
||||
if (GrColorType::kUnknown == srcColorType) {
|
||||
@ -631,7 +632,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, int left, int top,
|
||||
// giving the drawing manager the chance of skipping the flush (i.e., by passing in the
|
||||
// destination proxy)
|
||||
// TODO: should this policy decision just be moved into the drawing manager?
|
||||
this->flushSurface(caps->preferVRAMUseOverFlushes() ? dstProxy : nullptr);
|
||||
this->flush(caps->preferVRAMUseOverFlushes() ? dstProxy : nullptr);
|
||||
|
||||
return this->getGpu()->writePixels(dstSurface, left, top, width, height, srcColorType, buffer,
|
||||
rowBytes);
|
||||
|
@ -164,18 +164,22 @@ public:
|
||||
const SkImageInfo&, const GrVkDrawableInfo&, const SkSurfaceProps* = nullptr);
|
||||
|
||||
/**
|
||||
* Finalizes all pending reads and writes to the surfaces and also performs an MSAA resolves
|
||||
* if necessary. The GrSurfaceProxy array is treated as a hint. If it is supplied the context
|
||||
* will guarantee that the draws required for those proxies are flushed but it could do more.
|
||||
* If no array is provided then all current work will be flushed.
|
||||
* Call to ensure all drawing to the context has been issued to the
|
||||
* underlying 3D API.
|
||||
* The 'proxy' parameter is a hint. If it is supplied the context will guarantee that
|
||||
* the draws required for that proxy are flushed but it could do more. If no 'proxy' is
|
||||
* provided then all current work will be flushed.
|
||||
*/
|
||||
void flush(GrSurfaceProxy*);
|
||||
|
||||
/**
|
||||
* Finalizes all pending reads and writes to the surface and also performs an MSAA resolve
|
||||
* if necessary.
|
||||
*
|
||||
* It is not necessary to call this before reading the render target via Skia/GrContext.
|
||||
* GrContext will detect when it must perform a resolve before reading pixels back from the
|
||||
* surface or using it as a texture.
|
||||
*/
|
||||
GrSemaphoresSubmitted flushSurfaces(GrSurfaceProxy*[], int numProxies, const GrFlushInfo&);
|
||||
|
||||
/** Version of above that flushes for a single proxy and uses a default GrFlushInfo. */
|
||||
void flushSurface(GrSurfaceProxy*);
|
||||
|
||||
/**
|
||||
|
@ -194,12 +194,9 @@ void GrDrawingManager::freeGpuResources() {
|
||||
}
|
||||
|
||||
// MDB TODO: make use of the 'proxy' parameter.
|
||||
GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxies[],
|
||||
int numProxies,
|
||||
GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxy,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info) {
|
||||
SkASSERT(numProxies >= 0);
|
||||
SkASSERT(!numProxies || proxies);
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("GrDrawingManager", "flush", fContext);
|
||||
|
||||
if (fFlushing || this->wasAbandoned()) {
|
||||
@ -211,14 +208,9 @@ GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxies[],
|
||||
|
||||
SkDEBUGCODE(this->validate());
|
||||
|
||||
if (kNone_GrFlushFlags == info.fFlags && !info.fNumSemaphores && !info.fFinishedProc) {
|
||||
bool canSkip = numProxies > 0;
|
||||
for (int i = 0; i < numProxies && canSkip; ++i) {
|
||||
canSkip = !fDAG.isUsed(proxies[i]) && !this->isDDLTarget(proxies[i]);
|
||||
}
|
||||
if (canSkip) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
if (kNone_GrFlushFlags == info.fFlags && !info.fNumSemaphores && !info.fFinishedProc &&
|
||||
proxy && !this->isDDLTarget(proxy) && !fDAG.isUsed(proxy)) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
auto direct = fContext->priv().asDirectContext();
|
||||
@ -357,7 +349,7 @@ GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxies[],
|
||||
opMemoryPool->isEmpty();
|
||||
#endif
|
||||
|
||||
GrSemaphoresSubmitted result = gpu->finishFlush(proxies, numProxies, access, info);
|
||||
GrSemaphoresSubmitted result = gpu->finishFlush(proxy, access, info);
|
||||
|
||||
flushState.deinstantiateProxyTracker()->deinstantiateAllProxies();
|
||||
|
||||
@ -440,7 +432,7 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt
|
||||
onFlushOpList = nullptr;
|
||||
(*numOpListsExecuted)++;
|
||||
if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) {
|
||||
flushState->gpu()->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
flushState->gpu()->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
GrFlushInfo());
|
||||
*numOpListsExecuted = 0;
|
||||
}
|
||||
@ -458,7 +450,7 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt
|
||||
}
|
||||
(*numOpListsExecuted)++;
|
||||
if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) {
|
||||
flushState->gpu()->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
flushState->gpu()->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
GrFlushInfo());
|
||||
*numOpListsExecuted = 0;
|
||||
}
|
||||
@ -477,15 +469,13 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt
|
||||
return anyOpListsExecuted;
|
||||
}
|
||||
|
||||
GrSemaphoresSubmitted GrDrawingManager::flushSurfaces(GrSurfaceProxy* proxies[], int n,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info) {
|
||||
GrSemaphoresSubmitted GrDrawingManager::flushSurface(
|
||||
GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, const GrFlushInfo& info) {
|
||||
if (this->wasAbandoned()) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
SkDEBUGCODE(this->validate());
|
||||
SkASSERT(proxies);
|
||||
SkASSERT(n > 0);
|
||||
SkASSERT(proxy);
|
||||
|
||||
auto direct = fContext->priv().asDirectContext();
|
||||
if (!direct) {
|
||||
@ -498,25 +488,21 @@ GrSemaphoresSubmitted GrDrawingManager::flushSurfaces(GrSurfaceProxy* proxies[],
|
||||
}
|
||||
|
||||
// TODO: It is important to upgrade the drawingmanager to just flushing the
|
||||
// portion of the DAG required by 'proxies' in order to restore some of the
|
||||
// portion of the DAG required by 'proxy' in order to restore some of the
|
||||
// semantics of this method.
|
||||
GrSemaphoresSubmitted result = this->flush(proxies, n, access, info);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (!proxies[i]->isInstantiated()) {
|
||||
return result;
|
||||
}
|
||||
GrSemaphoresSubmitted result = this->flush(proxy, access, info);
|
||||
if (!proxy->isInstantiated()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
GrSurface* surface = proxies[i]->peekSurface();
|
||||
if (auto* rt = surface->asRenderTarget()) {
|
||||
gpu->resolveRenderTarget(rt);
|
||||
}
|
||||
if (auto* tex = surface->asTexture()) {
|
||||
if (tex->texturePriv().mipMapped() == GrMipMapped::kYes &&
|
||||
tex->texturePriv().mipMapsAreDirty()) {
|
||||
gpu->regenerateMipMapLevels(tex);
|
||||
}
|
||||
GrSurface* surface = proxy->peekSurface();
|
||||
if (auto* rt = surface->asRenderTarget()) {
|
||||
gpu->resolveRenderTarget(rt);
|
||||
}
|
||||
if (auto* tex = surface->asTexture()) {
|
||||
if (tex->texturePriv().mipMapped() == GrMipMapped::kYes &&
|
||||
tex->texturePriv().mipMapsAreDirty()) {
|
||||
gpu->regenerateMipMapLevels(tex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -745,7 +731,7 @@ void GrDrawingManager::flushIfNecessary() {
|
||||
|
||||
auto resourceCache = direct->priv().getResourceCache();
|
||||
if (resourceCache && resourceCache->requestsFlush()) {
|
||||
this->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
|
||||
this->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
|
||||
resourceCache->purgeAsNeeded();
|
||||
}
|
||||
}
|
||||
|
@ -71,15 +71,9 @@ public:
|
||||
|
||||
static bool ProgramUnitTest(GrContext* context, int maxStages, int maxLevels);
|
||||
|
||||
GrSemaphoresSubmitted flushSurfaces(GrSurfaceProxy* proxies[],
|
||||
int cnt,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info);
|
||||
GrSemaphoresSubmitted flushSurface(GrSurfaceProxy* proxy,
|
||||
GrSemaphoresSubmitted flushSurface(GrSurfaceProxy*,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info) {
|
||||
return this->flushSurfaces(&proxy, 1, access, info);
|
||||
}
|
||||
const GrFlushInfo& info);
|
||||
|
||||
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
|
||||
|
||||
@ -153,8 +147,7 @@ private:
|
||||
// return true if any opLists were actually executed; false otherwise
|
||||
bool executeOpLists(int startIndex, int stopIndex, GrOpFlushState*, int* numOpListsExecuted);
|
||||
|
||||
GrSemaphoresSubmitted flush(GrSurfaceProxy* proxies[],
|
||||
int numProxies,
|
||||
GrSemaphoresSubmitted flush(GrSurfaceProxy* proxy,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&);
|
||||
|
||||
|
@ -412,8 +412,7 @@ int GrGpu::findOrAssignSamplePatternKey(GrRenderTarget* renderTarget) {
|
||||
return fSamplePatternDictionary.findOrAssignSamplePatternKey(sampleLocations);
|
||||
}
|
||||
|
||||
GrSemaphoresSubmitted GrGpu::finishFlush(GrSurfaceProxy* proxies[],
|
||||
int n,
|
||||
GrSemaphoresSubmitted GrGpu::finishFlush(GrSurfaceProxy* proxy,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info) {
|
||||
this->stats()->incNumFinishFlushes();
|
||||
@ -437,7 +436,7 @@ GrSemaphoresSubmitted GrGpu::finishFlush(GrSurfaceProxy* proxies[],
|
||||
}
|
||||
}
|
||||
}
|
||||
this->onFinishFlush(proxies, n, access, info);
|
||||
this->onFinishFlush(proxy, access, info);
|
||||
return this->caps()->semaphoreSupport() ? GrSemaphoresSubmitted::kYes
|
||||
: GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
@ -303,8 +303,8 @@ public:
|
||||
// Provides a hook for post-flush actions (e.g. Vulkan command buffer submits). This will also
|
||||
// insert any numSemaphore semaphores on the gpu and set the backendSemaphores to match the
|
||||
// inserted semaphores.
|
||||
GrSemaphoresSubmitted finishFlush(GrSurfaceProxy*[], int n,
|
||||
SkSurface::BackendSurfaceAccess access, const GrFlushInfo&);
|
||||
GrSemaphoresSubmitted finishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&);
|
||||
|
||||
virtual void submit(GrGpuCommandBuffer*) = 0;
|
||||
|
||||
@ -547,7 +547,7 @@ private:
|
||||
const SkIRect& srcRect, const SkIPoint& dstPoint,
|
||||
bool canDiscardOutsideDstRect) = 0;
|
||||
|
||||
virtual void onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
virtual void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&) = 0;
|
||||
|
||||
#ifdef SK_ENABLE_DUMP_GPU
|
||||
|
@ -4274,7 +4274,7 @@ GrGLAttribArrayState* GrGLGpu::HWVertexArrayState::bindInternalVertexArray(GrGLG
|
||||
return attribState;
|
||||
}
|
||||
|
||||
void GrGLGpu::onFinishFlush(GrSurfaceProxy*[], int, SkSurface::BackendSurfaceAccess access,
|
||||
void GrGLGpu::onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info) {
|
||||
// If we inserted semaphores during the flush, we need to call GLFlush.
|
||||
bool insertedSemaphore = info.fNumSemaphores > 0 && this->caps()->semaphoreSupport();
|
||||
|
@ -295,7 +295,7 @@ private:
|
||||
|
||||
void flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle&);
|
||||
|
||||
void onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&) override;
|
||||
|
||||
bool waitSync(GrGLsync, uint64_t timeout, bool flush);
|
||||
|
@ -111,7 +111,7 @@ private:
|
||||
|
||||
void onResolveRenderTarget(GrRenderTarget* target) override { return; }
|
||||
|
||||
void onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info) override {
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
|
@ -184,7 +184,7 @@ private:
|
||||
|
||||
void onResolveRenderTarget(GrRenderTarget* target) override { return; }
|
||||
|
||||
void onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info) override {
|
||||
if (info.fFlags & kSyncCpu_GrFlushFlag) {
|
||||
this->submitCommandBuffer(kForce_SyncQueue);
|
||||
|
@ -1889,25 +1889,21 @@ void GrVkGpu::addImageMemoryBarrier(const GrVkResource* resource,
|
||||
barrier);
|
||||
}
|
||||
|
||||
void GrVkGpu::onFinishFlush(GrSurfaceProxy* proxies[], int n,
|
||||
SkSurface::BackendSurfaceAccess access, const GrFlushInfo& info) {
|
||||
SkASSERT(n >= 0);
|
||||
SkASSERT(!n || proxies);
|
||||
void GrVkGpu::onFinishFlush(GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info) {
|
||||
// Submit the current command buffer to the Queue. Whether we inserted semaphores or not does
|
||||
// not effect what we do here.
|
||||
if (n && access == SkSurface::BackendSurfaceAccess::kPresent) {
|
||||
if (proxy && access == SkSurface::BackendSurfaceAccess::kPresent) {
|
||||
GrVkImage* image;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
SkASSERT(proxies[i]->isInstantiated());
|
||||
if (GrTexture* tex = proxies[i]->peekTexture()) {
|
||||
image = static_cast<GrVkTexture*>(tex);
|
||||
} else {
|
||||
GrRenderTarget* rt = proxies[i]->peekRenderTarget();
|
||||
SkASSERT(rt);
|
||||
image = static_cast<GrVkRenderTarget*>(rt);
|
||||
}
|
||||
image->prepareForPresent(this);
|
||||
SkASSERT(proxy->isInstantiated());
|
||||
if (GrTexture* tex = proxy->peekTexture()) {
|
||||
image = static_cast<GrVkTexture*>(tex);
|
||||
} else {
|
||||
GrRenderTarget* rt = proxy->peekRenderTarget();
|
||||
SkASSERT(rt);
|
||||
image = static_cast<GrVkRenderTarget*>(rt);
|
||||
}
|
||||
image->prepareForPresent(this);
|
||||
}
|
||||
if (info.fFlags & kSyncCpu_GrFlushFlag) {
|
||||
this->submitCommandBuffer(kForce_SyncQueue, info.fFinishedProc, info.fFinishedContext);
|
||||
|
@ -225,7 +225,7 @@ private:
|
||||
GrSurfaceOrigin srcOrigin, const SkIRect& srcRect,
|
||||
const SkIPoint& dstPoint, bool canDiscardOutsideDstRect) override;
|
||||
|
||||
void onFinishFlush(GrSurfaceProxy*[], int, SkSurface::BackendSurfaceAccess access,
|
||||
void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&) override;
|
||||
|
||||
// Ends and submits the current command buffer to the queue and then creates a new command
|
||||
|
@ -160,12 +160,6 @@ bool SkImage::isValid(GrContext* context) const {
|
||||
return as_IB(this)->onIsValid(context);
|
||||
}
|
||||
|
||||
GrSemaphoresSubmitted SkImage::flush(GrContext* context, const GrFlushInfo& flushInfo) {
|
||||
return as_IB(this)->onFlush(context, flushInfo);
|
||||
}
|
||||
|
||||
void SkImage::flush(GrContext* context) { as_IB(this)->onFlush(context, {}); }
|
||||
|
||||
#else
|
||||
|
||||
GrTexture* SkImage::getTexture() const { return nullptr; }
|
||||
@ -184,12 +178,6 @@ bool SkImage::isValid(GrContext* context) const {
|
||||
return as_IB(this)->onIsValid(context);
|
||||
}
|
||||
|
||||
GrSemaphoresSubmitted SkImage::flush(GrContext*, const GrFlushInfo&) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
void SkImage::flush(GrContext*) {}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -48,10 +48,6 @@ public:
|
||||
virtual GrContext* context() const { return nullptr; }
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual GrSemaphoresSubmitted onFlush(GrContext* context, const GrFlushInfo&) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
// Return the proxy if this image is backed by a single proxy. For YUVA images, this
|
||||
// will return nullptr unless the YUVA planes have been converted to RGBA in which case
|
||||
// that single backing proxy will be returned.
|
||||
|
@ -64,15 +64,6 @@ SkImage_Gpu::SkImage_Gpu(sk_sp<GrContext> context, uint32_t uniqueID, SkAlphaTyp
|
||||
|
||||
SkImage_Gpu::~SkImage_Gpu() {}
|
||||
|
||||
GrSemaphoresSubmitted SkImage_Gpu::onFlush(GrContext* context, const GrFlushInfo& info) {
|
||||
if (!context || !fContext->priv().matches(context) || fContext->abandoned()) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
GrSurfaceProxy* p[1] = {fProxy.get()};
|
||||
return context->priv().flushSurfaces(p, 1, info);
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* context,
|
||||
SkColorType targetCT,
|
||||
sk_sp<SkColorSpace> targetCS) const {
|
||||
@ -665,8 +656,7 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrContext* context,
|
||||
|
||||
GrFlushInfo info;
|
||||
info.fFlags = kSyncCpu_GrFlushFlag;
|
||||
GrSurfaceProxy* p[1] = {proxy.get()};
|
||||
drawingManager->flush(p, 1, SkSurface::BackendSurfaceAccess::kNoAccess, info);
|
||||
drawingManager->flush(proxy.get(), SkSurface::BackendSurfaceAccess::kNoAccess, info);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
@ -26,8 +26,6 @@ public:
|
||||
sk_sp<SkColorSpace>);
|
||||
~SkImage_Gpu() override;
|
||||
|
||||
GrSemaphoresSubmitted onFlush(GrContext*, const GrFlushInfo&) override;
|
||||
|
||||
GrTextureProxy* peekProxy() const override {
|
||||
return fProxy.get();
|
||||
}
|
||||
|
@ -103,21 +103,6 @@ bool SkImage_GpuYUVA::setupMipmapsForPlanes(GrRecordingContext* context) const {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrSemaphoresSubmitted SkImage_GpuYUVA::onFlush(GrContext* context, const GrFlushInfo& info) {
|
||||
if (!context || !fContext->priv().matches(context) || fContext->abandoned()) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
GrSurfaceProxy* proxies[5] = {fProxies[0].get(), fProxies[1].get(),
|
||||
fProxies[2].get(), fProxies[3].get(), nullptr};
|
||||
int numProxies = fNumProxies;
|
||||
if (fRGBProxy) {
|
||||
proxies[fNumProxies] = fRGBProxy.get();
|
||||
++numProxies;
|
||||
}
|
||||
return context->priv().flushSurfaces(proxies, numProxies, info);
|
||||
}
|
||||
|
||||
GrTextureProxy* SkImage_GpuYUVA::peekProxy() const {
|
||||
return fRGBProxy.get();
|
||||
}
|
||||
|
@ -29,8 +29,6 @@ public:
|
||||
GrSurfaceOrigin, sk_sp<SkColorSpace>);
|
||||
~SkImage_GpuYUVA() override;
|
||||
|
||||
GrSemaphoresSubmitted onFlush(GrContext*, const GrFlushInfo&) override;
|
||||
|
||||
// This returns the single backing proxy if the YUV channels have already been flattened but
|
||||
// nullptr if they have not.
|
||||
GrTextureProxy* peekProxy() const override;
|
||||
@ -58,8 +56,6 @@ public:
|
||||
// Returns a ref-ed texture proxy with miplevels
|
||||
sk_sp<GrTextureProxy> asMippedTextureProxyRef(GrRecordingContext*) const;
|
||||
|
||||
bool testingOnly_IsFlattened() const { return SkToBool(fRGBProxy); }
|
||||
|
||||
/**
|
||||
* This is the implementation of SkDeferredDisplayListRecorder::makeYUVAPromiseTexture.
|
||||
*/
|
||||
|
@ -313,7 +313,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
||||
GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
|
||||
}
|
||||
// Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes)
|
||||
drawingManager->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
|
||||
drawingManager->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo());
|
||||
|
||||
const GrBackendFormat format =
|
||||
context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
|
||||
@ -342,7 +342,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
||||
auto blockFP = BlockInputFragmentProcessor::Make(std::move(fp));
|
||||
paint.addColorFragmentProcessor(std::move(blockFP));
|
||||
GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
|
||||
drawingManager->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
drawingManager->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
GrFlushInfo());
|
||||
}
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
|
||||
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info);
|
||||
SkCanvas* canvas = surface->getCanvas();
|
||||
|
||||
canvas->clear(SK_ColorGREEN);
|
||||
auto image = surface->makeImageSnapshot();
|
||||
|
||||
// We flush the surface first just to get rid of any discards/clears that got recorded from
|
||||
// making the surface.
|
||||
surface->flush();
|
||||
GrFlushInfo flushInfoSyncCpu;
|
||||
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
|
||||
ctx->flush(flushInfoSyncCpu);
|
||||
@ -78,9 +78,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
|
||||
ctx->flush(flushInfoSyncCpu);
|
||||
REPORTER_ASSERT(reporter, count == 2);
|
||||
|
||||
// Test flushing via the SkImage
|
||||
canvas->drawImage(image, 0, 0);
|
||||
image->flush(ctx, flushInfoFinishedProc);
|
||||
// Test flushing via the GrContext
|
||||
canvas->clear(SK_ColorBLUE);
|
||||
ctx->flush(flushInfoFinishedProc);
|
||||
if (expectAsyncCallback) {
|
||||
// On Vulkan the command buffer we just submitted may or may not have finished immediately
|
||||
// so the finish proc may not have been called.
|
||||
@ -91,23 +91,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
|
||||
ctx->flush(flushInfoSyncCpu);
|
||||
REPORTER_ASSERT(reporter, count == 3);
|
||||
|
||||
// Test flushing via the GrContext
|
||||
canvas->clear(SK_ColorBLUE);
|
||||
ctx->flush(flushInfoFinishedProc);
|
||||
if (expectAsyncCallback) {
|
||||
// On Vulkan the command buffer we just submitted may or may not have finished immediately
|
||||
// so the finish proc may not have been called.
|
||||
REPORTER_ASSERT(reporter, count == 3 || count == 4);
|
||||
} else {
|
||||
REPORTER_ASSERT(reporter, count == 4);
|
||||
}
|
||||
ctx->flush(flushInfoSyncCpu);
|
||||
REPORTER_ASSERT(reporter, count == 4);
|
||||
|
||||
// There is no work on the surface so flushing may immediately call the finished proc.
|
||||
ctx->flush(flushInfoFinishedProc);
|
||||
REPORTER_ASSERT(reporter, count == 4 || count == 5);
|
||||
busy_wait_for_callback(&count, 5, ctx, reporter);
|
||||
REPORTER_ASSERT(reporter, count == 3 || count == 4);
|
||||
busy_wait_for_callback(&count, 4, ctx, reporter);
|
||||
|
||||
count = 0;
|
||||
int count2 = 0;
|
||||
|
@ -20,23 +20,24 @@
|
||||
#include "include/core/SkSerialProcs.h"
|
||||
#include "include/core/SkStream.h"
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "include/gpu/GrContextThreadSafeProxy.h"
|
||||
#include "include/gpu/GrTexture.h"
|
||||
#include "src/core/SkAutoPixmapStorage.h"
|
||||
#include "src/core/SkColorSpacePriv.h"
|
||||
#include "src/core/SkImagePriv.h"
|
||||
#include "src/core/SkMakeUnique.h"
|
||||
#include "src/core/SkUtils.h"
|
||||
#include "src/image/SkImage_Base.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
|
||||
#include "tools/Resources.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
#include "include/gpu/GrContextThreadSafeProxy.h"
|
||||
#include "include/gpu/GrTexture.h"
|
||||
#include "src/gpu/GrContextPriv.h"
|
||||
#include "src/gpu/GrGpu.h"
|
||||
#include "src/gpu/GrResourceCache.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/image/SkImage_Base.h"
|
||||
#include "src/image/SkImage_GpuYUVA.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
#include "tools/Resources.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
using namespace sk_gpu_test;
|
||||
|
||||
@ -1376,76 +1377,3 @@ DEF_TEST(Image_nonfinite_dst, reporter) {
|
||||
}
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
|
||||
auto c = ctxInfo.grContext();
|
||||
auto ii = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||
auto s = SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kYes, ii, 1, nullptr);
|
||||
|
||||
s->getCanvas()->clear(SK_ColorRED);
|
||||
auto i0 = s->makeImageSnapshot();
|
||||
s->getCanvas()->clear(SK_ColorBLUE);
|
||||
auto i1 = s->makeImageSnapshot();
|
||||
s->getCanvas()->clear(SK_ColorGREEN);
|
||||
|
||||
// Make a YUVA image.
|
||||
SkAutoPixmapStorage pm;
|
||||
pm.alloc(SkImageInfo::Make(1, 1, kAlpha_8_SkColorType, kPremul_SkAlphaType));
|
||||
const SkPixmap pmaps[] = {pm, pm, pm, pm};
|
||||
SkYUVAIndex indices[] = {{0, SkColorChannel::kA}, {1, SkColorChannel::kA},
|
||||
{2, SkColorChannel::kA}, {3, SkColorChannel::kA}};
|
||||
auto i2 = SkImage::MakeFromYUVAPixmaps(c, kJPEG_SkYUVColorSpace, pmaps, indices,
|
||||
SkISize::Make(1, 1), kTopLeft_GrSurfaceOrigin, false);
|
||||
|
||||
// Flush all the setup work we did above and then make little lambda that reports the flush
|
||||
// count delta since the last time it was called.
|
||||
c->flush();
|
||||
auto numFlushes = [c, flushCnt = c->priv().getGpu()->stats()->numFinishFlushes()]() mutable {
|
||||
int curr = c->priv().getGpu()->stats()->numFinishFlushes();
|
||||
int n = curr - flushCnt;
|
||||
flushCnt = curr;
|
||||
return n;
|
||||
};
|
||||
|
||||
// Images aren't used therefore flush is ignored.
|
||||
i0->flush(c);
|
||||
i1->flush(c);
|
||||
i2->flush(c);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 0);
|
||||
|
||||
// Syncing forces the flush to happen even if the images aren't used.
|
||||
GrFlushInfo syncInfo;
|
||||
syncInfo.fFlags = kSyncCpu_GrFlushFlag;
|
||||
i0->flush(c, syncInfo);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 1);
|
||||
i1->flush(c, syncInfo);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 1);
|
||||
i2->flush(c, syncInfo);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 1);
|
||||
|
||||
// Use image 1
|
||||
s->getCanvas()->drawImage(i1, 0, 0);
|
||||
// Flushing image 0 should do nothing.
|
||||
i0->flush(c);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 0);
|
||||
// Flushing image 1 should flush.
|
||||
i1->flush(c);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 1);
|
||||
// Flushing image 2 should do nothing.
|
||||
i2->flush(c);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 0);
|
||||
|
||||
// Use image 2
|
||||
s->getCanvas()->drawImage(i2, 0, 0);
|
||||
// Flushing image 0 should do nothing.
|
||||
i0->flush(c);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 0);
|
||||
// Flushing image 1 do nothing.
|
||||
i1->flush(c);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 0);
|
||||
// Flushing image 2 should flush.
|
||||
i2->flush(c);
|
||||
REPORTER_ASSERT(reporter, numFlushes() == 1);
|
||||
// Since we just did a simple image draw it should not have been flattened.
|
||||
REPORTER_ASSERT(reporter,
|
||||
!static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->testingOnly_IsFlattened());
|
||||
}
|
||||
|
@ -104,13 +104,11 @@ void draw_child(skiatest::Reporter* reporter,
|
||||
check_pixels(reporter, bitmap);
|
||||
}
|
||||
|
||||
enum class FlushType { kSurface, kImage, kContext };
|
||||
|
||||
void surface_semaphore_test(skiatest::Reporter* reporter,
|
||||
const sk_gpu_test::ContextInfo& mainInfo,
|
||||
const sk_gpu_test::ContextInfo& childInfo1,
|
||||
const sk_gpu_test::ContextInfo& childInfo2,
|
||||
FlushType flushType) {
|
||||
bool flushContext) {
|
||||
GrContext* mainCtx = mainInfo.grContext();
|
||||
if (!mainCtx->priv().caps()->semaphoreSupport()) {
|
||||
return;
|
||||
@ -123,11 +121,7 @@ void surface_semaphore_test(skiatest::Reporter* reporter,
|
||||
ii, 0, kTopLeft_GrSurfaceOrigin,
|
||||
nullptr));
|
||||
SkCanvas* mainCanvas = mainSurface->getCanvas();
|
||||
auto blueSurface = mainSurface->makeSurface(ii);
|
||||
blueSurface->getCanvas()->clear(SK_ColorBLUE);
|
||||
auto blueImage = blueSurface->makeImageSnapshot();
|
||||
blueSurface.reset();
|
||||
mainCanvas->drawImage(blueImage, 0, 0);
|
||||
mainCanvas->clear(SK_ColorBLUE);
|
||||
|
||||
SkAutoTArray<GrBackendSemaphore> semaphores(2);
|
||||
#ifdef SK_VULKAN
|
||||
@ -152,16 +146,10 @@ void surface_semaphore_test(skiatest::Reporter* reporter,
|
||||
GrFlushInfo info;
|
||||
info.fNumSemaphores = 2;
|
||||
info.fSignalSemaphores = semaphores.get();
|
||||
switch (flushType) {
|
||||
case FlushType::kSurface:
|
||||
mainSurface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, info);
|
||||
break;
|
||||
case FlushType::kImage:
|
||||
blueImage->flush(mainCtx, info);
|
||||
break;
|
||||
case FlushType::kContext:
|
||||
mainCtx->flush(info);
|
||||
break;
|
||||
if (flushContext) {
|
||||
mainCtx->flush(info);
|
||||
} else {
|
||||
mainSurface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, info);
|
||||
}
|
||||
|
||||
sk_sp<SkImage> mainImage = mainSurface->makeImageSnapshot();
|
||||
@ -191,7 +179,7 @@ DEF_GPUTEST(SurfaceSemaphores, reporter, options) {
|
||||
#endif
|
||||
|
||||
for (int typeInt = 0; typeInt < sk_gpu_test::GrContextFactory::kContextTypeCnt; ++typeInt) {
|
||||
for (auto flushType : {FlushType::kSurface, FlushType::kImage, FlushType::kContext}) {
|
||||
for (auto flushContext : { false, true }) {
|
||||
sk_gpu_test::GrContextFactory::ContextType contextType =
|
||||
(sk_gpu_test::GrContextFactory::ContextType) typeInt;
|
||||
// Use "native" instead of explicitly trying OpenGL and OpenGL ES. Do not use GLES on
|
||||
@ -219,7 +207,7 @@ DEF_GPUTEST(SurfaceSemaphores, reporter, options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
surface_semaphore_test(reporter, ctxInfo, child1, child2, flushType);
|
||||
surface_semaphore_test(reporter, ctxInfo, child1, child2, flushContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C
|
||||
GrFlushInfo flushInfo;
|
||||
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
|
||||
if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
|
||||
gpu->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
|
||||
gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
|
||||
}
|
||||
|
||||
const auto* map = reinterpret_cast<const GrColor*>(buffer->map());
|
||||
@ -304,7 +304,7 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C
|
||||
++expectedTransferCnt;
|
||||
|
||||
if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
|
||||
gpu->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
|
||||
gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
|
||||
}
|
||||
|
||||
map = reinterpret_cast<const GrColor*>(buffer->map());
|
||||
|
Loading…
Reference in New Issue
Block a user