diff options
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/CMakeLists.txt | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_curves.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/bvh/bvh_embree.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_sky.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/light.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/mesh_volume.cpp | 1 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_XrContext.cpp | 80 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_XrContext.h | 9 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_XrSwapchain.cpp | 3 |
12 files changed, 103 insertions, 38 deletions
diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt index 2316800e21e..e0fa45dffbc 100644 --- a/intern/cycles/blender/CMakeLists.txt +++ b/intern/cycles/blender/CMakeLists.txt @@ -109,6 +109,10 @@ if(WITH_OPENIMAGEDENOISE) ) endif() +if(WITH_EXPERIMENTAL_FEATURES) + add_definitions(-DWITH_HAIR_NODES) +endif() + blender_add_lib(bf_intern_cycles "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") # avoid link failure with clang 3.4 debug diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp index 82c99631a89..6288c370567 100644 --- a/intern/cycles/blender/blender_curves.cpp +++ b/intern/cycles/blender/blender_curves.cpp @@ -628,6 +628,7 @@ void BlenderSync::sync_particle_hair( } } +#ifdef WITH_HAIR_NODES static float4 hair_point_as_float4(BL::HairPoint b_point) { float4 mP = float3_to_float4(get_float3(b_point.co())); @@ -806,6 +807,15 @@ void BlenderSync::sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motio export_hair_curves(scene, hair, b_hair); } } +#else +void BlenderSync::sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motion_step) +{ + (void)hair; + (void)b_ob; + (void)motion; + (void)motion_step; +} +#endif void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 3ea6892a349..e0792962b01 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -458,15 +458,19 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render, python_thread_state_restore(python_thread_state); b_engine.frame_set(frame, subframe); python_thread_state_save(python_thread_state); - sync_camera_motion(b_render, b_cam, width, height, 0.0f); + if (b_cam) { + sync_camera_motion(b_render, b_cam, width, height, 0.0f); + } sync_objects(b_depsgraph, b_v3d, 0.0f); } /* Insert motion times from camera. Motion times from other objects * have already been added in a sync_objects call. */ - uint camera_motion_steps = object_motion_steps(b_cam, b_cam); - for (size_t step = 0; step < camera_motion_steps; step++) { - motion_times.insert(scene->camera->motion_time(step)); + if (b_cam) { + uint camera_motion_steps = object_motion_steps(b_cam, b_cam); + for (size_t step = 0; step < camera_motion_steps; step++) { + motion_times.insert(scene->camera->motion_time(step)); + } } /* note iteration over motion_times set happens in sorted order */ diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp index 17e1f86a589..4ef873634f0 100644 --- a/intern/cycles/bvh/bvh_embree.cpp +++ b/intern/cycles/bvh/bvh_embree.cpp @@ -126,9 +126,13 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args) } else { kernel_embree_convert_hit(kg, ray, hit, ¤t_isect); - if (ctx->local_object_id != current_isect.object) { + int object = (current_isect.object == OBJECT_NONE) ? + kernel_tex_fetch(__prim_object, current_isect.prim) : + current_isect.object; + if (ctx->local_object_id != object) { /* This tells Embree to continue tracing. */ *args->valid = 0; + break; } } diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h index f824184c1d4..b908732f026 100644 --- a/intern/cycles/kernel/svm/svm_sky.h +++ b/intern/cycles/kernel/svm/svm_sky.h @@ -137,7 +137,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, float sun_rotation = nishita_data[7]; float angular_diameter = nishita_data[8]; float sun_intensity = nishita_data[9]; - bool sun_disc = (angular_diameter > 0.0f); + bool sun_disc = (angular_diameter >= 0.0f); float3 xyz; /* convert dir to spherical coordinates */ float2 direction = direction_to_spherical(dir); diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 9193067f444..33bd9f655b4 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -985,7 +985,7 @@ void LightManager::device_update_background(Device *device, sun_direction = transform_direction(&sky_transform, sun_direction); /* Pack sun direction and size. */ - float half_angle = sky->sun_size * 0.5f; + float half_angle = sky->get_sun_size() * 0.5f; kbackground->sun = make_float4( sun_direction.x, sun_direction.y, sun_direction.z, half_angle); diff --git a/intern/cycles/render/mesh_volume.cpp b/intern/cycles/render/mesh_volume.cpp index 0b57243fec1..2ee51f4b732 100644 --- a/intern/cycles/render/mesh_volume.cpp +++ b/intern/cycles/render/mesh_volume.cpp @@ -555,6 +555,7 @@ void GeometryManager::create_volume_mesh(Mesh *mesh, Progress &progress) mesh->clear(true); mesh->reserve_mesh(vertices.size(), indices.size() / 3); mesh->used_shaders.push_back(volume_shader); + mesh->need_update_rebuild = true; for (size_t i = 0; i < vertices.size(); ++i) { mesh->add_vertex(vertices[i]); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index d5f65fb54db..a50544242f7 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -776,7 +776,7 @@ static void sky_texture_precompute_nishita(SunSky *sunsky, sunsky->nishita_data[5] = pixel_top[2]; sunsky->nishita_data[6] = sun_elevation; sunsky->nishita_data[7] = sun_rotation; - sunsky->nishita_data[8] = sun_disc ? sun_size : 0.0f; + sunsky->nishita_data[8] = sun_disc ? sun_size : -1.0f; sunsky->nishita_data[9] = sun_intensity; } @@ -834,7 +834,7 @@ void SkyTextureNode::compile(SVMCompiler &compiler) sky_texture_precompute_nishita(&sunsky, sun_disc, - sun_size, + get_sun_size(), sun_intensity, sun_elevation, sun_rotation, @@ -930,7 +930,7 @@ void SkyTextureNode::compile(OSLCompiler &compiler) sky_texture_precompute_nishita(&sunsky, sun_disc, - sun_size, + get_sun_size(), sun_intensity, sun_elevation, sun_rotation, diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 326f1d14168..c21bcacb3ce 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -179,6 +179,12 @@ class SkyTextureNode : public TextureNode { float ozone_density; float3 vector; ImageHandle handle; + + float get_sun_size() + { + /* Clamping for numerical precision. */ + return fmaxf(sun_size, 0.0005f); + } }; class OutputNode : public ShaderNode { diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp index 16687c34679..6bbb6ea1bcc 100644 --- a/intern/ghost/intern/GHOST_XrContext.cpp +++ b/intern/ghost/intern/GHOST_XrContext.cpp @@ -23,6 +23,7 @@ #include <cassert> #include <sstream> #include <string> +#include <string_view> #include "GHOST_Types.h" #include "GHOST_XrException.h" @@ -88,18 +89,26 @@ void GHOST_XrContext::initialize(const GHOST_XrContextCreateInfo *create_info) printAvailableAPILayersAndExtensionsInfo(); } - m_gpu_binding_type = determineGraphicsBindingTypeToEnable(create_info); + /* Multiple graphics binding extensions can be enabled, but only one will actually be used + * (determined later on). */ + const std::vector<GHOST_TXrGraphicsBinding> graphics_binding_types = + determineGraphicsBindingTypesToEnable(create_info); assert(m_oxr->instance == XR_NULL_HANDLE); - createOpenXRInstance(); + createOpenXRInstance(graphics_binding_types); storeInstanceProperties(); + + /* Multiple bindings may be enabled. Now that we know the runtime in use, settle for one. */ + m_gpu_binding_type = determineGraphicsBindingTypeToUse(graphics_binding_types); + printInstanceInfo(); if (isDebugMode()) { initDebugMessenger(); } } -void GHOST_XrContext::createOpenXRInstance() +void GHOST_XrContext::createOpenXRInstance( + const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types) { XrInstanceCreateInfo create_info = {XR_TYPE_INSTANCE_CREATE_INFO}; @@ -108,7 +117,7 @@ void GHOST_XrContext::createOpenXRInstance() create_info.applicationInfo.apiVersion = XR_CURRENT_API_VERSION; getAPILayersToEnable(m_enabled_layers); - getExtensionsToEnable(m_enabled_extensions); + getExtensionsToEnable(graphics_binding_types, m_enabled_extensions); create_info.enabledApiLayerCount = m_enabled_layers.size(); create_info.enabledApiLayerNames = m_enabled_layers.data(); create_info.enabledExtensionCount = m_enabled_extensions.size(); @@ -340,7 +349,7 @@ static bool openxr_layer_is_available(const std::vector<XrApiLayerProperties> la } static bool openxr_extension_is_available(const std::vector<XrExtensionProperties> extensions_info, - const std::string &extension_name) + const std::string_view &extension_name) { for (const XrExtensionProperties &ext_info : extensions_info) { if (ext_info.extensionName == extension_name) { @@ -393,32 +402,30 @@ static const char *openxr_ext_name_from_wm_gpu_binding(GHOST_TXrGraphicsBinding /** * Gather an array of names for the extensions to enable. */ -void GHOST_XrContext::getExtensionsToEnable(std::vector<const char *> &r_ext_names) +void GHOST_XrContext::getExtensionsToEnable( + const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types, + std::vector<const char *> &r_ext_names) { - assert(m_gpu_binding_type != GHOST_kXrGraphicsUnknown); - - const char *gpu_binding = openxr_ext_name_from_wm_gpu_binding(m_gpu_binding_type); - static std::vector<std::string> try_ext; - - try_ext.clear(); + std::vector<std::string_view> try_ext; /* Try enabling debug extension. */ -#ifndef WIN32 if (isDebugMode()) { try_ext.push_back(XR_EXT_DEBUG_UTILS_EXTENSION_NAME); } -#endif - r_ext_names.reserve(try_ext.size() + 1); /* + 1 for graphics binding extension. */ + r_ext_names.reserve(try_ext.size() + graphics_binding_types.size()); - /* Add graphics binding extension. */ - assert(gpu_binding); - assert(openxr_extension_is_available(m_oxr->extensions, gpu_binding)); - r_ext_names.push_back(gpu_binding); + /* Add graphics binding extensions (may be multiple ones, we'll settle for one to use later, once + * we have more info about the runtime). */ + for (GHOST_TXrGraphicsBinding type : graphics_binding_types) { + const char *gpu_binding = openxr_ext_name_from_wm_gpu_binding(type); + assert(openxr_extension_is_available(m_oxr->extensions, gpu_binding)); + r_ext_names.push_back(gpu_binding); + } - for (const std::string &ext : try_ext) { + for (const std::string_view &ext : try_ext) { if (openxr_extension_is_available(m_oxr->extensions, ext)) { - r_ext_names.push_back(ext.c_str()); + r_ext_names.push_back(ext.data()); } } } @@ -427,9 +434,10 @@ void GHOST_XrContext::getExtensionsToEnable(std::vector<const char *> &r_ext_nam * Decide which graphics binding extension to use based on * #GHOST_XrContextCreateInfo.gpu_binding_candidates and available extensions. */ -GHOST_TXrGraphicsBinding GHOST_XrContext::determineGraphicsBindingTypeToEnable( +std::vector<GHOST_TXrGraphicsBinding> GHOST_XrContext::determineGraphicsBindingTypesToEnable( const GHOST_XrContextCreateInfo *create_info) { + std::vector<GHOST_TXrGraphicsBinding> result; assert(create_info->gpu_binding_candidates != NULL); assert(create_info->gpu_binding_candidates_count > 0); @@ -438,11 +446,35 @@ GHOST_TXrGraphicsBinding GHOST_XrContext::determineGraphicsBindingTypeToEnable( const char *ext_name = openxr_ext_name_from_wm_gpu_binding( create_info->gpu_binding_candidates[i]); if (openxr_extension_is_available(m_oxr->extensions, ext_name)) { - return create_info->gpu_binding_candidates[i]; + result.push_back(create_info->gpu_binding_candidates[i]); } } - return GHOST_kXrGraphicsUnknown; + if (result.empty()) { + throw GHOST_XrException("No supported graphics binding found."); + } + + return result; +} + +GHOST_TXrGraphicsBinding GHOST_XrContext::determineGraphicsBindingTypeToUse( + const std::vector<GHOST_TXrGraphicsBinding> &enabled_types) +{ + /* Return the first working type. */ + for (GHOST_TXrGraphicsBinding type : enabled_types) { +#ifdef WIN32 + /* The SteamVR OpenGL backend fails currently. Disable it and allow falling back to the DirectX + * one. */ + if ((m_runtime_id == OPENXR_RUNTIME_STEAMVR) && (type == GHOST_kXrGraphicsOpenGL)) { + continue; + } +#endif + + assert(type != GHOST_kXrGraphicsUnknown); + return type; + } + + throw GHOST_XrException("Failed to determine a graphics binding to use."); } /** \} */ /* OpenXR API-Layers and Extensions */ diff --git a/intern/ghost/intern/GHOST_XrContext.h b/intern/ghost/intern/GHOST_XrContext.h index d2edb40c080..0b59c934c4d 100644 --- a/intern/ghost/intern/GHOST_XrContext.h +++ b/intern/ghost/intern/GHOST_XrContext.h @@ -114,7 +114,7 @@ class GHOST_XrContext : public GHOST_IXrContext { bool m_debug = false; bool m_debug_time = false; - void createOpenXRInstance(); + void createOpenXRInstance(const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types); void storeInstanceProperties(); void initDebugMessenger(); @@ -126,7 +126,10 @@ class GHOST_XrContext : public GHOST_IXrContext { void initExtensions(); void initExtensionsEx(std::vector<XrExtensionProperties> &extensions, const char *layer_name); void getAPILayersToEnable(std::vector<const char *> &r_ext_names); - void getExtensionsToEnable(std::vector<const char *> &r_ext_names); - GHOST_TXrGraphicsBinding determineGraphicsBindingTypeToEnable( + void getExtensionsToEnable(const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types, + std::vector<const char *> &r_ext_names); + std::vector<GHOST_TXrGraphicsBinding> determineGraphicsBindingTypesToEnable( const GHOST_XrContextCreateInfo *create_info); + GHOST_TXrGraphicsBinding determineGraphicsBindingTypeToUse( + const std::vector<GHOST_TXrGraphicsBinding> &enabled_types); }; diff --git a/intern/ghost/intern/GHOST_XrSwapchain.cpp b/intern/ghost/intern/GHOST_XrSwapchain.cpp index f7808c20112..2f900c853ba 100644 --- a/intern/ghost/intern/GHOST_XrSwapchain.cpp +++ b/intern/ghost/intern/GHOST_XrSwapchain.cpp @@ -95,7 +95,8 @@ GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_IXrGraphicsBinding &gpu_binding, GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_XrSwapchain &&other) : m_oxr(std::move(other.m_oxr)), m_image_width(other.m_image_width), - m_image_height(other.m_image_height) + m_image_height(other.m_image_height), + m_is_srgb_buffer(other.m_is_srgb_buffer) { /* Prevent xrDestroySwapchain call for the moved out item. */ other.m_oxr = nullptr; |