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:
Sergey Sharybin
2015-01-23 14:00:48 +05:00
parent 7733bd5efc
commit 2dfe5e30ac
4 changed files with 13 additions and 8 deletions

View File

@@ -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;
}