44 static const char *component_suffixes[] = {
"R",
"G",
"B",
"A"};
47 std::vector<std::string> channel_names;
61 const string channel_name_prefix = prefix + string(pass.
name) +
".";
64 channel_names.push_back(channel_name_prefix + component_suffixes[
i]);
75 return attr_name_prefix + string(socket.
name);
78template<
typename Val
idateValueFunc,
typename GetValueFunc>
80 ImageSpec *image_spec,
83 const string &attr_name_prefix,
84 const ValidateValueFunc &validate_value_func,
85 const GetValueFunc &get_value_func)
87 if (!validate_value_func(node, socket)) {
92 get_value_func(node, socket));
100 const string &attr_name_prefix)
104 switch (socket.
type) {
106 const ustring value = node->
get_string(socket);
110 if (!enum_values.
exists(value)) {
111 LOG_DFATAL <<
"Node enum contains invalid value " << value;
115 image_spec->attribute(attr_name, value);
121 image_spec->attribute(attr_name, node->
get_string(socket));
125 image_spec->attribute(attr_name, node->
get_int(socket));
129 image_spec->attribute(attr_name, node->
get_float(socket));
133 image_spec->attribute(attr_name, node->
get_bool(socket));
137 LOG_DFATAL <<
"Unhandled socket type " << socket.
type <<
", should never happen.";
144 const ImageSpec &image_spec,
145 const string &attr_name_prefix)
149 switch (socket.
type) {
152 const ustring value(image_spec.get_string_attribute(attr_name,
""));
156 if (!enum_values.
exists(value)) {
157 LOG_ERROR <<
"Invalid enumerator value " << value;
161 node->
set(socket, enum_values[value]);
168 node->
set(socket, ustring(image_spec.get_string_attribute(attr_name,
"")));
172 node->
set(socket, image_spec.get_int_attribute(attr_name, 0));
176 node->
set(socket, image_spec.get_float_attribute(attr_name, 0));
180 node->
set(socket,
static_cast<bool>(image_spec.get_int_attribute(attr_name, 0)));
184 LOG_DFATAL <<
"Unhandled socket type " << socket.
type <<
", should never happen.";
191 const string &attr_name_prefix)
203 const ImageSpec &image_spec,
204 const string &attr_name_prefix)
224 const int num_passes = buffer_params.
passes.size();
227 for (
int pass_index = 0; pass_index < num_passes; ++pass_index) {
240 const ImageSpec &image_spec)
249 if (num_passes == 0) {
250 LOG_ERROR <<
"Missing passes count attribute.";
254 for (
int pass_index = 0; pass_index < num_passes; ++pass_index) {
263 buffer_params->
passes.emplace_back(std::move(pass));
283 const int num_channels = channel_names.size();
285 *image_spec = ImageSpec(
286 buffer_params.
width, buffer_params.
height, num_channels, TypeDesc::FLOAT);
288 image_spec->channelnames = std::move(channel_names);
294 if (tile_size.x != 0 || tile_size.y != 0) {
316 const int tile_manager_id =
g_instance_index.fetch_add(1, std::memory_order_relaxed);
318 to_string(
reinterpret_cast<uintptr_t
>(
this)) +
"-" +
329 const int computed_tile_size = (suggested_tile_size <=
IMAGE_TILE_SIZE) ?
330 suggested_tile_size :
337 LOG_DEBUG <<
"Using tile size of " << tile_size;
412 const int tile_index_y = index /
tile_state_.num_tiles_x;
413 const int tile_index_x = index - tile_index_y *
tile_state_.num_tiles_x;
415 const int tile_window_x = tile_index_x *
tile_size_.x;
416 const int tile_window_y = tile_index_y *
tile_size_.y;
423 tile.window_x = tile_window_x -
tile.x;
424 tile.window_y = tile_window_y -
tile.y;
458 LOG_ERROR <<
"Progress tile file format does not support tiling.";
502 const double time_start =
time_dt();
512 const int64_t tile_row_stride = tile_params.
width * pass_stride;
515 const float *pixels = tile_buffers.
buffer.
data() + tile_params.
window_x * pass_stride +
516 tile_params.
window_y * tile_row_stride;
527 float *pixels_continuous = pixel_storage.data();
529 const int64_t pixels_row_stride = pass_stride * tile_params.
width;
533 memcpy(pixels_continuous, pixels,
sizeof(
float) * pixels_continuous_row_stride);
534 pixels += pixels_row_stride;
535 pixels_continuous += pixels_continuous_row_stride;
538 pixels = pixel_storage.data();
541 LOG_DEBUG <<
"Write tile at " << tile_x <<
", " << tile_y;
595 const int tile_x =
tile.x +
tile.window_x;
596 const int tile_y =
tile.y +
tile.window_y;
598 LOG_DEBUG <<
"Write dummy tile at " << tile_x <<
", " << tile_y;
601 tile_x +
tile.window_width,
603 tile_y +
tile.window_height,
607 pixel_storage.data());
650 const int num_channels =
in->spec().nchannels;
651 if (!
in->read_image(0, 0, 0, num_channels, TypeDesc::FLOAT,
buffers->buffer.data())) {
652 LOG_ERROR <<
"Error reading pixels from the tile file " <<
in->geterror();
657 LOG_ERROR <<
"Error closing tile file " <<
in->geterror();
vector< BufferPass > passes
PassInfo get_info() const
DenoiseParams get_denoise_params() const
AdaptiveSampling get_adaptive_sampling() const
device_vector< float > buffer
BufferParams buffer_params_
void set_temp_dir(const string &temp_dir)
struct TileManager::@125027310271160227025200215276036146163231274365 write_state_
struct TileManager::@317216067254110143221163173360002321176262313034 tile_state_
int compute_render_tile_size(const int suggested_tile_size) const
bool has_multiple_tiles() const
void update(const BufferParams ¶ms, const Scene *scene)
const Tile & get_current_tile() const
std::function< void(string_view)> full_buffer_written_cb
bool write_tile(const RenderBuffers &tile_buffers)
bool read_full_buffer_from_disk(string_view filename, RenderBuffers *buffers, DenoiseParams *denoise_params)
Tile get_tile_for_index(const int index) const
static const int MAX_TILE_SIZE
string tile_file_unique_part_
void finish_write_tiles()
void reset_scheduling(const BufferParams ¶ms, const int2 tile_size)
static const int IMAGE_TILE_SIZE
#define CCL_NAMESPACE_END
static const char * to_string(const Interpolation &interp)
const ccl_global KernelWorkTile * tile
size_t path_file_size(const string &path)
string path_join(const string &dir, const string &file)
static const char * ATTR_PASS_SOCKET_PREFIX_FORMAT
static bool node_socket_generic_to_image_spec_atttributes(ImageSpec *image_spec, const Node *node, const SocketType &socket, const string &attr_name_prefix, const ValidateValueFunc &validate_value_func, const GetValueFunc &get_value_func)
static const char * ATTR_BUFFER_SOCKET_PREFIX
static std::vector< std::string > exr_channel_names_for_passes(const BufferParams &buffer_params)
static bool buffer_params_to_image_spec_atttributes(ImageSpec *image_spec, const BufferParams &buffer_params)
static const char * ATTR_DENOISE_SOCKET_PREFIX
static CCL_NAMESPACE_BEGIN const char * ATTR_PASSES_COUNT
static std::atomic< uint64_t > g_instance_index
static bool node_socket_from_image_spec_atttributes(Node *node, const SocketType &socket, const ImageSpec &image_spec, const string &attr_name_prefix)
static bool node_from_image_spec_atttributes(Node *node, const ImageSpec &image_spec, const string &attr_name_prefix)
static bool node_to_image_spec_atttributes(ImageSpec *image_spec, const Node *node, const string &attr_name_prefix)
string node_socket_attribute_name(const SocketType &socket, const string &attr_name_prefix)
static bool buffer_params_from_image_spec_atttributes(BufferParams *buffer_params, const ImageSpec &image_spec)
static bool configure_image_spec_from_buffer(ImageSpec *image_spec, const BufferParams &buffer_params, const int2 tile_size=make_int2(0, 0))
static bool node_socket_to_image_spec_atttributes(ImageSpec *image_spec, const Node *node, const SocketType &socket, const string &attr_name_prefix)
string string_human_readable_number(size_t num)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
bool exists(ustring x) const
vector< SocketType, std::allocator< SocketType > > inputs
float get_float(const SocketType &input) const
void set(const SocketType &input, bool value)
bool get_bool(const SocketType &input) const
ustring get_string(const SocketType &input) const
int get_int(const SocketType &input) const
unique_ptr< BakeManager > bake_manager
const NodeEnum * enum_values
uint64_t system_self_process_id()
CCL_NAMESPACE_BEGIN double time_dt()
ccl_device_inline size_t divide_up(const size_t x, const size_t y)
ccl_device_inline size_t align_up(const size_t offset, const size_t alignment)