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);
78 template<
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(
288 image_spec->channelnames = 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);
331 const int computed_tile_size = (suggested_tile_size <=
IMAGE_TILE_SIZE) ?
332 suggested_tile_size :
339 VLOG_WORK <<
"Using tile size of " << tile_size;
414 const int tile_index_y = index /
tile_state_.num_tiles_x;
415 const int tile_index_x = index - tile_index_y *
tile_state_.num_tiles_x;
417 const int tile_window_x = tile_index_x *
tile_size_.
x;
418 const int tile_window_y = tile_index_y *
tile_size_.
y;
455 LOG(ERROR) <<
"Error creating image output for " <<
write_state_.filename;
460 LOG(ERROR) <<
"Progress tile file format does not support tiling.";
465 LOG(ERROR) <<
"Error opening tile file: " <<
write_state_.tile_out->geterror();
487 LOG(ERROR) <<
"Error closing tile file.";
504 const double time_start =
time_dt();
518 tile_params.
window_y * tile_row_stride;
528 float *pixels_continuous = pixel_storage.data();
534 memcpy(pixels_continuous, pixels,
sizeof(
float) * pixels_continuous_row_stride);
535 pixels += pixels_row_stride;
536 pixels_continuous += pixels_continuous_row_stride;
539 pixels = pixel_storage.data();
542 VLOG_WORK <<
"Write tile at " << tile_x <<
", " << tile_y;
567 LOG(ERROR) <<
"Error writing tile " <<
write_state_.tile_out->geterror();
594 const int tile_x =
tile.
x +
tile.window_x;
595 const int tile_y =
tile.
y +
tile.window_y;
597 VLOG_WORK <<
"Write dummy tile at " << tile_x <<
", " << tile_y;
600 tile_x +
tile.window_width,
602 tile_y +
tile.window_height,
606 pixel_storage.data());
631 unique_ptr<ImageInput> in(ImageInput::open(
filename));
633 LOG(ERROR) <<
"Error opening tile file " <<
filename;
643 buffers->
reset(buffer_params);
650 LOG(ERROR) <<
"Error reading pixels from the tile file " << in->geterror();
655 LOG(ERROR) <<
"Error closing tile file " << in->geterror();
typedef float(TangentPoint)[2]
vector< BufferPass > passes
PassInfo get_info() const
DenoiseParams get_denoise_params() const
AdaptiveSampling get_adaptive_sampling() const
device_vector< float > buffer
void reset(const BufferParams ¶ms)
BufferParams buffer_params_
void set_temp_dir(const string &temp_dir)
function< void(string_view)> full_buffer_written_cb
void reset_scheduling(const BufferParams ¶ms, int2 tile_size)
int compute_render_tile_size(const int suggested_tile_size) const
bool has_multiple_tiles() const
struct TileManager::@1269 write_state_
Tile get_tile_for_index(int index) const
void update(const BufferParams ¶ms, const Scene *scene)
const int2 get_size() const
const Tile & get_current_tile() const
struct TileManager::@1268 tile_state_
bool write_tile(const RenderBuffers &tile_buffers)
bool read_full_buffer_from_disk(string_view filename, RenderBuffers *buffers, DenoiseParams *denoise_params)
static const int MAX_TILE_SIZE
string tile_file_unique_part_
void finish_write_tiles()
static const int IMAGE_TILE_SIZE
#define CCL_NAMESPACE_END
static const char * to_string(const Interpolation &interp)
ccl_global const KernelWorkTile * tile
ccl_gpu_kernel_postfix ccl_global float int int int int int int int pass_stride
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRefNull prop_name, int32_t value)
Allocate a new IDProperty of type IDP_INT, set its name and value.
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)
_W64 unsigned int uintptr_t
string string_human_readable_number(size_t num)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
bool exists(ustring x) const
BakeManager * bake_manager
const NodeEnum * enum_values
uint64_t system_self_process_id()
CCL_NAMESPACE_BEGIN double time_dt()
ccl_device_inline size_t align_up(size_t offset, size_t alignment)
ccl_device_inline size_t divide_up(size_t x, size_t y)