Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8262751: RenderPipelineState assertion error in J2DDemo #5227

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
@@ -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];
}
}