Re-create encoder when we hit texture pool threshold metal-prototype-branch
authorjdv
Wed, 26 Jun 2019 14:28:47 +0530
branchmetal-prototype-branch
changeset 57431 d5ab3442e44f
parent 57430 3d12309f78df
child 57440 10f701a91883
Re-create encoder when we hit texture pool threshold
src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m
src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.h
src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.m
--- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m	Wed Jun 26 12:41:05 2019 +0530
+++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m	Wed Jun 26 14:28:47 2019 +0530
@@ -334,7 +334,7 @@
     dy2 = y + height;
     J2dTraceLn4(J2D_TRACE_INFO,
         "Destination coordinates dx1 = %f dy1 = %f dx2 = %f dy2 = %f", dx1, dy1, dx2, dy2);
-    MTLVertexCache_AddGlyphTexture(mtlc, width, height, ginfo);
+    MTLVertexCache_AddGlyphTexture(mtlc, width, height, ginfo, dstOps);
     MTLVertexCache_AddVertexTriangles(dx1, dy1, dx2, dy2);
     return JNI_TRUE;
 }
@@ -385,6 +385,7 @@
     J2dTraceLn1(J2D_TRACE_INFO, "totalGlyphs = %d", totalGlyphs);
 
     MTLVertexCache_CreateSamplingEncoder(mtlc, dstOps);
+    MTLVertexCache_InitVertexCache();
 
     for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) {
         J2dTraceLn(J2D_TRACE_INFO, "Entered for loop for glyph list");
@@ -426,7 +427,6 @@
         // as we implement LCD, cache usage add new selection condition.
 
         if (grayscale) {
-            MTLVertexCache_InitVertexCache(mtlc);
             // grayscale or monochrome glyph data
             if (ginfo->width <= MTLTR_CACHE_CELL_WIDTH &&
                 ginfo->height <= MTLTR_CACHE_CELL_HEIGHT)
--- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.h	Wed Jun 26 12:41:05 2019 +0530
+++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.h	Wed Jun 26 14:28:47 2019 +0530
@@ -32,7 +32,7 @@
 /**
  * Constants that control the size of the vertex cache.
  */
-#define MTLVC_MAX_INDEX         960
+#define MTLVC_MAX_INDEX         192
 
 /**
  * Constants that control the size of the texture pool.
@@ -70,7 +70,7 @@
 /**
  * Exported methods.
  */
-jboolean MTLVertexCache_InitVertexCache(MTLContext *mtlc);
+jboolean MTLVertexCache_InitVertexCache();
 void MTLVertexCache_FlushVertexCache(MTLContext *mtlc);
 void MTLVertexCache_RestoreColorState(MTLContext *mtlc);
 
@@ -84,7 +84,8 @@
 
 void MTLVertexCache_AddGlyphTexture(MTLContext *mtlc,
                                     jint width, jint height,
-                                    GlyphInfo *ginfo);
+                                    GlyphInfo *ginfo,
+                                    BMTLSDOps *dstOps);
 void MTLVertexCache_AddVertexTriangles(jfloat dx1, jfloat dy1,
                                        jfloat dx2, jfloat dy2);
 void MTLVertexCache_CreateSamplingEncoder(MTLContext *mtlc, BMTLSDOps *dstOps);
--- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.m	Wed Jun 26 12:41:05 2019 +0530
+++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.m	Wed Jun 26 14:28:47 2019 +0530
@@ -70,7 +70,7 @@
     } while (0)
 
 jboolean
-MTLVertexCache_InitVertexCache(MTLContext *mtlc)
+MTLVertexCache_InitVertexCache()
 {
     J2dTraceLn(J2D_TRACE_INFO, "MTLVertexCache_InitVertexCache");
 
@@ -180,13 +180,15 @@
 void
 MTLVertexCache_AddGlyphTexture(MTLContext *mtlc,
                                jint width, jint height,
-                               GlyphInfo *ginfo)
+                               GlyphInfo *ginfo,
+                               BMTLSDOps *dstOps)
 {
     J2dTraceLn(J2D_TRACE_INFO, "MTLVertexCache_AddGlyphTexture");
     if (texturePoolIndex >= MTLVC_MAX_TEX_INDEX ||
         vertexCacheIndex >= MTLVC_MAX_INDEX)
     {
         MTLVertexCache_FlushVertexCache(mtlc);
+        MTLVertexCache_CreateSamplingEncoder(mtlc, dstOps);
     }
     id<MTLTexture> texture = [mtlc.texturePool getTexture:width height:height format:MTLPixelFormatA8Unorm];
     NSUInteger bytesPerRow = 1 * width;