Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8247831: Clamp texture height to maxTextureSize(16384)
  • Loading branch information
prsadhuk committed Jul 17, 2020
1 parent 01159e7 commit a0d86b77e6eb8ac80afd0fe9b623f7730e3e4bf4
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLSurfaceData.m
@@ -68,9 +68,19 @@ static jboolean MTLSurfaceData_initTexture(BMTLSDOps *bmtlsdo, jboolean isOpaque

MTLContext* ctx = mtlsdo->configInfo->context;

if (width > MaxTextureSize) {
width = MaxTextureSize;
width = (width <= MaxTextureSize) ? width : 0;
height = (height <= MaxTextureSize) ? height : 0;

J2dTraceLn3(J2D_TRACE_VERBOSE, " desired texture dimensions: w=%d h=%d max=%d",
width, height, MaxTextureSize);

// if either dimension is 0, we cannot allocate a texture with the
// requested dimensions
if ((width == 0 || height == 0)) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initTexture: texture dimensions too large");
return JNI_FALSE;
}

MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat: MTLPixelFormatBGRA8Unorm width: width height: height mipmapped: NO];
textureDescriptor.usage = MTLTextureUsageUnknown;
textureDescriptor.storageMode = MTLStorageModePrivate;

0 comments on commit a0d86b7

Please sign in to comment.