Merge branch 'main' into cycles-light-linking
This commit is contained in:
@@ -1305,9 +1305,7 @@ void PathTrace::set_guiding_params(const GuidingParams &guiding_params, const bo
|
||||
break;
|
||||
}
|
||||
}
|
||||
# if OPENPGL_VERSION_MINOR >= 4
|
||||
field_args.deterministic = guiding_params.deterministic;
|
||||
# endif
|
||||
reinterpret_cast<PGLKDTreeArguments *>(field_args.spatialSturctureArguments)->maxDepth = 16;
|
||||
openpgl::cpp::Device *guiding_device = static_cast<openpgl::cpp::Device *>(
|
||||
device_->get_guiding_device());
|
||||
@@ -1374,12 +1372,7 @@ void PathTrace::guiding_update_structures()
|
||||
|
||||
/* we wait until we have at least 1024 samples */
|
||||
if (num_valid_samples >= 1024) {
|
||||
# if OPENPGL_VERSION_MINOR < 4
|
||||
const size_t num_samples = 1;
|
||||
guiding_field_->Update(*guiding_sample_data_storage_, num_samples);
|
||||
# else
|
||||
guiding_field_->Update(*guiding_sample_data_storage_);
|
||||
# endif
|
||||
guiding_update_count++;
|
||||
|
||||
VLOG_DEBUG << "Path guiding field valid: " << guiding_field_->Validate();
|
||||
|
@@ -358,12 +358,7 @@ void PathTraceWorkCPU::guiding_push_sample_data_to_global_storage(
|
||||
# if PATH_GUIDING_LEVEL >= 2
|
||||
const bool use_direct_light = kernel_data.integrator.use_guiding_direct_light;
|
||||
const bool use_mis_weights = kernel_data.integrator.use_guiding_mis_weights;
|
||||
# if OPENPGL_VERSION_MINOR >= 5
|
||||
kg->opgl_path_segment_storage->PrepareSamples(use_mis_weights, use_direct_light, false);
|
||||
# else
|
||||
kg->opgl_path_segment_storage->PrepareSamples(
|
||||
false, nullptr, use_mis_weights, use_direct_light, false);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef WITH_CYCLES_DEBUG
|
||||
|
@@ -7,10 +7,6 @@
|
||||
#include "kernel/closure/bsdf.h"
|
||||
#include "kernel/film/write.h"
|
||||
|
||||
#if OPENPGL_VERSION_MINOR >= 5
|
||||
# define RIS_INCOMING_RADIANCE
|
||||
#endif
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* Utilities. */
|
||||
@@ -27,11 +23,7 @@ struct GuidingRISSample {
|
||||
float ris_pdf{0.0f};
|
||||
float ris_weight{0.0f};
|
||||
|
||||
#ifdef RIS_INCOMING_RADIANCE
|
||||
float incoming_radiance_pdf{0.0f};
|
||||
#else
|
||||
float cosine{0.0f};
|
||||
#endif
|
||||
BsdfEval bsdf_eval;
|
||||
float avg_bsdf_eval{0.0f};
|
||||
Spectrum eval{zero_spectrum()};
|
||||
@@ -45,16 +37,9 @@ ccl_device_forceinline bool calculate_ris_target(ccl_private GuidingRISSample *r
|
||||
if (ris_sample->avg_bsdf_eval > 0.0f && ris_sample->bsdf_pdf > 1e-10f &&
|
||||
ris_sample->guide_pdf > 0.0f)
|
||||
{
|
||||
|
||||
# ifdef RIS_INCOMING_RADIANCE
|
||||
ris_sample->ris_target = (ris_sample->avg_bsdf_eval *
|
||||
((((1.0f - guiding_sampling_prob) * (1.0f / (pi_factor * M_PI_F))) +
|
||||
(guiding_sampling_prob * ris_sample->incoming_radiance_pdf))));
|
||||
# else
|
||||
ris_sample->ris_target = (ris_sample->avg_bsdf_eval / ris_sample->cosine *
|
||||
((((1.0f - guiding_sampling_prob) * (1.0f / (pi_factor * M_PI_F))) +
|
||||
(guiding_sampling_prob * ris_sample->guide_pdf))));
|
||||
# endif
|
||||
ris_sample->ris_pdf = (0.5f * (ris_sample->bsdf_pdf + ris_sample->guide_pdf));
|
||||
ris_sample->ris_weight = ris_sample->ris_target / ris_sample->ris_pdf;
|
||||
return true;
|
||||
@@ -511,14 +496,8 @@ ccl_device_forceinline bool guiding_bsdf_init(KernelGlobals kg,
|
||||
ccl_private float &rand)
|
||||
{
|
||||
#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
|
||||
# if OPENPGL_VERSION_MINOR >= 5
|
||||
if (kg->opgl_surface_sampling_distribution->Init(
|
||||
kg->opgl_guiding_field, guiding_point3f(P), rand)) {
|
||||
# else
|
||||
if (kg->opgl_surface_sampling_distribution->Init(
|
||||
kg->opgl_guiding_field, guiding_point3f(P), rand, true))
|
||||
{
|
||||
# endif
|
||||
kg->opgl_surface_sampling_distribution->ApplyCosineProduct(guiding_point3f(N));
|
||||
return true;
|
||||
}
|
||||
@@ -558,7 +537,7 @@ ccl_device_forceinline float guiding_surface_incoming_radiance_pdf(KernelGlobals
|
||||
IntegratorState state,
|
||||
const float3 wo)
|
||||
{
|
||||
#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4 && OPENPGL_VERSION_MINOR >= 5
|
||||
#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
|
||||
return kg->opgl_surface_sampling_distribution->IncomingRadiancePDF(guiding_vec3f(wo));
|
||||
#else
|
||||
return 0.0f;
|
||||
@@ -580,14 +559,8 @@ ccl_device_forceinline bool guiding_phase_init(KernelGlobals kg,
|
||||
return false;
|
||||
}
|
||||
|
||||
# if OPENPGL_VERSION_MINOR >= 5
|
||||
if (kg->opgl_volume_sampling_distribution->Init(
|
||||
kg->opgl_guiding_field, guiding_point3f(P), rand)) {
|
||||
# else
|
||||
if (kg->opgl_volume_sampling_distribution->Init(
|
||||
kg->opgl_guiding_field, guiding_point3f(P), rand, true))
|
||||
{
|
||||
# endif
|
||||
kg->opgl_volume_sampling_distribution->ApplySingleLobeHenyeyGreensteinProduct(guiding_vec3f(D),
|
||||
g);
|
||||
return true;
|
||||
|
@@ -621,12 +621,7 @@ ccl_device_forceinline void volume_integrate_heterogeneous(
|
||||
const Spectrum emission = volume_emission_integrate(
|
||||
&coeff, closure_flag, transmittance, dt);
|
||||
accum_emission += result.indirect_throughput * emission;
|
||||
# if OPENPGL_VERSION_MINOR < 5 // WORKAROUND #104329
|
||||
if (kernel_data.integrator.max_volume_bounce > 1)
|
||||
# endif
|
||||
{
|
||||
guiding_record_volume_emission(kg, state, emission);
|
||||
}
|
||||
guiding_record_volume_emission(kg, state, emission);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -971,13 +966,9 @@ ccl_device_forceinline bool integrate_volume_phase_scatter(
|
||||
const Spectrum phase_weight = bsdf_eval_sum(&phase_eval) / phase_pdf;
|
||||
|
||||
/* Add phase function sampling data to the path segment. */
|
||||
# if OPENPGL_VERSION_MINOR < 5 // WORKAROUND #104329
|
||||
if (kernel_data.integrator.max_volume_bounce > 1)
|
||||
# endif
|
||||
{
|
||||
guiding_record_volume_bounce(
|
||||
kg, state, sd, phase_weight, phase_pdf, normalize(phase_wo), sampled_roughness);
|
||||
}
|
||||
guiding_record_volume_bounce(
|
||||
kg, state, sd, phase_weight, phase_pdf, normalize(phase_wo), sampled_roughness);
|
||||
|
||||
/* Update throughput. */
|
||||
const Spectrum throughput = INTEGRATOR_STATE(state, path, throughput);
|
||||
const Spectrum throughput_phase = throughput * phase_weight;
|
||||
@@ -1078,11 +1069,7 @@ ccl_device VolumeIntegrateEvent volume_integrate(KernelGlobals kg,
|
||||
const float3 direct_P = ray->P + result.direct_t * ray->D;
|
||||
|
||||
# ifdef __PATH_GUIDING__
|
||||
# if OPENPGL_VERSION_MINOR < 5 // WORKAROUND #104329
|
||||
if (kernel_data.integrator.use_guiding && kernel_data.integrator.max_volume_bounce > 1) {
|
||||
# else
|
||||
if (kernel_data.integrator.use_guiding) {
|
||||
# endif
|
||||
# if PATH_GUIDING_LEVEL >= 1
|
||||
if (result.direct_sample_method == VOLUME_SAMPLE_DISTANCE) {
|
||||
/* If the direct scatter event is generated using VOLUME_SAMPLE_DISTANCE the direct event
|
||||
@@ -1155,12 +1142,7 @@ ccl_device VolumeIntegrateEvent volume_integrate(KernelGlobals kg,
|
||||
# if defined(__PATH_GUIDING__)
|
||||
# if PATH_GUIDING_LEVEL >= 1
|
||||
if (!guiding_generated_new_segment) {
|
||||
# if OPENPGL_VERSION_MINOR < 5 // WORKAROUND #104329
|
||||
if (kernel_data.integrator.max_volume_bounce > 1)
|
||||
# endif
|
||||
{
|
||||
guiding_record_volume_segment(kg, state, sd.P, sd.wi);
|
||||
}
|
||||
guiding_record_volume_segment(kg, state, sd.P, sd.wi);
|
||||
}
|
||||
# endif
|
||||
# if PATH_GUIDING_LEVEL >= 4
|
||||
|
@@ -670,12 +670,8 @@ ccl_device int surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
|
||||
ris_samples[0].avg_bsdf_eval = average(ris_samples[0].bsdf_eval.sum);
|
||||
ris_samples[0].guide_pdf = guiding_bsdf_pdf(kg, state, ris_samples[0].wo);
|
||||
ris_samples[0].guide_pdf *= (1.0f - bssrdf_sampling_prob);
|
||||
# ifdef RIS_INCOMING_RADIANCE
|
||||
ris_samples[0].incoming_radiance_pdf = guiding_surface_incoming_radiance_pdf(
|
||||
kg, state, ris_samples[0].wo);
|
||||
# else
|
||||
ris_samples[0].cosine = max(0.01f, fabsf(dot(sd->N, ris_samples[0].wo)));
|
||||
# endif
|
||||
ris_samples[0].bsdf_pdf = max(0.0f, ris_samples[0].bsdf_pdf);
|
||||
}
|
||||
|
||||
@@ -687,12 +683,8 @@ ccl_device int surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
|
||||
ris_samples[1].guide_pdf = guiding_bsdf_sample(
|
||||
kg, state, float3_to_float2(ris_samples[1].rand), &ris_samples[1].wo);
|
||||
ris_samples[1].guide_pdf *= (1.0f - bssrdf_sampling_prob);
|
||||
# ifdef RIS_INCOMING_RADIANCE
|
||||
ris_samples[1].incoming_radiance_pdf = guiding_surface_incoming_radiance_pdf(
|
||||
kg, state, ris_samples[1].wo);
|
||||
# else
|
||||
ris_samples[1].cosine = max(0.01f, fabsf(dot(sd->N, ris_samples[1].wo)));
|
||||
# endif
|
||||
ris_samples[1].bsdf_pdf = surface_shader_bsdf_eval_pdfs(
|
||||
kg, sd, ris_samples[1].wo, &ris_samples[1].bsdf_eval, unguided_bsdf_pdfs, 0);
|
||||
ris_samples[1].label = ris_samples[0].label;
|
||||
|
@@ -18,11 +18,9 @@ static int guiding_device_type()
|
||||
# if defined(__ARM_NEON)
|
||||
return 8;
|
||||
# else
|
||||
# if OPENPGL_VERSION_MINOR >= 4
|
||||
if (system_cpu_support_avx2()) {
|
||||
return 8;
|
||||
}
|
||||
# endif
|
||||
if (system_cpu_support_sse41()) {
|
||||
return 4;
|
||||
}
|
||||
|
@@ -30,7 +30,17 @@
|
||||
|
||||
/* Set to 0 to allow devices that do not have the required features.
|
||||
* This allows development on OSX until we really needs these features. */
|
||||
#define STRICT_REQUIREMENTS 1
|
||||
#define STRICT_REQUIREMENTS true
|
||||
|
||||
/*
|
||||
* Should we only select surfaces that are known to be compatible. Or should we in case no
|
||||
* compatible surfaces have been found select the first one.
|
||||
*
|
||||
* Currently we also select incompatible surfaces as Vulkan is still experimental. Assuming we get
|
||||
* reports of color differences between OpenGL and Vulkan to narrow down if there are other
|
||||
* configurations we need to support.
|
||||
*/
|
||||
#define SELECT_COMPATIBLE_SURFACES_ONLY false
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -796,6 +806,49 @@ GHOST_TSuccess GHOST_ContextVK::createGraphicsCommandBuffers()
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
static bool surfaceFormatSupported(const VkSurfaceFormatKHR &surface_format)
|
||||
{
|
||||
if (surface_format.colorSpace != VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (surface_format.format == VK_FORMAT_R8G8B8A8_UNORM ||
|
||||
surface_format.format == VK_FORMAT_B8G8R8A8_UNORM)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the surface format that we will use.
|
||||
*
|
||||
* We will select any 8bit unorm surface.
|
||||
*/
|
||||
static bool selectSurfaceFormat(const VkPhysicalDevice physical_device,
|
||||
const VkSurfaceKHR surface,
|
||||
VkSurfaceFormatKHR &r_surfaceFormat)
|
||||
{
|
||||
uint32_t format_count;
|
||||
vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &format_count, NULL);
|
||||
vector<VkSurfaceFormatKHR> formats(format_count);
|
||||
vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &format_count, formats.data());
|
||||
|
||||
for (VkSurfaceFormatKHR &format : formats) {
|
||||
if (surfaceFormatSupported(format)) {
|
||||
r_surfaceFormat = format;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#if !SELECT_COMPATIBLE_SURFACES_ONLY
|
||||
r_surfaceFormat = formats[0];
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_ContextVK::createSwapchain()
|
||||
{
|
||||
assert(vulkan_device.has_value() && vulkan_device->device != VK_NULL_HANDLE);
|
||||
@@ -803,13 +856,14 @@ GHOST_TSuccess GHOST_ContextVK::createSwapchain()
|
||||
|
||||
VkPhysicalDevice physical_device = vulkan_device->physical_device;
|
||||
|
||||
uint32_t format_count;
|
||||
vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, m_surface, &format_count, NULL);
|
||||
vector<VkSurfaceFormatKHR> formats(format_count);
|
||||
vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, m_surface, &format_count, formats.data());
|
||||
|
||||
/* TODO choose appropriate format. */
|
||||
VkSurfaceFormatKHR format = formats[0];
|
||||
VkSurfaceFormatKHR format = {};
|
||||
#if SELECT_COMPATIBLE_SURFACES_ONLY
|
||||
if (!selectSurfaceFormat(physical_device, m_surface, format)) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
#else
|
||||
selectSurfaceFormat(physical_device, m_surface, format);
|
||||
#endif
|
||||
|
||||
VkPresentModeKHR present_mode;
|
||||
if (!selectPresentMode(physical_device, m_surface, &present_mode)) {
|
||||
@@ -1066,9 +1120,7 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
|
||||
/* According to the Vulkan specs, when `VK_KHR_portability_subset` is available it should be
|
||||
* enabled. See
|
||||
* https://vulkan.lunarg.com/doc/view/1.2.198.1/mac/1.2-extensions/vkspec.html#VUID-VkDeviceCreateInfo-pProperties-04451*/
|
||||
if (device_extensions_support(vulkan_device->physical_device,
|
||||
{VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME}))
|
||||
{
|
||||
if (vulkan_device->extensions_support({VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME})) {
|
||||
extensions_device.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
|
||||
}
|
||||
#endif
|
||||
|
@@ -86,7 +86,7 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
|
||||
}
|
||||
|
||||
/* This is ignored since we query using our own GPU capabilities system. */
|
||||
void setTextureMaxWidth(unsigned max_width) override {}
|
||||
void setTextureMaxWidth(unsigned /*max_width*/) override {}
|
||||
|
||||
unsigned getTextureMaxWidth() const noexcept override
|
||||
{
|
||||
@@ -255,7 +255,7 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
|
||||
/* This gets called before the finalize() method to construct the shader code. We just
|
||||
* concatenate the code except for the declarations section. That's because the ShaderCreateInfo
|
||||
* will add the declaration itself. */
|
||||
void createShaderText(const char *declarations,
|
||||
void createShaderText(const char * /*declarations*/,
|
||||
const char *helper_methods,
|
||||
const char *function_header,
|
||||
const char *function_body,
|
||||
|
@@ -132,7 +132,6 @@ DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain,
|
||||
scene_(nullptr),
|
||||
view_layer_(nullptr),
|
||||
view_layer_index_(-1),
|
||||
collection_(nullptr),
|
||||
is_parent_collection_visible_(true)
|
||||
{
|
||||
}
|
||||
@@ -723,10 +722,8 @@ void DepsgraphNodeBuilder::build_collection(LayerCollection *from_layer_collecti
|
||||
return;
|
||||
}
|
||||
/* Backup state. */
|
||||
Collection *current_state_collection = collection_;
|
||||
const bool is_current_parent_collection_visible = is_parent_collection_visible_;
|
||||
/* Modify state as we've entered new collection/ */
|
||||
collection_ = collection;
|
||||
is_parent_collection_visible_ = is_collection_visible;
|
||||
/* Build collection objects. */
|
||||
LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
|
||||
@@ -737,7 +734,6 @@ void DepsgraphNodeBuilder::build_collection(LayerCollection *from_layer_collecti
|
||||
build_collection(nullptr, child->collection);
|
||||
}
|
||||
/* Restore state. */
|
||||
collection_ = current_state_collection;
|
||||
is_parent_collection_visible_ = is_current_parent_collection_visible;
|
||||
id_node->is_collection_fully_expanded = true;
|
||||
}
|
||||
|
@@ -312,7 +312,6 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
|
||||
int view_layer_index_;
|
||||
/* NOTE: Collection are possibly built recursively, so be careful when
|
||||
* setting the current state. */
|
||||
Collection *collection_;
|
||||
/* Accumulated flag over the hierarchy of currently building collections.
|
||||
* Denotes whether all the hierarchy from parent of `collection_` to the
|
||||
* very root is visible (aka not restricted.). */
|
||||
|
@@ -634,11 +634,21 @@ void DepsgraphRelationBuilder::build_collection(LayerCollection *from_layer_coll
|
||||
const ComponentKey collection_hierarchy_key{&collection->id, NodeType::HIERARCHY};
|
||||
|
||||
if (from_layer_collection != nullptr) {
|
||||
// XXX: Documentation.
|
||||
/* If we came from layer collection we don't go deeper, view layer builder takes care of going
|
||||
* deeper.
|
||||
*
|
||||
* NOTE: Do early output before tagging build as done, so possible subsequent builds from
|
||||
* outside of the layer collection properly recurses into all the nested objects and
|
||||
* collections. */
|
||||
|
||||
LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
|
||||
Object *object = cob->ob;
|
||||
|
||||
/* Ensure that the hierarchy relations always exists, even for the layer collection.
|
||||
*
|
||||
* Note that the view layer builder can skip bases if they are constantly excluded from the
|
||||
* collections. In order to avoid noisy output check that the target node exists before
|
||||
* adding the relation. */
|
||||
const ComponentKey object_hierarchy_key{&object->id, NodeType::HIERARCHY};
|
||||
if (has_node(object_hierarchy_key)) {
|
||||
add_relation(collection_hierarchy_key,
|
||||
|
@@ -355,7 +355,7 @@ enum eVelocityStep : uint32_t {
|
||||
|
||||
struct VelocityObjectIndex {
|
||||
/** Offset inside #VelocityObjectBuf for each timestep. Indexed using eVelocityStep. */
|
||||
int3 ofs;
|
||||
packed_int3 ofs;
|
||||
/** Temporary index to copy this to the #VelocityIndexBuf. */
|
||||
uint resource_id;
|
||||
|
||||
@@ -367,11 +367,11 @@ BLI_STATIC_ASSERT_ALIGN(VelocityObjectIndex, 16)
|
||||
|
||||
struct VelocityGeometryIndex {
|
||||
/** Offset inside #VelocityGeometryBuf for each timestep. Indexed using eVelocityStep. */
|
||||
int3 ofs;
|
||||
packed_int3 ofs;
|
||||
/** If true, compute deformation motion blur. */
|
||||
bool1 do_deform;
|
||||
/** Length of data inside #VelocityGeometryBuf for each timestep. Indexed using eVelocityStep. */
|
||||
int3 len;
|
||||
packed_int3 len;
|
||||
|
||||
int _pad0;
|
||||
|
||||
|
@@ -60,6 +60,7 @@
|
||||
# define bool3 bvec3
|
||||
# define bool4 bvec4
|
||||
# define packed_float3 vec3
|
||||
# define packed_int3 int3
|
||||
# endif
|
||||
|
||||
#else /* C / C++ */
|
||||
@@ -85,6 +86,7 @@ using bool2 = blender::int2;
|
||||
using bool3 = blender::int3;
|
||||
using bool4 = blender::int4;
|
||||
using packed_float3 = blender::float3;
|
||||
using packed_int3 = blender::int3;
|
||||
|
||||
# else /* C */
|
||||
typedef float float2[2];
|
||||
@@ -102,6 +104,7 @@ typedef int bool2[2];
|
||||
typedef int bool3[2];
|
||||
typedef int bool4[4];
|
||||
typedef float3 packed_float3;
|
||||
typedef int3 packed_int3;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user