[Bf-blender-cvs] [570bbf6] object_nodes: Support for image sampling in the LLVM backend.
Lukas Tönne
noreply at git.blender.org
Thu Jun 2 17:31:59 CEST 2016
Commit: 570bbf680a58b6159792e22d6a1206e4a505bae4
Author: Lukas Tönne
Date: Thu Jun 2 17:30:33 2016 +0200
Branches: object_nodes
https://developer.blender.org/rB570bbf680a58b6159792e22d6a1206e4a505bae4
Support for image sampling in the LLVM backend.
This reintroduces the "globals" concept for mapping ID datablocks with
a consistent permanent identifier key.
===================================================================
M release/scripts/nodes/texture_nodes.py
M source/blender/blenkernel/BKE_texture.h
M source/blender/blenkernel/intern/texture.c
M source/blender/blenvm/BVM_api.h
M source/blender/blenvm/CMakeLists.txt
M source/blender/blenvm/bvm/CMakeLists.txt
M source/blender/blenvm/bvm/bvm_eval.cc
M source/blender/blenvm/bvm/bvm_eval.h
M source/blender/blenvm/compile/node_graph.cc
M source/blender/blenvm/compile/node_graph.h
M source/blender/blenvm/intern/bvm_api.cc
M source/blender/blenvm/llvm/CMakeLists.txt
M source/blender/blenvm/llvm/llvm_compiler.cc
M source/blender/blenvm/llvm/llvm_compiler.h
M source/blender/blenvm/llvm/llvm_compiler_dual.cc
A source/blender/blenvm/modules/mod_image.h
M source/blender/blenvm/modules/modules.h
A source/blender/blenvm/util/util_eval_globals.cc
A source/blender/blenvm/util/util_eval_globals.h
M source/blender/blenvm/util/util_opcode.h
M source/blender/modifiers/CMakeLists.txt
M source/blender/modifiers/intern/MOD_displace.c
M source/blender/render/intern/source/render_texture.c
===================================================================
diff --git a/release/scripts/nodes/texture_nodes.py b/release/scripts/nodes/texture_nodes.py
index d1fe4d3..78adad8 100644
--- a/release/scripts/nodes/texture_nodes.py
+++ b/release/scripts/nodes/texture_nodes.py
@@ -190,6 +190,7 @@ def register():
NodeItem("ObjectValueIntNode"),
NodeItem("ObjectValueVectorNode"),
NodeItem("ObjectValueColorNode"),
+ NodeItem("ImageSampleNode"),
]),
TextureNodeCategory("TEX_OUTPUT", "Output", items=[
NodeItem("TextureOutputNode"),
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index e4c9a6d..904c130 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -39,6 +39,7 @@ extern "C" {
struct bNode;
struct Brush;
+struct BVMEvalGlobals;
struct ColorBand;
struct EnvMap;
struct EvaluationContext;
@@ -136,8 +137,9 @@ bool BKE_texture_is_image_user(const struct Tex *tex);
void BKE_texture_get_value(
const struct Scene *scene, struct Tex *texture,
- float *tex_co, struct TexResult *texres, bool use_color_management);
-void BKE_texture_get_value_deriv(
+ const float *tex_co, struct TexResult *texres, bool use_color_management);
+void BKE_texture_get_value_ex(
+ struct BVMEvalGlobals *globals,
const struct Scene *scene, struct Tex *texture,
const float *tex_co, const float *tex_dx, const float *tex_dy,
struct TexResult *texres, struct TexResult *texres_dx, struct TexResult *texres_dy,
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 8e24dd1..b6ce24d 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -1660,45 +1660,36 @@ bool BKE_texture_dependsOnTime(const struct Tex *texture)
void BKE_texture_get_value(
const Scene *scene, Tex *texture,
- float *tex_co, TexResult *texres, bool use_color_management)
+ const float *tex_co, TexResult *texres,
+ bool use_color_management)
{
- int result_type;
- bool do_color_manage = false;
-
- if (scene && use_color_management) {
- do_color_manage = BKE_scene_check_color_management_enabled(scene);
- }
-
- /* no node textures for now */
- result_type = multitex_ext_safe(texture, tex_co, texres, NULL, do_color_manage, false);
-
- /* if the texture gave an RGB value, we assume it didn't give a valid
- * intensity, since this is in the context of modifiers don't use perceptual color conversion.
- * if the texture didn't give an RGB value, copy the intensity across
- */
- if (result_type & TEX_RGB) {
- texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
- }
- else {
- copy_v3_fl(&texres->tr, texres->tin);
- }
+ BKE_texture_get_value_ex(NULL, scene, texture,
+ tex_co, NULL, NULL,
+ texres, NULL, NULL,
+ use_color_management);
}
-void BKE_texture_get_value_deriv(
+void BKE_texture_get_value_ex(
+ struct BVMEvalGlobals *globals,
const Scene *scene, Tex *texture,
const float *tex_co, const float *tex_dx, const float *tex_dy,
TexResult *texres, TexResult *texres_dx, TexResult *texres_dy,
- bool UNUSED(use_color_management))
+ bool use_color_management)
{
int result_type;
+ bool do_color_manage = false;
+
+ if (scene && use_color_management) {
+ do_color_manage = BKE_scene_check_color_management_enabled(scene);
+ }
- /* no node textures for now */
if (texture->use_nodes && texture->nodetree) {
struct BVMFunction *fn = BVM_gen_texture_function_llvm(texture->nodetree, true);
if (fn) {
struct BVMEvalContext *context = BVM_context_create();
- BVM_eval_texture_llvm(context, fn,
+ BVM_eval_texture_llvm(globals,
+ context, fn,
texres, texres_dx, texres_dy,
tex_co, tex_dx, tex_dy,
0, 0, scene->r.cfra, false);
@@ -1708,6 +1699,10 @@ void BKE_texture_get_value_deriv(
BVM_function_llvm_release(fn);
}
}
+ else {
+ struct ImagePool *image_pool = (globals ? BVM_globals_image_pool(globals) : NULL);
+ result_type = multitex_ext_safe(texture, (float*)tex_co, texres, image_pool, do_color_manage, false);
+ }
/* if the texture gave an RGB value, we assume it didn't give a valid
* intensity, since this is in the context of modifiers don't use perceptual color conversion.
diff --git a/source/blender/blenvm/BVM_api.h b/source/blender/blenvm/BVM_api.h
index 45f3af3..467e147 100644
--- a/source/blender/blenvm/BVM_api.h
+++ b/source/blender/blenvm/BVM_api.h
@@ -91,6 +91,7 @@ BVMBufferType BVM_typedesc_buffer_type(struct BVMTypeDesc *typedesc);
/* ------------------------------------------------------------------------- */
+struct bNodeTree;
struct DepsNodeHandle;
void BVM_nodetree_compile_dependencies(struct bNodeTree *ntree, struct DepsNodeHandle *handle);
@@ -102,10 +103,12 @@ struct BVMEvalGlobals;
struct BVMEvalContext;
struct bNodeTree;
+struct ImagePool;
struct BVMEvalGlobals *BVM_globals_create(void);
void BVM_globals_free(struct BVMEvalGlobals *globals);
+struct ImagePool *BVM_globals_image_pool(struct BVMEvalGlobals *globals);
void BVM_globals_add_object(struct BVMEvalGlobals *globals, int key, struct Object *ob);
void BVM_globals_add_nodetree_relations(struct BVMEvalGlobals *globals, struct bNodeTree *ntree);
@@ -139,7 +142,7 @@ struct BVMFunction *BVM_gen_forcefield_function_bvm(struct bNodeTree *btree, boo
void BVM_debug_forcefield_nodes(struct bNodeTree *btree, FILE *debug_file, const char *label, BVMDebugMode mode);
void BVM_eval_forcefield_bvm(struct BVMEvalGlobals *globals, struct BVMEvalContext *context, struct BVMFunction *fn,
- struct Object *effob, const struct EffectedPoint *point, float force[3], float impulse[3]);
+ struct Object *effob, const struct EffectedPoint *point, float force[3], float impulse[3]);
/* ------------------------------------------------------------------------- */
@@ -151,11 +154,13 @@ struct BVMFunction *BVM_gen_texture_function_llvm(struct bNodeTree *btree, bool
void BVM_debug_texture_nodes(struct bNodeTree *btree, FILE *debug_file, const char *label, BVMDebugMode mode);
-void BVM_eval_texture_bvm(struct BVMEvalContext *context, struct BVMFunction *fn,
+void BVM_eval_texture_bvm(struct BVMEvalGlobals *globals, struct BVMEvalContext *context,
+ struct BVMFunction *fn,
struct TexResult *target,
float coord[3], float dxt[3], float dyt[3], int osatex,
short which_output, int cfra, int preview);
-void BVM_eval_texture_llvm(struct BVMEvalContext *context, struct BVMFunction *fn,
+void BVM_eval_texture_llvm(struct BVMEvalGlobals *globals, struct BVMEvalContext *context,
+ struct BVMFunction *fn,
struct TexResult *value,
struct TexResult *value_dx,
struct TexResult *value_dy,
diff --git a/source/blender/blenvm/CMakeLists.txt b/source/blender/blenvm/CMakeLists.txt
index 9b264a5..af06863 100644
--- a/source/blender/blenvm/CMakeLists.txt
+++ b/source/blender/blenvm/CMakeLists.txt
@@ -33,6 +33,7 @@ set(INC
../blenkernel
../blenlib
../depsgraph
+ ../imbuf
../makesdna
../makesrna
../render/extern/include
@@ -54,12 +55,15 @@ set(SRC
modules/mod_defines.h
modules/mod_base.h
modules/mod_color.h
+ modules/mod_image.h
modules/mod_math.h
modules/mod_texture.h
util/util_opcode.h
util/util_data_ptr.h
util/util_debug.h
+ util/util_eval_globals.cc
+ util/util_eval_globals.h
util/util_hash.h
util/util_map.h
util/util_math.h
diff --git a/source/blender/blenvm/bvm/CMakeLists.txt b/source/blender/blenvm/bvm/CMakeLists.txt
index 14601ef..ac668dd 100644
--- a/source/blender/blenvm/bvm/CMakeLists.txt
+++ b/source/blender/blenvm/bvm/CMakeLists.txt
@@ -26,6 +26,7 @@
set(INC
.
..
+ ../intern
../modules
../util
../../blenkernel
diff --git a/source/blender/blenvm/bvm/bvm_eval.cc b/source/blender/blenvm/bvm/bvm_eval.cc
index 79da5cb..fd053c7 100644
--- a/source/blender/blenvm/bvm/bvm_eval.cc
+++ b/source/blender/blenvm/bvm/bvm_eval.cc
@@ -59,70 +59,6 @@ extern "C" {
namespace blenvm {
-EvalGlobals::EvalGlobals()
-{
- m_image_pool = BKE_image_pool_new();
-}
-
-EvalGlobals::~EvalGlobals()
-{
- BKE_image_pool_free(m_image_pool);
-}
-
-int EvalGlobals::get_id_key(ID *id)
-{
- int hash = BLI_ghashutil_strhash(id->name);
- if (id->lib) {
- hash = hash_combine(hash, BLI_ghashutil_strhash(id->lib->name));
- }
- return hash;
-}
-
-void EvalGlobals::add_object(int key, Object *ob)
-{
- m_objects[key] = ob;
-}
-
-PointerRNA EvalGlobals::lookup_object(int key) const
-{
- ObjectMap::const_iterator it = m_objects.find(key);
- if (it != m_objects.end()) {
- PointerRNA ptr;
- RNA_id_pointer_create((ID *)it->second, &ptr);
- return ptr;
- }
- else {
- return PointerRNA_NULL;
- }
-}
-
-void EvalGlobals::add_image(int key, Image *ima)
-{
- m_images[key] = ima;
-}
-
-ImBuf *EvalGlobals::lookup_imbuf(int key, ImageUser *iuser) const
-{
- ImageMap::const_iterator ima_it = m_images.find(key);
- Image *ima = (ima_it != m_images.end()) ? ima_it->second : NULL;
- if (!ima)
- return NULL;
-
- /* local changes to the original ImageUser */
-// if (!BKE_image_is_multilayer(ima))
-// iuser->multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
-
- ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, iuser, m_image_pool);
- if (!ibuf || (!ibuf->rect && !ibuf->rect_float)) {
- BKE_image_pool_release_ibuf(ima, ibuf, m_image_pool);
- return NULL;
- }
-
- return ibuf;
-}
-
-/* ------------------------------------------------------------------------- */
-
int EvalStack::stack_size(size_t datasize)
{
return int_div_ceil(datasize, sizeof(EvalStack));
diff --git a/source/blender/blenvm/bvm/bvm_eval.h b/source/blender/blenvm/bvm/bvm_eval.h
index 68dd80f..c4d4c06 100644
--- a/source/blender/blen
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list