Skip to content

Commit

Permalink
Merge branch 'refs/heads/blender-3.6.1-release' into upbge-v0.36-release
Browse files Browse the repository at this point in the history
  • Loading branch information
lordloki committed Jul 29, 2023
2 parents daa5989 + 8bda729 commit 67ed28a
Show file tree
Hide file tree
Showing 70 changed files with 1,021 additions and 721 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ if(NOT APPLE)
mark_as_advanced(WITH_CYCLES_DEVICE_CUDA)

option(WITH_CYCLES_CUDA_BINARIES "Build Cycles NVIDIA CUDA binaries" OFF)
set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 sm_89 compute_89 CACHE STRING "CUDA architectures to build binaries for")
set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 sm_89 compute_75 CACHE STRING "CUDA architectures to build binaries for")
option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF)
option(WITH_CUDA_DYNLOAD "Dynamically load CUDA libraries at runtime (for developers, makes cuda-gdb work)" ON)

Expand Down
5 changes: 4 additions & 1 deletion extern/hipew/src/hipew.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ static int hipewHipInit(void) {
/* Default installation path. */
const char *hip_paths[] = {"", NULL};
#else
const char *hip_paths[] = {"libamdhip64.so", "/opt/rocm/hip/lib/libamdhip64.so", NULL};
const char *hip_paths[] = {"libamdhip64.so.5",
"/opt/rocm/hip/lib/libamdhip64.so.5",
"libamdhip64.so",
"/opt/rocm/hip/lib/libamdhip64.so", NULL};
#endif
static int initialized = 0;
static int result = 0;
Expand Down
8 changes: 5 additions & 3 deletions intern/cycles/blender/pointcloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ static void attr_create_motion(PointCloud *pointcloud,
const int num_points = pointcloud->get_points().size();

/* Find or add attribute */
float3 *P = &pointcloud->get_points()[0];
float3 *P = pointcloud->get_points().data();
float *radius = pointcloud->get_radius().data();
Attribute *attr_mP = pointcloud->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);

if (!attr_mP) {
Expand All @@ -41,10 +42,11 @@ static void attr_create_motion(PointCloud *pointcloud,
float motion_times[2] = {-1.0f, 1.0f};
for (int step = 0; step < 2; step++) {
const float relative_time = motion_times[step] * 0.5f * motion_scale;
float3 *mP = attr_mP->data_float3() + step * num_points;
float4 *mP = attr_mP->data_float4() + step * num_points;

for (int i = 0; i < num_points; i++) {
mP[i] = P[i] + get_float3(b_vector_attribute.data[i].vector()) * relative_time;
float3 Pi = P[i] + get_float3(b_vector_attribute.data[i].vector()) * relative_time;
mP[i] = make_float4(Pi.x, Pi.y, Pi.z, radius[i]);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions intern/cycles/bvh/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void BVHBuild::add_reference_points(BoundBox &root,
const float3 *points_data = &pointcloud->points[0];
const float *radius_data = &pointcloud->radius[0];
const size_t num_points = pointcloud->num_points();
const float3 *motion_data = (point_attr_mP) ? point_attr_mP->data_float3() : NULL;
const float4 *motion_data = (point_attr_mP) ? point_attr_mP->data_float4() : NULL;
const size_t num_steps = pointcloud->get_motion_steps();

if (point_attr_mP == NULL) {
Expand All @@ -295,7 +295,7 @@ void BVHBuild::add_reference_points(BoundBox &root,
BoundBox bounds = BoundBox::empty;
point.bounds_grow(points_data, radius_data, bounds);
for (size_t step = 0; step < num_steps - 1; step++) {
point.bounds_grow(motion_data + step * num_points, radius_data, bounds);
point.bounds_grow(motion_data[step * num_points + j], bounds);
}
if (bounds.valid()) {
references.push_back(BVHReference(bounds, j, i, PRIMITIVE_MOTION_POINT));
Expand All @@ -315,7 +315,7 @@ void BVHBuild::add_reference_points(BoundBox &root,
for (uint j = 0; j < num_points; j++) {
const PointCloud::Point point = pointcloud->get_point(j);
const size_t num_steps = pointcloud->get_motion_steps();
const float3 *point_steps = point_attr_mP->data_float3();
const float4 *point_steps = point_attr_mP->data_float4();

/* Calculate bounding box of the previous time step.
* Will be reused later to avoid duplicated work on
Expand Down
36 changes: 18 additions & 18 deletions intern/cycles/bvh/embree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ void BVHEmbree::set_tri_vertex_buffer(RTCGeometry geom_id, const Mesh *mesh, con
}
else {
if (!rtc_device_is_sycl) {
/* NOTE(sirgienko) Embree requires padding for VERTEX layout as last buffer element
* must be readable using 16-byte SSE load instructions. Because of this, we are
* artificially increasing shared buffer size by 1 - it shouldn't cause any memory
* access violation as this last element is not accessed directly since no triangle
* can reference it. */
rtcSetSharedGeometryBuffer(geom_id,
RTC_BUFFER_TYPE_VERTEX,
t,
Expand All @@ -357,16 +362,18 @@ void BVHEmbree::set_tri_vertex_buffer(RTCGeometry geom_id, const Mesh *mesh, con
* of making a shared geometry buffer - a new Embree buffer will be created and data
* will be copied. */
/* As float3 is packed on GPU side, we map it to packed_float3. */
/* There is no need for additional padding in rtcSetNewGeometryBuffer since Embree 3.6:
* "Fixed automatic vertex buffer padding when using rtcSetNewGeometry API function". */
packed_float3 *verts_buffer = (packed_float3 *)rtcSetNewGeometryBuffer(
geom_id,
RTC_BUFFER_TYPE_VERTEX,
t,
RTC_FORMAT_FLOAT3,
sizeof(packed_float3),
num_verts + 1);
num_verts);
assert(verts_buffer);
if (verts_buffer) {
for (size_t i = (size_t)0; i < num_verts + 1; ++i) {
for (size_t i = (size_t)0; i < num_verts; ++i) {
verts_buffer[i].x = verts[i].x;
verts_buffer[i].y = verts[i].y;
verts_buffer[i].z = verts[i].z;
Expand Down Expand Up @@ -463,20 +470,6 @@ void BVHEmbree::set_curve_vertex_buffer(RTCGeometry geom_id, const Hair *hair, c
}
}

/**
* Pack the motion points into a float4 as [x y z radius]
*/
template<typename T>
void pack_motion_points(size_t num_points, const T *verts, const float *radius, float4 *rtc_verts)
{
for (size_t j = 0; j < num_points; ++j) {
rtc_verts[j].x = verts[j].x;
rtc_verts[j].y = verts[j].y;
rtc_verts[j].z = verts[j].z;
rtc_verts[j].w = radius[j];
}
}

void BVHEmbree::set_point_vertex_buffer(RTCGeometry geom_id,
const PointCloud *pointcloud,
const bool update)
Expand Down Expand Up @@ -512,13 +505,20 @@ void BVHEmbree::set_point_vertex_buffer(RTCGeometry geom_id,
assert(rtc_verts);
if (rtc_verts) {
if (t == t_mid || attr_mP == NULL) {
/* Pack the motion points into a float4 as [x y z radius]. */
const float3 *verts = pointcloud->get_points().data();
pack_motion_points<float3>(num_points, verts, radius, rtc_verts);
for (size_t j = 0; j < num_points; ++j) {
rtc_verts[j].x = verts[j].x;
rtc_verts[j].y = verts[j].y;
rtc_verts[j].z = verts[j].z;
rtc_verts[j].w = radius[j];
}
}
else {
/* Motion blur is already packed as [x y z radius]. */
int t_ = (t > t_mid) ? (t - 1) : t;
const float4 *verts = &attr_mP->data_float4()[t_ * num_points];
pack_motion_points<float4>(num_points, verts, radius, rtc_verts);
memcpy(rtc_verts, verts, sizeof(float4) * num_points);
}
}

Expand Down
6 changes: 3 additions & 3 deletions intern/cycles/device/hiprt/device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ hiprtGeometryBuildInput HIPRTDevice::prepare_point_blas(BVHHIPRT *bvh, PointClou
const float3 *points_data = pointcloud->get_points().data();
const float *radius_data = pointcloud->get_radius().data();
const size_t num_points = pointcloud->num_points();
const float3 *motion_data = (point_attr_mP) ? point_attr_mP->data_float3() : NULL;
const float4 *motion_data = (point_attr_mP) ? point_attr_mP->data_float4() : NULL;
const size_t num_steps = pointcloud->get_motion_steps();

int num_bounds = 0;
Expand Down Expand Up @@ -645,7 +645,7 @@ hiprtGeometryBuildInput HIPRTDevice::prepare_point_blas(BVHHIPRT *bvh, PointClou
BoundBox bounds = BoundBox::empty;
point.bounds_grow(points_data, radius_data, bounds);
for (size_t step = 0; step < num_steps - 1; step++) {
point.bounds_grow(motion_data + step * num_points, radius_data, bounds);
point.bounds_grow(motion_data[step * num_points + j], bounds);
}
if (bounds.valid()) {
bvh->custom_primitive_bound[num_bounds] = bounds;
Expand All @@ -665,7 +665,7 @@ hiprtGeometryBuildInput HIPRTDevice::prepare_point_blas(BVHHIPRT *bvh, PointClou
for (uint j = 0; j < num_points; j++) {
const PointCloud::Point point = pointcloud->get_point(j);
const size_t num_steps = pointcloud->get_motion_steps();
const float3 *point_steps = point_attr_mP->data_float3();
const float4 *point_steps = point_attr_mP->data_float4();

float4 prev_key = point.motion_key(
points_data, radius_data, point_steps, num_points, num_steps, 0.0f, j);
Expand Down
33 changes: 22 additions & 11 deletions intern/cycles/device/metal/bvh.mm
Original file line number Diff line number Diff line change
Expand Up @@ -515,20 +515,31 @@
/* Get AABBs for each motion step */
size_t center_step = (num_motion_steps - 1) / 2;
for (size_t step = 0; step < num_motion_steps; ++step) {
/* The center step for motion vertices is not stored in the attribute */
if (step != center_step) {
size_t attr_offset = (step > center_step) ? step - 1 : step;
points = motion_keys->data_float3() + attr_offset * num_points;
if (step == center_step) {
/* The center step for motion vertices is not stored in the attribute */
for (size_t j = 0; j < num_points; ++j) {
const PointCloud::Point point = pointcloud->get_point(j);
BoundBox bounds = BoundBox::empty;
point.bounds_grow(points, radius, bounds);

const size_t index = step * num_points + j;
aabb_data[index].min = (MTLPackedFloat3 &)bounds.min;
aabb_data[index].max = (MTLPackedFloat3 &)bounds.max;
}
}
else {
size_t attr_offset = (step > center_step) ? step - 1 : step;
float4 *motion_points = motion_keys->data_float4() + attr_offset * num_points;

for (size_t j = 0; j < num_points; ++j) {
const PointCloud::Point point = pointcloud->get_point(j);
BoundBox bounds = BoundBox::empty;
point.bounds_grow(points, radius, bounds);
for (size_t j = 0; j < num_points; ++j) {
const PointCloud::Point point = pointcloud->get_point(j);
BoundBox bounds = BoundBox::empty;
point.bounds_grow(motion_points[j], bounds);

const size_t index = step * num_points + j;
aabb_data[index].min = (MTLPackedFloat3 &)bounds.min;
aabb_data[index].max = (MTLPackedFloat3 &)bounds.max;
const size_t index = step * num_points + j;
aabb_data[index].min = (MTLPackedFloat3 &)bounds.min;
aabb_data[index].max = (MTLPackedFloat3 &)bounds.max;
}
}
}

Expand Down
54 changes: 35 additions & 19 deletions intern/cycles/device/optix/device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,27 +1384,43 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit)
/* Get AABBs for each motion step. */
for (size_t step = 0; step < num_motion_steps; ++step) {
/* The center step for motion vertices is not stored in the attribute. */
const float3 *points = pointcloud->get_points().data();
const float *radius = pointcloud->get_radius().data();
size_t center_step = (num_motion_steps - 1) / 2;
if (step != center_step) {
size_t attr_offset = (step > center_step) ? step - 1 : step;
/* Technically this is a float4 array, but sizeof(float3) == sizeof(float4). */
points = motion_points->data_float3() + attr_offset * num_points;
}

for (size_t i = 0; i < num_points; ++i) {
const PointCloud::Point point = pointcloud->get_point(i);
BoundBox bounds = BoundBox::empty;
point.bounds_grow(points, radius, bounds);

const size_t index = step * num_points + i;
aabb_data[index].minX = bounds.min.x;
aabb_data[index].minY = bounds.min.y;
aabb_data[index].minZ = bounds.min.z;
aabb_data[index].maxX = bounds.max.x;
aabb_data[index].maxY = bounds.max.y;
aabb_data[index].maxZ = bounds.max.z;
if (step == center_step) {
const float3 *points = pointcloud->get_points().data();
const float *radius = pointcloud->get_radius().data();

for (size_t i = 0; i < num_points; ++i) {
const PointCloud::Point point = pointcloud->get_point(i);
BoundBox bounds = BoundBox::empty;
point.bounds_grow(points, radius, bounds);

const size_t index = step * num_points + i;
aabb_data[index].minX = bounds.min.x;
aabb_data[index].minY = bounds.min.y;
aabb_data[index].minZ = bounds.min.z;
aabb_data[index].maxX = bounds.max.x;
aabb_data[index].maxY = bounds.max.y;
aabb_data[index].maxZ = bounds.max.z;
}
}
else {
size_t attr_offset = (step > center_step) ? step - 1 : step;
const float4 *points = motion_points->data_float4() + attr_offset * num_points;

for (size_t i = 0; i < num_points; ++i) {
const PointCloud::Point point = pointcloud->get_point(i);
BoundBox bounds = BoundBox::empty;
point.bounds_grow(points[i], bounds);

const size_t index = step * num_points + i;
aabb_data[index].minX = bounds.min.x;
aabb_data[index].minY = bounds.min.y;
aabb_data[index].minZ = bounds.min.z;
aabb_data[index].maxX = bounds.max.x;
aabb_data[index].maxY = bounds.max.y;
aabb_data[index].maxZ = bounds.max.z;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion intern/cycles/kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ if(WITH_CYCLES_DEVICE_HIPRT AND WITH_CYCLES_HIP_BINARIES)
${SRC_UTIL_HEADERS})
set(bitcode_file ${CMAKE_CURRENT_BINARY_DIR}/kernel_rt_gfx.bc)
set(hiprt_file ${CMAKE_CURRENT_BINARY_DIR}/kernel_rt_gfx.hipfb)
set(kernel_sources ${sources})
set(kernel_sources ${hiprt_sources})
set(hiprt_kernel_src "/device/hiprt/kernel.cpp")
if(WIN32)
set(hiprt_compile_command ${CMAKE_COMMAND})
Expand Down
17 changes: 7 additions & 10 deletions intern/cycles/scene/pointcloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void PointCloud::Point::bounds_grow(const float4 &point, BoundBox &bounds) const

float4 PointCloud::Point::motion_key(const float3 *points,
const float *radius,
const float3 *point_steps,
const float4 *point_steps,
size_t num_points,
size_t num_steps,
float time,
Expand All @@ -55,7 +55,7 @@ float4 PointCloud::Point::motion_key(const float3 *points,

float4 PointCloud::Point::point_for_step(const float3 *points,
const float *radius,
const float3 *point_steps,
const float4 *point_steps,
size_t num_points,
size_t num_steps,
size_t step,
Expand All @@ -72,10 +72,7 @@ float4 PointCloud::Point::point_for_step(const float3 *points,
step--;
}
const size_t offset = step * num_points;
return make_float4(point_steps[offset + p].x,
point_steps[offset + p].y,
point_steps[offset + p].z,
radius[offset + p]);
return point_steps[offset + p];
}
}

Expand Down Expand Up @@ -188,10 +185,10 @@ void PointCloud::compute_bounds()
Attribute *attr = attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
if (use_motion_blur && attr) {
size_t steps_size = points.size() * (motion_steps - 1);
float3 *point_steps = attr->data_float3();
float4 *point_steps = attr->data_float4();

for (size_t i = 0; i < steps_size; i++)
bnds.grow(point_steps[i]);
bnds.grow(float4_to_float3(point_steps[i]), point_steps[i].w);
}

if (!bnds.valid()) {
Expand All @@ -203,10 +200,10 @@ void PointCloud::compute_bounds()

if (use_motion_blur && attr) {
size_t steps_size = points.size() * (motion_steps - 1);
float3 *point_steps = attr->data_float3();
float4 *point_steps = attr->data_float4();

for (size_t i = 0; i < steps_size; i++)
bnds.grow_safe(point_steps[i]);
bnds.grow_safe(float4_to_float3(point_steps[i]), point_steps[i].w);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions intern/cycles/scene/pointcloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class PointCloud : public Geometry {

float4 motion_key(const float3 *points,
const float *radius,
const float3 *point_steps,
const float4 *point_steps,
size_t num_points,
size_t num_steps,
float time,
size_t p) const;
float4 point_for_step(const float3 *points,
const float *radius,
const float3 *point_steps,
const float4 *point_steps,
size_t num_points,
size_t num_steps,
size_t step,
Expand Down

0 comments on commit 67ed28a

Please sign in to comment.