Store command buffer usages to GrSurface's on GrVkCommandBuffer.
Bug: skia:11038 Change-Id: I3a862ae7620a6453a6c0b1b45b97868bf6abf73f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/342918 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
4b6f54aaa5
commit
609e1a9293
@ -37,7 +37,7 @@ private:
|
||||
*/
|
||||
void release() {
|
||||
fResource->release();
|
||||
if (!fResource->hasRef()) {
|
||||
if (!fResource->hasRef() && fResource->hasNoCommandBufferUsages()) {
|
||||
delete fResource;
|
||||
}
|
||||
}
|
||||
@ -47,7 +47,7 @@ private:
|
||||
*/
|
||||
void abandon() {
|
||||
fResource->abandon();
|
||||
if (!fResource->hasRef()) {
|
||||
if (!fResource->hasRef() && fResource->hasNoCommandBufferUsages()) {
|
||||
delete fResource;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,9 @@ public:
|
||||
|
||||
bool isPurgeable() const { return fResource->isPurgeable(); }
|
||||
|
||||
bool hasRef() const { return fResource->hasRef(); }
|
||||
bool hasRefOrCommandBufferUsage() const {
|
||||
return fResource->hasRef() || !fResource->hasNoCommandBufferUsages();
|
||||
}
|
||||
|
||||
protected:
|
||||
ResourcePriv(GrGpuResource* resource) : fResource(resource) { }
|
||||
|
@ -38,7 +38,7 @@ void GrTextureResource::notifyFinishedWithWorkOnGpu() const {
|
||||
return;
|
||||
}
|
||||
if (fOwningTexture) {
|
||||
if (fOwningTexture->resourcePriv().hasRef()) {
|
||||
if (fOwningTexture->resourcePriv().hasRefOrCommandBufferUsage()) {
|
||||
// Wait for the texture to become idle in the cache to call the procs.
|
||||
return;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ void GrVkCommandBuffer::freeGPUData(const GrGpu* gpu, VkCommandPool cmdPool) con
|
||||
SkASSERT(!fTrackedResources.count());
|
||||
SkASSERT(!fTrackedRecycledResources.count());
|
||||
SkASSERT(!fTrackedGpuBuffers.count());
|
||||
SkASSERT(!fTrackedGpuSurfaces.count());
|
||||
SkASSERT(cmdPool != VK_NULL_HANDLE);
|
||||
SkASSERT(!this->isWrapped());
|
||||
|
||||
@ -78,6 +79,7 @@ void GrVkCommandBuffer::releaseResources() {
|
||||
}
|
||||
|
||||
fTrackedGpuBuffers.reset();
|
||||
fTrackedGpuSurfaces.reset();
|
||||
|
||||
this->invalidateState();
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define GrVkCommandBuffer_DEFINED
|
||||
|
||||
#include "include/gpu/vk/GrVkTypes.h"
|
||||
#include "src/gpu/GrCommandBufferRef.h"
|
||||
#include "src/gpu/GrManagedResource.h"
|
||||
#include "src/gpu/vk/GrVkGpu.h"
|
||||
#include "src/gpu/vk/GrVkSemaphore.h"
|
||||
@ -125,6 +126,10 @@ public:
|
||||
fTrackedGpuBuffers.push_back(std::move(buffer));
|
||||
}
|
||||
|
||||
void addGrSurface(sk_sp<const GrSurface> surface) {
|
||||
fTrackedGpuSurfaces.push_back(std::move(surface));
|
||||
}
|
||||
|
||||
void releaseResources();
|
||||
|
||||
void freeGPUData(const GrGpu* gpu, VkCommandPool pool) const;
|
||||
@ -146,9 +151,10 @@ protected:
|
||||
|
||||
void submitPipelineBarriers(const GrVkGpu* gpu, bool forSelfDependency = false);
|
||||
|
||||
SkTDArray<const GrManagedResource*> fTrackedResources;
|
||||
SkTDArray<const GrRecycledResource*> fTrackedRecycledResources;
|
||||
SkSTArray<16, sk_sp<const GrBuffer>> fTrackedGpuBuffers;
|
||||
SkTDArray<const GrManagedResource*> fTrackedResources;
|
||||
SkTDArray<const GrRecycledResource*> fTrackedRecycledResources;
|
||||
SkSTArray<16, sk_sp<const GrBuffer>> fTrackedGpuBuffers;
|
||||
SkSTArray<16, gr_cb<const GrSurface>> fTrackedGpuSurfaces;
|
||||
|
||||
// Tracks whether we are in the middle of a command buffer begin/end calls and thus can add
|
||||
// new commands to the buffer;
|
||||
|
@ -660,7 +660,8 @@ void GrVkGpu::resolveImage(GrSurface* dst, GrVkRenderTarget* src, const SkIRect&
|
||||
VK_ACCESS_TRANSFER_READ_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
false);
|
||||
|
||||
this->currentCommandBuffer()->addGrSurface(sk_ref_sp<const GrSurface>(src));
|
||||
this->currentCommandBuffer()->addGrSurface(sk_ref_sp<const GrSurface>(dst));
|
||||
this->currentCommandBuffer()->resolveImage(this, *src->msaaImage(), *dstImage, 1, &resolveInfo);
|
||||
}
|
||||
|
||||
@ -1710,6 +1711,7 @@ bool GrVkGpu::onUpdateBackendTexture(const GrBackendTexture& backendTexture,
|
||||
backendTexture.fMipmapped, data->color());
|
||||
}
|
||||
|
||||
cmdBuffer->addGrSurface(texture);
|
||||
cmdBuffer->copyBufferToImage(this, static_cast<GrVkTransferBuffer*>(slice.fBuffer),
|
||||
texture.get(), texture->currentLayout(), regions.count(),
|
||||
regions.begin());
|
||||
@ -2195,6 +2197,8 @@ void GrVkGpu::copySurfaceAsCopyImage(GrSurface* dst, GrSurface* src, GrVkImage*
|
||||
copyRegion.dstOffset = { dstPoint.fX, dstPoint.fY, 0 };
|
||||
copyRegion.extent = { (uint32_t)srcRect.width(), (uint32_t)srcRect.height(), 1 };
|
||||
|
||||
this->currentCommandBuffer()->addGrSurface(sk_ref_sp<const GrSurface>(src));
|
||||
this->currentCommandBuffer()->addGrSurface(sk_ref_sp<const GrSurface>(dst));
|
||||
this->currentCommandBuffer()->copyImage(this,
|
||||
srcImage,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
@ -2259,6 +2263,8 @@ void GrVkGpu::copySurfaceAsBlit(GrSurface* dst, GrSurface* src, GrVkImage* dstIm
|
||||
blitRegion.dstOffsets[0] = { dstRect.fLeft, dstRect.fTop, 0 };
|
||||
blitRegion.dstOffsets[1] = { dstRect.fRight, dstRect.fBottom, 1 };
|
||||
|
||||
this->currentCommandBuffer()->addGrSurface(sk_ref_sp<const GrSurface>(src));
|
||||
this->currentCommandBuffer()->addGrSurface(sk_ref_sp<const GrSurface>(dst));
|
||||
this->currentCommandBuffer()->blitImage(this,
|
||||
*srcImage,
|
||||
*dstImage,
|
||||
|
@ -147,6 +147,7 @@ bool GrVkPipelineState::setAndBindTextures(GrVkGpu* gpu,
|
||||
const auto& samplerState = samplerBindings[0].fState;
|
||||
const GrVkDescriptorSet* descriptorSet = texture->cachedSingleDescSet(samplerState);
|
||||
if (descriptorSet) {
|
||||
commandBuffer->addGrSurface(sk_ref_sp<const GrSurface>(texture));
|
||||
commandBuffer->addResource(texture->textureView());
|
||||
commandBuffer->addResource(texture->resource());
|
||||
commandBuffer->addRecycledResource(descriptorSet);
|
||||
|
@ -452,6 +452,7 @@ GrVkRenderTarget::~GrVkRenderTarget() {
|
||||
void GrVkRenderTarget::addResources(GrVkCommandBuffer& commandBuffer,
|
||||
bool withStencil,
|
||||
SelfDependencyFlags selfDepFlags) {
|
||||
commandBuffer.addGrSurface(sk_ref_sp<const GrSurface>(this));
|
||||
commandBuffer.addResource(this->getFramebuffer(withStencil, selfDepFlags));
|
||||
commandBuffer.addResource(this->colorAttachmentView());
|
||||
commandBuffer.addResource(fMSAAAttachment ? fMSAAAttachment->resource() : this->resource());
|
||||
|
Loading…
Reference in New Issue
Block a user