blender/intern/cycles/kernel/osl/globals.cpp
Brecht Van Lommel db9060b4d3 Cycles: Stop using OpenImageIO texture cache for OSL
This will be replaced by the texture cache. Advanced OpenImageIO features
will no longer be available, and texture filtering results will be different.
But performance will be better and there will be consistency with SVM.

OSL specifc image tests were removed as these now match SVM exactly and are
tested by WITH_CYCLES_TEST_OSL.

Pull Request: https://projects.blender.org/blender/blender/pulls/154913
2026-03-27 16:07:05 +01:00

62 lines
1.6 KiB
C++

/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#include <cstdint> /* Needed before `sdlexec.h` for `int32_t` with GCC 15.1. */
#include <OSL/oslexec.h>
#include "kernel/osl/globals.h"
CCL_NAMESPACE_BEGIN
OSLThreadData::OSLThreadData(OSLGlobals *osl_globals, const int thread_index)
: globals(osl_globals), thread_index(thread_index)
{
/* If OSL is not used, we don't need this. */
if (globals == nullptr || !(globals->use_shading || globals->use_camera)) {
return;
}
ss = globals->ss;
memset((void *)&shader_globals, 0, sizeof(shader_globals));
shader_globals.tracedata = &tracedata;
if (ss) {
osl_thread_info = ss->create_thread_info();
/* Dummy texture thread info, we don't need it. */
context = ss->get_context(osl_thread_info,
reinterpret_cast<OSL::TextureSystem::Perthread *>(1));
}
}
OSLThreadData::~OSLThreadData()
{
if (context) {
ss->release_context(context);
}
if (osl_thread_info) {
ss->destroy_thread_info(osl_thread_info);
}
}
OSLThreadData::OSLThreadData(OSLThreadData &&other) noexcept
: globals(other.globals),
ss(other.ss),
thread_index(other.thread_index),
shader_globals(other.shader_globals),
tracedata(other.tracedata),
osl_thread_info(other.osl_thread_info),
context(other.context)
{
shader_globals.tracedata = &tracedata;
memset((void *)&other.shader_globals, 0, sizeof(other.shader_globals));
memset((void *)&other.tracedata, 0, sizeof(other.tracedata));
other.thread_index = -1;
other.context = nullptr;
other.osl_thread_info = nullptr;
}
CCL_NAMESPACE_END