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:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-01-21 12:49:42 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-01-21 12:49:42 +0400
commit86991fbcb0e8a1c65acff5aed85ce55f8b108baa (patch)
treee39d2b4203e18052fea58691d3920093905f47dc /source/blender/render/intern/include
parent2b9ab8781d95609f529c2d5dcf770c82d23afe17 (diff)
Fixed render time regression in Blender Internal
It was caused by image threading safe commit and it was noticeable only on really multi-core CPU (like dual-socket Xeon stations), was not visible on core i7 machine. The reason of slowdown was spinlock around image buffer referencing, which lead to lots of cores waiting for single core and using image buffer after it was referenced was not so much longer than doing reference itself. The most clear solution here seemed to be introducing Image Pool which will contain list of loaded and referenced image buffers, so all threads could skip lock if the pool is used for reading only. Lock only needed in cases when buffer for requested image user is missing in the pool. This lock will happen only once per image so overall amount of locks is much less that it was before. To operate with pool: - BKE_image_pool_new() creates new pool - BKE_image_pool_free() destroys pool and dereferences all image buffers which were loaded to it - BKE_image_pool_acquire_ibuf() returns image buffer for given image and user. Pool could be NULL and in this case fallback to BKE_image_acquire_ibuf will happen. This helps to avoid lots to if(poll) checks in image sampling code. - BKE_image_pool_release_ibuf releases image buffer. In fact, it will only do something if pool is NULL, in all other case it'll equal to DoNothing operation.
Diffstat (limited to 'source/blender/render/intern/include')
-rw-r--r--source/blender/render/intern/include/envmap.h3
-rw-r--r--source/blender/render/intern/include/pixelshading.h2
-rw-r--r--source/blender/render/intern/include/render_types.h5
-rw-r--r--source/blender/render/intern/include/texture.h7
4 files changed, 13 insertions, 4 deletions
diff --git a/source/blender/render/intern/include/envmap.h b/source/blender/render/intern/include/envmap.h
index d0f346f7402..a6c6d46e2e9 100644
--- a/source/blender/render/intern/include/envmap.h
+++ b/source/blender/render/intern/include/envmap.h
@@ -44,9 +44,10 @@
struct Render;
struct TexResult;
+struct ImagePool;
void make_envmaps(struct Render *re);
-int envmaptex(struct Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres);
+int envmaptex(struct Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, struct TexResult *texres, struct ImagePool *pool);
#endif /* __ENVMAP_H__ */
diff --git a/source/blender/render/intern/include/pixelshading.h b/source/blender/render/intern/include/pixelshading.h
index 30d574694b2..faf8c5f54f5 100644
--- a/source/blender/render/intern/include/pixelshading.h
+++ b/source/blender/render/intern/include/pixelshading.h
@@ -32,6 +32,8 @@
#ifndef __PIXELSHADING_H__
#define __PIXELSHADING_H__
+struct ImagePool;
+
/**
* Render the pixel at (x,y) for object ap. Apply the jitter mask.
* Output is given in float collector[4]. The type vector:
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 905b4b4f4a8..d65da586b9a 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -62,6 +62,7 @@ struct RayFace;
struct RenderEngine;
struct ReportList;
struct Main;
+struct ImagePool;
#define TABLEINITSIZE 1024
@@ -260,6 +261,8 @@ struct Render
RenderStats i;
struct ReportList *reports;
+
+ struct ImagePool *pool;
};
/* ------------------------------------------------------------------------- */
@@ -373,6 +376,7 @@ struct halosort {
/* ------------------------------------------------------------------------- */
struct Material;
struct MTFace;
+struct ImagePool;
typedef struct RadFace {
float unshot[3], totrad[3];
@@ -402,6 +406,7 @@ typedef struct HaloRen {
int pixels;
unsigned int lay;
struct Material *mat;
+ struct ImagePool *pool;
} HaloRen;
/* ------------------------------------------------------------------------- */
diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h
index 4b9fa2d2042..2dc12f39db7 100644
--- a/source/blender/render/intern/include/texture.h
+++ b/source/blender/render/intern/include/texture.h
@@ -60,6 +60,7 @@ struct TexResult;
struct Tex;
struct Image;
struct ImBuf;
+struct ImagePool;
/* texture.h */
@@ -76,9 +77,9 @@ void render_realtime_texture(struct ShadeInput *shi, struct Image *ima);
/* imagetexture.h */
-int imagewraposa(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], const float dxt[2], const float dyt[2], struct TexResult *texres);
-int imagewrap(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], struct TexResult *texres);
-void image_sample(struct Image *ima, float fx, float fy, float dx, float dy, float result[4]);
+int imagewraposa(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], const float dxt[2], const float dyt[2], struct TexResult *texres, struct ImagePool *pool);
+int imagewrap(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], struct TexResult *texres, struct ImagePool *pool);
+void image_sample(struct Image *ima, float fx, float fy, float dx, float dy, float result[4], struct ImagePool *pool);
#endif /* __TEXTURE_H__ */