Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,10 +1534,22 @@ def InstallMaterialX(context, force, buildArgs):
]

if MacOSTargetEmbedded(context):
# The materialXShaderGen in hdSt assumes the GLSL shadergen is available
# but MaterialX intertwines GLSL shadergen support with also requiring rendering support.
cmakeOptions.extend([
'-DMATERIALX_BUILD_GEN_MSL=ON',
'-DMATERIALX_BUILD_GEN_GLSL=OFF',
'-DMATERIALX_BUILD_GEN_GLSL=ON',
'-DMATERIALX_BUILD_IOS=ON'])
PatchFile("CMakeLists.txt",
[(' set(MATERIALX_BUILD_GEN_GLSL OFF)',
' set(MATERIALX_BUILD_GEN_GLSL ON)'),
(' if (MATERIALX_BUILD_GEN_GLSL)\n' +
' add_subdirectory(source/MaterialXRenderGlsl)\n' +
' endif()',
' if (MATERIALX_BUILD_GEN_GLSL AND NOT MATERIALX_BUILD_IOS)\n' +
' add_subdirectory(source/MaterialXRenderGlsl)\n' +
' endif()')
], multiLineMatches=True)

cmakeOptions += buildArgs
RunCMake(context, force, cmakeOptions)
Expand Down Expand Up @@ -2255,7 +2267,7 @@ def __init__(self, args):

# - Imaging
self.buildImaging = (args.build_imaging == IMAGING or
args.build_imaging == USD_IMAGING) and not embedded
args.build_imaging == USD_IMAGING)
self.enablePtex = self.buildImaging and args.enable_ptex
self.enableOpenVDB = self.buildImaging and args.enable_openvdb

Expand Down
8 changes: 4 additions & 4 deletions cmake/defaults/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ if(APPLE)
MESSAGE(STATUS "Setting PXR_BUILD_USD_TOOLS=OFF because they are not supported on Apple embedded platforms")
set(PXR_BUILD_USD_TOOLS OFF)
endif()
if (${PXR_BUILD_IMAGING})
MESSAGE(STATUS "Setting PXR_BUILD_USD_IMAGING=OFF because it is not supported on Apple embedded platforms")
set(PXR_BUILD_IMAGING OFF)
endif ()
endif ()
endif()

Expand All @@ -71,6 +67,10 @@ option(PXR_ENABLE_METAL_SUPPORT "Enable Metal based components" "${pxr_enable_me
option(PXR_ENABLE_VULKAN_SUPPORT "Enable Vulkan based components" OFF)
option(PXR_ENABLE_GL_SUPPORT "Enable OpenGL based components" ON)

if (PXR_APPLE_EMBEDDED)
set(PXR_ENABLE_GL_SUPPORT OFF)
endif ()

# Precompiled headers are a win on Windows, not on gcc.
set(pxr_enable_pch "OFF")
if(MSVC)
Expand Down
2 changes: 1 addition & 1 deletion cmake/defaults/Packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ if (PXR_BUILD_IMAGING)
endif()
endif()
# --Opensubdiv
set(OPENSUBDIV_USE_GPU ${PXR_ENABLE_GL_SUPPORT})
set(OPENSUBDIV_USE_GPU ${PXR_ENABLE_GL_SUPPORT} OR PXR_APPLE_EMBEDDED)
find_package(OpenSubdiv 3 REQUIRED)
# --Ptex
if (PXR_ENABLE_PTEX_SUPPORT)
Expand Down
17 changes: 13 additions & 4 deletions pxr/imaging/garch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(PXR_PREFIX pxr/imaging)
set(PXR_PACKAGE garch)

if (NOT ${PXR_ENABLE_GL_SUPPORT})
if ((NOT ${PXR_ENABLE_GL_SUPPORT}) AND (NOT PXR_APPLE_EMBEDDED))
message(STATUS
"Skipping ${PXR_PACKAGE} because PXR_ENABLE_GL_SUPPORT is OFF")
return()
Expand All @@ -11,7 +11,13 @@ if(APPLE)
set(GARCH_GLPLATFORMCONTEXT glPlatformContextDarwin)
set(GARCH_GLPLATFORMDEBUGWINDOW glPlatformDebugWindowDarwin)
set(GARCH_SOURCE_EXTENSION mm)
set(GARCH_PLATFORM_LIBRARIES "-framework AppKit")
list(APPEND optionalLibs "-framework Foundation")
if(PXR_APPLE_EMBEDDED)
list(APPEND optionalLibs "-framework UIKit")
else()
list(APPEND optionalLibs "-framework AppKit")
endif()

elseif(X11_FOUND)
set(GARCH_GLPLATFORMCONTEXT glPlatformContextGLX)
set(GARCH_GLPLATFORMDEBUGWINDOW glPlatformDebugWindowGLX)
Expand All @@ -22,13 +28,16 @@ elseif(WIN32)
set(GARCH_SOURCE_EXTENSION cpp)
endif()

if (TARGET OpenGL::GL)
list(APPEND optionalLibs OpenGL::GL)
endif()

pxr_library(garch
LIBRARIES
arch
tf
${X11_LIBRARIES}
OpenGL::GL
${GARCH_PLATFORM_LIBRARIES}
${optionalLibs}

PUBLIC_CLASSES
glApi
Expand Down
25 changes: 23 additions & 2 deletions pxr/imaging/garch/glPlatformContextDarwin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,33 @@
// https://openusd.org/license.
//
#import <Foundation/Foundation.h>
#import <AppKit/NSOpenGL.h>

#include "pxr/pxr.h"
#include "glPlatformContextDarwin.h"

#if defined(PXR_GL_SUPPORT_ENABLED)
#ifdef ARCH_OS_IPHONE
#import <UIKit/UIKit.h>
typedef EAGLContext NSGLContext;
#else
#import <AppKit/NSOpenGL.h>
typedef NSOpenGLContext NSGLContext;
#endif
#else
typedef void* NSGLContext;
#endif

PXR_NAMESPACE_OPEN_SCOPE

class GarchNSGLContextState::Detail
{
public:
Detail() {
#if defined(PXR_GL_SUPPORT_ENABLED)
context = [NSGLContext currentContext];
#else
context = nil;
#endif
}
Detail(NullState) {
context = nil;
Expand Down Expand Up @@ -73,18 +82,26 @@
void
GarchNSGLContextState::MakeCurrent()
{
#if ARCH_OS_IPHONE
#if defined(PXR_GL_SUPPORT_ENABLED)
#if defined(ARCH_OS_IPHONE)
[EAGLContext setCurrentContext:_detail->context];
#else
[_detail->context makeCurrentContext];
#endif
#endif
}

/// Make no context current.
void
GarchNSGLContextState::DoneCurrent()
{
#if defined(PXR_GL_SUPPORT_ENABLED)
#if defined(ARCH_OS_IPHONE)
[EAGLContext setCurrentContext:nil];
#else
[NSGLContext clearCurrentContext];
#endif
#endif
}

GarchGLPlatformContextState
Expand All @@ -96,6 +113,7 @@
void *
GarchSelectCoreProfileMacVisual()
{
#if defined(ARCH_OS_OSX)
NSOpenGLPixelFormatAttribute attribs[10];
int c = 0;

Expand All @@ -105,6 +123,9 @@
attribs[c++] = 0;

return [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
#else // ARCH_OS_MACOS
return NULL;
#endif
}

PXR_NAMESPACE_CLOSE_SCOPE
30 changes: 30 additions & 0 deletions pxr/imaging/garch/glPlatformDebugWindowDarwin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
#include "pxr/imaging/garch/glDebugWindow.h"
#include "pxr/imaging/garch/glPlatformDebugWindowDarwin.h"

#if defined(ARCH_OS_OSX)
#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h>
#endif

PXR_NAMESPACE_USING_DIRECTIVE

#if defined(ARCH_OS_OSX)

static int
Garch_GetModifierKeys(NSUInteger flags)
{
Expand Down Expand Up @@ -222,4 +226,30 @@ - (void)keyDown:(NSEvent *)event
[NSApp stop:nil];
}

#else // IPHONE Derivatives

PXR_NAMESPACE_OPEN_SCOPE

Garch_GLPlatformDebugWindow::Garch_GLPlatformDebugWindow(GarchGLDebugWindow *w)
{

}

void Garch_GLPlatformDebugWindow::Init(const char *title, int width, int height, int nSamples)
{

}

void
Garch_GLPlatformDebugWindow::Run()
{
}

void
Garch_GLPlatformDebugWindow::ExitApp()
{
}
#endif

PXR_NAMESPACE_CLOSE_SCOPE

12 changes: 8 additions & 4 deletions pxr/imaging/glf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
set(PXR_PREFIX pxr/imaging)
set(PXR_PACKAGE glf)


if (NOT ${PXR_ENABLE_GL_SUPPORT})
message(STATUS
"Skipping ${PXR_PACKAGE} because PXR_ENABLE_GL_SUPPORT is OFF")
return()
"Building minimal ${PXR_PACKAGE} because PXR_ENABLE_GL_SUPPORT is OFF")
endif ()

if (TARGET OpenGL::GL)
list(APPEND optionalLibs OpenGL::GL)
endif()

set(optionalPublicClasses "")
if (X11_FOUND)
list(APPEND optionalLibs ${X11_LIBRARIES})
list(APPEND optionalPublicClasses testGLContext)
endif()

Expand All @@ -24,8 +29,7 @@ pxr_library(glf
tf
trace
sdf
OpenGL::GL
${X11_LIBRARIES}
${optionalLibs}

PUBLIC_CLASSES
bindingMap
Expand Down
8 changes: 6 additions & 2 deletions pxr/imaging/hdSt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set(PXR_PACKAGE hdSt)

# XXX We tmp check for PXR_ENABLE_GL_SUPPORT since Storm currently still only
# runs on OpenGL. Once Storm uses only Hgi, remove GL_SUPPORT check.
if (NOT ${PXR_BUILD_GPU_SUPPORT} OR NOT ${PXR_ENABLE_GL_SUPPORT})
if (NOT ${PXR_BUILD_GPU_SUPPORT} OR NOT (${PXR_ENABLE_GL_SUPPORT} OR PXR_APPLE_EMBEDDED))
message(STATUS
"Skipping ${PXR_PACKAGE} because PXR_BUILD_GPU_SUPPORT is OFF")
return()
Expand All @@ -13,6 +13,11 @@ set(optionalLibs "")
set(optionalIncludeDirs "")
set(optionalPublicClasses "")
set(optionalPrivateClasses "")

if (NOT (PXR_APPLE_EMBEDDED))
list(APPEND optionalLibs hgiGL)
endif()

if (${PXR_ENABLE_MATERIALX_SUPPORT})
list(APPEND optionalLibs
MaterialXGenShader
Expand Down Expand Up @@ -41,7 +46,6 @@ pxr_library(hdSt
glf
hd
hdsi
hgiGL
hgiInterop
sdr
tf
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/hdx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set(PXR_PACKAGE hdx)

# XXX We tmp check for PXR_ENABLE_GL_SUPPORT since Hdx currently still uses
# OpenGL directly. Once Hdx uses only Hgi, remove GL_SUPPORT check.
if (NOT ${PXR_BUILD_GPU_SUPPORT} OR NOT ${PXR_ENABLE_GL_SUPPORT})
if (NOT ${PXR_BUILD_GPU_SUPPORT} OR NOT ${PXR_ENABLE_GL_SUPPORT} AND NOT PXR_APPLE_EMBEDDED)
message(STATUS
"Skipping ${PXR_PACKAGE} because PXR_BUILD_GPU_SUPPORT is OFF")
return()
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/hgiGL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(PXR_PREFIX pxr/imaging)
set(PXR_PACKAGE hgiGL)

if (NOT ${PXR_ENABLE_GL_SUPPORT})
if (NOT ${PXR_ENABLE_GL_SUPPORT} AND NOT PXR_APPLE_EMBEDDED)
message(STATUS
"Skipping ${PXR_PACKAGE} because PXR_ENABLE_GL_SUPPORT is OFF")
return()
Expand Down
8 changes: 7 additions & 1 deletion pxr/imaging/hgiInterop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(optionalPrivateHeaders "")

# Destination of hgiInterop is always OpenGL, so always include garch
list(APPEND optionalLibraries garch)
list(APPEND optionalLibraries hgiGL)

if (PXR_ENABLE_GL_SUPPORT)
list(APPEND optionalCppFiles opengl.cpp)
Expand All @@ -27,7 +28,12 @@ endif()

if (PXR_ENABLE_METAL_SUPPORT)
add_compile_options(-x objective-c++)
list(APPEND optionalLibraries "-framework CoreVideo" hgiMetal)
list(APPEND optionalLibraries hgiMetal)
endif()

if (PXR_ENABLE_METAL_SUPPORT AND PXR_ENABLE_GL_SUPPORT)
list(APPEND optionalLibraries "-framework Foundation")
list(APPEND optionalLibraries "-framework CoreVideo")
list(APPEND optionalCppFiles metal.mm)
list(APPEND optionalPrivateHeaders metal.h)
endif()
Expand Down
8 changes: 6 additions & 2 deletions pxr/imaging/hgiInterop/hgiInterop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

#if defined(PXR_METAL_SUPPORT_ENABLED)
#include "pxr/imaging/hgiMetal/hgi.h"
#if defined(ARCH_OS_OSX)
#include "pxr/imaging/hgiInterop/metal.h"
#endif
#endif

PXR_NAMESPACE_OPEN_SCOPE

Expand All @@ -32,8 +34,10 @@ struct HgiInteropImpl
std::unique_ptr<HgiInteropVulkan> _vulkanToOpenGL;
#endif
#if defined(PXR_METAL_SUPPORT_ENABLED)
#if !defined(ARCH_OS_IPHONE)
std::unique_ptr<HgiInteropMetal> _metalToOpenGL;
#endif
#endif
};

HgiInterop::HgiInterop()
Expand All @@ -58,7 +62,7 @@ void HgiInterop::TransferToApp(
return;
}

#if defined(PXR_GL_SUPPORT_ENABLED)
#if defined(PXR_GL_SUPPORT_ENABLED) && !defined(ARCH_OS_IPHONE)
if (srcApi == HgiTokens->OpenGL) {
// Transfer OpenGL textures to OpenGL application
if (!_hgiInteropImpl->_openGLToOpenGL) {
Expand Down Expand Up @@ -86,7 +90,7 @@ void HgiInterop::TransferToApp(
}
#endif

#if defined(PXR_METAL_SUPPORT_ENABLED)
#if defined(PXR_METAL_SUPPORT_ENABLED) && !defined(ARCH_OS_IPHONE)
if (srcApi == HgiTokens->Metal) {
// Transfer Metal textures to OpenGL application
// XXX: It's possible that if we use the same HgiInterop with a
Expand Down
9 changes: 8 additions & 1 deletion pxr/imaging/hgiMetal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ if (NOT ${PXR_BUILD_GPU_SUPPORT} OR NOT ${PXR_ENABLE_METAL_SUPPORT})
return()
endif()

if (PXR_APPLE_EMBEDDED)
set(APPLE_UI_FRAMEWORK "UIKit")
else()
set(APPLE_UI_FRAMEWORK "AppKit")
endif()

pxr_library(hgiMetal
LIBRARIES
arch
hgi
tf
trace
"-framework Foundation"
"-framework Metal"
"-framework AppKit"
"-framework ${APPLE_UI_FRAMEWORK}"

PUBLIC_HEADERS
api.h
Expand Down
Loading