mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
This helps avoid out of memory errors for complex scenes, and improves performance for smaller scenes with more memory available for states. Metal already had logic like this, now the logic is centralized and can be used for all GPU backends. The parameters have been somewhat tuned per device, based on earlier work for oneAPI in #163437 and CUDA in #163532. For Metal the behavior should remain basically the same. For oneAPI, this enables free_memory queries on iGPUs, as driver have been exposing this for some time. Co-authored-by: Patrick Mours <pmours@nvidia.com> Co-authored-by; Xavier Hallade <xavier.hallade@intel.com> Pull Request: https://projects.blender.org/blender/blender/pulls/163930
61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#pragma once
|
|
|
|
#ifdef WITH_CUDA
|
|
|
|
# include "device/memory.h"
|
|
# include "device/queue.h"
|
|
|
|
# include "device/cuda/util.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
class CUDADevice;
|
|
class device_memory;
|
|
|
|
/* Base class for CUDA queues. */
|
|
class CUDADeviceQueue : public DeviceQueue {
|
|
public:
|
|
CUDADeviceQueue(CUDADevice *device);
|
|
~CUDADeviceQueue() override;
|
|
|
|
int num_sort_partitions(int max_num_paths, uint max_scene_shaders) const override;
|
|
bool supports_local_atomic_sort() const override;
|
|
|
|
void init_execution() override;
|
|
void load_image_info() override;
|
|
|
|
bool enqueue(DeviceKernel kernel,
|
|
const int work_size,
|
|
const DeviceKernelArguments &args) override;
|
|
|
|
bool synchronize() override;
|
|
|
|
void zero_to_device(device_memory &mem) override;
|
|
void copy_to_device(device_memory &mem) override;
|
|
void copy_from_device(device_memory &mem) override;
|
|
void *copy_from_device_synchronized(device_memory &mem, vector<uint8_t> &storage) override;
|
|
|
|
virtual CUstream stream()
|
|
{
|
|
return cuda_stream_;
|
|
}
|
|
|
|
unique_ptr<DeviceGraphicsInterop> graphics_interop_create() override;
|
|
|
|
protected:
|
|
CUDADevice *cuda_device_;
|
|
CUstream cuda_stream_;
|
|
|
|
ConcurrentStatesParams concurrent_states_params() const override;
|
|
void get_memory_info(size_t &total, size_t &free) const override;
|
|
|
|
void assert_success(CUresult result, const char *operation);
|
|
};
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
#endif /* WITH_CUDA */
|