Revision: 15781
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15781
Author:   joeedh
Date:     2008-07-26 19:27:50 +0200 (Sat, 26 Jul 2008)

Log Message:
-----------
fixed slowdown in strands, though note strand renderer by its nature\n will be 
slower then with it disabled.  I might make a minimum strand angle limit for 
shadows,\n since I'm not sure if people care about strands looking perfectly 
smooth in shadows.

Modified Paths:
--------------
    branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
    branches/soc-2007-joeedh/source/blender/blenkernel/BKE_tile.h
    branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_bucketbuffer.c
    branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
    branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h
    branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/strand.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h        
2008-07-26 15:38:05 UTC (rev 15780)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h        
2008-07-26 17:27:50 UTC (rev 15781)
@@ -102,6 +102,10 @@
 
 #define DSM_SAMPLEMERGE_LIMIT  (0x7FFFFFFF) //20000000
 
+//angle limit of strands.  is in degrees, so
+//code has to convert.ss
+#define DSM_STRAND_MAX_ADAPTCOS 25.0
+
 #define DSM_LINEAR     1
 #define DSM_SOFT       0
 //#define DOQMCDEBUG

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_tile.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_tile.h       
2008-07-26 15:38:05 UTC (rev 15780)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_tile.h       
2008-07-26 17:27:50 UTC (rev 15781)
@@ -152,10 +152,6 @@
  
  /*TCS_TilePool->flag*/
  
- /*the tile size is fixed, so the pool may safely
-   reuse tiles.*/
- #define TCS_POOL_TSIZEFIXED   1
- 
  typedef struct TCS_TileBuffer {
        struct TCS_TileBuffer *next, *prev;
        struct TCS_TileBuffer *(*newBuffer)(TCS_TilePool *pool, int tilesizex, 
int tilesizey, 
@@ -171,16 +167,11 @@
        int (*getSizeX)(struct TCS_TileBuffer *self);
        int (*getSizeY)(struct TCS_TileBuffer *self);
        unsigned int flag;
-       
+
        /*should be set by TCS_MakePool, not the newBuffer function*/
        TCS_TilePool *pool;
  } TCS_TileBuffer;
 
-/* TCS_TileBuffer->flags */
- /*Read only buffer means once a tile is written once, we
-  never have to write it to disk again.*/
-#define TCS_READONLY   1
-
  /*utility macro to check if a tile is cached.*/
 #define TCS_ISTILECACHED(tile) (((TCS_Tile*)tile)->is_compressed)
 
@@ -217,7 +208,7 @@
 void TCS_AddToPool(TCS_TilePool *pool, void *vtile);
 
 /*this function removes a tile from a tile pool.
-  this is automatically called by TCS_FreeTile.*/
+  this is automatically called by TCS_UnlinkTile.*/
 void TCS_RemFromPool(void *vtile);
 
 TCS_TileBuffer *TCS_MakeBuffer(TCS_TilePool *pool, TCS_TileBuffer *type, int 
tilesizex, int tilesizey, 
@@ -252,13 +243,17 @@
 
 /*This function frees generic data associated with a tile, removes it from its 
pool, etc,
   but it doesn't actually free the client tile data itself.*/
-void TCS_FreeTile(void *vtile);
+void TCS_UnlinkTile(void *vtile);
 
 /*hrm, not sure if this next one will be needed, its possible it can
   all be done from within TCS_GetTile(), perhaps even progressively*/
 void TCS_RunCacher(TCS_TilePool *pool);
 void TCS_SetCacheLimit(TCS_TilePool *pool, unsigned long max_mem_bytes);
 
+/*makes a fixed-tilesize-pool.  note that tilesize is the on-disk size of the 
+  part of the tile that's saved on disk.*/
+TCS_TilePool *TCS_MakeFixedPool(unsigned long max_mem_bytes, char *name, int 
tilesize);
+
 /******************* File wrapper to support both memory and real files. 
************************/
 /*this should all probably become part of blenlib*/
 
@@ -290,4 +285,14 @@
 #define BASSERT(eval)  if (!(eval)) printf("\nassert \"%s\" in file:\n%s\n on 
line %d failed.\n\n", #eval, __FILE__, __LINE__)
 //#define BASSERT(eval)
 
+/* TCS_TileBuffer->flag */
+ /*Read only buffer means once a tile is written once, we
+  never have to write it to disk again.*/
+#define TCS_READONLY   1
+
+/*TCS_TilePool>flag*/
+/*the tile size is fixed, so the pool may safely
+  reuse tiles.*/
+#define TCS_POOL_TSIZEFIXED    1
+
 #endif /* BKE_TILE_H */

Modified: 
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_bucketbuffer.c
===================================================================
--- 
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_bucketbuffer.c    
    2008-07-26 15:38:05 UTC (rev 15780)
+++ 
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_bucketbuffer.c    
    2008-07-26 17:27:50 UTC (rev 15781)
@@ -41,7 +41,7 @@
 extern TCS_TileBuffer TCS_BucketBuffer;
 TCS_TilePool *re_bucket_pool = NULL;
 
-#define POOLMAXMEM     75*1024*1024
+#define POOLMAXMEM     40*1024*1024
 
 RE_BucketBuffer *RE_Bucket_New(int sizex, int sizey, int tsizex, int tsizey) {
        if (re_bucket_pool == NULL) re_bucket_pool = TCS_MakePool(POOLMAXMEM, 
"bucketpool");
@@ -172,7 +172,8 @@
        for (x=0; x<buf->tilex; x++) {
                for (y=0; y<buf->tiley; y++) {
                        tile = &buf->tilerect[y*buf->tilex+x];
-                       
+                       TCS_UnlinkTile(tile);
+
                        /*we don't use the BLI stuff since we're dealing
                          with a singly-linked list, not a doubly-linked list*/
                        for (entry=tile->ventries; entry; entry=next) {

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c       
2008-07-26 15:38:05 UTC (rev 15780)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c       
2008-07-26 17:27:50 UTC (rev 15781)
@@ -50,7 +50,7 @@
 {
        TCS_TilePool *pool = MEM_callocN(sizeof(TCS_TilePool), "tilepool");
        
-       strncpy(pool->name, name, 32);
+       strncpy(pool->name, name, 31);
 
        /*sadly, strncpy does *not* do this. . .*/
        pool->name[31] = 0;
@@ -59,7 +59,7 @@
        pool->maxmem = max_mem_bytes;
        
        /*this is to group cache runs so they process no less then 5 megs at a 
time.*/
-       pool->grace_period = 1024*1024*5; 
+       pool->grace_period = 5*1024*1024; 
        
        return pool;
 }
@@ -147,7 +147,7 @@
        MEM_freeN(pool);
 }
 
-void TCS_FreeTile(void *vtile)
+void TCS_UnlinkTile(void *vtile)
 {
        TCS_Tile *tile = vtile;
        
@@ -553,6 +553,17 @@
 
                        TCS_fwrite(&tile->compressed_memfile->length, 
sizeof(unsigned long), 1, tile->file);
                        TCS_fwrite(tile->compressed_memfile->ptr, 
tile->compressed_memfile->length, 1, tile->file);
+                       
+                       /*if TCS_POOL_TSIZEFIXED is set, then we have to ensure 
the entire uncompressed
+                         tile region on the disk is reserved, even if it's not 
used.*/
+                       if (pool->flag & TCS_POOL_TSIZEFIXED) {
+                               int diff = pool->tilesize - 
tile->compressed_memfile->length;
+                               int i, zero=0;
+                               for (i=0; i<diff; i++) {
+                                       TCS_fwrite(&zero, sizeof(int), 1, 
tile->file);
+                               }
+                       }
+
                        TCS_fflush(tile->file);
                }
 

Modified: 
branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h
===================================================================
--- 
branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h    
    2008-07-26 15:38:05 UTC (rev 15780)
+++ 
branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h    
    2008-07-26 17:27:50 UTC (rev 15781)
@@ -267,6 +267,7 @@
        struct VertTableNode *vertnodes;
        struct VlakTableNode *vlaknodes;
        struct StrandTableNode *strandnodes;
+
        struct HaloRen **bloha;
        struct StrandBuffer *strandbuf;
 

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c  
2008-07-26 15:38:05 UTC (rev 15780)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c  
2008-07-26 17:27:50 UTC (rev 15781)
@@ -97,7 +97,7 @@
        int i;
 
        for (i=0; i<dbuf->tilex*dbuf->tiley; i++) {
-               TCS_FreeTile(&dbuf->vfunc_rect[i]);
+               TCS_UnlinkTile(&dbuf->vfunc_rect[i]);
                if (dbuf->vfunc_rect[i].arena) 
BLI_memarena_free(dbuf->vfunc_rect[i].arena);
                if (dbuf->vfunc_rect[i].funcarray) 
MEM_freeN(dbuf->vfunc_rect[i].funcarray);
        }
@@ -207,7 +207,8 @@
        StrandRen *strand= NULL;
        StrandVert *svert;
        ObjectRen *obr;
-       float imat[3][3], mat[3][3], viewinv[4][4];
+       ObjectInstanceRen *obi;
+       float imat[3][3], mat[3][3], mat4[4][4], mat3[3][3], viewinv[4][4];
        int i, j, a;
        
        if (mode == 0) {
@@ -217,7 +218,19 @@
        MTC_Mat4Invert(viewinv, oldview);
        Mat3CpyMat4(imat, viewinv);
        Mat3CpyMat4(mat, newview);
+       
+       for (obi=re->instancetable.first; obi; obi=obi->next) {
+               if(obi->flag & R_DUPLI_TRANSFORMED || obi->flag & 
R_TRANSFORMED) {
+                       Mat4CpyMat4(mat4, obi->mat);
+                       MTC_Mat4MulMat4(mat4, obi->mat, viewinv);
+                       MTC_Mat4MulMat4(obi->mat, mat4, newview);
 
+                       Mat3CpyMat4(mat3, obi->mat);
+                       Mat3Inv(obi->nmat, mat3);
+                       Mat3Transp(obi->nmat);
+               }
+       }
+
        for(i=0, obr=re->objecttable.first; obr; i++, obr=obr->next) {
                for (j=0; j<obr->totvert; j++) {
                        vert = RE_findOrAddVert(obr, j);
@@ -384,7 +397,7 @@
        }
 
        bucketbuf = RE_BucketData(re, projmat, shb->size, shb->size, 
-                                     tilesize, tilesize, shb->soft, shb->soft, 
lay);
+                                     tilesize, tilesize, shb->soft+25, 
shb->soft+25, lay);
 
        dbuf->vfunc_rect = 
MEM_mapallocN(sizeof(DSMTile)*dbuf->tilex*dbuf->tiley, "dsm tiles");
 
@@ -537,7 +550,7 @@
                                re->i.infostr= NULL;
                        }
                        lastdone = done;
-                       PIL_sleep_ms(300);
+                       PIL_sleep_ms(30);
                }
 
                BLI_end_threads(&threads);

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/strand.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/strand.c       
2008-07-26 15:38:05 UTC (rev 15780)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/strand.c       
2008-07-26 17:27:50 UTC (rev 15781)
@@ -45,6 +45,7 @@
 #include "BKE_DerivedMesh.h"
 #include "BKE_key.h"
 #include "BKE_utildefines.h"
+#include "BKE_global.h"
 
 #include "render_types.h"
 #include "initrender.h"
@@ -661,13 +662,22 @@
                projectvert(p2->co, winmat, hoco2);
   
                for(a=0; a<totzspan; a++) {
-#if 0
-                       /* render both strand and single pixel wire to counter 
aliasing */
-                       zbufclip4(re, &zspan[a], obi, index, p1->hoco2, 
p1->hoco1, p2->hoco1, p2->hoco2, p1->clip2, p1->clip1, p2->clip1, p2->clip2);
-#endif
-                       /* only render a line for now, which makes the shadow 
map more
-                          similiar across frames, and so reduces flicker */
-                       zbufsinglewire(&zspan[a], obi, index, hoco1, hoco2);
+                       if (G.rt != 17) {
+                               projectvert(p1->co1, winmat, p1->hoco1);
+                               projectvert(p1->co2, winmat, p1->hoco2);
+
+                               projectvert(p2->co1, winmat, p2->hoco1);
+                               projectvert(p2->co2, winmat, p2->hoco2);
+                               
+                               zbufclip4(re, &zspan[a], obi, index, p1->hoco2, 
p1->hoco1, p2->hoco1, p2->hoco2, p1->clip2, p1->clip1, p2->clip1, p2->clip2);
+                               //zbufclip(re, &zspan[a], obi, index, 
p1->hoco2, p1->hoco1, p2->hoco1, p1->clip2, p1->clip1, p2->clip1);
+                               //zbufclip(re, &zspan[a], obi, index, 
p1->hoco2, p2->hoco1, p2->hoco2, p1->clip2, p2->clip1, p2->clip2);
+                       } else {
+                               /* (DISABLED for now):
+                                  only render a line for now, which makes the 
shadow map more

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to