2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 02:50:24 +01:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BLENDER_SESSION_H__
|
|
|
|
#define __BLENDER_SESSION_H__
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "device/device.h"
|
|
|
|
#include "render/scene.h"
|
|
|
|
#include "render/session.h"
|
|
|
|
#include "render/bake.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "util/util_vector.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class Scene;
|
|
|
|
class Session;
|
2012-09-04 13:29:07 +00:00
|
|
|
class RenderBuffers;
|
|
|
|
class RenderTile;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
class BlenderSession {
|
|
|
|
public:
|
2016-01-30 14:18:29 +01:00
|
|
|
BlenderSession(BL::RenderEngine& b_engine,
|
|
|
|
BL::UserPreferences& b_userpref,
|
|
|
|
BL::BlendData& b_data,
|
|
|
|
BL::Scene& b_scene);
|
|
|
|
|
|
|
|
BlenderSession(BL::RenderEngine& b_engine,
|
|
|
|
BL::UserPreferences& b_userpref,
|
|
|
|
BL::BlendData& b_data,
|
|
|
|
BL::Scene& b_scene,
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
int width, int height);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
~BlenderSession();
|
|
|
|
|
2014-02-12 23:13:45 +01:00
|
|
|
void create();
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* session */
|
|
|
|
void create_session();
|
|
|
|
void free_session();
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void reset_session(BL::BlendData& b_data,
|
|
|
|
BL::Scene& b_scene);
|
2012-11-09 08:46:53 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* offline render */
|
|
|
|
void render();
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void bake(BL::Object& b_object,
|
2016-01-15 13:00:56 -02:00
|
|
|
const string& pass_type,
|
|
|
|
const int custom_flag,
|
|
|
|
const int object_id,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::BakePixel& pixel_array,
|
2016-01-15 13:00:56 -02:00
|
|
|
const size_t num_pixels,
|
|
|
|
const int depth,
|
|
|
|
float pixels[]);
|
2014-01-02 19:05:07 -02:00
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void write_render_result(BL::RenderResult& b_rr,
|
|
|
|
BL::RenderLayer& b_rlay,
|
|
|
|
RenderTile& rtile);
|
2012-09-04 13:29:07 +00:00
|
|
|
void write_render_tile(RenderTile& rtile);
|
|
|
|
|
|
|
|
/* update functions are used to update display buffer only after sample was rendered
|
|
|
|
* only needed for better visual feedback */
|
2016-01-30 14:18:29 +01:00
|
|
|
void update_render_result(BL::RenderResult& b_rr,
|
|
|
|
BL::RenderLayer& b_rlay,
|
|
|
|
RenderTile& rtile);
|
2017-05-07 14:40:58 +02:00
|
|
|
void update_render_tile(RenderTile& rtile, bool highlight);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* interactive updates */
|
|
|
|
void synchronize();
|
|
|
|
|
|
|
|
/* drawing */
|
|
|
|
bool draw(int w, int h);
|
|
|
|
void tag_redraw();
|
|
|
|
void tag_update();
|
|
|
|
void get_status(string& status, string& substatus);
|
2015-01-14 23:06:10 +05:00
|
|
|
void get_progress(float& progress, double& total_time, double& render_time);
|
2011-04-27 11:58:34 +00:00
|
|
|
void test_cancel();
|
2011-08-23 12:20:11 +00:00
|
|
|
void update_status_progress();
|
2014-07-22 18:41:01 -03:00
|
|
|
void update_bake_progress();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
bool background;
|
|
|
|
Session *session;
|
|
|
|
Scene *scene;
|
|
|
|
BlenderSync *sync;
|
|
|
|
double last_redraw_time;
|
|
|
|
|
|
|
|
BL::RenderEngine b_engine;
|
2012-01-09 16:58:01 +00:00
|
|
|
BL::UserPreferences b_userpref;
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::BlendData b_data;
|
2013-03-14 07:38:37 +00:00
|
|
|
BL::RenderSettings b_render;
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::Scene b_scene;
|
|
|
|
BL::SpaceView3D b_v3d;
|
|
|
|
BL::RegionView3D b_rv3d;
|
2012-09-04 13:29:07 +00:00
|
|
|
string b_rlay_name;
|
2015-04-06 10:40:12 -03:00
|
|
|
string b_rview_name;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-10-30 10:12:34 +00:00
|
|
|
string last_status;
|
2014-12-05 21:27:52 +05:00
|
|
|
string last_error;
|
2011-10-30 10:12:34 +00:00
|
|
|
float last_progress;
|
2017-01-19 00:41:55 +01:00
|
|
|
double last_status_time;
|
2011-10-30 10:12:34 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
int width, height;
|
2013-04-24 20:12:12 +00:00
|
|
|
double start_resize_time;
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2014-02-12 23:13:45 +01:00
|
|
|
void *python_thread_state;
|
|
|
|
|
2016-03-30 15:55:12 +02:00
|
|
|
/* Global state which is common for all render sessions created from Blender.
|
|
|
|
* Usually denotes command line arguments.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Blender is running from the command line, no windows are shown and some
|
|
|
|
* extra render optimization is possible (possible to free draw-only data and
|
|
|
|
* so on.
|
|
|
|
*/
|
|
|
|
static bool headless;
|
|
|
|
|
|
|
|
/* ** Resumable render ** */
|
|
|
|
|
|
|
|
/* Overall number of chunks in which the sample range is to be devided. */
|
|
|
|
static int num_resumable_chunks;
|
|
|
|
|
|
|
|
/* Current resumable chunk index to render. */
|
|
|
|
static int current_resumable_chunk;
|
|
|
|
|
2017-03-15 15:52:27 +01:00
|
|
|
/* Alternative to single-chunk rendering to render a range of chunks. */
|
|
|
|
static int start_resumable_chunk;
|
|
|
|
static int end_resumable_chunk;
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
protected:
|
2016-01-30 14:18:29 +01:00
|
|
|
void do_write_update_render_result(BL::RenderResult& b_rr,
|
|
|
|
BL::RenderLayer& b_rlay,
|
|
|
|
RenderTile& rtile,
|
|
|
|
bool do_update_only);
|
2017-05-07 14:40:58 +02:00
|
|
|
void do_write_update_render_tile(RenderTile& rtile, bool do_update_only, bool highlight);
|
Packed and generated images support for Cycles
This commit adds support of packed and generated images
for Cycles when using SVM backend. Movies are still not
supported. This changes also doesn't touch OSL which is
much less trivial to adopt for any images which are not
saved to disk.
Implementation details:
- When adding images to Image Manager is now possible
to mark image as builtin. Builtin images will bypass
OIIO loader and will use special loading callbacks.
- Callbacks are set by Blender Session and they're
using C++ RNA interface to obtain needed data (pixels,
dimensions, is_float flag).
- Image Manager assumes file path is used as reference
to a builtin images, but in fact currently image
datablock name is used for reference. This makes it
easy to find an image in BlendData database.
- Added some extra properties to Image RNA:
* channels, which denotes actual number of channels
in ImBuf. This is needed to treat image's pixels
correct (before it wasn't possible because API
used internal number of channels for pixels which
is in fact doesn't correlate with image depth)
* is_float, which is truth if image is stored in
float buffer of ImBuf.
- Implemented string lookup for C++ RNA collections
for cases there's no manual lookup function.
OSL is not supported because it used own image loading
and filtering routines and there's seems to be no API
to feed pre-loaded pixels directly to the library.
Think we'll either need to add some API to support
such kind of feeding or consider OSL does not have
support of packed images at all.
Movies are not supported at this moment because of lack
of RNA API to load specified frame. It's not difficult
to solve, just need to consider what to best here:
* Either write some general python interface for ImBuf
and use it via C++ API, or
* Write a PY API function which will return pixels for
given frame, or
* Use bad-level BKE_* call
Anyway, small steps, further improvements later.
Reviewed by Brecht, thanks!
2013-01-12 10:59:13 +00:00
|
|
|
|
2013-01-30 13:42:12 +00:00
|
|
|
int builtin_image_frame(const string &builtin_name);
|
2016-11-29 11:03:11 +01:00
|
|
|
void builtin_image_info(const string &builtin_name,
|
|
|
|
void *builtin_data,
|
|
|
|
bool &is_float,
|
|
|
|
int &width,
|
|
|
|
int &height,
|
|
|
|
int &depth,
|
2017-07-20 22:31:46 +02:00
|
|
|
int &channels,
|
|
|
|
bool &free_cache);
|
2016-11-29 11:03:11 +01:00
|
|
|
bool builtin_image_pixels(const string &builtin_name,
|
|
|
|
void *builtin_data,
|
|
|
|
unsigned char *pixels,
|
2017-07-20 22:31:46 +02:00
|
|
|
const size_t pixels_size,
|
|
|
|
const bool free_cache);
|
2016-11-29 11:03:11 +01:00
|
|
|
bool builtin_image_float_pixels(const string &builtin_name,
|
|
|
|
void *builtin_data,
|
|
|
|
float *pixels,
|
2017-07-20 22:31:46 +02:00
|
|
|
const size_t pixels_size,
|
|
|
|
const bool free_cache);
|
2016-03-30 15:55:12 +02:00
|
|
|
|
|
|
|
/* Update tile manager to reflect resumable render settings. */
|
|
|
|
void update_resumable_tile_manager(int num_samples);
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __BLENDER_SESSION_H__ */
|