main sync #3

Merged
Patrick Busch merged 318 commits from blender/blender:main into main 2023-03-17 15:52:21 +01:00
7 changed files with 1311 additions and 978 deletions
Showing only changes of commit 3ea36e9134 - Show all commits

View File

@ -1,6 +1,5 @@
Project: TinyGLTF Project: TinyGLTF
URL: https://github.com/syoyo/tinygltf URL: https://github.com/syoyo/tinygltf
License: MIT License: MIT
Upstream version: 2.5.0, 19a41d20ec0 Upstream version: 2.8.3, 84a83d39f55d
Local modifications: Local modifications: None
* Silence "enum value not handled in switch" warnings due to JSON dependency.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -621,6 +621,8 @@ void MetalKernelPipeline::compile()
MTLPipelineOption pipelineOptions = MTLPipelineOptionNone; MTLPipelineOption pipelineOptions = MTLPipelineOptionNone;
bool use_binary_archive = should_use_binary_archive(); bool use_binary_archive = should_use_binary_archive();
bool loading_existing_archive = false;
bool creating_new_archive = false;
id<MTLBinaryArchive> archive = nil; id<MTLBinaryArchive> archive = nil;
string metalbin_path; string metalbin_path;
@ -650,42 +652,39 @@ void MetalKernelPipeline::compile()
metalbin_path = path_cache_get(path_join("kernels", metalbin_name)); metalbin_path = path_cache_get(path_join("kernels", metalbin_name));
path_create_directories(metalbin_path); path_create_directories(metalbin_path);
/* Retrieve shader binary from disk, and update the file timestamp for LRU purging to work as /* Check if shader binary exists on disk, and if so, update the file timestamp for LRU purging
* intended. */ * to work as intended. */
if (use_binary_archive && path_cache_kernel_exists_and_mark_used(metalbin_path)) { loading_existing_archive = path_cache_kernel_exists_and_mark_used(metalbin_path);
creating_new_archive = !loading_existing_archive;
if (@available(macOS 11.0, *)) { if (@available(macOS 11.0, *)) {
MTLBinaryArchiveDescriptor *archiveDesc = [[MTLBinaryArchiveDescriptor alloc] init]; MTLBinaryArchiveDescriptor *archiveDesc = [[MTLBinaryArchiveDescriptor alloc] init];
if (loading_existing_archive) {
archiveDesc.url = [NSURL fileURLWithPath:@(metalbin_path.c_str())]; archiveDesc.url = [NSURL fileURLWithPath:@(metalbin_path.c_str())];
archive = [mtlDevice newBinaryArchiveWithDescriptor:archiveDesc error:nil];
[archiveDesc release];
} }
} NSError *error = nil;
} archive = [mtlDevice newBinaryArchiveWithDescriptor:archiveDesc error:&error];
bool creating_new_archive = false;
bool recreate_archive = false;
if (@available(macOS 11.0, *)) {
if (use_binary_archive) {
if (!archive) { if (!archive) {
MTLBinaryArchiveDescriptor *archiveDesc = [[MTLBinaryArchiveDescriptor alloc] init]; const char *err = error ? [[error localizedDescription] UTF8String] : nullptr;
archiveDesc.url = nil; metal_printf("newBinaryArchiveWithDescriptor failed: %s\n", err ? err : "nil");
archive = [mtlDevice newBinaryArchiveWithDescriptor:archiveDesc error:nil];
creating_new_archive = true;
} }
else { [archiveDesc release];
if (loading_existing_archive) {
pipelineOptions = MTLPipelineOptionFailOnBinaryArchiveMiss; pipelineOptions = MTLPipelineOptionFailOnBinaryArchiveMiss;
computePipelineStateDescriptor.binaryArchives = [NSArray arrayWithObjects:archive, nil]; computePipelineStateDescriptor.binaryArchives = [NSArray arrayWithObjects:archive, nil];
} }
} }
} }
bool recreate_archive = false;
/* Lambda to do the actual pipeline compilation. */ /* Lambda to do the actual pipeline compilation. */
auto do_compilation = [&]() { auto do_compilation = [&]() {
__block bool compilation_finished = false; __block bool compilation_finished = false;
__block string error_str; __block string error_str;
if (archive && path_exists(metalbin_path)) { if (loading_existing_archive) {
/* Use the blocking variant of newComputePipelineStateWithDescriptor if an archive exists on /* Use the blocking variant of newComputePipelineStateWithDescriptor if an archive exists on
* disk. It should load almost instantaneously, and will fail gracefully when loading a * disk. It should load almost instantaneously, and will fail gracefully when loading a
* corrupt archive (unlike the async variant). */ * corrupt archive (unlike the async variant). */
@ -698,8 +697,30 @@ void MetalKernelPipeline::compile()
error_str = err ? err : "nil"; error_str = err ? err : "nil";
} }
else { else {
/* TODO / MetalRT workaround:
* Workaround for a crash when addComputePipelineFunctionsWithDescriptor is called *after*
* newComputePipelineStateWithDescriptor with linked functions (i.e. with MetalRT enabled).
* Ideally we would like to call newComputePipelineStateWithDescriptor (async) first so we
* can bail out if needed, but we can stop the crash by flipping the order when there are
* linked functions. However when addComputePipelineFunctionsWithDescriptor is called first
* it will block while it builds the pipeline, offering no way of bailing out. */
auto addComputePipelineFunctionsWithDescriptor = [&]() {
if (creating_new_archive && ShaderCache::running) {
NSError *error;
if (![archive addComputePipelineFunctionsWithDescriptor:computePipelineStateDescriptor
error:&error]) {
NSString *errStr = [error localizedDescription];
metal_printf("Failed to add PSO to archive:\n%s\n",
errStr ? [errStr UTF8String] : "nil");
}
}
};
if (computePipelineStateDescriptor.linkedFunctions) {
addComputePipelineFunctionsWithDescriptor();
}
/* Use the async variant of newComputePipelineStateWithDescriptor if no archive exists on /* Use the async variant of newComputePipelineStateWithDescriptor if no archive exists on
* disk. This allows us responds to app shutdown. */ * disk. This allows us to respond to app shutdown. */
[mtlDevice [mtlDevice
newComputePipelineStateWithDescriptor:computePipelineStateDescriptor newComputePipelineStateWithDescriptor:computePipelineStateDescriptor
options:pipelineOptions options:pipelineOptions
@ -725,21 +746,14 @@ void MetalKernelPipeline::compile()
while (ShaderCache::running && !compilation_finished) { while (ShaderCache::running && !compilation_finished) {
std::this_thread::sleep_for(std::chrono::milliseconds(5)); std::this_thread::sleep_for(std::chrono::milliseconds(5));
} }
/* Add pipeline into the new archive (unless we did it earlier). */
if (pipeline && !computePipelineStateDescriptor.linkedFunctions) {
addComputePipelineFunctionsWithDescriptor();
}
} }
if (creating_new_archive && pipeline && ShaderCache::running) { if (!pipeline) {
/* Add pipeline into the new archive. It should be instantaneous following
* newComputePipelineStateWithDescriptor. */
NSError *error;
computePipelineStateDescriptor.binaryArchives = [NSArray arrayWithObjects:archive, nil];
if (![archive addComputePipelineFunctionsWithDescriptor:computePipelineStateDescriptor
error:&error]) {
NSString *errStr = [error localizedDescription];
metal_printf("Failed to add PSO to archive:\n%s\n", errStr ? [errStr UTF8String] : "nil");
}
}
else if (!pipeline) {
metal_printf( metal_printf(
"newComputePipelineStateWithDescriptor failed for \"%s\"%s. " "newComputePipelineStateWithDescriptor failed for \"%s\"%s. "
"Error:\n%s\n", "Error:\n%s\n",

View File

@ -752,10 +752,9 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
-shared -shared
-DWITH_ONEAPI -DWITH_ONEAPI
-ffast-math -ffast-math
-DNDEBUG
-O2 -O2
-o ${cycles_kernel_oneapi_lib} -o"${cycles_kernel_oneapi_lib}"
-I${CMAKE_CURRENT_SOURCE_DIR}/.. -I"${CMAKE_CURRENT_SOURCE_DIR}/.."
${SYCL_CPP_FLAGS} ${SYCL_CPP_FLAGS}
) )
@ -783,14 +782,14 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
list(APPEND sycl_compiler_flags -fsycl-targets=${targets_string}) list(APPEND sycl_compiler_flags -fsycl-targets=${targets_string})
foreach(target ${CYCLES_ONEAPI_SYCL_TARGETS}) foreach(target ${CYCLES_ONEAPI_SYCL_TARGETS})
if(DEFINED CYCLES_ONEAPI_SYCL_OPTIONS_${target}) if(DEFINED CYCLES_ONEAPI_SYCL_OPTIONS_${target})
list(APPEND sycl_compiler_flags -Xsycl-target-backend=${target} "${CYCLES_ONEAPI_SYCL_OPTIONS_${target}}") list(APPEND sycl_compiler_flags "-Xsycl-target-backend=${target} \"${CYCLES_ONEAPI_SYCL_OPTIONS_${target}}\"")
endif() endif()
endforeach() endforeach()
else() else()
# If AOT is disabled, build for spir64 # If AOT is disabled, build for spir64
list(APPEND sycl_compiler_flags list(APPEND sycl_compiler_flags
-fsycl-targets=spir64 -fsycl-targets=spir64
-Xsycl-target-backend=spir64 "${CYCLES_ONEAPI_SYCL_OPTIONS_spir64}") "-Xsycl-target-backend=spir64 \"${CYCLES_ONEAPI_SYCL_OPTIONS_spir64}\"")
endif() endif()
if(WITH_NANOVDB) if(WITH_NANOVDB)
@ -804,7 +803,6 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
endif() endif()
get_filename_component(sycl_compiler_root ${SYCL_COMPILER} DIRECTORY) get_filename_component(sycl_compiler_root ${SYCL_COMPILER} DIRECTORY)
get_filename_component(sycl_compiler_compiler_name ${SYCL_COMPILER} NAME_WE)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
if(NOT WITH_CXX11_ABI) if(NOT WITH_CXX11_ABI)
@ -816,7 +814,7 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
endif() endif()
endif() endif()
if(WIN32) if(WIN32) # Add Windows specific compiler flags.
list(APPEND sycl_compiler_flags list(APPEND sycl_compiler_flags
-fuse-ld=link -fuse-ld=link
-fms-extensions -fms-extensions
@ -846,17 +844,40 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
-L"${MSVC_TOOLS_DIR}/lib/x64" -L"${MSVC_TOOLS_DIR}/lib/x64"
-L"${WINDOWS_KIT_DIR}/um/x64" -L"${WINDOWS_KIT_DIR}/um/x64"
-L"${WINDOWS_KIT_DIR}/ucrt/x64") -L"${WINDOWS_KIT_DIR}/ucrt/x64")
else() # Add Linux specific compiler flags.
list(APPEND sycl_compiler_flags -fPIC)
# We avoid getting __FAST_MATH__ to be defined when building on CentOS-7 and Rocky-8
# until the compilation issues it triggers at either AoT or JIT stages gets fixed.
list(APPEND sycl_compiler_flags -fhonor-nans)
# add $ORIGIN to cycles_kernel_oneapi.so rpath so libsycl.so and
# libpi_level_zero.so can be placed next to it and get found.
list(APPEND sycl_compiler_flags -Wl,-rpath,'$$ORIGIN')
endif()
# Create CONFIG specific compiler flags.
set(sycl_compiler_flags_Release ${sycl_compiler_flags}) set(sycl_compiler_flags_Release ${sycl_compiler_flags})
set(sycl_compiler_flags_Debug ${sycl_compiler_flags}) set(sycl_compiler_flags_Debug ${sycl_compiler_flags})
set(sycl_compiler_flags_RelWithDebInfo ${sycl_compiler_flags}) set(sycl_compiler_flags_RelWithDebInfo ${sycl_compiler_flags})
set(sycl_compiler_flags_MinSizeRel ${sycl_compiler_flags})
list(APPEND sycl_compiler_flags_RelWithDebInfo -g) list(APPEND sycl_compiler_flags_Release
-DNDEBUG
)
list(APPEND sycl_compiler_flags_RelWithDebInfo
-DNDEBUG
-g
)
list(APPEND sycl_compiler_flags_Debug list(APPEND sycl_compiler_flags_Debug
-g -g
-D_DEBUG )
-nostdlib -Xclang --dependent-lib=msvcrtd)
if(WIN32)
list(APPEND sycl_compiler_flags_Debug
-D_DEBUG
-nostdlib
-Xclang --dependent-lib=msvcrtd
)
add_custom_command( add_custom_command(
OUTPUT ${cycles_kernel_oneapi_lib} ${cycles_kernel_oneapi_linker_lib} OUTPUT ${cycles_kernel_oneapi_lib} ${cycles_kernel_oneapi_linker_lib}
COMMAND ${CMAKE_COMMAND} -E env COMMAND ${CMAKE_COMMAND} -E env
@ -870,27 +891,29 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
COMMAND_EXPAND_LISTS COMMAND_EXPAND_LISTS
DEPENDS ${cycles_oneapi_kernel_sources}) DEPENDS ${cycles_oneapi_kernel_sources})
else() else()
list(APPEND sycl_compiler_flags -fPIC)
# We avoid getting __FAST_MATH__ to be defined when building on CentOS-7 until the compilation
# crash it triggers at either AoT or JIT stages gets fixed.
# TODO: check if this is still needed on Rocky-8.
list(APPEND sycl_compiler_flags -fhonor-nans)
# add $ORIGIN to cycles_kernel_oneapi.so rpath so libsycl.so and
# libpi_level_zero.so can be placed next to it and get found.
list(APPEND sycl_compiler_flags -Wl,-rpath,'$$ORIGIN')
if(NOT IGC_INSTALL_DIR) if(NOT IGC_INSTALL_DIR)
get_filename_component(IGC_INSTALL_DIR "${sycl_compiler_root}/../lib/igc" ABSOLUTE) get_filename_component(IGC_INSTALL_DIR "${sycl_compiler_root}/../lib/igc" ABSOLUTE)
endif() endif()
# The following join/replace operations are to prevent cmake from
# escaping space chars with backslashes in add_custom_command.
list(JOIN sycl_compiler_flags_Release " " sycl_compiler_flags_Release_str)
string(REPLACE " " ";" sycl_compiler_flags_Release_str ${sycl_compiler_flags_Release_str})
list(JOIN sycl_compiler_flags_RelWithDebInfo " " sycl_compiler_flags_RelWithDebInfo_str)
string(REPLACE " " ";" sycl_compiler_flags_RelWithDebInfo_str ${sycl_compiler_flags_RelWithDebInfo_str})
list(JOIN sycl_compiler_flags_Debug " " sycl_compiler_flags_Debug_str)
string(REPLACE " " ";" sycl_compiler_flags_Debug_str ${sycl_compiler_flags_Debug_str})
add_custom_command( add_custom_command(
OUTPUT ${cycles_kernel_oneapi_lib} OUTPUT ${cycles_kernel_oneapi_lib}
COMMAND ${CMAKE_COMMAND} -E env COMMAND ${CMAKE_COMMAND} -E env
"LD_LIBRARY_PATH=${sycl_compiler_root}/../lib:${OCLOC_INSTALL_DIR}/lib:${IGC_INSTALL_DIR}/lib" "LD_LIBRARY_PATH=${sycl_compiler_root}/../lib:${OCLOC_INSTALL_DIR}/lib:${IGC_INSTALL_DIR}/lib"
# `$ENV{PATH}` is for compiler to find `ld`. # `$ENV{PATH}` is for compiler to find `ld`.
"PATH=${OCLOC_INSTALL_DIR}/bin:${sycl_compiler_root}:$ENV{PATH}" "PATH=${OCLOC_INSTALL_DIR}/bin:${sycl_compiler_root}:$ENV{PATH}"
${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags} ${SYCL_COMPILER}
"$<$<CONFIG:Release>:${sycl_compiler_flags_Release_str}>"
"$<$<CONFIG:RelWithDebInfo>:${sycl_compiler_flags_RelWithDebInfo_str}>"
"$<$<CONFIG:Debug>:${sycl_compiler_flags_Debug_str}>"
"$<$<CONFIG:MinSizeRel>:${sycl_compiler_flags_Release_str}>"
COMMAND_EXPAND_LISTS
DEPENDS ${cycles_oneapi_kernel_sources}) DEPENDS ${cycles_oneapi_kernel_sources})
endif() endif()

View File

@ -312,7 +312,7 @@ class NODE_MT_node(Menu):
snode = context.space_data snode = context.space_data
is_compositor = snode.tree_type == 'CompositorNodeTree' is_compositor = snode.tree_type == 'CompositorNodeTree'
layout.operator("transform.translate") layout.operator("transform.translate").view2d_edge_pan = True
layout.operator("transform.rotate") layout.operator("transform.rotate")
layout.operator("transform.resize") layout.operator("transform.resize")

View File

@ -836,7 +836,7 @@ class SEQUENCER_MT_strip_transform(Menu):
layout.operator("transform.rotate", text="Rotate") layout.operator("transform.rotate", text="Rotate")
layout.operator("transform.resize", text="Scale") layout.operator("transform.resize", text="Scale")
else: else:
layout.operator("transform.seq_slide", text="Move") layout.operator("transform.seq_slide", text="Move").view2d_edge_pan = True
layout.operator("transform.transform", text="Move/Extend from Current Frame").mode = 'TIME_EXTEND' layout.operator("transform.transform", text="Move/Extend from Current Frame").mode = 'TIME_EXTEND'
layout.operator("sequencer.slip", text="Slip Strip Contents") layout.operator("sequencer.slip", text="Slip Strip Contents")