20#ifdef WITH_CYCLES_STANDALONE_GUI
34#ifdef WITH_CYCLES_STANDALONE_GUI
60 static int maxlen = 0;
61 const int len =
str.size();
64 for (
int i =
len; i < maxlen; i++) {
81 if (!substatus.empty()) {
82 status +=
": " + substatus;
86 status =
string_printf(
"Progress %05.2f %s", progress * 100, status.c_str());
135#ifdef WITH_CYCLES_STANDALONE_GUI
137 options.
session->set_display_driver(make_unique<OpenGLDisplayDriver>(
150#ifdef WITH_CYCLES_STANDALONE_GUI
180#ifdef WITH_CYCLES_STANDALONE_GUI
181static void display_info(
Progress &progress)
183 static double latency = 0.0;
184 static double last = 0;
185 const double elapsed =
time_dt();
189 latency = (elapsed - last);
197 progress.
get_time(total_time, sample_time);
201 if (!substatus.empty()) {
202 status +=
": " + substatus;
219 interactive.c_str());
235static void motion(
const int x,
const int y,
int button)
247 else if (button == 2) {
264static void resize(
const int width,
const int height)
281static void keyboard(
unsigned char key)
289 else if (key ==
'r') {
294 else if (key == 27) {
299 else if (key ==
'p') {
305 else if (key ==
'i') {
310 else if (
options.
interactive && (key ==
'w' || key ==
'a' || key ==
's' || key ==
'd')) {
317 else if (key ==
's') {
320 else if (key ==
'a') {
323 else if (key ==
'd') {
338 else if (
options.
interactive && (key ==
'0' || key ==
'1' || key ==
'2' || key ==
'3')) {
365static void parse_int(OIIO::cspan<const char *> argv,
int *i)
371static void parse_string(OIIO::cspan<const char *> argv, std::string *s)
389 string devicename =
"CPU";
395 if (!device_names.empty()) {
396 device_names +=
", ";
403 string ssname =
"svm";
408 bool profile =
false;
409 bool version =
false;
412 ap.usage(
"cycles [options] file.xml");
413 ap.arg(
"filename").hidden().action([&](
auto argv) {
options.
filepath = argv[0]; });
414 ap.arg(
"--device %s:DEVICE").help(
"Devices to use: " + device_names).action([&](
auto argv) {
418 ap.arg(
"--shadingsys %s:SHADINGSYSTEM")
419 .help(
"Shading system to use: svm, osl")
420 .action([&](
auto argv) {
parse_string(argv, &ssname); });
423 .help(
"Render in background, without user interface");
424 ap.arg(
"--quiet", &
options.
quiet).help(
"In background mode, don't print progress messages");
425 ap.arg(
"--samples %d:SAMPLES").help(
"Number of samples to render").action([&](
auto argv) {
428 ap.arg(
"--output %s:OUTPUT").help(
"File path to write output image").action([&](
auto argv) {
431 ap.arg(
"--threads %d:THREADS").help(
"CPU Rendering Threads").action([&](
auto argv) {
434 ap.arg(
"--width %d:WIDTH").help(
"Image width in pixelx").action([&](
auto argv) {
437 ap.arg(
"--height %d:HEIGHT").help(
"Image height in pixel").action([&](
auto argv) {
440 ap.arg(
"--tile-size %d:TILE_SIZE").help(
"Tile size in pixels").action([&](
auto argv) {
443 ap.arg(
"--list-devices", &list).help(
"List information about all available devices");
444 ap.arg(
"--profile", &profile).help(
"Enable profile logging");
445 ap.arg(
"--log-level %s:LEVEL")
446 .help(
"Log verbosity: fatal, error, warning, info, stats, debug")
447 .action([&](
auto argv) {
parse_string(argv, &log_level); });
448 ap.arg(
"--help", &help).help(
"Print help message");
449 ap.arg(
"--version", &version).help(
"Print version number");
451 if (ap.parse_args(argc, argv) < 0) {
452 fprintf(stderr,
"%s\n", ap.geterror().c_str());
457 if (!log_level.empty()) {
468 info.description.c_str(),
469 (info.display_device) ?
" (display)" :
"",
470 (info.meets_driver_requirement) ?
"" :
" (driver outdated)");
486 if (ssname ==
"osl") {
489 else if (ssname ==
"svm") {
493#ifndef WITH_CYCLES_STANDALONE_GUI
504 bool device_available =
false;
505 bool device_driver_outdated =
false;
507 if (info.meets_driver_requirement) {
509 device_available =
true;
512 device_driver_outdated =
true;
517 if (device_driver_outdated) {
518 fprintf(stderr,
"Device driver outdated: %s\n", devicename.c_str());
521 fprintf(stderr,
"Unknown device: %s\n", devicename.c_str());
526 else if (!(ssname ==
"osl" || ssname ==
"svm")) {
527 fprintf(stderr,
"Unknown shading system: %s\n", ssname.c_str());
533 fprintf(stderr,
"OSL shading system only works with CPU device\n");
542 fprintf(stderr,
"No file path specified\n");
551int main(
const int argc,
const char **argv)
558#ifdef WITH_CYCLES_STANDALONE_GUI
564#ifdef WITH_CYCLES_STANDALONE_GUI
void compute_auto_viewplane()
static DeviceType type_from_string(const char *name)
static vector< DeviceType > available_types()
static string string_from_type(DeviceType type)
static vector< DeviceInfo > available_devices(const uint device_type_mask=DEVICE_MASK_ALL)
void get_status(string &status_, string &substatus_) const
void get_time(double &total_time_, double &render_time_) const
double get_progress() const
ShadingSystem shadingsystem
T * create_node(Args &&...)=delete
static void session_init()
static void options_parse(const int argc, const char **argv)
static BufferParams & session_buffer_params()
static void session_print_status()
static void session_exit()
static void parse_string(OIIO::cspan< const char * > argv, std::string *s)
CCL_NAMESPACE_BEGIN struct Options options
static void session_print(const string &str)
static void parse_int(OIIO::cspan< const char * > argv, int *i)
void xml_read_file(Scene *scene, const char *filepath)
#define CCL_NAMESPACE_END
#define DEVICE_MASK(type)
#define assert(assertion)
float4x4 translate(float4x4 mat, float3 translation)
void log_init(const LogFunction func)
void log_level_set(const LogLevel level)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
string path_filename(const string &path)
void path_init(const string &path, const string &user_path)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
bool string_endswith(const string_view s, const string_view end)
string string_to_lower(const string &s)
SessionParams session_params
unique_ptr< Session > session
void system_max_open_files_ensure()
CCL_NAMESPACE_BEGIN double time_dt()
#define CYCLES_VERSION_STRING
void window_opengl_context_disable()
bool window_opengl_context_enable()
void window_display_info(const char *info)
void window_main_loop(const char *title, const int width, const int height, WindowInitFunc initf, WindowExitFunc exitf, WindowResizeFunc resize, WindowDisplayFunc display, WindowKeyboardFunc keyboard, WindowMotionFunc motion)
void window_display_help()