1
1
/*
2
- * Copyright (c) 2019, 2021 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2019, 2022 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
48
48
49
49
extern void MTLGC_DestroyMTLGraphicsConfig (jlong pConfigInfo);
50
50
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
+
51
63
void MTLRenderQueue_CheckPreviousOp (jint op) {
52
64
53
65
if (mtlPreviousOp == op) {
54
66
// The op is the same as last time, so we can return immediately.
55
67
return ;
56
68
}
57
69
70
+ if (isDrawOp (mtlPreviousOp) && !isDrawOp (op)) {
71
+ // submit the vertex batch
72
+ MTLRenderer_SubmitVertexBatch (mtlc, dstOps);
73
+ mtlPreviousOp = op;
74
+ }
75
+
58
76
if (op == MTL_OP_SET_COLOR) {
59
77
if (mtlPreviousOp != MTL_OP_MASK_OP) {
60
78
return ; // SET_COLOR should not cause endEncoder
@@ -128,7 +146,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
128
146
// draw ops
129
147
case sun_java2d_pipe_BufferedOpCodes_DRAW_LINE:
130
148
{
131
- CHECK_PREVIOUS_OP (MTL_OP_OTHER );
149
+ CHECK_PREVIOUS_OP (MTL_OP_DRAW_LINE );
132
150
133
151
if ([mtlc useXORComposite ]) {
134
152
commitEncodedCommands ();
@@ -144,9 +162,10 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
144
162
}
145
163
case sun_java2d_pipe_BufferedOpCodes_DRAW_RECT:
146
164
{
147
- CHECK_PREVIOUS_OP (MTL_OP_OTHER );
165
+ CHECK_PREVIOUS_OP (MTL_OP_DRAW_RECT );
148
166
149
167
if ([mtlc useXORComposite ]) {
168
+
150
169
commitEncodedCommands ();
151
170
J2dTraceLn (J2D_TRACE_VERBOSE,
152
171
" DRAW_RECT in XOR mode - Force commit earlier draw calls before DRAW_RECT." );
@@ -228,7 +247,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
228
247
}
229
248
case sun_java2d_pipe_BufferedOpCodes_DRAW_PARALLELOGRAM:
230
249
{
231
- CHECK_PREVIOUS_OP (MTL_OP_OTHER );
250
+ CHECK_PREVIOUS_OP (MTL_OP_DRAW_PARALLELOGRAM );
232
251
233
252
if ([mtlc useXORComposite ]) {
234
253
commitEncodedCommands ();
@@ -276,7 +295,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
276
295
// fill ops
277
296
case sun_java2d_pipe_BufferedOpCodes_FILL_RECT:
278
297
{
279
- CHECK_PREVIOUS_OP (MTL_OP_OTHER );
298
+ CHECK_PREVIOUS_OP (MTL_OP_FILL_RECT );
280
299
281
300
if ([mtlc useXORComposite ]) {
282
301
commitEncodedCommands ();
@@ -308,7 +327,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
308
327
}
309
328
case sun_java2d_pipe_BufferedOpCodes_FILL_PARALLELOGRAM:
310
329
{
311
- CHECK_PREVIOUS_OP (MTL_OP_OTHER );
330
+ CHECK_PREVIOUS_OP (MTL_OP_FILL_PARALLELOGRAM );
312
331
313
332
if ([mtlc useXORComposite ]) {
314
333
commitEncodedCommands ();
@@ -582,6 +601,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
582
601
jlong pDst = NEXT_LONG (b);
583
602
584
603
if (mtlc != NULL ) {
604
+ MTLRenderer_SubmitVertexBatch (mtlc, dstOps);
585
605
[mtlc.encoderManager endEncoder ];
586
606
MTLCommandBufferWrapper * cbwrapper = [mtlc pullCommandBufferWrapper ];
587
607
id <MTLCommandBuffer > commandbuf = [cbwrapper getCommandBuffer ];
@@ -609,6 +629,7 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
609
629
610
630
} else {
611
631
if (mtlc != NULL ) {
632
+ MTLRenderer_SubmitVertexBatch (mtlc, dstOps);
612
633
[mtlc.encoderManager endEncoder ];
613
634
MTLCommandBufferWrapper * cbwrapper = [mtlc pullCommandBufferWrapper ];
614
635
id <MTLCommandBuffer > commandbuf = [cbwrapper getCommandBuffer ];
@@ -878,6 +899,8 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
878
899
if (mtlPreviousOp == MTL_OP_MASK_OP) {
879
900
MTLVertexCache_DisableMaskCache (mtlc);
880
901
}
902
+ MTLRenderer_SubmitVertexBatch (mtlc, dstOps);
903
+
881
904
[mtlc.encoderManager endEncoder ];
882
905
MTLCommandBufferWrapper * cbwrapper = [mtlc pullCommandBufferWrapper ];
883
906
id <MTLCommandBuffer > commandbuf = [cbwrapper getCommandBuffer ];
@@ -923,6 +946,9 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
923
946
* these would be rendered to the back-buffer - which is read in shader while rendering in XOR mode
924
947
*/
925
948
void commitEncodedCommands () {
949
+
950
+ MTLRenderer_SubmitVertexBatch (mtlc, dstOps);
951
+
926
952
[mtlc.encoderManager endEncoder ];
927
953
928
954
MTLCommandBufferWrapper *cbwrapper = [mtlc pullCommandBufferWrapper ];
0 commit comments