38 bool Device::need_types_update =
true;
39 bool Device::need_devices_update =
true;
46 uint Device::devices_initialized_mask = 0;
52 os <<
"Experimental features: " << (requested_features.
experimental ?
"On" :
"Off") << std::endl;
53 os <<
"Max nodes group: " << requested_features.
max_nodes_group << std::endl;
55 os <<
"Nodes features: " << requested_features.
nodes_features << std::endl;
97 "uniform vec2 fullscreen;\n"
100 "out vec2 texCoord_interp;\n"
102 "vec2 normalize_coordinates()\n"
104 " return (vec2(2.0) * (pos / fullscreen)) - vec2(1.0);\n"
109 " gl_Position = vec4(normalize_coordinates(), 0.0, 1.0);\n"
110 " texCoord_interp = texCoord;\n"
115 "uniform sampler2D image_texture;\n"
116 "in vec2 texCoord_interp;\n"
117 "out vec4 fragColor;\n"
121 " fragColor = texture(image_texture, texCoord_interp);\n"
126 LOG(ERROR) <<
"Shader: " <<
task <<
" error:";
127 LOG(ERROR) <<
"===== shader string ====";
129 stringstream stream(code);
133 while (getline(stream, partial,
'\n')) {
135 LOG(ERROR) <<
" " << line <<
" " << partial;
138 LOG(ERROR) << line <<
" " << partial;
160 for (
int i = 0; i < 2; i++) {
163 string source_str =
shaders[i].source;
164 const char *c_str = source_str.c_str();
169 glGetShaderiv(
shader, GL_COMPILE_STATUS, &status);
181 glBindFragDataLocation(
program, 0,
"fragColor");
186 glGetProgramiv(
program, GL_LINK_STATUS, &status);
214 LOG(ERROR) <<
"Shader doesn't contain the 'image_texture' uniform.";
220 LOG(ERROR) <<
"Shader doesn't contain the 'fullscreen' uniform.";
253 glActiveTexture(GL_TEXTURE0);
254 glGenTextures(1, &texid);
255 glBindTexture(GL_TEXTURE_2D, texid);
259 data_pointer += 4 *
y *
w;
260 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F,
w, h, 0, GL_RGBA, GL_HALF_FLOAT, data_pointer);
264 data_pointer += 4 *
y *
w;
265 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data_pointer);
268 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
269 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
273 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
276 GLint shader_program;
277 if (use_fallback_shader) {
285 glGetIntegerv(GL_CURRENT_PROGRAM, &shader_program);
295 glBufferData(GL_ARRAY_BUFFER, 16 *
sizeof(
float),
NULL, GL_STREAM_DRAW);
297 float *vpointer = (
float *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
322 glUnmapBuffer(GL_ARRAY_BUFFER);
326 GLuint vertex_array_object;
327 GLuint position_attribute, texcoord_attribute;
329 glGenVertexArrays(1, &vertex_array_object);
330 glBindVertexArray(vertex_array_object);
332 texcoord_attribute = glGetAttribLocation(shader_program,
"texCoord");
333 position_attribute = glGetAttribLocation(shader_program,
"pos");
335 glEnableVertexAttribArray(texcoord_attribute);
336 glEnableVertexAttribArray(position_attribute);
338 glVertexAttribPointer(
339 texcoord_attribute, 2, GL_FLOAT, GL_FALSE, 4 *
sizeof(
float), (
const GLvoid *)0);
340 glVertexAttribPointer(position_attribute,
345 (
const GLvoid *)(
sizeof(
float) * 2));
347 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
350 glBindBuffer(GL_ARRAY_BUFFER, 0);
353 if (use_fallback_shader) {
360 glDeleteVertexArrays(1, &vertex_array_object);
361 glBindTexture(GL_TEXTURE_2D, 0);
362 glDeleteTextures(1, &texid);
373 BVH2 *
const bvh2 =
static_cast<BVH2 *
>(bvh);
375 bvh2->
refit(progress);
426 if (device ==
NULL) {
435 if (strcmp(name,
"CPU") == 0)
437 else if (strcmp(name,
"CUDA") == 0)
439 else if (strcmp(name,
"OPTIX") == 0)
441 else if (strcmp(name,
"OPENCL") == 0)
443 else if (strcmp(name,
"NETWORK") == 0)
445 else if (strcmp(name,
"MULTI") == 0)
510 #if defined(WITH_CUDA) || defined(WITH_OPTIX)
576 string capabilities =
"";
579 capabilities +=
"\nCPU device capabilities: ";
586 capabilities +=
"\nOpenCL device capabilities:\n";
595 capabilities +=
"\nCUDA device capabilities:\n";
608 assert(subdevices.size() > 0);
610 if (subdevices.size() == 1) {
612 return subdevices.front();
616 info.
type = subdevices.front().type;
631 foreach (
const DeviceInfo &device, subdevices) {
636 int cpu_threads =
max(orig_cpu_threads - (subdevices.size() - 1), 0);
638 VLOG(1) <<
"CPU render threads reduced from " << orig_cpu_threads <<
" to " << cpu_threads
639 <<
", to dedicate to GPU.";
641 if (cpu_threads >= 1) {
651 VLOG(1) <<
"CPU render threads disabled for interactive render.";
689 devices_initialized_mask = 0;
705 if (!optix_devices.empty()) {
714 for (
const DeviceInfo &optix_device : optix_devices) {
715 if (cuda_device.num == optix_device.num) {
716 id += optix_device.id;
726 const DeviceInfo optix_device = optix_devices.front();
727 id += optix_device.
id;
typedef float(TangentPoint)[2]
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void refit(btStridingMeshInterface *triangles, const btVector3 &aabbMin, const btVector3 &aabbMax)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
void refit(Progress &progress)
void build(Progress &progress, Stats *stats)
vector< DeviceInfo > denoising_devices
vector< DeviceInfo > multi_devices
void add_denoising_devices(DenoiserType denoiser_type)
DenoiserTypeMask denoisers
bool has_adaptive_stop_per_sample
bool has_volume_decoupled
bool use_integrator_branched
bool use_background_light
bool use_patch_evaluation
bool use_true_displacement
static Device * create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background=true)
virtual void draw_pixels(device_memory &mem, int y, int w, int h, int width, int height, int dx, int dy, int dw, int dh, bool transparent, const DeviceDrawParams &draw_params)
static void free_memory()
static DeviceInfo dummy_device(const string &error_msg="")
int fallback_shader_program
static vector< DeviceInfo > available_devices(uint device_type_mask=DEVICE_MASK_ALL)
virtual void mem_copy_from(device_memory &mem, int y, int w, int h, int elem)=0
virtual ~Device() noexcept(false)
virtual void build_bvh(BVH *bvh, Progress &progress, bool refit)
unsigned int vertex_buffer
static DeviceType type_from_string(const char *name)
@ FALLBACK_SHADER_STATUS_SUCCESS
@ FALLBACK_SHADER_STATUS_ERROR
@ FALLBACK_SHADER_STATUS_NONE
bool bind_fallback_display_space_shader(const float width, const float height)
static string device_capabilities(uint device_type_mask=DEVICE_MASK_ALL)
static vector< DeviceType > available_types()
static string string_from_type(DeviceType type)
int image_texture_location
static DeviceInfo get_multi_device(const vector< DeviceInfo > &subdevices, int threads, bool background)
size_t memory_elements_size(int elements)
const char * FALLBACK_VERTEX_SHADER
static int bind_fallback_shader(void)
std::ostream & operator<<(std::ostream &os, const DeviceRequestedFeatures &requested_features)
const char * FALLBACK_FRAGMENT_SHADER
static void shader_print_errors(const char *task, const char *log, const char *code)
Device * device_cpu_create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background)
void device_cpu_info(vector< DeviceInfo > &devices)
string device_cpu_capabilities()
Device * device_dummy_create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background)
Device * device_optix_create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background)
Device * device_multi_create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background)
void device_network_info(vector< DeviceInfo > &devices)
void device_cuda_info(vector< DeviceInfo > &devices)
Device * device_network_create(DeviceInfo &info, Stats &stats, Profiler &profiler, const char *address)
string device_cuda_capabilities()
Device * device_cuda_create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background)
void device_optix_info(const vector< DeviceInfo > &cuda_devices, vector< DeviceInfo > &devices)
bool device_opencl_init()
void device_opencl_info(vector< DeviceInfo > &devices)
Device * device_opencl_create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background)
string device_opencl_capabilities()
@ DENOISER_OPENIMAGEDENOISE
#define CCL_NAMESPACE_END
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
INLINE Rall1d< T, V, S > log(const Rall1d< T, V, S > &arg)
Vector< CPUDevice > devices
list of all CPUDevices. for every hardware thread an instance of CPUDevice is created
ListBase threads
list of all thread for every CPUDevice in cpudevices a thread exists.
struct blender::compositor::@172::@174 task
function< void()> unbind_display_space_shader_cb
function< void()> bind_display_space_shader_cb
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
string string_from_bool(bool var)
int system_cpu_thread_count()
std::unique_lock< std::mutex > thread_scoped_lock
CCL_NAMESPACE_BEGIN typedef std::mutex thread_mutex