From f98a61be70fe7c73d446213bb143edc4035ddef7 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Fri, 5 Sep 2025 17:58:46 -0700 Subject: [PATCH] Improvements found in reviewing mac_arm branch #4629 --- indra/cmake/Variables.cmake | 13 ----- indra/llcommon/llmd5.cpp | 2 +- indra/llkdu/llimagej2ckdu.cpp | 2 +- indra/llwindow/llopenglview-objc.mm | 80 ++++++++++++++--------------- indra/newview/llappviewer.cpp | 2 + 5 files changed, 44 insertions(+), 55 deletions(-) diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake index c637e464fe..22c2156bb8 100644 --- a/indra/cmake/Variables.cmake +++ b/indra/cmake/Variables.cmake @@ -154,19 +154,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL "${CMAKE_MATCH_1}") message(STATUS "CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL = '${CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL}'") - # allow disabling this check by setting LL_SKIP_REQUIRE_SYSROOT either ON as cmake cache var or non-empty as environment var - # set(LL_SKIP_REQUIRE_SYSROOT OFF CACHE BOOL "Skip requirement to set toolchain sysroot ahead of time. Not skipped by default for consistency, but skipping can be useful for selecting alternative xcode versions side by side") - # if("$ENV{LL_SKIP_REQUIRE_SYSROOT}" STREQUAL "" AND NOT ${LL_SKIP_REQUIRE_SYSROOT}) - # string(REGEX MATCHALL "[^ ]+" LL_BUILD_LIST "$ENV{LL_BUILD}") - # list(FIND LL_BUILD_LIST "-iwithsysroot" sysroot_idx) - # if ("${sysroot_idx}" LESS 0) - # message(FATAL_ERROR "Environment variable LL_BUILD must contain '-iwithsysroot'") - # endif () - # math(EXPR sysroot_idx "${sysroot_idx} + 1") - # list(GET LL_BUILD_LIST "${sysroot_idx}" CMAKE_OSX_SYSROOT) - # endif() - # message(STATUS "CMAKE_OSX_SYSROOT = '${CMAKE_OSX_SYSROOT}'") - set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO) set(CMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH NO) set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS sse4.2) diff --git a/indra/llcommon/llmd5.cpp b/indra/llcommon/llmd5.cpp index c806c0ab2e..c8ca586e7f 100644 --- a/indra/llcommon/llmd5.cpp +++ b/indra/llcommon/llmd5.cpp @@ -279,7 +279,7 @@ void LLMD5::hex_digest(char* s) const } #if LL_DARWIN -#pragma clang diagnostic push +#pragma clang diagnostic pop #endif std::ostream& operator<<(std::ostream& stream, const LLMD5& context) diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 598455a31a..7eba9494a6 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -316,7 +316,7 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod // *TODO: This seems to be wrong. The base class should have no idea of // how j2c compression works so no good way of computing what's the byte // range to be used. - mCodeStreamp->set_max_bytes(max_bytes); + mCodeStreamp->set_max_bytes(max_bytes); // If you want to flip or rotate the image for some reason, change // the resolution, or identify a restricted region of interest, this is diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index f3aa164f92..c9a62eedb1 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -28,7 +28,7 @@ #import "llwindowmacosx-objc.h" #import "llappdelegate-objc.h" -#import +#import extern BOOL gHiDPISupport; @@ -66,16 +66,16 @@ attributedStringInfo getSegments(NSAttributedString *str) segment_standouts seg_standouts; NSRange effectiveRange; NSRange limitRange = NSMakeRange(0, [str length]); - + while (limitRange.length > 0) { NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange]; limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange)); - + if (effectiveRange.length <= 0) { effectiveRange.length = 1; } - + if ([attr integerValue] == 2) { seg_lengths.push_back(effectiveRange.length); @@ -98,12 +98,12 @@ @implementation NSScreen (PointConversion) + (NSScreen *)currentScreenForMouseLocation { NSPoint mouseLocation = [NSEvent mouseLocation]; - + NSEnumerator *screenEnumerator = [[NSScreen screens] objectEnumerator]; NSScreen *screen; while ((screen = [screenEnumerator nextObject]) && !NSMouseInRect(mouseLocation, screen.frame, NO)) ; - + return screen; } @@ -131,7 +131,7 @@ - (unsigned long)getVramSize { vram_megabytes = 256; } - + return (unsigned long)vram_megabytes; // return value is in megabytes. } @@ -140,15 +140,15 @@ - (void)viewDidMoveToWindow [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowResized:) name:NSWindowDidResizeNotification object:[self window]]; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillMiniaturize:) name:NSWindowWillMiniaturizeNotification object:[self window]]; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:[self window]]; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:[self window]]; @@ -222,7 +222,7 @@ - (id) initWithFrame:(NSRect)frame withSamples:(NSUInteger)samples andVsync:(BOO { [self registerForDraggedTypes:[NSArray arrayWithObject:NSPasteboardTypeURL]]; [self initWithFrame:frame]; - + // Initialize with a default "safe" pixel format that will work with versions dating back to OS X 10.6. // Any specialized pixel formats, i.e. a core profile pixel format, should be initialized through rebuildContextWithFormat. // 10.7 and 10.8 don't really care if we're defining a profile or not. If we don't explicitly request a core or legacy profile, it'll always assume a legacy profile (for compatibility reasons). @@ -240,34 +240,34 @@ - (id) initWithFrame:(NSRect)frame withSamples:(NSUInteger)samples andVsync:(BOO NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core, 0 }; - + NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease]; - + if (pixelFormat == nil) { NSLog(@"Failed to create pixel format!", nil); return nil; } - + NSOpenGLContext *glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; - + if (glContext == nil) { NSLog(@"Failed to create OpenGL context!", nil); return nil; } - + [self setPixelFormat:pixelFormat]; //for retina support [self setWantsBestResolutionOpenGLSurface:gHiDPISupport]; [self setOpenGLContext:glContext]; - + [glContext setView:self]; - + [glContext makeCurrentContext]; - + if (vsync) { GLint value = 1; @@ -291,16 +291,16 @@ - (BOOL) rebuildContext - (BOOL) rebuildContextWithFormat:(NSOpenGLPixelFormat *)format { NSOpenGLContext *ctx = [self openGLContext]; - + [ctx clearDrawable]; [ctx initWithFormat:format shareContext:nil]; - + if (ctx == nil) { NSLog(@"Failed to create OpenGL context!", nil); return false; } - + [self setOpenGLContext:ctx]; [ctx setView:self]; [ctx makeCurrentContext]; @@ -405,9 +405,9 @@ - (void) mouseDragged:(NSEvent *)theEvent float(dev_delta.x), float(dev_delta.y) }; - + callDeltaUpdate(mouseDeltas, 0); - + NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]]; mMousePos[0] = mPoint.x; mMousePos[1] = mPoint.y; @@ -431,7 +431,7 @@ - (void) rightMouseDragged:(NSEvent *)theEvent - (void) otherMouseDragged:(NSEvent *)theEvent { - [self mouseDragged:theEvent]; + [self mouseDragged:theEvent]; } - (void) scrollWheel:(NSEvent *)theEvent @@ -455,7 +455,7 @@ - (void) keyDown:(NSEvent *)theEvent { NativeKeyEventData eventData = extractKeyDataFromKeyEvent(theEvent); eventData.mKeyEvent = NativeKeyEventData::KEYDOWN; - + uint keycode = [theEvent keyCode]; // We must not depend on flagsChange event to detect modifier flags changed, // must depend on the modifire flags in the event parameter. @@ -489,13 +489,13 @@ - (void) keyDown:(NSEvent *)theEvent - (void)flagsChanged:(NSEvent *)theEvent { NativeKeyEventData eventData = extractKeyDataFromModifierEvent(theEvent); - + mModifiers = [theEvent modifierFlags]; callModifier([theEvent modifierFlags]); - + NSInteger mask = 0; switch([theEvent keyCode]) - { + { case kVK_Shift: mask = NSEventModifierFlagShift; break; @@ -506,9 +506,9 @@ - (void)flagsChanged:(NSEvent *)theEvent mask = NSEventModifierFlagControl; break; default: - return; + return; } - + if (mModifiers & mask) { eventData.mKeyEvent = NativeKeyEventData::KEYDOWN; @@ -527,7 +527,7 @@ - (void)flagsChanged:(NSEvent *)theEvent { eventData.mKeyEvent = NativeKeyEventData::KEYUP; callKeyUp(&eventData, [theEvent keyCode], 0); - } + } } - (BOOL) acceptsFirstResponder @@ -539,11 +539,11 @@ - (NSDragOperation) draggingEntered:(id)sender { NSPasteboard *pboard; NSDragOperation sourceDragMask; - + sourceDragMask = [sender draggingSourceOperationMask]; - + pboard = [sender draggingPasteboard]; - + if ([[pboard types] containsObject:NSPasteboardTypeURL]) { if (sourceDragMask & NSDragOperationLink) { @@ -558,7 +558,7 @@ - (NSDragOperation) draggingEntered:(id)sender - (NSDragOperation)draggingUpdated:(id )sender { callHandleDragUpdated(mLastDraggedUrl); - + return NSDragOperationLink; } @@ -612,12 +612,12 @@ - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replaceme unsigned(selectedRange.location), unsigned(selectedRange.length) }; - + unsigned int replacement[2] = { unsigned(replacementRange.location), unsigned(replacementRange.length) }; - + int string_length = [aString length]; unichar *text = new unichar[string_length]; attributedStringInfo segments; @@ -728,7 +728,7 @@ - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange return; } } - + @try { if (!mHasMarkedText) @@ -741,7 +741,7 @@ - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange resetPreedit(); // We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text. // But just in case... - + for (NSInteger i = 0; i < [aString length]; i++) { handleUnicodeCharacter([aString characterAtIndex:i]); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 9eb0d3fade..2dabf3355a 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -5660,6 +5660,8 @@ void LLAppViewer::forceErrorBreakpoint() #else #if defined(LL_X86) || defined(LL_X86_64) asm ("int $3"); +#else + __builtin_trap(); #endif #endif return;