Skip to content
Permalink
Browse files

8249659: [Lanai] Crash while running RenderPerfTest with metal pipeli…

  • Loading branch information
Alexey Ushakov committed Jul 29, 2020
1 parent 74618f7 commit a5c3460875b6e1d72e38e7616212f6e8058b5874
Showing with 41 additions and 40 deletions.
  1. +41 −40 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/EncoderManager.m
@@ -332,48 +332,49 @@ - (void)setContext:(MTLContex * _Nonnull)mtlc {
_useStencil = [_mtlc.clip isShape];
forceUpdate = JNI_TRUE;

MTLCommandBufferWrapper *cbw = [_mtlc getCommandBufferWrapper];
MTLRenderPassDescriptor *rpd =
[MTLRenderPassDescriptor renderPassDescriptor];
MTLRenderPassColorAttachmentDescriptor *ca = rpd.colorAttachments[0];
if (renderOptions->isAA && !renderOptions->isTexture) {
MTLTexturePoolItem *tiBuf = [_mtlc.texturePool getTexture:dest.width
height:dest.height
format:MTLPixelFormatBGRA8Unorm];
[cbw registerPooledTexture:tiBuf];
[tiBuf release];
_aaDestination = tiBuf.texture;

MTLTexturePoolItem *ti = [_mtlc.texturePool getTexture:dest.width
height:dest.height
format:_aaDestination.pixelFormat
isMultiSample:YES];
[cbw registerPooledTexture:ti];
[ti release];
ca.texture = ti.texture;
ca.resolveTexture = _aaDestination;
ca.clearColor = MTLClearColorMake(0.0f, 0.0f, 0.0f, 0.0f);
ca.loadAction = MTLLoadActionClear;
ca.storeAction = MTLStoreActionMultisampleResolve;
} else {
ca.texture = dest;
ca.loadAction = MTLLoadActionLoad;
ca.storeAction = MTLStoreActionStore;
}

if (_useStencil && !renderOptions->isAA) {
// If you enable stencil testing or stencil writing, the
// MTLRenderPassDescriptor must include a stencil attachment.
rpd.stencilAttachment.loadAction = MTLLoadActionLoad;
rpd.stencilAttachment.storeAction = MTLStoreActionStore;
rpd.stencilAttachment.texture = _mtlc.clip.stencilTextureRef;
}
@autoreleasepool {
MTLCommandBufferWrapper *cbw = [_mtlc getCommandBufferWrapper];
MTLRenderPassDescriptor *rpd =
[MTLRenderPassDescriptor renderPassDescriptor];
MTLRenderPassColorAttachmentDescriptor *ca = rpd.colorAttachments[0];
if (renderOptions->isAA && !renderOptions->isTexture) {
MTLTexturePoolItem *tiBuf = [_mtlc.texturePool getTexture:dest.width
height:dest.height
format:MTLPixelFormatBGRA8Unorm];
[cbw registerPooledTexture:tiBuf];
[tiBuf release];
_aaDestination = tiBuf.texture;

MTLTexturePoolItem *ti = [_mtlc.texturePool getTexture:dest.width
height:dest.height
format:_aaDestination.pixelFormat
isMultiSample:YES];
[cbw registerPooledTexture:ti];
[ti release];
ca.texture = ti.texture;
ca.resolveTexture = _aaDestination;
ca.clearColor = MTLClearColorMake(0.0f, 0.0f, 0.0f, 0.0f);
ca.loadAction = MTLLoadActionClear;
ca.storeAction = MTLStoreActionMultisampleResolve;
} else {
ca.texture = dest;
ca.loadAction = MTLLoadActionLoad;
ca.storeAction = MTLStoreActionStore;
}

// J2dTraceLn1(J2D_TRACE_VERBOSE, "created render encoder to draw on
// tex=%p", dest);
_encoder = [[cbw getCommandBuffer] renderCommandEncoderWithDescriptor:rpd];
[rpd release];
if (_useStencil && !renderOptions->isAA) {
// If you enable stencil testing or stencil writing, the
// MTLRenderPassDescriptor must include a stencil attachment.
rpd.stencilAttachment.loadAction = MTLLoadActionLoad;
rpd.stencilAttachment.storeAction = MTLStoreActionStore;
rpd.stencilAttachment.texture = _mtlc.clip.stencilTextureRef;
}

// J2dTraceLn1(J2D_TRACE_VERBOSE, "created render encoder to draw on
// tex=%p", dest);
_encoder = [[cbw getCommandBuffer] renderCommandEncoderWithDescriptor:rpd];
[_encoder retain];
}
[_encoderStates reset:dest
isDstOpaque:renderOptions->dstFlags.isOpaque
isDstPremultiplied:YES

0 comments on commit a5c3460

Please sign in to comment.