Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/device/device.h')
-rw-r--r--intern/cycles/device/device.h145
1 files changed, 97 insertions, 48 deletions
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index ccee25ae34e..b856bdd9d01 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -19,15 +19,18 @@
#include <stdlib.h>
-#include "device_memory.h"
-#include "device_task.h"
+#include "bvh/bvh_params.h"
-#include "util_list.h"
-#include "util_stats.h"
-#include "util_string.h"
-#include "util_thread.h"
-#include "util_types.h"
-#include "util_vector.h"
+#include "device/device_memory.h"
+#include "device/device_task.h"
+
+#include "util/util_list.h"
+#include "util/util_stats.h"
+#include "util/util_string.h"
+#include "util/util_thread.h"
+#include "util/util_texture.h"
+#include "util/util_types.h"
+#include "util/util_vector.h"
CCL_NAMESPACE_BEGIN
@@ -51,11 +54,14 @@ public:
string description;
string id; /* used for user preferences, should stay fixed with changing hardware config */
int num;
- bool display_device;
- bool advanced_shading;
- bool pack_images;
- bool has_bindless_textures; /* flag for GPU and Multi device */
- bool use_split_kernel; /* Denotes if the device is going to run cycles using split-kernel */
+ bool display_device; /* GPU is used as a display device. */
+ bool advanced_shading; /* Supports full shading system. */
+ bool has_half_images; /* Support half-float textures. */
+ bool has_volume_decoupled; /* Decoupled volume shading. */
+ BVHLayoutMask bvh_layout_mask; /* Bitmask of supported BVH layouts. */
+ bool has_osl; /* Support Open Shading Language. */
+ bool use_split_kernel; /* Use split or mega kernel. */
+ int cpu_threads;
vector<DeviceInfo> multi_devices;
DeviceInfo()
@@ -63,10 +69,13 @@ public:
type = DEVICE_CPU;
id = "CPU";
num = 0;
+ cpu_threads = 0;
display_device = false;
advanced_shading = true;
- pack_images = false;
- has_bindless_textures = false;
+ has_half_images = false;
+ has_volume_decoupled = false;
+ bvh_layout_mask = BVH_LAYOUT_NONE;
+ has_osl = false;
use_split_kernel = false;
}
@@ -82,9 +91,6 @@ public:
/* Use experimental feature set. */
bool experimental;
- /* Maximum number of closures in shader trees. */
- int max_closure;
-
/* Selective nodes compilation. */
/* Identifier of a node group up to which all the nodes needs to be
@@ -121,11 +127,22 @@ public:
/* Use Transparent shadows */
bool use_transparent;
+ /* Use various shadow tricks, such as shadow catcher. */
+ bool use_shadow_tricks;
+
+ /* Per-uber shader usage flags. */
+ bool use_principled;
+
+ /* Denoising features. */
+ bool use_denoising;
+
+ /* Use raytracing in shaders. */
+ bool use_shader_raytrace;
+
DeviceRequestedFeatures()
{
/* TODO(sergey): Find more meaningful defaults. */
experimental = false;
- max_closure = 0;
max_nodes_group = 0;
nodes_features = 0;
use_hair = false;
@@ -137,12 +154,15 @@ public:
use_integrator_branched = false;
use_patch_evaluation = false;
use_transparent = false;
+ use_shadow_tricks = false;
+ use_principled = false;
+ use_denoising = false;
+ use_shader_raytrace = false;
}
bool modified(const DeviceRequestedFeatures& requested_features)
{
return !(experimental == requested_features.experimental &&
- max_closure == requested_features.max_closure &&
max_nodes_group == requested_features.max_nodes_group &&
nodes_features == requested_features.nodes_features &&
use_hair == requested_features.use_hair &&
@@ -153,7 +173,11 @@ public:
use_volume == requested_features.use_volume &&
use_integrator_branched == requested_features.use_integrator_branched &&
use_patch_evaluation == requested_features.use_patch_evaluation &&
- use_transparent == requested_features.use_transparent);
+ use_transparent == requested_features.use_transparent &&
+ use_shadow_tricks == requested_features.use_shadow_tricks &&
+ use_principled == requested_features.use_principled &&
+ use_denoising == requested_features.use_denoising &&
+ use_shader_raytrace == requested_features.use_shader_raytrace);
}
/* Convert the requested features structure to a build options,
@@ -169,7 +193,6 @@ public:
string_printf("%d", max_nodes_group);
build_options += " -D__NODES_FEATURES__=" +
string_printf("%d", nodes_features);
- build_options += string_printf(" -D__MAX_CLOSURE__=%d", max_closure);
if(!use_hair) {
build_options += " -D__NO_HAIR__";
}
@@ -194,9 +217,21 @@ public:
if(!use_patch_evaluation) {
build_options += " -D__NO_PATCH_EVAL__";
}
- if(!use_transparent) {
+ if(!use_transparent && !use_volume) {
build_options += " -D__NO_TRANSPARENT__";
}
+ if(!use_shadow_tricks) {
+ build_options += " -D__NO_SHADOW_TRICKS__";
+ }
+ if(!use_principled) {
+ build_options += " -D__NO_PRINCIPLED__";
+ }
+ if(!use_denoising) {
+ build_options += " -D__NO_DENOISING__";
+ }
+ if(!use_shader_raytrace) {
+ build_options += " -D__NO_SHADER_RAYTRACE__";
+ }
return build_options;
}
};
@@ -212,6 +247,7 @@ struct DeviceDrawParams {
};
class Device {
+ friend class device_sub_ptr;
protected:
Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background), vertex_buffer(0), info(info_), stats(stats_) {}
@@ -221,6 +257,14 @@ protected:
/* used for real time display */
unsigned int vertex_buffer;
+ virtual device_ptr mem_alloc_sub_ptr(device_memory& /*mem*/, int /*offset*/, int /*size*/)
+ {
+ /* Only required for devices that implement denoising. */
+ assert(false);
+ return (device_ptr) 0;
+ }
+ virtual void mem_free_sub_ptr(device_ptr /*ptr*/) {};
+
public:
virtual ~Device();
@@ -228,39 +272,25 @@ public:
DeviceInfo info;
virtual const string& error_message() { return error_msg; }
bool have_error() { return !error_message().empty(); }
+ virtual void set_error(const string& error)
+ {
+ if(!have_error()) {
+ error_msg = error;
+ }
+ fprintf(stderr, "%s\n", error.c_str());
+ fflush(stderr);
+ }
virtual bool show_samples() const { return false; }
/* statistics */
Stats &stats;
- /* regular memory */
- virtual void mem_alloc(device_memory& mem, MemoryType type) = 0;
- virtual void mem_copy_to(device_memory& mem) = 0;
- virtual void mem_copy_from(device_memory& mem,
- int y, int w, int h, int elem) = 0;
- virtual void mem_zero(device_memory& mem) = 0;
- virtual void mem_free(device_memory& mem) = 0;
+ /* memory alignment */
+ virtual int mem_sub_ptr_alignment() { return MIN_ALIGNMENT_CPU_DATA_TYPES; }
/* constant memory */
virtual void const_copy_to(const char *name, void *host, size_t size) = 0;
- /* texture memory */
- virtual void tex_alloc(const char * /*name*/,
- device_memory& /*mem*/,
- InterpolationType interpolation = INTERPOLATION_NONE,
- ExtensionType extension = EXTENSION_REPEAT)
- {
- (void)interpolation; /* Ignored. */
- (void)extension; /* Ignored. */
- };
-
- virtual void tex_free(device_memory& /*mem*/) {};
-
- /* pixel memory */
- virtual void pixels_alloc(device_memory& mem);
- virtual void pixels_copy_from(device_memory& mem, int y, int w, int h);
- virtual void pixels_free(device_memory& mem);
-
/* open shading language, only for CPU device */
virtual void *osl_memory() { return NULL; }
@@ -288,6 +318,8 @@ public:
/* multi device */
virtual void map_tile(Device * /*sub_device*/, RenderTile& /*tile*/) {}
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 Device *create(DeviceInfo& info, Stats &stats, bool background = true);
@@ -297,15 +329,32 @@ public:
static vector<DeviceType>& available_types();
static vector<DeviceInfo>& available_devices();
static string device_capabilities();
- static DeviceInfo get_multi_device(vector<DeviceInfo> subdevices);
+ static DeviceInfo get_multi_device(const vector<DeviceInfo>& subdevices,
+ int threads,
+ bool background);
/* Tag devices lists for update. */
static void tag_update();
static void free_memory();
+
+protected:
+ /* Memory allocation, only accessed through device_memory. */
+ friend class MultiDevice;
+ friend class DeviceServer;
+ friend class device_memory;
+
+ virtual void mem_alloc(device_memory& mem) = 0;
+ virtual void mem_copy_to(device_memory& mem) = 0;
+ virtual void mem_copy_from(device_memory& mem,
+ int y, int w, int h, int elem) = 0;
+ virtual void mem_zero(device_memory& mem) = 0;
+ virtual void mem_free(device_memory& mem) = 0;
+
private:
/* Indicted whether device types and devices lists were initialized. */
static bool need_types_update, need_devices_update;
+ static thread_mutex device_mutex;
static vector<DeviceType> types;
static vector<DeviceInfo> devices;
};