forked from bartvdbraak/blender
Fix #35896: cycles crash with OSL image textures and viewport + preview render
running at the same time.
This commit is contained in:
parent
0d7dbbb6e1
commit
54b1976958
@ -104,9 +104,10 @@ OSLRenderServices::~OSLRenderServices()
|
||||
{
|
||||
}
|
||||
|
||||
void OSLRenderServices::thread_init(KernelGlobals *kernel_globals_)
|
||||
void OSLRenderServices::thread_init(KernelGlobals *kernel_globals_, OSL::TextureSystem *osl_ts_)
|
||||
{
|
||||
kernel_globals = kernel_globals_;
|
||||
osl_ts = osl_ts_;
|
||||
}
|
||||
|
||||
bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time)
|
||||
@ -767,7 +768,7 @@ bool OSLRenderServices::texture(ustring filename, TextureOpt &options,
|
||||
float s, float t, float dsdx, float dtdx,
|
||||
float dsdy, float dtdy, float *result)
|
||||
{
|
||||
OSL::TextureSystem *ts = kernel_globals->osl->ts;
|
||||
OSL::TextureSystem *ts = osl_ts;
|
||||
bool status = ts->texture(filename, options, s, t, dsdx, dtdx, dsdy, dtdy, result);
|
||||
|
||||
if(!status) {
|
||||
@ -789,7 +790,7 @@ bool OSLRenderServices::texture3d(ustring filename, TextureOpt &options,
|
||||
const OSL::Vec3 &dPdx, const OSL::Vec3 &dPdy,
|
||||
const OSL::Vec3 &dPdz, float *result)
|
||||
{
|
||||
OSL::TextureSystem *ts = kernel_globals->osl->ts;
|
||||
OSL::TextureSystem *ts = osl_ts;
|
||||
bool status = ts->texture3d(filename, options, P, dPdx, dPdy, dPdz, result);
|
||||
|
||||
if(!status) {
|
||||
@ -811,7 +812,7 @@ bool OSLRenderServices::environment(ustring filename, TextureOpt &options,
|
||||
OSL::ShaderGlobals *sg, const OSL::Vec3 &R,
|
||||
const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, float *result)
|
||||
{
|
||||
OSL::TextureSystem *ts = kernel_globals->osl->ts;
|
||||
OSL::TextureSystem *ts = osl_ts;
|
||||
bool status = ts->environment(filename, options, R, dRdx, dRdy, result);
|
||||
|
||||
if(!status) {
|
||||
@ -832,7 +833,7 @@ bool OSLRenderServices::get_texture_info(ustring filename, int subimage,
|
||||
ustring dataname,
|
||||
TypeDesc datatype, void *data)
|
||||
{
|
||||
OSL::TextureSystem *ts = kernel_globals->osl->ts;
|
||||
OSL::TextureSystem *ts = osl_ts;
|
||||
return ts->get_texture_info(filename, subimage, dataname, datatype, data);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
OSLRenderServices();
|
||||
~OSLRenderServices();
|
||||
|
||||
void thread_init(KernelGlobals *kernel_globals);
|
||||
void thread_init(KernelGlobals *kernel_globals, OSL::TextureSystem *ts);
|
||||
|
||||
bool get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
|
||||
bool get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
|
||||
@ -148,6 +148,7 @@ public:
|
||||
|
||||
private:
|
||||
KernelGlobals *kernel_globals;
|
||||
OSL::TextureSystem *osl_ts;
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
@ -47,7 +47,7 @@ void OSLShader::thread_init(KernelGlobals *kg, KernelGlobals *kernel_globals, OS
|
||||
|
||||
/* per thread kernel data init*/
|
||||
kg->osl = osl_globals;
|
||||
kg->osl->services->thread_init(kernel_globals);
|
||||
kg->osl->services->thread_init(kernel_globals, osl_globals->ts);
|
||||
|
||||
OSL::ShadingSystem *ss = kg->osl->ss;
|
||||
OSLThreadData *tdata = new OSLThreadData();
|
||||
|
@ -38,6 +38,7 @@ Background::Background()
|
||||
use = true;
|
||||
|
||||
visibility = ~0;
|
||||
shader = 0;
|
||||
|
||||
transparent = false;
|
||||
need_update = true;
|
||||
@ -54,6 +55,11 @@ void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene
|
||||
|
||||
device_free(device, dscene);
|
||||
|
||||
if(use)
|
||||
shader = scene->default_background;
|
||||
else
|
||||
shader = scene->default_empty;
|
||||
|
||||
/* set shader index and transparent option */
|
||||
KernelBackground *kbackground = &dscene->data.background;
|
||||
|
||||
@ -61,10 +67,7 @@ void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene
|
||||
kbackground->ao_distance = ao_distance;
|
||||
|
||||
kbackground->transparent = transparent;
|
||||
if(use)
|
||||
kbackground->shader = scene->shader_manager->get_shader_id(scene->default_background);
|
||||
else
|
||||
kbackground->shader = scene->shader_manager->get_shader_id(scene->default_empty);
|
||||
kbackground->shader = scene->shader_manager->get_shader_id(shader);
|
||||
|
||||
if(!(visibility & PATH_RAY_DIFFUSE))
|
||||
kbackground->shader |= SHADER_EXCLUDE_DIFFUSE;
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
bool use;
|
||||
|
||||
uint visibility;
|
||||
uint shader;
|
||||
|
||||
bool transparent;
|
||||
bool need_update;
|
||||
|
@ -122,6 +122,12 @@ void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
|
||||
scene->image_manager->set_osl_texture_system((void*)ts);
|
||||
|
||||
device_update_common(device, dscene, scene, progress);
|
||||
|
||||
/* greedyjit test
|
||||
{
|
||||
thread_scoped_lock lock(ss_shared_mutex);
|
||||
ss->optimize_all_groups();
|
||||
}*/
|
||||
}
|
||||
|
||||
void OSLShaderManager::device_free(Device *device, DeviceScene *dscene, Scene *scene)
|
||||
@ -187,6 +193,7 @@ void OSLShaderManager::shading_system_init()
|
||||
ss_shared->attribute("lockgeom", 1);
|
||||
ss_shared->attribute("commonspace", "world");
|
||||
ss_shared->attribute("searchpath:shader", path_get("shader"));
|
||||
//ss_shared->attribute("greedyjit", 1);
|
||||
|
||||
/* our own ray types */
|
||||
static const char *raytypes[] = {
|
||||
@ -714,7 +721,7 @@ void OSLCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
|
||||
|
||||
current_type = type;
|
||||
|
||||
ss->ShaderGroupBegin();
|
||||
ss->ShaderGroupBegin(shader->name.c_str());
|
||||
|
||||
ShaderNode *output = graph->output();
|
||||
set<ShaderNode*> dependencies;
|
||||
@ -777,9 +784,11 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
|
||||
if(shader->graph_bump) {
|
||||
ss->clear_state();
|
||||
compile_type(shader, shader->graph_bump, SHADER_TYPE_SURFACE);
|
||||
shader->osl_surface_bump_ref = ss->state();
|
||||
}
|
||||
else
|
||||
shader->osl_surface_bump_ref = shader->osl_surface_ref;
|
||||
|
||||
shader->osl_surface_bump_ref = ss->state();
|
||||
ss->clear_state();
|
||||
|
||||
shader->has_surface = true;
|
||||
|
@ -180,7 +180,6 @@ public:
|
||||
int default_surface;
|
||||
int default_light;
|
||||
int default_background;
|
||||
int default_holdout;
|
||||
int default_empty;
|
||||
|
||||
/* device */
|
||||
|
@ -16,6 +16,7 @@
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "background.h"
|
||||
#include "bssrdf.h"
|
||||
#include "device.h"
|
||||
#include "graph.h"
|
||||
@ -191,10 +192,10 @@ void ShaderManager::device_update_shaders_used(Scene *scene)
|
||||
foreach(Shader *shader, scene->shaders)
|
||||
shader->used = false;
|
||||
|
||||
scene->shaders[scene->background->shader]->used = true;
|
||||
scene->shaders[scene->default_surface]->used = true;
|
||||
scene->shaders[scene->default_light]->used = true;
|
||||
scene->shaders[scene->default_background]->used = true;
|
||||
scene->shaders[scene->default_holdout]->used = true;
|
||||
scene->shaders[scene->default_empty]->used = true;
|
||||
|
||||
foreach(Mesh *mesh, scene->meshes)
|
||||
@ -327,22 +328,6 @@ void ShaderManager::add_default(Scene *scene)
|
||||
scene->default_background = scene->shaders.size() - 1;
|
||||
}
|
||||
|
||||
/* default holdout */
|
||||
{
|
||||
graph = new ShaderGraph();
|
||||
|
||||
closure = graph->add(new HoldoutNode());
|
||||
out = graph->output();
|
||||
|
||||
graph->connect(closure->output("Holdout"), out->input("Surface"));
|
||||
|
||||
shader = new Shader();
|
||||
shader->name = "default_holdout";
|
||||
shader->graph = graph;
|
||||
scene->shaders.push_back(shader);
|
||||
scene->default_holdout = scene->shaders.size() - 1;
|
||||
}
|
||||
|
||||
/* default empty */
|
||||
{
|
||||
graph = new ShaderGraph();
|
||||
|
Loading…
Reference in New Issue
Block a user