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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-08-05 16:49:15 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-08-05 16:49:15 +0400
commit3bf175f27047d9b6894327e5ea7216110288aaa2 (patch)
tree6ec119c444f3f7192f82f6901123ff4e5ec852de /intern/cycles/kernel/osl/osl_services.cpp
parent83617429cf28f2a19e991a0f71d892fc159a4419 (diff)
Cycles OSL: image texture lookup optimization, acquire the per thread handle
for texture system in advance. Patch by Martijn Berger, with some tweaks. There was about a 10% performance improvement on OS X in my tests with the images.blend test file. This may be less on other platforms because OS X has particularly slow mutex locks.
Diffstat (limited to 'intern/cycles/kernel/osl/osl_services.cpp')
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index f3b79da8894..95cd73c6019 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -775,7 +775,15 @@ bool OSLRenderServices::texture(ustring filename, TextureOpt &options,
float dsdy, float dtdy, float *result)
{
OSL::TextureSystem *ts = osl_ts;
- bool status = ts->texture(filename, options, s, t, dsdx, dtdx, dsdy, dtdy, result);
+ ShaderData *sd = (ShaderData *)(sg->renderstate);
+ KernelGlobals *kg = sd->osl_globals;
+ OSLThreadData *tdata = kg->osl_tdata;
+ OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
+
+ OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
+
+ bool status = ts->texture(th, thread_info,
+ options, s, t, dsdx, dtdx, dsdy, dtdy, result);
if(!status) {
if(options.nchannels == 3 || options.nchannels == 4) {
@@ -797,7 +805,15 @@ bool OSLRenderServices::texture3d(ustring filename, TextureOpt &options,
const OSL::Vec3 &dPdz, float *result)
{
OSL::TextureSystem *ts = osl_ts;
- bool status = ts->texture3d(filename, options, P, dPdx, dPdy, dPdz, result);
+ ShaderData *sd = (ShaderData *)(sg->renderstate);
+ KernelGlobals *kg = sd->osl_globals;
+ OSLThreadData *tdata = kg->osl_tdata;
+ OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
+
+ OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
+
+ bool status = ts->texture3d(th, thread_info,
+ options, P, dPdx, dPdy, dPdz, result);
if(!status) {
if(options.nchannels == 3 || options.nchannels == 4) {
@@ -819,7 +835,14 @@ bool OSLRenderServices::environment(ustring filename, TextureOpt &options,
const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, float *result)
{
OSL::TextureSystem *ts = osl_ts;
- bool status = ts->environment(filename, options, R, dRdx, dRdy, result);
+ ShaderData *sd = (ShaderData *)(sg->renderstate);
+ KernelGlobals *kg = sd->osl_globals;
+ OSLThreadData *tdata = kg->osl_tdata;
+ OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
+
+ OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
+ bool status = ts->environment(th, thread_info,
+ options, R, dRdx, dRdy, result);
if(!status) {
if(options.nchannels == 3 || options.nchannels == 4) {