Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/device.h
| Show First 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | |||||
| /* Device */ | /* Device */ | ||||
| struct DeviceDrawParams { | struct DeviceDrawParams { | ||||
| function<void(void)> bind_display_space_shader_cb; | function<void(void)> bind_display_space_shader_cb; | ||||
| function<void(void)> unbind_display_space_shader_cb; | function<void(void)> unbind_display_space_shader_cb; | ||||
| }; | }; | ||||
| class Device { | class Device { | ||||
| friend class device_sub_ptr; | |||||
| protected: | protected: | ||||
| Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background), vertex_buffer(0), info(info_), stats(stats_) {} | Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background), vertex_buffer(0), info(info_), stats(stats_) {} | ||||
| bool background; | bool background; | ||||
| string error_msg; | string error_msg; | ||||
| /* used for real time display */ | /* used for real time display */ | ||||
| unsigned int vertex_buffer; | unsigned int vertex_buffer; | ||||
| virtual device_ptr mem_alloc_sub_ptr(device_memory& /*mem*/, int /*offset*/, int /*size*/, MemoryType /*type*/) | |||||
| { | |||||
| /* Only required for devices that implement denoising. */ | |||||
| assert(false); | |||||
| return (device_ptr) 0; | |||||
| } | |||||
| virtual void mem_free_sub_ptr(device_ptr /*ptr*/) {}; | |||||
| public: | public: | ||||
| virtual ~Device(); | virtual ~Device(); | ||||
| /* info */ | /* info */ | ||||
| DeviceInfo info; | DeviceInfo info; | ||||
| virtual const string& error_message() { return error_msg; } | virtual const string& error_message() { return error_msg; } | ||||
| bool have_error() { return !error_message().empty(); } | bool have_error() { return !error_message().empty(); } | ||||
| virtual void set_error(const string& error) | virtual void set_error(const string& error) | ||||
| Show All 12 Lines | public: | ||||
| /* regular memory */ | /* regular memory */ | ||||
| virtual void mem_alloc(const char *name, device_memory& mem, MemoryType type) = 0; | virtual void mem_alloc(const char *name, device_memory& mem, MemoryType type) = 0; | ||||
| virtual void mem_copy_to(device_memory& mem) = 0; | virtual void mem_copy_to(device_memory& mem) = 0; | ||||
| virtual void mem_copy_from(device_memory& mem, | virtual void mem_copy_from(device_memory& mem, | ||||
| int y, int w, int h, int elem) = 0; | int y, int w, int h, int elem) = 0; | ||||
| virtual void mem_zero(device_memory& mem) = 0; | virtual void mem_zero(device_memory& mem) = 0; | ||||
| virtual void mem_free(device_memory& mem) = 0; | virtual void mem_free(device_memory& mem) = 0; | ||||
| virtual int mem_address_alignment() { return 16; } | |||||
brecht: `mem_address_alignment()` seems like a more clear name, not sure what offsets have to do with… | |||||
| /* constant memory */ | /* constant memory */ | ||||
| virtual void const_copy_to(const char *name, void *host, size_t size) = 0; | virtual void const_copy_to(const char *name, void *host, size_t size) = 0; | ||||
| /* texture memory */ | /* texture memory */ | ||||
| virtual void tex_alloc(const char * /*name*/, | virtual void tex_alloc(const char * /*name*/, | ||||
| device_memory& /*mem*/, | device_memory& /*mem*/, | ||||
Done Inline ActionsMaybe rename to mem_alloc_sub_ptr and mem_free_sub_ptr. brecht: Maybe rename to `mem_alloc_sub_ptr` and `mem_free_sub_ptr`. | |||||
| InterpolationType interpolation = INTERPOLATION_NONE, | InterpolationType interpolation = INTERPOLATION_NONE, | ||||
| ExtensionType extension = EXTENSION_REPEAT) | ExtensionType extension = EXTENSION_REPEAT) | ||||
| { | { | ||||
| (void)interpolation; /* Ignored. */ | (void)interpolation; /* Ignored. */ | ||||
| (void)extension; /* Ignored. */ | (void)extension; /* Ignored. */ | ||||
| }; | }; | ||||
| virtual void tex_free(device_memory& /*mem*/) {}; | virtual void tex_free(device_memory& /*mem*/) {}; | ||||
| Show All 25 Lines | |||||
| #ifdef WITH_NETWORK | #ifdef WITH_NETWORK | ||||
| /* networking */ | /* networking */ | ||||
| void server_run(); | void server_run(); | ||||
| #endif | #endif | ||||
| /* multi device */ | /* multi device */ | ||||
| virtual void map_tile(Device * /*sub_device*/, RenderTile& /*tile*/) {} | virtual void map_tile(Device * /*sub_device*/, RenderTile& /*tile*/) {} | ||||
| virtual int device_number(Device * /*sub_device*/) { return 0; } | virtual int device_number(Device * /*sub_device*/) { return 0; } | ||||
| virtual void map_neighbor_tiles(Device * /*sub_device*/, RenderTile * /*tiles*/) {} | |||||
| virtual void unmap_neighbor_tiles(Device * /*sub_device*/, RenderTile * /*tiles*/) {} | |||||
| /* static */ | /* static */ | ||||
| static Device *create(DeviceInfo& info, Stats &stats, bool background = true); | static Device *create(DeviceInfo& info, Stats &stats, bool background = true); | ||||
| static DeviceType type_from_string(const char *name); | static DeviceType type_from_string(const char *name); | ||||
| static string string_from_type(DeviceType type); | static string string_from_type(DeviceType type); | ||||
| static vector<DeviceType>& available_types(); | static vector<DeviceType>& available_types(); | ||||
| static vector<DeviceInfo>& available_devices(); | static vector<DeviceInfo>& available_devices(); | ||||
| Show All 18 Lines | |||||
mem_address_alignment() seems like a more clear name, not sure what offsets have to do with it.
I'm not sure what the require alignment is on CUDA, and on older CPUs SSE needs alignment as well. I suggest to use 16 as the default value here instead of 1.