Skip to content
This repository has been archived by the owner. It is now read-only.

8247304: Use separate MTLCommandQueue for final blit and MTLDrawable … #56

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -756,7 +756,7 @@ jboolean clipDestCoords(
// Consider to use [mtlc.encoderManager createBlitEncoder] and [mtlc commitCommandBuffer:JNI_TRUE];
J2dTraceLn1(J2D_TRACE_VERBOSE, "MTLBlitLoops_SurfaceToSwBlit: source texture %p", srcOps->pTexture);

id<MTLCommandBuffer> cb = [mtlc createBlitCommandBuffer];
id<MTLCommandBuffer> cb = [mtlc createCommandBuffer];
id<MTLBlitCommandEncoder> blitEncoder = [cb blitCommandEncoder];
[blitEncoder synchronizeTexture:srcOps->pTexture slice:0 level:0];
[blitEncoder copyFromTexture:srcOps->pTexture
@@ -819,7 +819,7 @@ jboolean clipDestCoords(
#endif //DEBUG

@autoreleasepool {
id<MTLCommandBuffer> cb = [mtlc createBlitCommandBuffer];
id<MTLCommandBuffer> cb = [mtlc createCommandBuffer];
id<MTLBlitCommandEncoder> blitEncoder = [cb blitCommandEncoder];

// Create an intrermediate buffer
@@ -153,7 +153,7 @@ - (void)beginShapeClip:(BMTLSDOps *)dstOps context:(MTLContext *)mtlc {
NSUInteger height = (NSUInteger)dstOps->height;
NSUInteger size = width*height;
id <MTLBuffer> buff = [mtlc.device newBufferWithLength:size*4 options:MTLResourceStorageModePrivate];
id<MTLCommandBuffer> commandBuf = [mtlc createBlitCommandBuffer];
id<MTLCommandBuffer> commandBuf = [mtlc createCommandBuffer];
id<MTLBlitCommandEncoder> blitEncoder = [commandBuf blitCommandEncoder];
[blitEncoder fillBuffer:buff range:NSMakeRange(0, size*4) value:0];

@@ -204,7 +204,7 @@ - (void)endShapeClip:(BMTLSDOps *)dstOps context:(MTLContext *)mtlc {
NSUInteger size = width*height;
NSUInteger sizeX4 = size*4;

id<MTLCommandBuffer> cb = [mtlc createBlitCommandBuffer];
id<MTLCommandBuffer> cb = [mtlc createCommandBuffer];
id<MTLBlitCommandEncoder> blitEncoder = [cb blitCommandEncoder];
MTLSize sourceSize = MTLSizeMake(width, height, 1);
MTLOrigin origin = MTLOriginMake(0, 0, 0);
@@ -300,7 +300,7 @@ - (NSString *)getDescription __unused {

if (!_clipReady) {
@autoreleasepool {
id <MTLCommandBuffer> cb = [_mtlc createBlitCommandBuffer];
id <MTLCommandBuffer> cb = [_mtlc createCommandBuffer];
id <MTLBlitCommandEncoder> blitEncoder = [cb blitCommandEncoder];
id <MTLBuffer> _stencilDataBufRef = _dstOps->pStencilDataBuf;

@@ -334,7 +334,7 @@ - (NSString *)getDescription __unused {

@autoreleasepool {

id <MTLCommandBuffer> cb = [_mtlc createBlitCommandBuffer];
id <MTLCommandBuffer> cb = [_mtlc createCommandBuffer];
id <MTLComputeCommandEncoder> computeEncoder = [cb computeCommandEncoder];
id<MTLComputePipelineState> computePipelineState = [_mtlc.pipelineStateStorage getComputePipelineState:@"stencil2tex"];
id <MTLBuffer> _stencilDataBufRef = _dstOps->pStencilDataBuf;
@@ -70,6 +70,7 @@
@property (readonly, strong) id<MTLDevice> device;
@property (strong) id<MTLLibrary> library;
@property (strong) id<MTLCommandQueue> commandQueue;
@property (strong) id<MTLCommandQueue> blitCommandQueue;
@property (strong) id<MTLBuffer> vertexBuffer;

@property (readonly) EncoderManager * encoderManager;
@@ -253,6 +254,7 @@

-(NSObject*)getBufImgOp;

- (id<MTLCommandBuffer>)createCommandBuffer;
- (id<MTLCommandBuffer>)createBlitCommandBuffer;
@end

@@ -97,7 +97,7 @@ @implementation MTLContext {

@synthesize textureFunction,
vertexCacheEnabled, aaEnabled, device, library, pipelineStateStorage,
commandQueue, vertexBuffer,
commandQueue, blitCommandQueue, vertexBuffer,
texturePool;

extern void initSamplers(id<MTLDevice> device);
@@ -135,6 +135,7 @@ - (id)initWithDevice:(id<MTLDevice>)d shadersLib:(NSString*)shadersLib {

// Create command queue
commandQueue = [device newCommandQueue];
blitCommandQueue = [device newCommandQueue];

initSamplers(device);
}
@@ -148,6 +149,7 @@ - (void)dealloc {
self.library = nil;
self.vertexBuffer = nil;
self.commandQueue = nil;
self.blitCommandQueue = nil;
self.pipelineStateStorage = nil;
[_encoderManager release];
[_composite release];
@@ -412,10 +414,18 @@ - (void)setTexturePaint:(jboolean)useMask
yp3:yp3];
}

- (id<MTLCommandBuffer>)createBlitCommandBuffer {
- (id<MTLCommandBuffer>)createCommandBuffer {
return [self.commandQueue commandBuffer];
}

/*
* This should be exclusively used only for final blit
* and present of CAMetalDrawable in MTLLayer
*/
- (id<MTLCommandBuffer>)createBlitCommandBuffer {
return [self.blitCommandQueue commandBuffer];
}

-(void)setBufImgOp:(NSObject*)bufImgOp {
if (_bufImgOp != nil) {
[_bufImgOp release]; // context owns bufImgOp object