Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-11-11 04:14:48 +0300
committerHans Goudey <h.goudey@me.com>2022-11-11 04:41:13 +0300
commit9465b109af0b70244a36f9e68493e316d9f8b56f (patch)
treec4d933bf09f8313071556063156538ec3356b24c /intern/cycles/kernel/osl/services.cpp
parent026d21a225521670c6b5083da9da61227da69e65 (diff)
parentca1642cd0c5cdf634fe2022c955d93983de95934 (diff)
Merge branch 'master' into refactor-mesh-position-genericrefactor-mesh-position-generic
Diffstat (limited to 'intern/cycles/kernel/osl/services.cpp')
-rw-r--r--intern/cycles/kernel/osl/services.cpp62
1 files changed, 42 insertions, 20 deletions
diff --git a/intern/cycles/kernel/osl/services.cpp b/intern/cycles/kernel/osl/services.cpp
index b744422ee78..3fd098de4bb 100644
--- a/intern/cycles/kernel/osl/services.cpp
+++ b/intern/cycles/kernel/osl/services.cpp
@@ -119,8 +119,8 @@ ustring OSLRenderServices::u_u("u");
ustring OSLRenderServices::u_v("v");
ustring OSLRenderServices::u_empty;
-OSLRenderServices::OSLRenderServices(OSL::TextureSystem *texture_system)
- : OSL::RendererServices(texture_system)
+OSLRenderServices::OSLRenderServices(OSL::TextureSystem *texture_system, int device_type)
+ : OSL::RendererServices(texture_system), device_type_(device_type)
{
}
@@ -131,6 +131,17 @@ OSLRenderServices::~OSLRenderServices()
}
}
+int OSLRenderServices::supports(string_view feature) const
+{
+#ifdef WITH_OPTIX
+ if (feature == "OptiX") {
+ return device_type_ == DEVICE_OPTIX;
+ }
+#endif
+
+ return false;
+}
+
bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg,
OSL::Matrix44 &result,
OSL::TransformationPtr xform,
@@ -1139,29 +1150,40 @@ TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(ustring file
{
OSLTextureHandleMap::iterator it = textures.find(filename);
- /* For non-OIIO textures, just return a pointer to our own OSLTextureHandle. */
- if (it != textures.end()) {
- if (it->second->type != OSLTextureHandle::OIIO) {
- return (TextureSystem::TextureHandle *)it->second.get();
+ if (device_type_ == DEVICE_CPU) {
+ /* For non-OIIO textures, just return a pointer to our own OSLTextureHandle. */
+ if (it != textures.end()) {
+ if (it->second->type != OSLTextureHandle::OIIO) {
+ return (TextureSystem::TextureHandle *)it->second.get();
+ }
}
- }
- /* Get handle from OpenImageIO. */
- OSL::TextureSystem *ts = m_texturesys;
- TextureSystem::TextureHandle *handle = ts->get_texture_handle(filename);
- if (handle == NULL) {
- return NULL;
- }
+ /* Get handle from OpenImageIO. */
+ OSL::TextureSystem *ts = m_texturesys;
+ TextureSystem::TextureHandle *handle = ts->get_texture_handle(filename);
+ if (handle == NULL) {
+ return NULL;
+ }
+
+ /* Insert new OSLTextureHandle if needed. */
+ if (it == textures.end()) {
+ textures.insert(filename, new OSLTextureHandle(OSLTextureHandle::OIIO));
+ it = textures.find(filename);
+ }
- /* Insert new OSLTextureHandle if needed. */
- if (it == textures.end()) {
- textures.insert(filename, new OSLTextureHandle(OSLTextureHandle::OIIO));
- it = textures.find(filename);
+ /* Assign OIIO texture handle and return. */
+ it->second->oiio_handle = handle;
+ return (TextureSystem::TextureHandle *)it->second.get();
}
+ else {
+ if (it != textures.end() && it->second->type == OSLTextureHandle::SVM &&
+ it->second->svm_slots[0].w == -1) {
+ return reinterpret_cast<TextureSystem::TextureHandle *>(
+ static_cast<uintptr_t>(it->second->svm_slots[0].y + 1));
+ }
- /* Assign OIIO texture handle and return. */
- it->second->oiio_handle = handle;
- return (TextureSystem::TextureHandle *)it->second.get();
+ return NULL;
+ }
}
bool OSLRenderServices::good(TextureSystem::TextureHandle *texture_handle)