[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12253] trunk/blender/extern/qdune: Some minor modifications, and a fix for the valgrind unitialized padding var

Alfredo de Greef eeshlo at yahoo.com
Fri Oct 12 04:53:22 CEST 2007


Revision: 12253
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12253
Author:   eeshlo
Date:     2007-10-12 04:53:21 +0200 (Fri, 12 Oct 2007)

Log Message:
-----------
Some minor modifications, and a fix for the valgrind unitialized padding var
'bug' in the Attributes class again.
Also adapted the example ribfiles a bit, shadowmaps are now rendered
before the main image, without the need to render them separately.

Modified Paths:
--------------
    trunk/blender/extern/qdune/core/Attributes.cpp
    trunk/blender/extern/qdune/core/Attributes.h
    trunk/blender/extern/qdune/core/Camera.cpp
    trunk/blender/extern/qdune/core/Options.cpp
    trunk/blender/extern/qdune/core/Options.h
    trunk/blender/extern/qdune/core/State.cpp
    trunk/blender/extern/qdune/framework/ReyesFramework.cpp
    trunk/blender/extern/qdune/framework/ReyesFramework.h
    trunk/blender/extern/qdune/hider/ZbufferHider.cpp
    trunk/blender/extern/qdune/primitives/CCSubdivision.cpp
    trunk/blender/extern/qdune/primitives/Curves.cpp
    trunk/blender/extern/qdune/primitives/Nurbs.cpp
    trunk/blender/extern/qdune/primitives/Parametric.cpp
    trunk/blender/extern/qdune/primitives/Patches.cpp
    trunk/blender/extern/qdune/qdtl/qdtl.h
    trunk/blender/extern/qdune/ribparse/ri.cpp
    trunk/blender/extern/qdune/ribparse/ri.h
    trunk/blender/extern/qdune/ribs/blsuz.rib
    trunk/blender/extern/qdune/ribs/curvetest2.rib
    trunk/blender/extern/qdune/ribs/fig12.10.rib
    trunk/blender/extern/qdune/ribs/fig12.12.rib
    trunk/blender/extern/qdune/ribs/fig12.14.rib
    trunk/blender/extern/qdune/ribs/mblurtest.rib
    trunk/blender/extern/qdune/svm/ImageTextures.cpp

Removed Paths:
-------------
    trunk/blender/extern/qdune/ribs/smokesm.rib

Modified: trunk/blender/extern/qdune/core/Attributes.cpp
===================================================================
--- trunk/blender/extern/qdune/core/Attributes.cpp	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/core/Attributes.cpp	2007-10-12 02:53:21 UTC (rev 12253)
@@ -1,7 +1,6 @@
 #include "Attributes.h"
 
-#include "slshader.h"
-#include <iostream>
+#include <cstring>
 
 __BEGIN_QDRENDER
 
@@ -12,7 +11,7 @@
 Attributes::Attributes()
 {
 	// default flags:
-	// RiOrientation=OUTSIDE, RiSides=2, RiShadingInterpolation=CONSTANT, RiMatte=false
+	// RiOrientation=OUTSIDE, RiSides=2, RiShadingInterpolation=CONSTANT, RiMatte=false, dice_binary=false
 	flags = 0;
 
 	// Shading
@@ -29,14 +28,7 @@
 	effectiveShadingRate = 1;
 
 	// array of all current active lightshaders
-	// NOTE: so, at some point I got an enormous amount of 'uninitialised value' error reports from valgrind, ordering me to 'fix my program!'...
-	// seemingly without any apparent reason whatsoever...
-	// After spending the whole day grasping at straws, it finally occured to me, padding!!!
-	// Valgrind was seeing some padding bytes as an uninitialized value or something. That was not quite the end of it though...
-	// In any case, this is why the padding variable itself also needs to be initialized as well... Something to remember...
-	numlights = pad0 = 0;
 	lightsources = NULL;
-
 	// shaders
 	surface_shader = NULL;
 	displacement_shader = NULL;
@@ -70,8 +62,14 @@
 	//  since to make that work properly, opacity would have to be set to less than 0.98,
 	//  or this value itself must be reset)
 	opacity_threshold = 3.f;
-	// power of 2 grids
-	dice_binary = RI_FALSE;
+	// the number of lights in list
+	numlights = 0;
+	// NOTE: so, at some point I got an enormous amount of 'uninitialised value' error reports from valgrind, ordering me to 'fix my program!'...
+	// seemingly without any apparent reason whatsoever...
+	// After spending the whole day grasping at straws, it finally occured to me, padding!!!
+	// Valgrind was seeing some padding bytes as an uninitialized value or something. That was not quite the end of it though...
+	// In any case, this is why the padding variable itself also needs to be initialized as well... Something to remember...
+	pad0 = 0;
 }
 
 // copy constructor

Modified: trunk/blender/extern/qdune/core/Attributes.h
===================================================================
--- trunk/blender/extern/qdune/core/Attributes.h	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/core/Attributes.h	2007-10-12 02:53:21 UTC (rev 12253)
@@ -10,7 +10,7 @@
 class Transform;
 
 // attribute flag bits
-enum atFlagBits {AF_SMOOTH=1, AF_MATTE=2, AF_SIDES1=4, AF_ORIENTATION=8};
+enum atFlagBits {AF_SMOOTH=1, AF_MATTE=2, AF_SIDES1=4, AF_ORIENTATION=8, AF_DICE_BINARY=16};
 typedef int atFlags;
 
 class Attributes
@@ -34,7 +34,6 @@
 
 	// array of all current active lightsources, borrowed reference, do not delete!
 	SlShaderInstance** lightsources;
-	unsigned int numlights, pad0;
 
 	// Shaders, borrowed references, do not delete!
 	SlShaderInstance* surface_shader;
@@ -58,7 +57,7 @@
 	// optional attributes
 	RtFloat displacementbound_sphere;
 	RtFloat opacity_threshold;
-	RtBoolean dice_binary;
+	unsigned int numlights, pad0;
 };
 
 __END_QDRENDER

Modified: trunk/blender/extern/qdune/core/Camera.cpp
===================================================================
--- trunk/blender/extern/qdune/core/Camera.cpp	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/core/Camera.cpp	2007-10-12 02:53:21 UTC (rev 12253)
@@ -36,8 +36,8 @@
 	aspect = opt.pixelAspectRatio;
 	float scr[4] = {opt.left, opt.right, opt.bottom, opt.top};
 	scr2ras = Scale((float)width, (float)height, 1.f) *
-						Scale(1.f/(scr[1] - scr[0]), 1.f/(scr[2] - scr[3]), 1.f) *
-						Translate(-scr[0], -scr[3], 0.f);
+	          Scale(1.f/(scr[1] - scr[0]), 1.f/(scr[2] - scr[3]), 1.f) *
+	          Translate(-scr[0], -scr[3], 0.f);
 	ras2scr = scr2ras;
 	ras2scr.invert();
 	ras2cam = cam2scr;

Modified: trunk/blender/extern/qdune/core/Options.cpp
===================================================================
--- trunk/blender/extern/qdune/core/Options.cpp	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/core/Options.cpp	2007-10-12 02:53:21 UTC (rev 12253)
@@ -78,6 +78,7 @@
 	bucketsize = 32;
 	texturememory = 10*1024*1024;	// 10Mb default should be enough
 	gridsize = 1024;
+	eyesplits = 5;
 
 	// basepath relative to current file for ReadArchive/etc
 	basepath[0] = 0;

Modified: trunk/blender/extern/qdune/core/Options.h
===================================================================
--- trunk/blender/extern/qdune/core/Options.h	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/core/Options.h	2007-10-12 02:53:21 UTC (rev 12253)
@@ -66,6 +66,7 @@
 	RtInt bucketsize;	// size of bucket in pixels
 	RtInt texturememory;	// texture cache size in kb
 	RtInt gridsize;	// maximum size of grid (num of verts)
+	RtInt eyesplits;
 
 	// basepath relative to current file for ReadArchive/etc
 	char basepath[256];

Modified: trunk/blender/extern/qdune/core/State.cpp
===================================================================
--- trunk/blender/extern/qdune/core/State.cpp	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/core/State.cpp	2007-10-12 02:53:21 UTC (rev 12253)
@@ -122,7 +122,8 @@
 	{ RI_BUCKETSIZE, {SC_CONSTANT|DT_INT, 1, 1}},
 	{ RI_TEXTUREMEMORY, {SC_CONSTANT|DT_INT, 1, 1}},
 	{ RI_GRIDSIZE, {SC_CONSTANT|DT_INT, 1, 1}},
-	{ RI_BINARY, {SC_CONSTANT|DT_INT, 1, 1}}
+	{ RI_BINARY, {SC_CONSTANT|DT_INT, 1, 1}},
+	{ RI_EYESPLITS, {SC_CONSTANT|DT_INT, 1, 1}}
 };
 
 // state create
@@ -257,7 +258,7 @@
 	else if (openAreaLight)
 		TODO
 	else */
-	if (motion_pos >= 0) {
+	if (motion_pos >= 0) {	// motion blurred primitive
 		if (openBlurPrim == NULL) openBlurPrim = new BlurredPrimitive();
 		// set lightarray and std_dice flags first before calling cloneAttributes(),
 		Attributes& attr = topAttributes();

Modified: trunk/blender/extern/qdune/framework/ReyesFramework.cpp
===================================================================
--- trunk/blender/extern/qdune/framework/ReyesFramework.cpp	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/framework/ReyesFramework.cpp	2007-10-12 02:53:21 UTC (rev 12253)
@@ -3,6 +3,7 @@
 #include "Primitive.h"
 #include "Color.h"
 #include "MicroPolygonGrid.h"
+#include "Options.h"
 
 #include <iostream>
 
@@ -12,6 +13,8 @@
 ReyesFramework::ReyesFramework(const Attributes& attr, const Options& opt)
 {
 	hider = new ZbufferHider(attr, opt);
+	max_eyesplits = opt.eyesplits;
+	total_eyesplits = 0;
 }
 
 ReyesFramework::~ReyesFramework()
@@ -35,8 +38,6 @@
 	return Color(0);
 }
 
-// TODO: make user option
-#define MAX_EYE_SPLITS 5
 void ReyesFramework::insert(Primitive* prim) const
 {
 	int v = hider->inFrustum(prim);
@@ -44,12 +45,12 @@
 		hider->insert(prim);
 	else if (v == EYE_SPLIT) {
 		if (prim->splitable()) {
-			if (prim->getEyeSplits() < MAX_EYE_SPLITS) {
+			if (prim->getEyeSplits() < max_eyesplits) {
 				prim->incEyeSplits();
 				prim->split(*this, true, true);
 			}
 			else	// max split exceeded, discard...
-				std::cout << "Max eyesplits exceeded, discarding primitive\n";
+				++total_eyesplits;
 			delete prim;
 		}
 	}
@@ -60,6 +61,8 @@
 
 void ReyesFramework::worldEnd() const
 {
+	if (total_eyesplits)
+		std::cout << "\rExceeded maximum eyesplitcount " << total_eyesplits << " times" << std::endl;
 	while (hider->bucketBegin()) {
 		Primitive* p;
 		while ((p = hider->firstPrim()) != NULL) {

Modified: trunk/blender/extern/qdune/framework/ReyesFramework.h
===================================================================
--- trunk/blender/extern/qdune/framework/ReyesFramework.h	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/framework/ReyesFramework.h	2007-10-12 02:53:21 UTC (rev 12253)
@@ -19,6 +19,9 @@
 	virtual void remove(const Primitive*) const;
 	virtual void worldEnd() const;
 	virtual Color trace(const Point3 &p, const Vector &r) const;
+protected:
+	int max_eyesplits;
+	mutable int total_eyesplits;
 };
 
 __END_QDRENDER

Modified: trunk/blender/extern/qdune/hider/ZbufferHider.cpp
===================================================================
--- trunk/blender/extern/qdune/hider/ZbufferHider.cpp	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/hider/ZbufferHider.cpp	2007-10-12 02:53:21 UTC (rev 12253)
@@ -587,7 +587,7 @@
 	const float p_zmin = MIN2(b.minmax[0].z, b.minmax[1].z);
 	const float p_zmax = MAX2(b.minmax[0].z, b.minmax[1].z);
 	const Options& opts = State::Instance()->topOptions();
-	if ((p_zmax < opts.nearClip) || (p_zmin > opts.farClip)) // completely behind nearclip or farclip
+	if ((p_zmax < opts.nearClip) or (p_zmin > opts.farClip)) // completely behind nearclip or farclip
 	{
 		prim_culled++;
 		return NOT_VISIBLE;
@@ -630,7 +630,7 @@
 		prim_culled++;
 		return NOT_VISIBLE;
 	}
-	else if ((p_zmin < (float)RI_EPSILON) && (p_zmax < opts.farClip))
+	if ((p_zmin < (float)RI_EPSILON) and (p_zmax > opts.nearClip))
 	{
 		// crossing eyeplane, the dreaded 'eyesplit'!
 		prim_culled++;

Modified: trunk/blender/extern/qdune/primitives/CCSubdivision.cpp
===================================================================
--- trunk/blender/extern/qdune/primitives/CCSubdivision.cpp	2007-10-10 23:36:58 UTC (rev 12252)
+++ trunk/blender/extern/qdune/primitives/CCSubdivision.cpp	2007-10-12 02:53:21 UTC (rev 12253)
@@ -2402,10 +2402,10 @@
 
 	const Attributes* attr = getAttributeReference();
 	// 2x2 mp minimum
-	unsigned int xdim = attr->dice_binary ? (1 << MAX2(1, int(0.5f + (float)log(MAX2(1e-7f, TESTSIZE*maxUDist) / attr->effectiveShadingRate)*(float)M_LOG2E)))
-	                                      : MAX2(2, int(0.5f + (TESTSIZE*maxUDist) / attr->effectiveShadingRate));
-	unsigned int ydim = attr->dice_binary ? (1 << MAX2(1, int(0.5f + (float)log(MAX2(1e-7f, TESTSIZE*maxVDist) / attr->effectiveShadingRate)*(float)M_LOG2E)))
-	                                      : MAX2(2, int(0.5f + (TESTSIZE*maxVDist) / attr->effectiveShadingRate));
+	unsigned int xdim = (attr->flags & AF_DICE_BINARY) ? (1 << MAX2(1, int(0.5f + (float)log(MAX2(1e-7f, TESTSIZE*maxUDist) / attr->effectiveShadingRate)*(float)M_LOG2E)))

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list