Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.
/ jdk20 Public archive

Commit 3b7970c

Browse files
committed
8298217: Regressions 30-110% in SwingMark on MacOS, more so on aarch64
Reviewed-by: avu, prr, jdv
1 parent 0ecad28 commit 3b7970c

File tree

5 files changed

+104
-379
lines changed

5 files changed

+104
-379
lines changed

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLRenderQueue.h

-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ enum {
5151
MTL_OP_SYNC,
5252
MTL_OP_SHAPE_CLIP_SPANS,
5353
MTL_OP_MASK_OP,
54-
MTL_OP_FILL_PARALLELOGRAM,
55-
MTL_OP_FILL_RECT,
56-
MTL_OP_DRAW_LINE,
57-
MTL_OP_DRAW_RECT,
58-
MTL_OP_DRAW_PARALLELOGRAM,
5954
MTL_OP_OTHER
6055
};
6156
/*

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLRenderQueue.m

+5-35
Original file line numberDiff line numberDiff line change
@@ -48,35 +48,13 @@
4848

4949
extern void MTLGC_DestroyMTLGraphicsConfig(jlong pConfigInfo);
5050

51-
bool isDrawOp (jint op) {
52-
switch(op) {
53-
case MTL_OP_DRAW_LINE:
54-
case MTL_OP_DRAW_RECT:
55-
case MTL_OP_DRAW_PARALLELOGRAM:
56-
case MTL_OP_FILL_RECT:
57-
case MTL_OP_FILL_PARALLELOGRAM:
58-
return true;
59-
default: return false;
60-
}
61-
}
62-
6351
void MTLRenderQueue_CheckPreviousOp(jint op) {
6452

6553
if (mtlPreviousOp == op) {
6654
// The op is the same as last time, so we can return immediately.
6755
return;
6856
}
6957

70-
if (isDrawOp(mtlPreviousOp)) {
71-
// submit the vertex batch
72-
MTLRenderer_SubmitVertexBatch(mtlc, dstOps);
73-
if (isDrawOp(op)) {
74-
// Do not cause endEncoder if we continue with Draw operations
75-
mtlPreviousOp = op;
76-
return;
77-
}
78-
}
79-
8058
if (op == MTL_OP_SET_COLOR) {
8159
if (mtlPreviousOp != MTL_OP_MASK_OP) {
8260
return; // SET_COLOR should not cause endEncoder
@@ -150,7 +128,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
150128
// draw ops
151129
case sun_java2d_pipe_BufferedOpCodes_DRAW_LINE:
152130
{
153-
CHECK_PREVIOUS_OP(MTL_OP_DRAW_LINE);
131+
CHECK_PREVIOUS_OP(MTL_OP_OTHER);
154132

155133
if ([mtlc useXORComposite]) {
156134
commitEncodedCommands();
@@ -166,10 +144,9 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
166144
}
167145
case sun_java2d_pipe_BufferedOpCodes_DRAW_RECT:
168146
{
169-
CHECK_PREVIOUS_OP(MTL_OP_DRAW_RECT);
147+
CHECK_PREVIOUS_OP(MTL_OP_OTHER);
170148

171149
if ([mtlc useXORComposite]) {
172-
173150
commitEncodedCommands();
174151
J2dTraceLn(J2D_TRACE_VERBOSE,
175152
"DRAW_RECT in XOR mode - Force commit earlier draw calls before DRAW_RECT.");
@@ -251,7 +228,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
251228
}
252229
case sun_java2d_pipe_BufferedOpCodes_DRAW_PARALLELOGRAM:
253230
{
254-
CHECK_PREVIOUS_OP(MTL_OP_DRAW_PARALLELOGRAM);
231+
CHECK_PREVIOUS_OP(MTL_OP_OTHER);
255232

256233
if ([mtlc useXORComposite]) {
257234
commitEncodedCommands();
@@ -299,7 +276,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
299276
// fill ops
300277
case sun_java2d_pipe_BufferedOpCodes_FILL_RECT:
301278
{
302-
CHECK_PREVIOUS_OP(MTL_OP_FILL_RECT);
279+
CHECK_PREVIOUS_OP(MTL_OP_OTHER);
303280

304281
if ([mtlc useXORComposite]) {
305282
commitEncodedCommands();
@@ -331,7 +308,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
331308
}
332309
case sun_java2d_pipe_BufferedOpCodes_FILL_PARALLELOGRAM:
333310
{
334-
CHECK_PREVIOUS_OP(MTL_OP_FILL_PARALLELOGRAM);
311+
CHECK_PREVIOUS_OP(MTL_OP_OTHER);
335312

336313
if ([mtlc useXORComposite]) {
337314
commitEncodedCommands();
@@ -605,7 +582,6 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
605582
jlong pDst = NEXT_LONG(b);
606583

607584
if (mtlc != NULL) {
608-
MTLRenderer_SubmitVertexBatch(mtlc, dstOps);
609585
[mtlc.encoderManager endEncoder];
610586
MTLCommandBufferWrapper * cbwrapper = [mtlc pullCommandBufferWrapper];
611587
id<MTLCommandBuffer> commandbuf = [cbwrapper getCommandBuffer];
@@ -633,7 +609,6 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
633609

634610
} else {
635611
if (mtlc != NULL) {
636-
MTLRenderer_SubmitVertexBatch(mtlc, dstOps);
637612
[mtlc.encoderManager endEncoder];
638613
MTLCommandBufferWrapper * cbwrapper = [mtlc pullCommandBufferWrapper];
639614
id<MTLCommandBuffer> commandbuf = [cbwrapper getCommandBuffer];
@@ -903,8 +878,6 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
903878
if (mtlPreviousOp == MTL_OP_MASK_OP) {
904879
MTLVertexCache_DisableMaskCache(mtlc);
905880
}
906-
MTLRenderer_SubmitVertexBatch(mtlc, dstOps);
907-
908881
[mtlc.encoderManager endEncoder];
909882
MTLCommandBufferWrapper * cbwrapper = [mtlc pullCommandBufferWrapper];
910883
id<MTLCommandBuffer> commandbuf = [cbwrapper getCommandBuffer];
@@ -950,9 +923,6 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
950923
* these would be rendered to the back-buffer - which is read in shader while rendering in XOR mode
951924
*/
952925
void commitEncodedCommands() {
953-
954-
MTLRenderer_SubmitVertexBatch(mtlc, dstOps);
955-
956926
[mtlc.encoderManager endEncoder];
957927

958928
MTLCommandBufferWrapper *cbwrapper = [mtlc pullCommandBufferWrapper];

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLRenderer.h

-4
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,5 @@ void MTLRenderer_FillAAParallelogram(MTLContext *mtlc, BMTLSDOps * dstOps,
7272
jfloat fx11, jfloat fy11,
7373
jfloat dx21, jfloat dy21,
7474
jfloat dx12, jfloat dy12);
75-
void MTLRenderer_AddVertexToBatch(float x, float y);
76-
void MTLRenderer_SubmitVertexBatch(MTLContext* mtlc, BMTLSDOps* dstOps);
77-
void MTLRenderer_SetPrimitiveType(MTLPrimitiveType type);
78-
7975

8076
#endif /* MTLRenderer_h_Included */

0 commit comments

Comments
 (0)