Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/device_memory.h
| Show All 29 Lines | |||||
| #include "util/util_debug.h" | #include "util/util_debug.h" | ||||
| #include "util/util_half.h" | #include "util/util_half.h" | ||||
| #include "util/util_types.h" | #include "util/util_types.h" | ||||
| #include "util/util_vector.h" | #include "util/util_vector.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| class Device; | |||||
| enum MemoryType { | enum MemoryType { | ||||
| MEM_READ_ONLY, | MEM_READ_ONLY, | ||||
| MEM_WRITE_ONLY, | MEM_WRITE_ONLY, | ||||
| MEM_READ_WRITE | MEM_READ_WRITE | ||||
| }; | }; | ||||
| /* Supported Data Types */ | /* Supported Data Types */ | ||||
| ▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| /* Device Memory */ | /* Device Memory */ | ||||
| class device_memory | class device_memory | ||||
| { | { | ||||
| public: | public: | ||||
| size_t memory_size() { return data_size*data_elements*datatype_size(data_type); } | size_t memory_size() { return data_size*data_elements*datatype_size(data_type); } | ||||
| size_t memory_num_to_bytes(int elements) { | |||||
brecht: Would rename to `memory_elements_size`. | |||||
| return elements*data_elements*datatype_size(data_type); | |||||
| } | |||||
| /* data information */ | /* data information */ | ||||
| DataType data_type; | DataType data_type; | ||||
| int data_elements; | int data_elements; | ||||
| device_ptr data_pointer; | device_ptr data_pointer; | ||||
| size_t data_size; | size_t data_size; | ||||
| size_t device_size; | size_t device_size; | ||||
| size_t data_width; | size_t data_width; | ||||
| ▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | public: | ||||
| { | { | ||||
| return &data[0]; | return &data[0]; | ||||
| } | } | ||||
| private: | private: | ||||
| array<T> data; | array<T> data; | ||||
| }; | }; | ||||
| class offset_ptr | |||||
brechtUnsubmitted Done Inline ActionsCan you add a comment explaining what this class is? Perhaps device_sub_ptr would be a better name, following OpenCL terminology. brecht: Can you add a comment explaining what this class is?
Perhaps `device_sub_ptr` would be a… | |||||
| { | |||||
| public: | |||||
| offset_ptr(Device *device, device_memory& mem, int offset, int size, MemoryType type); | |||||
| ~offset_ptr(); | |||||
| /* No copying. */ | |||||
| offset_ptr& operator = (const offset_ptr&); | |||||
| device_ptr operator*() const | |||||
| { | |||||
| return ptr; | |||||
| } | |||||
| protected: | |||||
| Device *device; | |||||
| device_ptr ptr; | |||||
| }; | |||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
| #endif /* __DEVICE_MEMORY_H__ */ | #endif /* __DEVICE_MEMORY_H__ */ | ||||
Would rename to memory_elements_size.