Cycles: Don't re-generate blackbody/beckmann tables on every shaders update
This commit makes it so blackbody and beckmann lookup tables are stored on CPU after being generated and then only being copied to the device if needed. This solves lag of viewport update when tweaking shader tree by using 266KB of CPU memory.
This commit is contained in:
parent
7733bd5efc
commit
2dfe5e30ac
|
@ -38,7 +38,7 @@
|
|||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
vector<float> blackbody_table()
|
||||
vector<float> blackbody_table_build()
|
||||
{
|
||||
/* quoted from OSLs opcolor.cpp
|
||||
In order to speed up the blackbody computation, we have a table
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
vector<float> blackbody_table();
|
||||
vector<float> blackbody_table_build();
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
|
|
@ -387,8 +387,10 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
|
|||
KernelTables *ktables = &dscene->data.tables;
|
||||
|
||||
if(has_converter_blackbody && blackbody_table_offset == TABLE_OFFSET_INVALID) {
|
||||
vector<float> table = blackbody_table();
|
||||
blackbody_table_offset = scene->lookup_tables->add_table(dscene, table);
|
||||
if(blackbody_table.size() == 0) {
|
||||
blackbody_table = blackbody_table_build();
|
||||
}
|
||||
blackbody_table_offset = scene->lookup_tables->add_table(dscene, blackbody_table);
|
||||
|
||||
ktables->blackbody_offset = (int)blackbody_table_offset;
|
||||
}
|
||||
|
@ -399,10 +401,10 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
|
|||
|
||||
/* beckmann lookup table */
|
||||
if(beckmann_table_offset == TABLE_OFFSET_INVALID) {
|
||||
vector<float> table;
|
||||
beckmann_table_build(table);
|
||||
beckmann_table_offset = scene->lookup_tables->add_table(dscene, table);
|
||||
|
||||
if(beckmann_table.size() == 0) {
|
||||
beckmann_table_build(beckmann_table);
|
||||
}
|
||||
beckmann_table_offset = scene->lookup_tables->add_table(dscene, beckmann_table);
|
||||
ktables->beckmann_offset = (int)beckmann_table_offset;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,6 +170,9 @@ protected:
|
|||
typedef unordered_map<ustring, uint, ustringHash> AttributeIDMap;
|
||||
AttributeIDMap unique_attribute_id;
|
||||
|
||||
vector<float> blackbody_table;
|
||||
vector<float> beckmann_table;
|
||||
|
||||
size_t blackbody_table_offset;
|
||||
size_t beckmann_table_offset;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue