[Bf-blender-cvs] [41997389979] cycles_texture_cache: Merge branch 'master' into cycles_texture_cache
Stefan Werner
noreply at git.blender.org
Mon Jan 4 13:36:28 CET 2021
Commit: 41997389979cd2e91e52260e1c308cae255a31dd
Author: Stefan Werner
Date: Mon Dec 21 09:09:27 2020 +0100
Branches: cycles_texture_cache
https://developer.blender.org/rB41997389979cd2e91e52260e1c308cae255a31dd
Merge branch 'master' into cycles_texture_cache
===================================================================
===================================================================
diff --cc intern/cycles/blender/blender_python.cpp
index 33d8948f3a6,525525e1047..b749278532e
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@@ -632,21 -637,6 +638,22 @@@ static PyObject *osl_compile_func(PyObj
}
#endif
+static PyObject *oiio_make_tx(PyObject * /*self*/, PyObject *args)
+{
+ const char *inputfile = NULL, *outputfile = NULL, *colorspace = NULL;
+ int extension = EXTENSION_CLIP;
+
+ if (!PyArg_ParseTuple(args, "sssi", &inputfile, &outputfile, &colorspace, &extension))
+ return NULL;
+
+ /* return */
- if (!OIIOImageLoader::make_tx(inputfile, outputfile, ustring(colorspace), (ExtensionType)extension))
++ if (!OIIOImageLoader::make_tx(
++ inputfile, outputfile, ustring(colorspace), (ExtensionType)extension))
+ Py_RETURN_FALSE;
+
+ Py_RETURN_TRUE;
+}
+
static PyObject *system_info_func(PyObject * /*self*/, PyObject * /*value*/)
{
string system_info = Device::device_capabilities();
diff --cc intern/cycles/device/device_cpu.cpp
index ebeb952e619,fea4fc53d1f..41941fc33e5
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@@ -179,9 -184,6 +185,9 @@@ class CPUDevice : public Device
#ifdef WITH_OSL
OSLGlobals osl_globals;
#endif
-
++
+ OIIOGlobals oiio_globals;
-
++
#ifdef WITH_OPENIMAGEDENOISE
oidn::DeviceRef oidn_device;
oidn::FilterRef oidn_filter;
@@@ -306,9 -312,9 +316,12 @@@
#ifdef WITH_OSL
kernel_globals.osl = &osl_globals;
#endif
+ oiio_globals.tex_sys = NULL;
+ kernel_globals.oiio = &oiio_globals;
+
+ #ifdef WITH_EMBREE
+ embree_device = rtcNewDevice("verbose=0");
+ #endif
use_split_kernel = DebugFlags().cpu.split_kernel;
if (use_split_kernel) {
VLOG(1) << "Will be using split kernel.";
@@@ -346,17 -352,14 +359,20 @@@
~CPUDevice()
{
+ #ifdef WITH_EMBREE
+ rtcReleaseDevice(embree_device);
+ #endif
task_pool.cancel();
texture_info.free();
+ if (oiio_globals.tex_sys) {
+ VLOG(1) << oiio_globals.tex_sys->getstats();
+ oiio_globals.tex_sys->reset_stats();
+ TextureSystem::destroy(oiio_globals.tex_sys);
+ }
+ kernel_globals.oiio = NULL;
}
- virtual bool show_samples() const
+ virtual bool show_samples() const override
{
return (info.cpu_threads == 1);
}
@@@ -536,11 -549,28 +562,33 @@@
#endif
}
+ void *oiio_memory()
+ {
+ return &oiio_globals;
+ }
+
+ void build_bvh(BVH *bvh, Progress &progress, bool refit) override
+ {
+ #ifdef WITH_EMBREE
+ if (bvh->params.bvh_layout == BVH_LAYOUT_EMBREE ||
+ bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) {
+ BVHEmbree *const bvh_embree = static_cast<BVHEmbree *>(bvh);
+ if (refit) {
+ bvh_embree->refit(progress);
+ }
+ else {
+ bvh_embree->build(progress, &stats, embree_device);
+ }
+
+ if (bvh->params.top_level) {
+ embree_scene = bvh_embree->scene;
+ }
+ }
+ else
+ #endif
+ Device::build_bvh(bvh, progress, refit);
+ }
+
void thread_run(DeviceTask &task)
{
if (task.type == DeviceTask::RENDER)
diff --cc intern/cycles/kernel/kernel_oiio_globals.h
index 4771f2d1c54,00000000000..4fbfd9651f1
mode 100644,000000..100644
--- a/intern/cycles/kernel/kernel_oiio_globals.h
+++ b/intern/cycles/kernel/kernel_oiio_globals.h
@@@ -1,43 -1,0 +1,43 @@@
+/*
+ * Copyright 2011-2017 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * 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.
+ */
+
+#ifndef __KERNEL_OIIO_GLOBALS_H__
+#define __KERNEL_OIIO_GLOBALS_H__
+
- #include <OpenImageIO/texture.h>
- #include "util/util_vector.h"
+#include "util/util_thread.h"
++#include "util/util_vector.h"
++#include <OpenImageIO/texture.h>
+
+CCL_NAMESPACE_BEGIN
+
+struct OIIOTexture {
+ OIIO::TextureSystem::TextureHandle *handle;
+ OIIO::TextureOpt::InterpMode interpolation;
+ OIIO::TextureOpt::Wrap extension;
+ bool is_linear;
+};
+
+struct OIIOGlobals {
+ OIIO::TextureSystem *tex_sys;
+ thread_mutex tex_paths_mutex;
+ vector<OIIOTexture> textures;
+ float diffuse_blur;
+ float glossy_blur;
+};
+
+CCL_NAMESPACE_END
+
+#endif
diff --cc intern/cycles/kernel/kernel_shader.h
index 856931210f3,e461e1642b6..f6d39546a45
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@@ -253,11 -211,7 +253,11 @@@ ccl_device_inlin
# ifdef __DPDU__
object_dir_transform_auto(kg, sd, &sd->dPdu);
object_dir_transform_auto(kg, sd, &sd->dPdv);
- # endif
- # ifdef __DNDU__
++# endif
++# ifdef __DNDU__
+ object_dir_transform(kg, sd, &sd->dNdx);
+ object_dir_transform(kg, sd, &sd->dNdy);
- # endif
+ # endif
}
/* backfacing test */
diff --cc intern/cycles/kernel/svm/svm_image.h
index f6db9151b17,f57c85fc23e..4d9dbab2c2a
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@@ -38,59 -23,7 +38,59 @@@ ccl_device float4 svm_image_texture(Ker
TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A);
}
- float4 r = kernel_tex_image_interp(kg, id, x, y);
+ float4 r;
+#ifdef __OIIO__
+ if (kg->oiio && kg->oiio->textures.size() > id && kg->oiio->textures[id].handle) {
+ OIIO::TextureOpt options;
+ options.swrap = options.twrap = kg->oiio->textures[id].extension;
+ options.anisotropic = 8;
+ float missingcolor[4] = {
+ TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A};
+ options.missingcolor = missingcolor;
+
+ if (path_flag & NEAREST_LOOKUP_PATHS && !(path_flag & PATH_RAY_SINGULAR)) {
+ options.interpmode = OIIO::TextureOpt::InterpClosest;
+ options.mipmode = OIIO::TextureOpt::MipModeOneLevel;
+ }
+ else {
+ options.interpmode = kg->oiio->textures[id].interpolation;
+ options.mipmode = OIIO::TextureOpt::MipModeAniso;
+ }
+
+ if (path_flag & DIFFUSE_BLUR_PATHS) {
+ options.sblur = options.tblur = kg->oiio->diffuse_blur;
+ }
+ else if (path_flag & PATH_RAY_GLOSSY) {
+ options.sblur = options.tblur = kg->oiio->glossy_blur;
+ }
+ else {
+ options.sblur = options.tblur = 0.0f;
+ }
+
+ bool success = kg->oiio->tex_sys->texture(kg->oiio->textures[id].handle,
+ (OIIO::TextureSystem::Perthread *)kg->oiio_tdata,
+ options,
+ x,
+ y,
+ ds.dx,
+ ds.dy,
+ dt.dx,
+ dt.dy,
+ 4,
+ (float *)&r);
+ if (!success) {
+ (void)kg->oiio->tex_sys->geterror();
+ }
+ else {
+ /* Mip maps are always linear. */
+ if (kg->oiio->textures[id].is_linear) {
+ flags &= ~NODE_IMAGE_COMPRESS_AS_SRGB;
+ }
+ }
+ }
+ else
+#endif
- r = kernel_tex_image_interp(kg, id, x, y);
++ r = kernel_tex_image_interp(kg, id, x, y);
const float alpha = r.w;
if ((flags & NODE_IMAGE_ALPHA_UNASSOCIATE) && alpha != 1.0f && alpha != 0.0f) {
@@@ -219,7 -116,7 +219,8 @@@ ccl_device void svm_node_tex_image
stack_store_float(stack, alpha_offset, f.w);
}
- ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint4 node)
-ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
++ccl_device void svm_node_tex_image_box(
++ KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint4 node)
{
/* get object space normal */
float3 N = sd->N;
diff --cc intern/cycles/render/graph.cpp
index 5e1dbffe304,4adfebf80ae..b5a26549790
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@@ -957,91 -954,6 +958,91 @@@ void ShaderGraph::refine_bump_nodes(
}
}
+void ShaderGraph::add_differentials()
+{
+ /* we transverse the node graph looking for texture nodes, when we find them,
+ * we copy the sub-graph defined from "Vector"
+ * input to the inputs "Vector_dx" and "Vector_dy" */
+
+ foreach (ShaderNode *node, nodes) {
+ if (node->special_type == SHADER_SPECIAL_TYPE_IMAGE_SLOT && node->input("Vector")->link &&
+ node->input("Vector_dx") && node->input("Vector_dy")) {
+ ShaderInput *vector_input = node->input("Vector");
+ ShaderNodeSet nodes_vector;
+
+ /* make 2 extra copies of the subgraph defined in Vector input */
+ ShaderNodeMap nodes_dx;
+ ShaderNodeMap nodes_dy;
+
+ /* find dependencies for the given input */
+ find_dependencies(nodes_vector, vector_input);
+
+ copy_nodes(nodes_vector, nodes_dx);
+ copy_nodes(nodes_vector, nodes_dy);
+
+ /* First: Nodes that have no bump are set to center, others are left untouched. */
+ foreach (ShaderNode *node, nodes_vector)
+ node->bump = node->bump == SHADER_BUMP_NONE ? SHADER_BUMP_CENTER : node->bump;
+
+ /* Second: Nodes that have no bump are set DX, others are shifted by one. */
+ foreach (NodePair &pair, nodes_dx) {
+ switch (pair.second->bump) {
+ case SHADER_BUMP_DX:
+ pair.second->bump = SHADER_BUMP_DY;
+ break;
+ case SHADER_BUMP_DY:
+ pair.second->bump = SHADER_BUMP_CENTER;
+ break;
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list