Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
8247831: Clamp texture height to maxTextureSize(16384)
Browse files Browse the repository at this point in the history
  • Loading branch information
prsadhuk committed Jul 17, 2020
1 parent 01159e7 commit a0d86b7
Showing 1 changed file with 12 additions and 2 deletions.
Expand Up @@ -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;
Expand Down

0 comments on commit a0d86b7

Please sign in to comment.