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:
Diffstat (limited to 'intern/cycles/kernel/osl/osl_services.cpp')
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp63
1 files changed, 46 insertions, 17 deletions
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index a9694651e14..1f6015d0d6b 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -11,9 +11,17 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License
+ * limitations under the License.
*/
+/* TODO(sergey): There is a bit of headers dependency hell going on
+ * here, so for now we just put here. In the future it might be better
+ * to have dedicated file for such tweaks.
+ */
+#if defined(__GNUC__) && defined(NDEBUG)
+# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
#include <string.h>
#include "mesh.h"
@@ -834,7 +842,7 @@ bool OSLRenderServices::has_userdata(ustring name, TypeDesc type, OSL::ShaderGlo
bool OSLRenderServices::texture(ustring filename, TextureOpt &options,
OSL::ShaderGlobals *sg,
float s, float t, float dsdx, float dtdx,
- float dsdy, float dtdy, float *result)
+ float dsdy, float dtdy, int nchannels, float *result)
{
OSL::TextureSystem *ts = osl_ts;
ShaderData *sd = (ShaderData *)(sg->renderstate);
@@ -869,9 +877,9 @@ bool OSLRenderServices::texture(ustring filename, TextureOpt &options,
PtexFilter::Options opts(PtexFilter::f_bicubic, mipmaplerp, sharpness);
PtexPtr<PtexFilter> f(PtexFilter::getFilter(r, opts));
- f->eval(result, options.firstchannel, options.nchannels, faceid, u, v, dudx, dvdx, dudy, dvdy);
+ f->eval(result, options.firstchannel, nchannels, faceid, u, v, dudx, dvdx, dudy, dvdy);
- for(int c = r->numChannels(); c < options.nchannels; c++)
+ for(int c = r->numChannels(); c < nchannels; c++)
result[c] = result[0];
return true;
@@ -880,15 +888,15 @@ bool OSLRenderServices::texture(ustring filename, TextureOpt &options,
bool status;
if(filename[0] == '@' && filename.find('.') == -1) {
- int slot = atoi(filename.c_str() + 1);
+ int slot = atoi(filename.c_str() + 1);
float4 rgba = kernel_tex_image_interp(slot, s, 1.0f - t);
result[0] = rgba[0];
- if(options.nchannels > 1)
+ if(nchannels > 1)
result[1] = rgba[1];
- if(options.nchannels > 2)
+ if(nchannels > 2)
result[2] = rgba[2];
- if(options.nchannels > 3)
+ if(nchannels > 3)
result[3] = rgba[3];
status = true;
}
@@ -898,17 +906,24 @@ bool OSLRenderServices::texture(ustring filename, TextureOpt &options,
OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
+#if OIIO_VERSION < 10500
status = ts->texture(th, thread_info,
- options, s, t, dsdx, dtdx, dsdy, dtdy, result);
+ options, s, t, dsdx, dtdx, dsdy, dtdy,
+ result);
+#else
+ status = ts->texture(th, thread_info,
+ options, s, t, dsdx, dtdx, dsdy, dtdy,
+ nchannels, result);
+#endif
}
if(!status) {
- if(options.nchannels == 3 || options.nchannels == 4) {
+ if(nchannels == 3 || nchannels == 4) {
result[0] = 1.0f;
result[1] = 0.0f;
result[2] = 1.0f;
- if(options.nchannels == 4)
+ if(nchannels == 4)
result[3] = 1.0f;
}
}
@@ -919,7 +934,7 @@ bool OSLRenderServices::texture(ustring filename, TextureOpt &options,
bool OSLRenderServices::texture3d(ustring filename, TextureOpt &options,
OSL::ShaderGlobals *sg, const OSL::Vec3 &P,
const OSL::Vec3 &dPdx, const OSL::Vec3 &dPdy,
- const OSL::Vec3 &dPdz, float *result)
+ const OSL::Vec3 &dPdz, int nchannels, float *result)
{
OSL::TextureSystem *ts = osl_ts;
ShaderData *sd = (ShaderData *)(sg->renderstate);
@@ -929,16 +944,22 @@ bool OSLRenderServices::texture3d(ustring filename, TextureOpt &options,
OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
+#if OIIO_VERSION < 10500
bool status = ts->texture3d(th, thread_info,
options, P, dPdx, dPdy, dPdz, result);
+#else
+ bool status = ts->texture3d(th, thread_info,
+ options, P, dPdx, dPdy, dPdz,
+ nchannels, result);
+#endif
if(!status) {
- if(options.nchannels == 3 || options.nchannels == 4) {
+ if(nchannels == 3 || nchannels == 4) {
result[0] = 1.0f;
result[1] = 0.0f;
result[2] = 1.0f;
- if(options.nchannels == 4)
+ if(nchannels == 4)
result[3] = 1.0f;
}
@@ -949,7 +970,8 @@ bool OSLRenderServices::texture3d(ustring filename, TextureOpt &options,
bool OSLRenderServices::environment(ustring filename, TextureOpt &options,
OSL::ShaderGlobals *sg, const OSL::Vec3 &R,
- const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, float *result)
+ const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy,
+ int nchannels, float *result)
{
OSL::TextureSystem *ts = osl_ts;
ShaderData *sd = (ShaderData *)(sg->renderstate);
@@ -958,16 +980,23 @@ bool OSLRenderServices::environment(ustring filename, TextureOpt &options,
OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
+
+#if OIIO_VERSION < 10500
bool status = ts->environment(th, thread_info,
options, R, dRdx, dRdy, result);
+#else
+ bool status = ts->environment(th, thread_info,
+ options, R, dRdx, dRdy,
+ nchannels, result);
+#endif
if(!status) {
- if(options.nchannels == 3 || options.nchannels == 4) {
+ if(nchannels == 3 || nchannels == 4) {
result[0] = 1.0f;
result[1] = 0.0f;
result[2] = 1.0f;
- if(options.nchannels == 4)
+ if(nchannels == 4)
result[3] = 1.0f;
}
}