Merge branch 'blender-v2.91-release'

This commit is contained in:
Brecht Van Lommel 2020-11-12 20:19:30 +01:00
commit b6988de22a
7 changed files with 95 additions and 78 deletions

View File

@ -260,6 +260,8 @@ void BlenderSession::reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsg
void BlenderSession::free_session()
{
session->cancel();
delete sync;
delete session;
}

View File

@ -242,13 +242,6 @@ class BlenderVolumeLoader : public VDBImageLoader {
#endif
}
bool equals(const ImageLoader &other) const override
{
/* TODO: detect multiple volume datablocks with the same filepath. */
const BlenderVolumeLoader &other_loader = (const BlenderVolumeLoader &)other;
return b_volume == other_loader.b_volume && grid_name == other_loader.grid_name;
}
BL::Volume b_volume;
};
@ -307,23 +300,8 @@ static void sync_volume_object(BL::BlendData &b_data,
}
}
/* If the voxel attributes change, we need to rebuild the bounding mesh. */
static vector<int> get_voxel_image_slots(Mesh *mesh)
{
vector<int> slots;
for (const Attribute &attr : mesh->attributes.attributes) {
if (attr.element == ATTR_ELEMENT_VOXEL) {
slots.push_back(attr.data_voxel().svm_slot());
}
}
return slots;
}
void BlenderSync::sync_volume(BL::Object &b_ob, Volume *volume)
{
vector<int> old_voxel_slots = get_voxel_image_slots(volume);
volume->clear(true);
if (view_layer.use_volumes) {
@ -339,8 +317,7 @@ void BlenderSync::sync_volume(BL::Object &b_ob, Volume *volume)
}
/* Tag update. */
bool rebuild = (old_voxel_slots != get_voxel_image_slots(volume));
volume->tag_update(scene, rebuild);
volume->tag_update(scene, true);
}
CCL_NAMESPACE_END

View File

@ -1410,12 +1410,17 @@ void GeometryManager::device_update(Device *device,
true_displacement_used = true;
}
if (progress.get_cancel())
if (progress.get_cancel()) {
return;
}
}
}
}
if (progress.get_cancel()) {
return;
}
/* Tessellate meshes that are using subdivision */
if (total_tess_needed) {
scoped_callback_timer timer([scene](double time) {
@ -1453,10 +1458,15 @@ void GeometryManager::device_update(Device *device,
i++;
if (progress.get_cancel())
if (progress.get_cancel()) {
return;
}
}
}
if (progress.get_cancel()) {
return;
}
}
/* Update images needed for true displacement. */
@ -1486,8 +1496,9 @@ void GeometryManager::device_update(Device *device,
});
device_update_mesh(device, dscene, scene, true, progress);
}
if (progress.get_cancel())
if (progress.get_cancel()) {
return;
}
{
scoped_callback_timer timer([scene](double time) {
@ -1496,8 +1507,9 @@ void GeometryManager::device_update(Device *device,
}
});
device_update_attributes(device, dscene, scene, progress);
if (progress.get_cancel())
if (progress.get_cancel()) {
return;
}
}
/* Update displacement. */
@ -1527,11 +1539,16 @@ void GeometryManager::device_update(Device *device,
}
}
if (progress.get_cancel())
if (progress.get_cancel()) {
return;
}
}
}
if (progress.get_cancel()) {
return;
}
/* Device re-update after displacement. */
if (displacement_done) {
scoped_callback_timer timer([scene](double time) {
@ -1543,8 +1560,9 @@ void GeometryManager::device_update(Device *device,
device_free(device, dscene);
device_update_attributes(device, dscene, scene, progress);
if (progress.get_cancel())
if (progress.get_cancel()) {
return;
}
}
{
@ -1591,8 +1609,9 @@ void GeometryManager::device_update(Device *device,
}
}
if (progress.get_cancel())
if (progress.get_cancel()) {
return;
}
{
scoped_callback_timer timer([scene](double time) {
@ -1601,8 +1620,9 @@ void GeometryManager::device_update(Device *device,
}
});
device_update_bvh(device, dscene, scene, progress);
if (progress.get_cancel())
if (progress.get_cancel()) {
return;
}
}
{
@ -1613,8 +1633,9 @@ void GeometryManager::device_update(Device *device,
}
});
device_update_mesh(device, dscene, scene, false, progress);
if (progress.get_cancel())
if (progress.get_cancel()) {
return;
}
}
need_update = false;

View File

@ -98,21 +98,7 @@ Session::Session(const SessionParams &params_)
Session::~Session()
{
if (session_thread) {
/* wait for session thread to end */
progress.set_cancel("Exiting");
gpu_need_display_buffer_update = false;
gpu_need_display_buffer_update_cond.notify_all();
{
thread_scoped_lock pause_lock(pause_mutex);
pause = false;
}
pause_cond.notify_all();
wait();
}
cancel();
if (buffers && params.write_render_cb) {
/* Copy to display buffer and write out image if requested */
@ -146,6 +132,25 @@ void Session::start()
}
}
void Session::cancel()
{
if (session_thread) {
/* wait for session thread to end */
progress.set_cancel("Exiting");
gpu_need_display_buffer_update = false;
gpu_need_display_buffer_update_cond.notify_all();
{
thread_scoped_lock pause_lock(pause_mutex);
pause = false;
}
pause_cond.notify_all();
wait();
}
}
bool Session::ready_to_reset()
{
double dt = time_dt() - reset_time;

View File

@ -146,6 +146,7 @@ class Session {
~Session();
void start();
void cancel();
bool draw(BufferParams &params, DeviceDrawParams &draw_params);
void wait();

View File

@ -491,6 +491,39 @@ void GeometryManager::create_volume_mesh(Volume *volume, Progress &progress)
string msg = string_printf("Computing Volume Mesh %s", volume->name.c_str());
progress.set_status("Updating Mesh", msg);
/* Find shader and compute padding based on volume shader interpolation settings. */
Shader *volume_shader = NULL;
int pad_size = 0;
foreach (Node *node, volume->get_used_shaders()) {
Shader *shader = static_cast<Shader *>(node);
if (!shader->has_volume) {
continue;
}
volume_shader = shader;
if (shader->get_volume_interpolation_method() == VOLUME_INTERPOLATION_LINEAR) {
pad_size = max(1, pad_size);
}
else if (shader->get_volume_interpolation_method() == VOLUME_INTERPOLATION_CUBIC) {
pad_size = max(2, pad_size);
}
break;
}
/* Clear existing volume mesh, done here in case we early out due to
* empty grid or missing volume shader. */
volume->clear();
volume->need_update_rebuild = true;
if (!volume_shader) {
return;
}
/* Create volume mesh builder. */
VolumeMeshBuilder builder;
#ifdef WITH_OPENVDB
@ -537,37 +570,11 @@ void GeometryManager::create_volume_mesh(Volume *volume, Progress &progress)
}
#endif
/* If nothing to build, early out. */
if (builder.empty_grid()) {
return;
}
/* Compute padding. */
Shader *volume_shader = NULL;
int pad_size = 0;
foreach (Node *node, volume->get_used_shaders()) {
Shader *shader = static_cast<Shader *>(node);
if (!shader->has_volume) {
continue;
}
volume_shader = shader;
if (shader->get_volume_interpolation_method() == VOLUME_INTERPOLATION_LINEAR) {
pad_size = max(1, pad_size);
}
else if (shader->get_volume_interpolation_method() == VOLUME_INTERPOLATION_CUBIC) {
pad_size = max(2, pad_size);
}
break;
}
if (!volume_shader) {
return;
}
builder.add_padding(pad_size);
/* Slightly offset vertex coordinates to avoid overlapping faces with other
@ -583,11 +590,9 @@ void GeometryManager::create_volume_mesh(Volume *volume, Progress &progress)
vector<float3> face_normals;
builder.create_mesh(vertices, indices, face_normals, face_overlap_avoidance);
volume->clear();
volume->reserve_mesh(vertices.size(), indices.size() / 3);
volume->used_shaders.clear();
volume->used_shaders.push_back_slow(volume_shader);
volume->tag_modified();
volume->need_update_rebuild = true;
for (size_t i = 0; i < vertices.size(); ++i) {
volume->add_vertex(vertices[i]);

View File

@ -576,6 +576,12 @@ class USERPREF_PT_system_sound(SystemPanel, CenterAlignMixIn, Panel):
class USERPREF_PT_system_cycles_devices(SystemPanel, CenterAlignMixIn, Panel):
bl_label = "Cycles Render Devices"
@classmethod
def poll(cls, context):
# No GPU rendering on macOS currently.
import sys
return bpy.app.build_options.cycles and sys.platform != "darwin"
def draw_centered(self, context, layout):
prefs = context.preferences