me-main #1

Merged
Nate Rupsis merged 123 commits from me-main into main 2023-02-13 18:39:11 +01:00
3 changed files with 26 additions and 15 deletions
Showing only changes of commit 9c03a1c92f - Show all commits

View File

@ -13,6 +13,7 @@
#include "scene/light.h" #include "scene/light.h"
#include "scene/mesh.h" #include "scene/mesh.h"
#include "scene/object.h" #include "scene/object.h"
#include "scene/osl.h"
#include "scene/pointcloud.h" #include "scene/pointcloud.h"
#include "scene/scene.h" #include "scene/scene.h"
#include "scene/shader.h" #include "scene/shader.h"
@ -25,7 +26,6 @@
#ifdef WITH_OSL #ifdef WITH_OSL
# include "kernel/osl/globals.h" # include "kernel/osl/globals.h"
# include "kernel/osl/services.h"
#endif #endif
#include "util/foreach.h" #include "util/foreach.h"
@ -1717,20 +1717,7 @@ void GeometryManager::device_update_displacement_images(Device *device,
/* If any OSL node is used for displacement, it may reference a texture. But it's /* If any OSL node is used for displacement, it may reference a texture. But it's
* unknown which ones, so have to load them all. */ * unknown which ones, so have to load them all. */
if (has_osl_node) { if (has_osl_node) {
set<OSLRenderServices *> services_shared; OSLShaderManager::osl_image_slots(device, image_manager, bump_images);
device->foreach_device([&services_shared](Device *sub_device) {
OSLGlobals *og = (OSLGlobals *)sub_device->get_cpu_osl_memory();
services_shared.insert(og->services);
});
for (OSLRenderServices *services : services_shared) {
for (auto it = services->textures.begin(); it != services->textures.end(); ++it) {
if (it->second->handle.get_manager() == image_manager) {
const int slot = it->second->handle.svm_slot();
bump_images.insert(slot);
}
}
}
} }
#endif #endif

View File

@ -665,6 +665,27 @@ OSLNode *OSLShaderManager::osl_node(ShaderGraph *graph,
return node; return node;
} }
/* Static function, so only this file needs to be compile with RTTT. */
void OSLShaderManager::osl_image_slots(Device *device,
ImageManager *image_manager,
set<int> &image_slots)
{
set<OSLRenderServices *> services_shared;
device->foreach_device([&services_shared](Device *sub_device) {
OSLGlobals *og = (OSLGlobals *)sub_device->get_cpu_osl_memory();
services_shared.insert(og->services);
});
for (OSLRenderServices *services : services_shared) {
for (auto it = services->textures.begin(); it != services->textures.end(); ++it) {
if (it->second->handle.get_manager() == image_manager) {
const int slot = it->second->handle.svm_slot();
image_slots.insert(slot);
}
}
}
}
/* Graph Compiler */ /* Graph Compiler */
OSLCompiler::OSLCompiler(OSLShaderManager *manager, OSL::ShadingSystem *ss, Scene *scene) OSLCompiler::OSLCompiler(OSLShaderManager *manager, OSL::ShadingSystem *ss, Scene *scene)

View File

@ -92,6 +92,9 @@ class OSLShaderManager : public ShaderManager {
const std::string &bytecode_hash = "", const std::string &bytecode_hash = "",
const std::string &bytecode = ""); const std::string &bytecode = "");
/* Get image slots used by OSL services on device. */
static void osl_image_slots(Device *device, ImageManager *image_manager, set<int> &image_slots);
private: private:
void texture_system_init(); void texture_system_init();
void texture_system_free(); void texture_system_free();