Skip to content
Permalink
Browse files
8262751: RenderPipelineState assertion error in J2DDemo
Reviewed-by: jdv
  • Loading branch information
Alexey Ushakov committed Aug 26, 2021
1 parent a3308af commit 49b2789a49e4e476dfcdf0a65e061a40264a4683
Showing with 59 additions and 10 deletions.
  1. +10 −0 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLPaints.h
  2. +49 −10 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLPaints.m
@@ -63,7 +63,17 @@
@end

@interface MTLColorPaint : MTLPaint
+ (void)setPipelineState:(id <MTLRenderCommandEncoder>)encoder
context:(MTLContext *)mtlc
renderOptions:(const RenderOptions *)renderOptions
pipelineStateStorage:(MTLPipelineStatesStorage *)pipelineStateStorage
rpDesc:(MTLRenderPipelineDescriptor *)rpDesc
vertShader:(NSString *)vertShader
fragShader:(NSString *)fragShader
color:(jint)color;

- (id)initWithColor:(jint)color;

@property (nonatomic, readonly) jint color;
@end

@@ -141,6 +141,27 @@ @implementation MTLColorPaint {
// color-mode
jint _color;
}
+ (void)setPipelineState:(id <MTLRenderCommandEncoder>)encoder
context:(MTLContext *)mtlc
renderOptions:(const RenderOptions *)renderOptions
pipelineStateStorage:(MTLPipelineStatesStorage *)pipelineStateStorage
rpDesc:(MTLRenderPipelineDescriptor *)rpDesc
vertShader:(NSString *)vertShader
fragShader:(NSString *)fragShader
color:(jint)color {

struct FrameUniforms uf = {RGBA_TO_V4(color)};
[encoder setVertexBytes:&uf length:sizeof(uf) atIndex:FrameUniformBuffer];

id <MTLRenderPipelineState> pipelineState = [pipelineStateStorage getPipelineState:rpDesc
vertexShaderId:vertShader
fragmentShaderId:fragShader
composite:mtlc.composite
renderOptions:renderOptions
stencilNeeded:[mtlc.clip isShape]];
[encoder setRenderPipelineState:pipelineState];
}

- (id)initWithColor:(jint)color {
self = [super initWithState:sun_java2d_SunGraphics2D_PAINT_ALPHACOLOR];

@@ -217,16 +238,14 @@ - (void)setPipelineState:(id<MTLRenderCommandEncoder>)encoder
rpDesc = [[templateRenderPipelineDesc copy] autorelease];
}

struct FrameUniforms uf = {RGBA_TO_V4(_color)};
[encoder setVertexBytes:&uf length:sizeof(uf) atIndex:FrameUniformBuffer];

id <MTLRenderPipelineState> pipelineState = [pipelineStateStorage getPipelineState:rpDesc
vertexShaderId:vertShader
fragmentShaderId:fragShader
composite:mtlc.composite
renderOptions:renderOptions
stencilNeeded:[mtlc.clip isShape]];
[encoder setRenderPipelineState:pipelineState];
[MTLColorPaint setPipelineState:encoder
context:mtlc
renderOptions:renderOptions
pipelineStateStorage:pipelineStateStorage
rpDesc:rpDesc
vertShader:vertShader
fragShader:fragShader
color:_color];
}

- (void)setXorModePipelineState:(id<MTLRenderCommandEncoder>)encoder
@@ -948,6 +967,16 @@ - (void)setPipelineState:(id <MTLRenderCommandEncoder>)encoder
renderOptions:renderOptions
stencilNeeded:[mtlc.clip isShape]];
[encoder setRenderPipelineState:pipelineState];
} else {
// Fallback to default pipeline state
[MTLColorPaint setPipelineState:encoder
context:mtlc
renderOptions:renderOptions
pipelineStateStorage:pipelineStateStorage
rpDesc:[[templateRenderPipelineDesc copy] autorelease]
vertShader:@"vert_col"
fragShader:@"frag_col"
color:0];
}
}

@@ -987,6 +1016,16 @@ - (void)setXorModePipelineState:(id <MTLRenderCommandEncoder>)encoder
renderOptions:renderOptions
stencilNeeded:[mtlc.clip isShape]];
[encoder setRenderPipelineState:pipelineState];
} else {
// Fallback to default pipeline state
[MTLColorPaint setPipelineState:encoder
context:mtlc
renderOptions:renderOptions
pipelineStateStorage:pipelineStateStorage
rpDesc:[[templateRenderPipelineDesc copy] autorelease]
vertShader:@"vert_col"
fragShader:@"frag_col"
color:0];
}
}

1 comment on commit 49b2789

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 49b2789 Aug 26, 2021

Please sign in to comment.