Disable some code to handle Metal TSAN errors.
This is a temporary fix until I can figure out where these errors are coming from. Bug: skia:9213 Change-Id: Iac21415bf26f39f5237e12ec146769252e833d36 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223981 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
205224fbd5
commit
ccd895e16d
@ -381,7 +381,7 @@ GrMtlPipelineState* GrMtlPipelineStateBuilder::finalize(GrRenderTarget* renderTa
|
||||
SkASSERT(pipelineDescriptor.vertexDescriptor);
|
||||
SkASSERT(pipelineDescriptor.colorAttachments[0]);
|
||||
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
#if defined(SK_BUILD_FOR_MAC) && defined(GR_USE_COMPLETION_HANDLER)
|
||||
bool timedout;
|
||||
id<MTLRenderPipelineState> pipelineState = GrMtlNewRenderPipelineStateWithDescriptor(
|
||||
fGpu->device(), pipelineDescriptor, &timedout);
|
||||
|
@ -106,6 +106,12 @@ private:
|
||||
size_t fTail; // where we start deallocating
|
||||
SkSpinlock fMutex;
|
||||
};
|
||||
static constexpr size_t kBufferSuballocatorStartSize = 1024*1024;
|
||||
#if GR_USE_COMPLETION_HANDLER
|
||||
static constexpr size_t kBufferSuballocatorMaxSize = 8*1024*1024;
|
||||
#else
|
||||
static constexpr size_t kBufferSuballocatorMaxSize = 2*1024*1024;
|
||||
#endif
|
||||
|
||||
GrMtlGpu* fGpu;
|
||||
|
||||
|
@ -21,7 +21,11 @@
|
||||
GrMtlResourceProvider::GrMtlResourceProvider(GrMtlGpu* gpu)
|
||||
: fGpu(gpu) {
|
||||
fPipelineStateCache.reset(new PipelineStateCache(gpu));
|
||||
fBufferSuballocator.reset(new BufferSuballocator(gpu->device(), 512*1024));
|
||||
#ifdef USE_COMPLETION_HANDLER
|
||||
fBufferSuballocator.reset(new BufferSuballocator(gpu->device(), kBufferSuballocatorStartSize));
|
||||
#else
|
||||
fBufferSuballocator.reset(new BufferSuballocator(gpu->device(), kBufferSuballocatorMaxSize));
|
||||
#endif
|
||||
}
|
||||
|
||||
GrMtlPipelineState* GrMtlResourceProvider::findOrCreateCompatiblePipelineState(
|
||||
@ -242,26 +246,25 @@ id<MTLBuffer> GrMtlResourceProvider::BufferSuballocator::getAllocation(size_t si
|
||||
void GrMtlResourceProvider::BufferSuballocator::addCompletionHandler(
|
||||
GrMtlCommandBuffer* cmdBuffer) {
|
||||
this->ref();
|
||||
__block size_t newTail = fHead;
|
||||
size_t newTail = fHead;
|
||||
cmdBuffer->addCompletedHandler(^(id <MTLCommandBuffer>commandBuffer) {
|
||||
// Make sure SkAutoSpinlock goes out of scope before
|
||||
// the BufferSuballocator is potentially deleted.
|
||||
{
|
||||
SkAutoSpinlock lock(this->fMutex);
|
||||
this->fTail = newTail;
|
||||
SkAutoSpinlock lock(fMutex);
|
||||
fTail = newTail;
|
||||
}
|
||||
this->unref();
|
||||
});
|
||||
}
|
||||
|
||||
id<MTLBuffer> GrMtlResourceProvider::getDynamicBuffer(size_t size, size_t* offset) {
|
||||
static size_t kMaxDynamicBufferAllocationSize = 8*1024*1024;
|
||||
|
||||
id<MTLBuffer> buffer = fBufferSuballocator->getAllocation(size, offset);
|
||||
if (buffer) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#ifdef GR_USE_COMPLETION_HANDLER
|
||||
// Try to grow allocation (old allocation will age out).
|
||||
// We grow up to a maximum size, and only grow if the requested allocation will
|
||||
// fit into half of the new buffer (to prevent very large transient buffers forcing
|
||||
@ -275,11 +278,24 @@ id<MTLBuffer> GrMtlResourceProvider::getDynamicBuffer(size_t size, size_t* offse
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// For now, just create a new buffer on failure if requested alloc small enough
|
||||
if (size <= kBufferSuballocatorMaxSize/2) {
|
||||
fBufferSuballocator.reset(new BufferSuballocator(fGpu->device(),
|
||||
kBufferSuballocatorMaxSize));
|
||||
id<MTLBuffer> buffer = fBufferSuballocator->getAllocation(size, offset);
|
||||
if (buffer) {
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
*offset = 0;
|
||||
return alloc_dynamic_buffer(fGpu->device(), size);
|
||||
}
|
||||
|
||||
void GrMtlResourceProvider::addBufferCompletionHandler(GrMtlCommandBuffer* cmdBuffer) {
|
||||
#ifdef GR_USE_COMPLETION_HANDLER
|
||||
fBufferSuballocator->addCompletionHandler(cmdBuffer);
|
||||
#endif
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ id<MTLLibrary> GrCompileMtlShaderLibrary(const GrMtlGpu* gpu,
|
||||
#endif
|
||||
|
||||
MTLCompileOptions* defaultOptions = [[MTLCompileOptions alloc] init];
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
#if defined(SK_BUILD_FOR_MAC) && defined(GR_USE_COMPLETION_HANDLER)
|
||||
bool timedout;
|
||||
id<MTLLibrary> compiledLibrary = GrMtlNewLibraryWithSource(gpu->device(), mtlCode,
|
||||
defaultOptions, &timedout);
|
||||
|
Loading…
Reference in New Issue
Block a user