Revert "Metal: Add labels and debug groups to help with GPU Debugging."
This reverts commit 9e583bfa3f
.
Reason for revert: breaking flutter, needs available checks
Original change's description:
> Metal: Add labels and debug groups to help with GPU Debugging.
>
> * Adds SK_ENABLE_MTL_DEBUG_INFO to enable labels and debug groups,
> dependent on skia_enable_gpu_debug_layers.
>
> Bug: skia:12150
> Change-Id: I5b4538c0f6df6ceed72d7e8e6f1952fd193b7b90
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/422756
> Commit-Queue: Jim Van Verth <jvanverth@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,jvanverth@google.com,chinmaygarde@google.com
Change-Id: I62deacb3527dc709fa8bb8c9f4631e523eae27f0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12150
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423816
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
11dd57aeb7
commit
34b52bf634
3
BUILD.gn
3
BUILD.gn
@ -1027,9 +1027,6 @@ optional("gpu") {
|
||||
if (skia_use_metal) {
|
||||
public_defines += [ "SK_METAL" ]
|
||||
sources += skia_metal_sources
|
||||
if (skia_enable_metal_debug_info) {
|
||||
public_defines += [ "SK_ENABLE_MTL_DEBUG_INFO" ]
|
||||
}
|
||||
frameworks += [ "Metal.framework" ]
|
||||
frameworks += [ "Foundation.framework" ]
|
||||
cflags_objcc += [ "-fobjc-arc" ]
|
||||
|
@ -115,7 +115,6 @@ declare_args() {
|
||||
skia_use_sfntly = skia_use_icu
|
||||
skia_enable_vulkan_debug_layers = skia_enable_gpu_debug_layers
|
||||
skia_enable_direct3d_debug_layer = skia_enable_gpu_debug_layers
|
||||
skia_enable_metal_debug_info = skia_enable_gpu_debug_layers
|
||||
skia_use_vma = skia_use_vulkan
|
||||
}
|
||||
|
||||
|
@ -42,13 +42,9 @@ sk_sp<GrMtlAttachment> GrMtlAttachment::MakeStencil(GrMtlGpu* gpu,
|
||||
if (sampleCnt > 1) {
|
||||
desc.textureType = MTLTextureType2DMultisample;
|
||||
}
|
||||
id<MTLTexture> stencilTexture = [gpu->device() newTextureWithDescriptor:desc];
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
stencilTexture.label = @"Stencil";
|
||||
#endif
|
||||
return sk_sp<GrMtlAttachment>(
|
||||
new GrMtlAttachment(gpu, dimensions, UsageFlags::kStencilAttachment,
|
||||
stencilTexture));
|
||||
[gpu->device() newTextureWithDescriptor:desc]));
|
||||
}
|
||||
|
||||
GrMtlAttachment::~GrMtlAttachment() {
|
||||
|
@ -23,17 +23,6 @@
|
||||
|
||||
GR_NORETAIN_BEGIN
|
||||
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
NSString* kBufferTypeNames[kGrGpuBufferTypeCount] = {
|
||||
@"Vertex",
|
||||
@"Index",
|
||||
@"Indirect",
|
||||
@"Xfer CPU to GPU",
|
||||
@"Xfer GPU to CPU",
|
||||
@"Uniform",
|
||||
};
|
||||
#endif
|
||||
|
||||
sk_sp<GrMtlBuffer> GrMtlBuffer::Make(GrMtlGpu* gpu, size_t size, GrGpuBufferType intendedType,
|
||||
GrAccessPattern accessPattern, const void* data) {
|
||||
sk_sp<GrMtlBuffer> buffer(new GrMtlBuffer(gpu, size, intendedType, accessPattern));
|
||||
@ -68,9 +57,6 @@ GrMtlBuffer::GrMtlBuffer(GrMtlGpu* gpu, size_t size, GrGpuBufferType intendedTyp
|
||||
fMtlBuffer = size == 0 ? nil :
|
||||
[gpu->device() newBufferWithLength: size
|
||||
options: options];
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
fMtlBuffer.label = kBufferTypeNames[(int)intendedType];
|
||||
#endif
|
||||
this->registerWithCache(SkBudgeted::kYes);
|
||||
VALIDATE();
|
||||
}
|
||||
@ -208,8 +194,7 @@ void GrMtlBuffer::validate() const {
|
||||
this->intendedType() == GrGpuBufferType::kIndex ||
|
||||
this->intendedType() == GrGpuBufferType::kXferCpuToGpu ||
|
||||
this->intendedType() == GrGpuBufferType::kXferGpuToCpu ||
|
||||
this->intendedType() == GrGpuBufferType::kDrawIndirect ||
|
||||
this->intendedType() == GrGpuBufferType::kUniform);
|
||||
this->intendedType() == GrGpuBufferType::kDrawIndirect);
|
||||
SkASSERT(fMappedBuffer == nil || fMtlBuffer == nil ||
|
||||
fMappedBuffer.length <= fMtlBuffer.length);
|
||||
}
|
||||
|
@ -60,14 +60,6 @@ public:
|
||||
}
|
||||
void callFinishedCallbacks() { fFinishedCallbacks.reset(); }
|
||||
|
||||
void pushDebugGroup(NSString* string) {
|
||||
[fCmdBuffer pushDebugGroup:string];
|
||||
}
|
||||
|
||||
void popDebugGroup() {
|
||||
[fCmdBuffer popDebugGroup];
|
||||
}
|
||||
|
||||
private:
|
||||
static const int kInitialTrackedResourcesCount = 32;
|
||||
|
||||
|
@ -25,9 +25,7 @@ sk_sp<GrMtlCommandBuffer> GrMtlCommandBuffer::Make(id<MTLCommandQueue> queue) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
mtlCommandBuffer.label = @"GrMtlCommandBuffer::Make";
|
||||
#endif
|
||||
mtlCommandBuffer.label = @"GrMtlCommandBuffer::Create";
|
||||
|
||||
return sk_sp<GrMtlCommandBuffer>(new GrMtlCommandBuffer(mtlCommandBuffer));
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ GrMtlGpu::GrMtlGpu(GrDirectContext* direct, const GrContextOptions& options,
|
||||
, fOutstandingCommandBuffers(sizeof(OutstandingCommandBuffer), kDefaultOutstandingAllocCnt)
|
||||
, fResourceProvider(this)
|
||||
, fStagingBufferManager(this)
|
||||
, fUniformsRingBuffer(this, 128 * 1024, 256, GrGpuBufferType::kUniform)
|
||||
, fUniformsRingBuffer(this, 128 * 1024, 256, GrGpuBufferType::kVertex)
|
||||
, fDisconnected(false) {
|
||||
fMtlCaps.reset(new GrMtlCaps(options, fDevice, featureSet));
|
||||
this->initCapsAndCompiler(fMtlCaps);
|
||||
@ -413,9 +413,6 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex,
|
||||
|
||||
auto cmdBuffer = this->commandBuffer();
|
||||
id<MTLBlitCommandEncoder> GR_NORETAIN blitCmdEncoder = cmdBuffer->getBlitCommandEncoder();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder pushDebugGroup:@"uploadToTexture"];
|
||||
#endif
|
||||
for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; currentMipLevel++) {
|
||||
if (texels[currentMipLevel].fPixels) {
|
||||
SkASSERT(1 == mipLevelCount || currentHeight == layerHeight);
|
||||
@ -444,9 +441,6 @@ bool GrMtlGpu::uploadToTexture(GrMtlTexture* tex,
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
[mtlBuffer->mtlBuffer() didModifyRange: NSMakeRange(slice.fOffset, combinedBufferSize)];
|
||||
#endif
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder popDebugGroup];
|
||||
#endif
|
||||
|
||||
if (mipLevelCount < (int) tex->mtlTexture().mipmapLevelCount) {
|
||||
tex->markMipmapsDirty();
|
||||
@ -493,25 +487,25 @@ bool GrMtlGpu::clearTexture(GrMtlTexture* tex, size_t bpp, uint32_t levelMask) {
|
||||
}
|
||||
SkASSERT(combinedBufferSize > 0 && !individualMipOffsets.empty());
|
||||
|
||||
// TODO: Create GrMtlTransferBuffer
|
||||
NSUInteger options = 0;
|
||||
if (@available(macOS 10.11, iOS 9.0, *)) {
|
||||
options |= MTLResourceStorageModePrivate;
|
||||
}
|
||||
id<MTLBuffer> transferBuffer = [fDevice newBufferWithLength: combinedBufferSize
|
||||
options: options];
|
||||
if (nil == transferBuffer) {
|
||||
return false;
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
static const size_t kMinAlignment = 4;
|
||||
#else
|
||||
static const size_t kMinAlignment = 1;
|
||||
#endif
|
||||
size_t alignment = std::max(bpp, kMinAlignment);
|
||||
GrStagingBufferManager::Slice slice = fStagingBufferManager.allocateStagingBufferSlice(
|
||||
combinedBufferSize, alignment);
|
||||
if (!slice.fBuffer) {
|
||||
return nullptr;
|
||||
}
|
||||
GrMtlBuffer* mtlBuffer = static_cast<GrMtlBuffer*>(slice.fBuffer);
|
||||
id<MTLBuffer> transferBuffer = mtlBuffer->mtlBuffer();
|
||||
|
||||
auto cmdBuffer = this->commandBuffer();
|
||||
id<MTLBlitCommandEncoder> GR_NORETAIN blitCmdEncoder = cmdBuffer->getBlitCommandEncoder();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder pushDebugGroup:@"clearTexture"];
|
||||
#endif
|
||||
// clear the buffer to transparent black
|
||||
NSRange clearRange;
|
||||
clearRange.location = 0;
|
||||
clearRange.location = slice.fOffset;
|
||||
clearRange.length = combinedBufferSize;
|
||||
[blitCmdEncoder fillBuffer: transferBuffer
|
||||
range: clearRange
|
||||
@ -526,7 +520,7 @@ bool GrMtlGpu::clearTexture(GrMtlTexture* tex, size_t bpp, uint32_t levelMask) {
|
||||
const size_t rowBytes = currentWidth * bpp;
|
||||
|
||||
[blitCmdEncoder copyFromBuffer: transferBuffer
|
||||
sourceOffset: individualMipOffsets[currentMipLevel]
|
||||
sourceOffset: slice.fOffset + individualMipOffsets[currentMipLevel]
|
||||
sourceBytesPerRow: rowBytes
|
||||
sourceBytesPerImage: rowBytes * currentHeight
|
||||
sourceSize: MTLSizeMake(currentWidth, currentHeight, 1)
|
||||
@ -539,9 +533,6 @@ bool GrMtlGpu::clearTexture(GrMtlTexture* tex, size_t bpp, uint32_t levelMask) {
|
||||
currentHeight = std::max(1, currentHeight/2);
|
||||
}
|
||||
// Don't need didModifyRange: here because fillBuffer: happens on the GPU
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder popDebugGroup];
|
||||
#endif
|
||||
|
||||
if (mipLevelCount < (int) tex->mtlTexture().mipmapLevelCount) {
|
||||
tex->markMipmapsDirty();
|
||||
@ -701,9 +692,6 @@ sk_sp<GrTexture> GrMtlGpu::onCreateCompressedTexture(SkISize dimensions,
|
||||
|
||||
auto cmdBuffer = this->commandBuffer();
|
||||
id<MTLBlitCommandEncoder> GR_NORETAIN blitCmdEncoder = cmdBuffer->getBlitCommandEncoder();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder pushDebugGroup:@"onCreateCompressedTexture"];
|
||||
#endif
|
||||
|
||||
// copy data into the buffer, skipping any trailing bytes
|
||||
memcpy(bufferData, data, dataSize);
|
||||
@ -731,9 +719,6 @@ sk_sp<GrTexture> GrMtlGpu::onCreateCompressedTexture(SkISize dimensions,
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
[mtlBuffer->mtlBuffer() didModifyRange: NSMakeRange(slice.fOffset, dataSize)];
|
||||
#endif
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder popDebugGroup];
|
||||
#endif
|
||||
|
||||
return std::move(tex);
|
||||
}
|
||||
@ -943,9 +928,6 @@ bool GrMtlGpu::createMtlTextureForBackendSurface(MTLPixelFormat mtlFormat,
|
||||
desc.textureType = MTLTextureType2DMultisample;
|
||||
}
|
||||
id<MTLTexture> testTexture = [fDevice newTextureWithDescriptor: desc];
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
testTexture.label = @"testTexture";
|
||||
#endif
|
||||
info->fTexture.reset(GrRetainPtrFromId(testTexture));
|
||||
return true;
|
||||
}
|
||||
@ -1013,9 +995,6 @@ bool GrMtlGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
|
||||
|
||||
GrMtlCommandBuffer* cmdBuffer = this->commandBuffer();
|
||||
id<MTLBlitCommandEncoder> GR_NORETAIN blitCmdEncoder = cmdBuffer->getBlitCommandEncoder();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder pushDebugGroup:@"onClearBackendTexture"];
|
||||
#endif
|
||||
GrMtlBuffer* mtlBuffer = static_cast<GrMtlBuffer*>(slice.fBuffer);
|
||||
|
||||
SkISize levelDimensions(backendTexture.dimensions());
|
||||
@ -1046,7 +1025,6 @@ bool GrMtlGpu::onClearBackendTexture(const GrBackendTexture& backendTexture,
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
[mtlBuffer->mtlBuffer() didModifyRange: NSMakeRange(slice.fOffset, combinedBufferSize)];
|
||||
#endif
|
||||
[blitCmdEncoder popDebugGroup];
|
||||
|
||||
if (finishedCallback) {
|
||||
this->addFinishedCallback(std::move(finishedCallback));
|
||||
@ -1114,9 +1092,6 @@ bool GrMtlGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendT
|
||||
|
||||
GrMtlCommandBuffer* cmdBuffer = this->commandBuffer();
|
||||
id<MTLBlitCommandEncoder> blitCmdEncoder = cmdBuffer->getBlitCommandEncoder();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder pushDebugGroup:@"onUpdateCompressedBackendTexture"];
|
||||
#endif
|
||||
GrMtlBuffer* mtlBuffer = static_cast<GrMtlBuffer*>(slice.fBuffer);
|
||||
|
||||
SkISize levelDimensions(backendTexture.dimensions());
|
||||
@ -1146,7 +1121,6 @@ bool GrMtlGpu::onUpdateCompressedBackendTexture(const GrBackendTexture& backendT
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
[mtlBuffer->mtlBuffer() didModifyRange:NSMakeRange(slice.fOffset, combinedBufferSize)];
|
||||
#endif
|
||||
[blitCmdEncoder popDebugGroup];
|
||||
|
||||
if (finishedCallback) {
|
||||
this->addFinishedCallback(std::move(finishedCallback));
|
||||
@ -1261,9 +1235,6 @@ void GrMtlGpu::copySurfaceAsBlit(GrSurface* dst, GrSurface* src, const SkIRect&
|
||||
|
||||
auto cmdBuffer = this->commandBuffer();
|
||||
id<MTLBlitCommandEncoder> GR_NORETAIN blitCmdEncoder = cmdBuffer->getBlitCommandEncoder();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder pushDebugGroup:@"copySurfaceAsBlit"];
|
||||
#endif
|
||||
[blitCmdEncoder copyFromTexture: srcTex
|
||||
sourceSlice: 0
|
||||
sourceLevel: 0
|
||||
@ -1273,9 +1244,6 @@ void GrMtlGpu::copySurfaceAsBlit(GrSurface* dst, GrSurface* src, const SkIRect&
|
||||
destinationSlice: 0
|
||||
destinationLevel: 0
|
||||
destinationOrigin: MTLOriginMake(dstPoint.fX, dstPoint.fY, 0)];
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder popDebugGroup];
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GrMtlGpu::onCopySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
|
||||
@ -1415,9 +1383,6 @@ bool GrMtlGpu::onTransferPixelsTo(GrTexture* texture,
|
||||
|
||||
auto cmdBuffer = this->commandBuffer();
|
||||
id<MTLBlitCommandEncoder> GR_NORETAIN blitCmdEncoder = cmdBuffer->getBlitCommandEncoder();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder pushDebugGroup:@"onTransferPixelsTo"];
|
||||
#endif
|
||||
[blitCmdEncoder copyFromBuffer: mtlBuffer
|
||||
sourceOffset: offset + grMtlBuffer->offset()
|
||||
sourceBytesPerRow: rowBytes
|
||||
@ -1427,9 +1392,6 @@ bool GrMtlGpu::onTransferPixelsTo(GrTexture* texture,
|
||||
destinationSlice: 0
|
||||
destinationLevel: 0
|
||||
destinationOrigin: origin];
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder popDebugGroup];
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1499,9 +1461,6 @@ bool GrMtlGpu::readOrTransferPixels(GrSurface* surface,
|
||||
|
||||
auto cmdBuffer = this->commandBuffer();
|
||||
id<MTLBlitCommandEncoder> GR_NORETAIN blitCmdEncoder = cmdBuffer->getBlitCommandEncoder();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder pushDebugGroup:@"readOrTransferPixels"];
|
||||
#endif
|
||||
[blitCmdEncoder copyFromTexture: mtlTexture
|
||||
sourceSlice: 0
|
||||
sourceLevel: 0
|
||||
@ -1515,9 +1474,6 @@ bool GrMtlGpu::readOrTransferPixels(GrSurface* surface,
|
||||
// Sync GPU data back to the CPU
|
||||
[blitCmdEncoder synchronizeResource: transferBuffer];
|
||||
#endif
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
[blitCmdEncoder popDebugGroup];
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -74,9 +74,6 @@ private:
|
||||
MTLRenderPassDescriptor* fRenderPassDesc;
|
||||
SkRect fBounds;
|
||||
size_t fCurrentVertexStride;
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
bool fDebugGroupActive = false;
|
||||
#endif
|
||||
|
||||
static constexpr size_t kNumBindings = GrMtlUniformHandler::kUniformBindingCount + 2;
|
||||
struct {
|
||||
|
@ -94,12 +94,6 @@ bool GrMtlOpsRenderPass::onBindPipeline(const GrProgramInfo& programInfo,
|
||||
}
|
||||
|
||||
fActiveRenderCmdEncoder->setRenderPipelineState(fActivePipelineState->mtlPipelineState());
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
if (!fDebugGroupActive) {
|
||||
fActiveRenderCmdEncoder->pushDebugGroup(@"bindAndDraw");
|
||||
fDebugGroupActive = true;
|
||||
}
|
||||
#endif
|
||||
fActivePipelineState->setDrawState(fActiveRenderCmdEncoder,
|
||||
programInfo.pipeline().writeSwizzle(),
|
||||
programInfo.pipeline().getXferProcessor());
|
||||
@ -134,12 +128,6 @@ bool GrMtlOpsRenderPass::onBindTextures(const GrGeometryProcessor& geomProc,
|
||||
const GrPipeline& pipeline) {
|
||||
SkASSERT(fActivePipelineState);
|
||||
SkASSERT(fActiveRenderCmdEncoder);
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
if (!fDebugGroupActive) {
|
||||
fActiveRenderCmdEncoder->pushDebugGroup(@"bindAndDraw");
|
||||
fDebugGroupActive = true;
|
||||
}
|
||||
#endif
|
||||
fActivePipelineState->setTextures(geomProc, pipeline, geomProcTextures);
|
||||
fActivePipelineState->bindTextures(fActiveRenderCmdEncoder);
|
||||
return true;
|
||||
@ -195,9 +183,7 @@ void GrMtlOpsRenderPass::inlineUpload(GrOpFlushState* state, GrDeferredTextureUp
|
||||
}
|
||||
|
||||
void GrMtlOpsRenderPass::initRenderState(GrMtlRenderCommandEncoder* encoder) {
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
encoder->pushDebugGroup(@"initRenderState");
|
||||
#endif
|
||||
encoder->setFrontFacingWinding(MTLWindingCounterClockwise);
|
||||
// Strictly speaking we shouldn't have to set this, as the default viewport is the size of
|
||||
// the drawable used to generate the renderCommandEncoder -- but just in case.
|
||||
@ -205,9 +191,7 @@ void GrMtlOpsRenderPass::initRenderState(GrMtlRenderCommandEncoder* encoder) {
|
||||
(double) fRenderTarget->width(), (double) fRenderTarget->height(),
|
||||
0.0, 1.0 };
|
||||
encoder->setViewport(viewport);
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
encoder->popDebugGroup();
|
||||
#endif
|
||||
}
|
||||
|
||||
void GrMtlOpsRenderPass::setupRenderPass(
|
||||
@ -278,12 +262,6 @@ void GrMtlOpsRenderPass::onBindBuffers(sk_sp<const GrBuffer> indexBuffer,
|
||||
sk_sp<const GrBuffer> instanceBuffer,
|
||||
sk_sp<const GrBuffer> vertexBuffer,
|
||||
GrPrimitiveRestart primRestart) {
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
if (!fDebugGroupActive) {
|
||||
fActiveRenderCmdEncoder->pushDebugGroup(@"bindAndDraw");
|
||||
fDebugGroupActive = true;
|
||||
}
|
||||
#endif
|
||||
SkASSERT(GrPrimitiveRestart::kNo == primRestart);
|
||||
int inputBufferIndex = 0;
|
||||
if (vertexBuffer) {
|
||||
@ -311,21 +289,10 @@ void GrMtlOpsRenderPass::onBindBuffers(sk_sp<const GrBuffer> indexBuffer,
|
||||
void GrMtlOpsRenderPass::onDraw(int vertexCount, int baseVertex) {
|
||||
SkASSERT(fActivePipelineState);
|
||||
SkASSERT(nil != fActiveRenderCmdEncoder);
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
if (!fDebugGroupActive) {
|
||||
fActiveRenderCmdEncoder->pushDebugGroup(@"bindAndDraw");
|
||||
fDebugGroupActive = true;
|
||||
}
|
||||
#endif
|
||||
this->setVertexBuffer(fActiveRenderCmdEncoder, fActiveVertexBuffer.get(), 0, 0);
|
||||
|
||||
fActiveRenderCmdEncoder->drawPrimitives(fActivePrimitiveType, baseVertex, vertexCount);
|
||||
fGpu->stats()->incNumDraws();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
SkASSERT(fDebugGroupActive);
|
||||
fActiveRenderCmdEncoder->popDebugGroup();
|
||||
fDebugGroupActive = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GrMtlOpsRenderPass::onDrawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue,
|
||||
@ -333,12 +300,6 @@ void GrMtlOpsRenderPass::onDrawIndexed(int indexCount, int baseIndex, uint16_t m
|
||||
SkASSERT(fActivePipelineState);
|
||||
SkASSERT(nil != fActiveRenderCmdEncoder);
|
||||
SkASSERT(fActiveIndexBuffer);
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
if (!fDebugGroupActive) {
|
||||
fActiveRenderCmdEncoder->pushDebugGroup(@"bindAndDraw");
|
||||
fDebugGroupActive = true;
|
||||
}
|
||||
#endif
|
||||
this->setVertexBuffer(fActiveRenderCmdEncoder, fActiveVertexBuffer.get(),
|
||||
fCurrentVertexStride * baseVertex, 0);
|
||||
|
||||
@ -348,23 +309,12 @@ void GrMtlOpsRenderPass::onDrawIndexed(int indexCount, int baseIndex, uint16_t m
|
||||
fActiveRenderCmdEncoder->drawIndexedPrimitives(fActivePrimitiveType, indexCount,
|
||||
MTLIndexTypeUInt16, indexBuffer, indexOffset);
|
||||
fGpu->stats()->incNumDraws();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
SkASSERT(fDebugGroupActive);
|
||||
fActiveRenderCmdEncoder->popDebugGroup();
|
||||
fDebugGroupActive = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GrMtlOpsRenderPass::onDrawInstanced(int instanceCount, int baseInstance, int vertexCount,
|
||||
int baseVertex) {
|
||||
SkASSERT(fActivePipelineState);
|
||||
SkASSERT(nil != fActiveRenderCmdEncoder);
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
if (!fDebugGroupActive) {
|
||||
fActiveRenderCmdEncoder->pushDebugGroup(@"bindAndDraw");
|
||||
fDebugGroupActive = true;
|
||||
}
|
||||
#endif
|
||||
this->setVertexBuffer(fActiveRenderCmdEncoder, fActiveVertexBuffer.get(), 0, 0);
|
||||
|
||||
if (@available(macOS 10.11, iOS 9.0, *)) {
|
||||
@ -374,11 +324,6 @@ void GrMtlOpsRenderPass::onDrawInstanced(int instanceCount, int baseInstance, in
|
||||
SkASSERT(false);
|
||||
}
|
||||
fGpu->stats()->incNumDraws();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
SkASSERT(fDebugGroupActive);
|
||||
fActiveRenderCmdEncoder->popDebugGroup();
|
||||
fDebugGroupActive = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GrMtlOpsRenderPass::onDrawIndexedInstanced(
|
||||
@ -386,12 +331,6 @@ void GrMtlOpsRenderPass::onDrawIndexedInstanced(
|
||||
SkASSERT(fActivePipelineState);
|
||||
SkASSERT(nil != fActiveRenderCmdEncoder);
|
||||
SkASSERT(fActiveIndexBuffer);
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
if (!fDebugGroupActive) {
|
||||
fActiveRenderCmdEncoder->pushDebugGroup(@"bindAndDraw");
|
||||
fDebugGroupActive = true;
|
||||
}
|
||||
#endif
|
||||
this->setVertexBuffer(fActiveRenderCmdEncoder, fActiveVertexBuffer.get(), 0, 0);
|
||||
|
||||
auto mtlIndexBuffer = static_cast<const GrMtlBuffer*>(fActiveIndexBuffer.get());
|
||||
@ -405,11 +344,6 @@ void GrMtlOpsRenderPass::onDrawIndexedInstanced(
|
||||
SkASSERT(false);
|
||||
}
|
||||
fGpu->stats()->incNumDraws();
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
SkASSERT(fDebugGroupActive);
|
||||
fActiveRenderCmdEncoder->popDebugGroup();
|
||||
fDebugGroupActive = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GrMtlOpsRenderPass::onDrawIndirect(const GrBuffer* drawIndirectBuffer,
|
||||
@ -418,12 +352,6 @@ void GrMtlOpsRenderPass::onDrawIndirect(const GrBuffer* drawIndirectBuffer,
|
||||
SkASSERT(fGpu->caps()->nativeDrawIndirectSupport());
|
||||
SkASSERT(fActivePipelineState);
|
||||
SkASSERT(nil != fActiveRenderCmdEncoder);
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
if (!fDebugGroupActive) {
|
||||
fActiveRenderCmdEncoder->pushDebugGroup(@"bindAndDraw");
|
||||
fDebugGroupActive = true;
|
||||
}
|
||||
#endif
|
||||
this->setVertexBuffer(fActiveRenderCmdEncoder, fActiveVertexBuffer.get(), 0, 0);
|
||||
|
||||
auto mtlIndirectBuffer = static_cast<const GrMtlBuffer*>(drawIndirectBuffer);
|
||||
@ -439,11 +367,6 @@ void GrMtlOpsRenderPass::onDrawIndirect(const GrBuffer* drawIndirectBuffer,
|
||||
bufferOffset += stride;
|
||||
fGpu->stats()->incNumDraws();
|
||||
}
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
SkASSERT(fDebugGroupActive);
|
||||
fActiveRenderCmdEncoder->popDebugGroup();
|
||||
fDebugGroupActive = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GrMtlOpsRenderPass::onDrawIndexedIndirect(const GrBuffer* drawIndirectBuffer,
|
||||
@ -453,12 +376,6 @@ void GrMtlOpsRenderPass::onDrawIndexedIndirect(const GrBuffer* drawIndirectBuffe
|
||||
SkASSERT(fActivePipelineState);
|
||||
SkASSERT(nil != fActiveRenderCmdEncoder);
|
||||
SkASSERT(fActiveIndexBuffer);
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
if (!fDebugGroupActive) {
|
||||
fActiveRenderCmdEncoder->pushDebugGroup(@"bindAndDraw");
|
||||
fDebugGroupActive = true;
|
||||
}
|
||||
#endif
|
||||
this->setVertexBuffer(fActiveRenderCmdEncoder, fActiveVertexBuffer.get(), 0, 0);
|
||||
|
||||
auto mtlIndexBuffer = static_cast<const GrMtlBuffer*>(fActiveIndexBuffer.get());
|
||||
@ -481,11 +398,6 @@ void GrMtlOpsRenderPass::onDrawIndexedIndirect(const GrBuffer* drawIndirectBuffe
|
||||
bufferOffset += stride;
|
||||
fGpu->stats()->incNumDraws();
|
||||
}
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
SkASSERT(fDebugGroupActive);
|
||||
fActiveRenderCmdEncoder->popDebugGroup();
|
||||
fDebugGroupActive = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GrMtlOpsRenderPass::setVertexBuffer(GrMtlRenderCommandEncoder* encoder,
|
||||
|
@ -107,9 +107,11 @@ void GrMtlPipelineState::setTextures(const GrGeometryProcessor& geomProc,
|
||||
void GrMtlPipelineState::setDrawState(GrMtlRenderCommandEncoder* renderCmdEncoder,
|
||||
const GrSwizzle& writeSwizzle,
|
||||
const GrXferProcessor& xferProcessor) {
|
||||
renderCmdEncoder->pushDebugGroup(@"setDrawState");
|
||||
this->bindUniforms(renderCmdEncoder);
|
||||
this->setBlendConstants(renderCmdEncoder, writeSwizzle, xferProcessor);
|
||||
this->setDepthStencilState(renderCmdEncoder);
|
||||
renderCmdEncoder->popDebugGroup();
|
||||
}
|
||||
|
||||
void GrMtlPipelineState::bindUniforms(GrMtlRenderCommandEncoder* renderCmdEncoder) {
|
||||
|
@ -400,15 +400,6 @@ static uint32_t buffer_size(uint32_t offset, uint32_t maxAlignment) {
|
||||
static MTLRenderPipelineDescriptor* read_pipeline_data(SkReadBuffer* reader) {
|
||||
auto pipelineDescriptor = [[MTLRenderPipelineDescriptor alloc] init];
|
||||
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
// set label
|
||||
{
|
||||
SkString description;
|
||||
reader->readString(&description);
|
||||
pipelineDescriptor.label = @(description.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
// set up vertex descriptor
|
||||
{
|
||||
auto vertexDescriptor = [[MTLVertexDescriptor alloc] init];
|
||||
@ -504,16 +495,6 @@ GrMtlPipelineState* GrMtlPipelineStateBuilder::finalize(
|
||||
|
||||
// Ordering in how we set these matters. If it changes adjust read_pipeline_data, above.
|
||||
auto pipelineDescriptor = [[MTLRenderPipelineDescriptor alloc] init];
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
SkString description = GrProgramDesc::Describe(programInfo, *fGpu->caps());
|
||||
int split = description.find("\n");
|
||||
description.resize(split);
|
||||
pipelineDescriptor.label = @(description.c_str());
|
||||
if (writer) {
|
||||
writer->writeString(description.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
pipelineDescriptor.vertexDescriptor = create_vertex_descriptor(programInfo.geomProc(),
|
||||
writer.get());
|
||||
|
||||
@ -704,7 +685,6 @@ GrMtlPipelineState* GrMtlPipelineStateBuilder::finalize(
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
id<MTLRenderPipelineState> pipelineState;
|
||||
{
|
||||
TRACE_EVENT0("skia.shaders", "newRenderPipelineStateWithDescriptor");
|
||||
|
@ -33,15 +33,12 @@ public:
|
||||
[fCommandEncoder setLabel:label];
|
||||
}
|
||||
|
||||
void pushDebugGroup(NSString* string) {
|
||||
[fCommandEncoder pushDebugGroup:string];
|
||||
void pushDebugGroup(NSString* debugString) {
|
||||
[fCommandEncoder pushDebugGroup:debugString];
|
||||
}
|
||||
void popDebugGroup() {
|
||||
[fCommandEncoder popDebugGroup];
|
||||
}
|
||||
void insertDebugSignpost(NSString* string) {
|
||||
[fCommandEncoder insertDebugSignpost:string];
|
||||
}
|
||||
|
||||
void setRenderPipelineState(id<MTLRenderPipelineState> pso) {
|
||||
if (fCurrentRenderPipelineState != pso) {
|
||||
@ -51,10 +48,7 @@ public:
|
||||
}
|
||||
|
||||
void setTriangleFillMode(MTLTriangleFillMode fillMode) {
|
||||
if (fCurrentTriangleFillMode != fillMode) {
|
||||
[fCommandEncoder setTriangleFillMode:fillMode];
|
||||
fCurrentTriangleFillMode = fillMode;
|
||||
}
|
||||
[fCommandEncoder setTriangleFillMode:fillMode];
|
||||
}
|
||||
|
||||
void setFrontFacingWinding(MTLWinding winding) {
|
||||
@ -254,7 +248,6 @@ private:
|
||||
__weak id<MTLTexture> fCurrentTexture[GrSamplerState::kNumUniqueSamplers];
|
||||
GrMtlSampler* fCurrentSampler[GrSamplerState::kNumUniqueSamplers] = { 0 };
|
||||
MTLScissorRect fCurrentScissorRect = { 0, 0, 0, 0 };
|
||||
MTLTriangleFillMode fCurrentTriangleFillMode = (MTLTriangleFillMode)-1;
|
||||
};
|
||||
|
||||
GR_NORETAIN_END
|
||||
|
@ -100,9 +100,6 @@ sk_sp<GrMtlRenderTarget> GrMtlRenderTarget::MakeWrappedRenderTarget(GrMtlGpu* gp
|
||||
SkASSERT((MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget) &
|
||||
colorTexture.usage);
|
||||
}
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
colorTexture.label = @"MSAA RenderTarget";
|
||||
#endif
|
||||
mtlRT = new GrMtlRenderTarget(
|
||||
gpu, dimensions, sampleCnt, colorTexture, texture, kWrapped);
|
||||
mtlRT->setRequiresManualMSAAResolve();
|
||||
|
@ -82,14 +82,7 @@ id<MTLTexture> create_msaa_texture(GrMtlGpu* gpu, SkISize dimensions, MTLPixelFo
|
||||
texDesc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
|
||||
}
|
||||
|
||||
id<MTLTexture> msaaTexture = [gpu->device() newTextureWithDescriptor:texDesc];
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
msaaTexture.label = @"MSAA RenderTarget";
|
||||
#endif
|
||||
if (@available(macOS 10.11, iOS 9.0, *)) {
|
||||
SkASSERT((MTLTextureUsageShaderRead|MTLTextureUsageRenderTarget) & msaaTexture.usage);
|
||||
}
|
||||
return msaaTexture;
|
||||
return [gpu->device() newTextureWithDescriptor:texDesc];
|
||||
}
|
||||
|
||||
sk_sp<GrMtlTextureRenderTarget> GrMtlTextureRenderTarget::MakeNewTextureRenderTarget(
|
||||
@ -113,15 +106,12 @@ sk_sp<GrMtlTextureRenderTarget> GrMtlTextureRenderTarget::MakeNewTextureRenderTa
|
||||
if (!colorTexture) {
|
||||
return nullptr;
|
||||
}
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
texture.label = @"Resolve TextureRenderTarget";
|
||||
#endif
|
||||
if (@available(macOS 10.11, iOS 9.0, *)) {
|
||||
SkASSERT((MTLTextureUsageShaderRead|MTLTextureUsageRenderTarget) & colorTexture.usage);
|
||||
}
|
||||
return sk_sp<GrMtlTextureRenderTarget>(new GrMtlTextureRenderTarget(
|
||||
gpu, budgeted, dimensions, sampleCnt, colorTexture, texture, mipmapStatus));
|
||||
} else {
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
texture.label = @"TextureRenderTarget";
|
||||
#endif
|
||||
return sk_sp<GrMtlTextureRenderTarget>(
|
||||
new GrMtlTextureRenderTarget(gpu, budgeted, dimensions, texture, mipmapStatus));
|
||||
}
|
||||
@ -146,6 +136,9 @@ sk_sp<GrMtlTextureRenderTarget> GrMtlTextureRenderTarget::MakeWrappedTextureRend
|
||||
if (!colorTexture) {
|
||||
return nullptr;
|
||||
}
|
||||
if (@available(macOS 10.11, iOS 9.0, *)) {
|
||||
SkASSERT((MTLTextureUsageShaderRead|MTLTextureUsageRenderTarget) & colorTexture.usage);
|
||||
}
|
||||
return sk_sp<GrMtlTextureRenderTarget>(new GrMtlTextureRenderTarget(
|
||||
gpu, dimensions, sampleCnt, colorTexture, texture, mipmapStatus, cacheable));
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user