Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/multi/device.cpp
| Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | public: | ||||
| { | { | ||||
| foreach (SubDevice &sub, devices) | foreach (SubDevice &sub, devices) | ||||
| if (!sub.device->load_kernels(kernel_features)) | if (!sub.device->load_kernels(kernel_features)) | ||||
| return false; | return false; | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool load_osl_kernels() override | |||||
| { | |||||
| foreach (SubDevice &sub, devices) | |||||
| if (!sub.device->load_osl_kernels()) | |||||
| return false; | |||||
| return true; | |||||
| } | |||||
| void build_bvh(BVH *bvh, Progress &progress, bool refit) override | void build_bvh(BVH *bvh, Progress &progress, bool refit) override | ||||
| { | { | ||||
| /* Try to build and share a single acceleration structure, if possible */ | /* Try to build and share a single acceleration structure, if possible */ | ||||
| if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2 || bvh->params.bvh_layout == BVH_LAYOUT_EMBREE) { | if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2 || bvh->params.bvh_layout == BVH_LAYOUT_EMBREE) { | ||||
| devices.back().device->build_bvh(bvh, progress, refit); | devices.back().device->build_bvh(bvh, progress, refit); | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | void build_bvh(BVH *bvh, Progress &progress, bool refit) override | ||||
| /* Change geometry BVH pointers back to the multi BVH. */ | /* Change geometry BVH pointers back to the multi BVH. */ | ||||
| for (size_t k = 0; k < bvh->geometry.size(); ++k) { | for (size_t k = 0; k < bvh->geometry.size(); ++k) { | ||||
| bvh->geometry[k]->bvh = geom_bvhs[k]; | bvh->geometry[k]->bvh = geom_bvhs[k]; | ||||
| } | } | ||||
| } | } | ||||
| virtual void *get_cpu_osl_memory() override | virtual void *get_cpu_osl_memory() override | ||||
| { | { | ||||
| if (devices.size() > 1) { | /* Always return the OSL memory of the CPU device (this works since the constructor above | ||||
| * guarantees that CPU devices are always added to the back). */ | |||||
| if (devices.size() > 1 && devices.back().device->info.type != DEVICE_CPU) { | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| return devices.front().device->get_cpu_osl_memory(); | return devices.back().device->get_cpu_osl_memory(); | ||||
brecht: I'd rather no make assumptions about the order of the devices, better to loop over the devices… | |||||
Not Done Inline ActionsThe order is technically guaranteed by the implementation, which always adds CPU devices at the back: https://developer.blender.org/diffusion/B/browse/master/intern/cycles/device/multi/device.cpp$41 pmoursnv: The order is technically guaranteed by the implementation, which always adds CPU devices at the… | |||||
| } | } | ||||
| bool is_resident(device_ptr key, Device *sub_device) override | bool is_resident(device_ptr key, Device *sub_device) override | ||||
| { | { | ||||
| foreach (SubDevice &sub, devices) { | foreach (SubDevice &sub, devices) { | ||||
| if (sub.device == sub_device) { | if (sub.device == sub_device) { | ||||
| return find_matching_mem_device(key, sub)->device == sub_device; | return find_matching_mem_device(key, sub)->device == sub_device; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines | |||||
I'd rather no make assumptions about the order of the devices, better to loop over the devices here to find the CPU device.