From 22b97743ef42c1b5d0c6a57f4004e72d55341c7a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 3 Jan 2011 06:13:50 +0000 Subject: avoid int/float comparisons within a number of for loops in deep shadow map compression. gives minor overall speedup. --- source/blender/editors/render/render_preview.c | 2 +- source/blender/render/intern/source/shadbuf.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index b60f948dc79..efe30533ac2 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1030,7 +1030,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs /* handle results */ if(sp->pr_method==PR_ICON_RENDER) { - char *rct= (char *)(sp->pr_rect + 32*16 + 16); + // char *rct= (char *)(sp->pr_rect + 32*16 + 16); if(sp->pr_rect) RE_ResultGet32(re, sp->pr_rect); diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index e589bb3a840..7d6edde2c0d 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -300,8 +300,14 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A DeepSample *ds[RE_MAX_OSA], *sampleds[RE_MAX_OSA], *dsb, *newbuf; APixstr *ap, *apn; APixstrand *aps, *apns; - float visibility, totbuf= shb->totbuf; - int a, b, c, tot, minz, found, size= shb->size, prevtot, newtot; + float visibility; + + const int totbuf= shb->totbuf; + const float totbuf_f= (float)shb->totbuf; + const float totbuf_f_inv= 1.0f/totbuf_f; + const int size= shb->size; + + int a, b, c, tot, minz, found, prevtot, newtot; int sampletot[RE_MAX_OSA], totsample = 0, totsamplec = 0; shsample= MEM_callocN( sizeof(ShadSampleBuf), "shad sample buf"); @@ -456,9 +462,9 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A } if(sampleds[c] == ds[c]) - visibility += 1.0f/totbuf; + visibility += totbuf_f_inv; else - visibility += (ds[c]-1)->v/totbuf; + visibility += (ds[c]-1)->v / totbuf_f; } dsb->v= visibility; -- cgit v1.2.3