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 1 commit
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 valid pipeline state

This comment has been minimized.

Loading
@jayathirthrao

jayathirthrao Aug 25, 2021
Member Outdated

We should not call it a valid pipeline state. It is more of standard pipeline state with color 0 which we are using after reset.

We are hitting default MTLPaint without any texture(which seems to be the main root cause for this issue- state management problem) and we end up not setting any pipeline state. Please reword this comment.

This comment has been minimized.

Loading
@jayathirthrao

jayathirthrao Aug 25, 2021
Member Outdated

Also is it possible for us to just return at any earlier stage before we hit setRenderPipelineState() without valid texture or color?

This comment has been minimized.

Loading
@avu

avu Aug 25, 2021
Author Outdated

Yes, I agree it's not valid but standard or default state.

Also is it possible for us to just return at any earlier stage before we hit setRenderPipelineState() without valid texture or color?

The problem is that I'm unable to reproduce this failure. So, it's difficult to provide a robust empirical solution.

[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 valid pipeline state
[MTLColorPaint setPipelineState:encoder
context:mtlc
renderOptions:renderOptions
pipelineStateStorage:pipelineStateStorage
rpDesc:[[templateRenderPipelineDesc copy] autorelease]
vertShader:@"vert_col"
fragShader:@"frag_col"
color:0];
}
}