Merge pull request #9517 from torarnv/improve-metal-debugging

Improve metal debugging
This commit is contained in:
Twinaphex 2019-09-26 06:10:17 +02:00 committed by GitHub
commit e8bd94aab8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 12 deletions

View File

@ -493,8 +493,10 @@
- (id<MTLCommandBuffer>)blitCommandBuffer
{
if (!_blitCommandBuffer)
if (!_blitCommandBuffer) {
_blitCommandBuffer = [_commandQueue commandBuffer];
_blitCommandBuffer.label = @"Blit command buffer";
}
return _blitCommandBuffer;
}
@ -562,6 +564,7 @@
assert(_commandBuffer == nil);
dispatch_semaphore_wait(_inflightSemaphore, DISPATCH_TIME_FOREVER);
_commandBuffer = [_commandQueue commandBuffer];
_commandBuffer.label = @"Frame command buffer";
_backBuffer = nil;
}
@ -579,6 +582,7 @@
_backBuffer = self.nextDrawable.texture;
}
_rce = [_commandBuffer renderCommandEncoderWithDescriptor:rpd];
_rce.label = @"Frame command encoder";
}
return _rce;
}

View File

@ -52,7 +52,6 @@
{
id<MTLComputeCommandEncoder> ce = [cb computeCommandEncoder];
ce.label = @"filter kernel";
[ce pushDebugGroup:@"filter kernel"];
[ce setComputePipelineState:_kernel];
@ -67,7 +66,6 @@
[ce dispatchThreadgroups:count threadsPerThreadgroup:size];
[ce popDebugGroup];
[ce endEncoding];
}
@ -75,7 +73,6 @@
{
id<MTLComputeCommandEncoder> ce = [cb computeCommandEncoder];
ce.label = @"filter kernel";
[ce pushDebugGroup:@"filter kernel"];
[ce setComputePipelineState:_kernel];
@ -89,7 +86,6 @@
[ce dispatchThreadgroups:count threadsPerThreadgroup:size];
[ce popDebugGroup];
[ce endEncoding];
}

View File

@ -299,10 +299,11 @@
[self _drawCore:video_info];
[self _drawMenu:video_info];
id<MTLRenderCommandEncoder> rce = _context.rce;
#ifdef HAVE_OVERLAY
if (_overlay.enabled)
{
id<MTLRenderCommandEncoder> rce = _context.rce;
[rce pushDebugGroup:@"overlay"];
[_context resetRenderViewport:_overlay.fullscreen ? kFullscreenViewport : kVideoViewport];
[rce setRenderPipelineState:[_context getStockShader:VIDEO_SHADER_STOCK_BLEND blend:YES]];
@ -319,19 +320,29 @@
if (osd_params)
{
[rce pushDebugGroup:@"video stats"];
font_driver_render_msg(video_info, NULL, video_info->stat_text, osd_params);
[rce popDebugGroup];
}
}
#ifdef HAVE_MENU
#ifdef HAVE_MENU_WIDGETS
if (video_info->widgets_inited)
{
[rce pushDebugGroup:@"menu widgets"];
menu_widgets_frame(video_info);
[rce popDebugGroup];
}
#endif
#endif
if (msg && *msg)
{
[rce pushDebugGroup:@"message"];
[self _renderMessage:msg info:video_info];
[rce popDebugGroup];
}
[self _endFrame];
}
@ -928,6 +939,7 @@ typedef struct MTLALIGN(16)
}
id<MTLCommandBuffer> cb = ctx.blitCommandBuffer;
[cb pushDebugGroup:@"shaders"];
MTLRenderPassDescriptor *rpd = [MTLRenderPassDescriptor new];
rpd.colorAttachments[0].loadAction = MTLLoadActionDontCare;
@ -949,12 +961,11 @@ typedef struct MTLALIGN(16)
rce = [cb renderCommandEncoderWithDescriptor:rpd];
}
#if DEBUG && METAL_DEBUG
rce.label = [NSString stringWithFormat:@"pass %d", i];
#endif
[rce setRenderPipelineState:_engine.pass[i]._state];
NSURL *shaderPath = [NSURL fileURLWithPath:_engine.pass[i]._state.label];
rce.label = shaderPath.lastPathComponent.stringByDeletingPathExtension;
_engine.pass[i].frame_count = (uint32_t)_frameCount;
if (_shader->pass[i].frame_count_mod)
_engine.pass[i].frame_count %= _shader->pass[i].frame_count_mod;
@ -1026,6 +1037,8 @@ typedef struct MTLALIGN(16)
_drawState = ViewDrawStateContext;
else
_drawState = ViewDrawStateAll;
[cb popDebugGroup];
}
- (void)_updateRenderTargets
@ -1170,6 +1183,9 @@ typedef struct MTLALIGN(16)
config_file_t *conf = video_shader_read_preset(path.UTF8String);
struct video_shader *shader = (struct video_shader *)calloc(1, sizeof(*shader));
settings_t *settings = config_get_ptr();
NSString *shadersPath = [NSString stringWithFormat:@"%s/", settings->paths.directory_video_shader];
@try
{
unsigned i;
@ -1245,7 +1261,9 @@ typedef struct MTLALIGN(16)
vd.layouts[4].stepFunction = MTLVertexStepFunctionPerVertex;
MTLRenderPipelineDescriptor *psd = [MTLRenderPipelineDescriptor new];
psd.label = [NSString stringWithFormat:@"pass %d", i];
psd.label = [[NSString stringWithUTF8String:shader->pass[i].source.path]
stringByReplacingOccurrencesOfString:shadersPath withString:@""];
MTLRenderPipelineColorAttachmentDescriptor *ca = psd.colorAttachments[0];