Refactor: Cycles: Avoid double host alloc in HIP-RT
This code should be changed to not modify host pointers directly. But as long as we are going to do it, avoid unnecessary alloc and immediate free. Pull Request: https://projects.blender.org/blender/blender/pulls/132912
This commit is contained in:
@@ -1015,12 +1015,13 @@ hiprtScene HIPRTDevice::build_tlas(BVHHIPRT *bvh,
|
||||
blas_ptr.copy_to_device();
|
||||
transform_headers.copy_to_device();
|
||||
{
|
||||
instance_transform_matrix.alloc(frame_count);
|
||||
instance_transform_matrix.host_free();
|
||||
instance_transform_matrix.host_pointer = transform_matrix.data();
|
||||
instance_transform_matrix.data_elements = sizeof(hiprtFrameMatrix);
|
||||
instance_transform_matrix.data_type = TYPE_UCHAR;
|
||||
instance_transform_matrix.data_size = frame_count;
|
||||
instance_transform_matrix.data_width = frame_count;
|
||||
instance_transform_matrix.data_height = 0;
|
||||
instance_transform_matrix.data_depth = 0;
|
||||
instance_transform_matrix.copy_to_device();
|
||||
instance_transform_matrix.host_pointer = nullptr;
|
||||
}
|
||||
@@ -1068,12 +1069,13 @@ hiprtScene HIPRTDevice::build_tlas(BVHHIPRT *bvh,
|
||||
|
||||
if (bvh->custom_prim_info.size()) {
|
||||
size_t data_size = bvh->custom_prim_info.size();
|
||||
custom_prim_info.alloc(data_size);
|
||||
custom_prim_info.host_free();
|
||||
custom_prim_info.host_pointer = bvh->custom_prim_info.data();
|
||||
custom_prim_info.data_elements = 2;
|
||||
custom_prim_info.data_type = TYPE_INT;
|
||||
custom_prim_info.data_size = data_size;
|
||||
custom_prim_info.data_width = data_size;
|
||||
custom_prim_info.data_height = 0;
|
||||
custom_prim_info.data_depth = 0;
|
||||
custom_prim_info.copy_to_device();
|
||||
custom_prim_info.host_pointer = nullptr;
|
||||
|
||||
@@ -1082,12 +1084,13 @@ hiprtScene HIPRTDevice::build_tlas(BVHHIPRT *bvh,
|
||||
|
||||
if (bvh->prims_time.size()) {
|
||||
size_t data_size = bvh->prims_time.size();
|
||||
prims_time.alloc(data_size);
|
||||
prims_time.host_free();
|
||||
prims_time.host_pointer = bvh->prims_time.data();
|
||||
prims_time.data_elements = 2;
|
||||
prims_time.data_type = TYPE_FLOAT;
|
||||
prims_time.data_size = data_size;
|
||||
prims_time.data_width = data_size;
|
||||
prims_time.data_height = 0;
|
||||
prims_time.data_depth = 0;
|
||||
prims_time.copy_to_device();
|
||||
prims_time.host_pointer = nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user