Mercurial > hg > Game > Cerium
changeset 1172:614562ada648 draft
add span_calc func
author | Yutaka_Kinjyo |
---|---|
date | Sun, 05 Jun 2011 17:59:02 +0900 |
parents | b93ff55ba015 |
children | cce350bed940 |
files | Renderer/Engine/Makefile.def Renderer/Engine/spe/CreateSpan.cc Renderer/Engine/task/CreateSpan.cc |
diffstat | 3 files changed, 221 insertions(+), 201 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.def Tue May 31 13:57:03 2011 +0900 +++ b/Renderer/Engine/Makefile.def Sun Jun 05 17:59:02 2011 +0900 @@ -5,7 +5,7 @@ ABIBIT = 64 ABI = -m$(ABIBIT) CC = g++ -OPT = -g -DUSE_TASKARRAY -DUSE_PIPELINE -DUSE_SEGMENT +OPT = -g -DUSE_TASKARRAY -DUSE_PIPELINE -DUSE_SEGMENT # OPT = -O9 -DUSE_TASKARRAY -DUSE_PIPELINE -DUSE_SEGMENT CFLAGS = -Wall $(ABI) $(OPT) # -DDEBUG
--- a/Renderer/Engine/spe/CreateSpan.cc Tue May 31 13:57:03 2011 +0900 +++ b/Renderer/Engine/spe/CreateSpan.cc Sun Jun 05 17:59:02 2011 +0900 @@ -188,6 +188,109 @@ //return scale_max; } + +static void +span_calc(SpanPackPtr spack, VertexPackPtr vMid, VertexPackPtr vMid10, VertexPackPtr vMin, + NormalPackPtr normal1, NormalPackPtr normal2, NormalPackPtr normal3, + TriangleTexInfoPtr tex_info, int length_y, float tex_y_len, float div_y, int y, int i) +{ + + float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2; + float tmp_xpos,tmp_end,tmp_zpos; + float start_z, end_z; + float start_tex_x, end_tex_x, start_tex_y, end_tex_y; + int x,length; + + tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x); + tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); + tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); + tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); + + length = (tmp_xpos > tmp_end) + ? (int)tmp_xpos - (int)tmp_end : (int)tmp_end - (int)tmp_xpos; + if (length == 0) { + return; + } + + tmp_tex1 =((i/(div_y)) * vMid10->tex_x) + + ( ((div_y - i)/(div_y)) * vMin->tex_x); + tmp_tex2 =( (i/(div_y)) * vMid->tex_x) + + ( ((div_y - i)/(div_y)) * vMin->tex_x); + + tmp_tey1 =( (i/(div_y)) * vMid10->tex_y) + + ( ((div_y - i)/(div_y)) * vMin->tex_y); + tmp_tey2 =( (i/(div_y)) * vMid->tex_y) + + ( ((div_y - i)/(div_y)) * vMin->tex_y); + + if (tmp_xpos > tmp_end) { + x = (int)tmp_end; + length = (int)(tmp_xpos)-(int)(tmp_end)+1; + start_z = tmp_zpos; + end_z = tmp_z; + start_tex_x = tmp_tex2; + end_tex_x = tmp_tex1; + start_tex_y = tmp_tey2; + end_tex_y = tmp_tey1; + } else { + x = (int)tmp_xpos; + length = (int)(tmp_end)-(int)(tmp_xpos)+1; + start_z = tmp_z; + end_z = tmp_zpos; + start_tex_x = tmp_tex1; + end_tex_x = tmp_tex2; + start_tex_y = tmp_tey1; + end_tex_y = tmp_tey2; + } + + // ここいる? load してその後必ず、wait してるように見える。 + // この wait に対応しているloadはないはずだ・・・きっと。 + //smanager->dma_wait(SPAN_PACK_LOAD); + + Span *span = &spack->span[spack->info.size++]; + + span->x = x; + span->y = y; + span->length_x = length; + span->start_z = start_z; + span->end_z = end_z; + span->tex_x1 = start_tex_x; + span->tex_x2 = end_tex_x; + span->tex_y1 = start_tex_y; + span->tex_y2 = end_tex_y; + + /* + * ここで頂点分法線ベクトルがあったんだけど、 + * 一つだけ取り出して、spanに一つの法線ベクトルを持たしている + */ + + span->normal_x = normal1->x; + span->normal_y = normal1->y; + span->normal_z = normal1->z; + + float tex_x_len = span->tex_x2 - span->tex_x1; + + span->tex_width = tex_info->width; + span->tex_height = tex_info->height; + + /** + * tex_x_len, tex_y_len を掛ける理由は + * Changelog の 2008-12-16 を参照 + */ + int scale = getScale(span->length_x, length_y, + (int)(span->tex_width*tex_x_len), + (int)(span->tex_height*tex_y_len), + tex_info->scale_max); + //scale = tex_info->scale_max; + + uint32 *tapestry = getTapestry(tex_info->width, + tex_info->height, scale, + tex_info->addr); + span->tex_addr = tapestry; + span->tex_width = tex_info->width/scale; + span->tex_height = tex_info->height/scale; + +} + /** * x軸に水平な辺を持つ三角形ポリゴンから、 * Span を抜き出す @@ -220,12 +323,8 @@ #endif int length_y, float tex_y_len) { - float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2; - float tmp_xpos,tmp_end,tmp_zpos; - float start_z, end_z; - float start_tex_x, end_tex_x, start_tex_y, end_tex_y; - int x, y, length; + int y; #if 1 // これじゃないと @@ -286,7 +385,6 @@ for (int i = k; i < (int)div_y+1; i++) { y = (int)vMin->y + i*l; -#if 1 /** * 担当 y 範囲内 @@ -352,8 +450,7 @@ if (spack->info.size >= MAX_SIZE_SPAN) { SpanPackPtr next; - - + smanager->mainMem_alloc(0, sizeof(SpanPack)); smanager->mainMem_wait(); next = (SpanPackPtr)smanager->mainMem_get(0); @@ -404,107 +501,20 @@ */ continue; } - - tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x); - tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); - tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); - tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); - - length = (tmp_xpos > tmp_end) - ? (int)tmp_xpos - (int)tmp_end : (int)tmp_end - (int)tmp_xpos; - if (length == 0) { - continue; - } - - tmp_tex1 =((i/(div_y)) * vMid10->tex_x) + - ( ((div_y - i)/(div_y)) * vMin->tex_x); - tmp_tex2 =( (i/(div_y)) * vMid->tex_x) + - ( ((div_y - i)/(div_y)) * vMin->tex_x); - - tmp_tey1 =( (i/(div_y)) * vMid10->tex_y) + - ( ((div_y - i)/(div_y)) * vMin->tex_y); - tmp_tey2 =( (i/(div_y)) * vMid->tex_y) + - ( ((div_y - i)/(div_y)) * vMin->tex_y); - - if (tmp_xpos > tmp_end) { - x = (int)tmp_end; - length = (int)(tmp_xpos)-(int)(tmp_end)+1; - start_z = tmp_zpos; - end_z = tmp_z; - start_tex_x = tmp_tex2; - end_tex_x = tmp_tex1; - start_tex_y = tmp_tey2; - end_tex_y = tmp_tey1; - } else { - x = (int)tmp_xpos; - length = (int)(tmp_end)-(int)(tmp_xpos)+1; - start_z = tmp_z; - end_z = tmp_zpos; - start_tex_x = tmp_tex1; - end_tex_x = tmp_tex2; - start_tex_y = tmp_tey1; - end_tex_y = tmp_tey2; - } - - // ここいる? load してその後必ず、wait してるように見える。 - // この wait に対応しているloadはないはずだ・・・きっと。 - smanager->dma_wait(SPAN_PACK_LOAD); - - Span *span = &spack->span[spack->info.size++]; - - span->x = x; - span->y = y; - span->length_x = length; - span->start_z = start_z; - span->end_z = end_z; - span->tex_x1 = start_tex_x; - span->tex_x2 = end_tex_x; - span->tex_y1 = start_tex_y; - span->tex_y2 = end_tex_y; - - /* - * ここで頂点分法線ベクトルがあったんだけど、 - * 一つだけ取り出して、spanに一つの法線ベクトルを持たしている - */ - - span->normal_x = normal1->x; - span->normal_y = normal1->y; - span->normal_z = normal1->z; - float tex_x_len = span->tex_x2 - span->tex_x1; - - span->tex_width = tex_info->width; - span->tex_height = tex_info->height; + span_calc(spack, vMid, vMid10, vMin, + normal1, normal2, normal3, + tex_info, length_y, tex_y_len, div_y, y, i); - /** - * tex_x_len, tex_y_len を掛ける理由は - * Changelog の 2008-12-16 を参照 - */ - int scale = getScale(span->length_x, length_y, - (int)(span->tex_width*tex_x_len), - (int)(span->tex_height*tex_y_len), - tex_info->scale_max); - //scale = tex_info->scale_max; - - uint32 *tapestry = getTapestry(tex_info->width, - tex_info->height, scale, - tex_info->addr); - span->tex_addr = tapestry; - span->tex_width = tex_info->width/scale; - span->tex_height = tex_info->height/scale; } -#else - - /** - * ここに SIMD 化した記述をしようとして断念 - */ -#endif } + + static int run(SchedTask *smanager, void *rbuf, void *wbuf) {
--- a/Renderer/Engine/task/CreateSpan.cc Tue May 31 13:57:03 2011 +0900 +++ b/Renderer/Engine/task/CreateSpan.cc Sun Jun 05 17:59:02 2011 +0900 @@ -188,6 +188,109 @@ //return scale_max; } + +static void +span_calc(SpanPackPtr spack, VertexPackPtr vMid, VertexPackPtr vMid10, VertexPackPtr vMin, + NormalPackPtr normal1, NormalPackPtr normal2, NormalPackPtr normal3, + TriangleTexInfoPtr tex_info, int length_y, float tex_y_len, float div_y, int y, int i) +{ + + float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2; + float tmp_xpos,tmp_end,tmp_zpos; + float start_z, end_z; + float start_tex_x, end_tex_x, start_tex_y, end_tex_y; + int x,length; + + tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x); + tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); + tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); + tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); + + length = (tmp_xpos > tmp_end) + ? (int)tmp_xpos - (int)tmp_end : (int)tmp_end - (int)tmp_xpos; + if (length == 0) { + return; + } + + tmp_tex1 =((i/(div_y)) * vMid10->tex_x) + + ( ((div_y - i)/(div_y)) * vMin->tex_x); + tmp_tex2 =( (i/(div_y)) * vMid->tex_x) + + ( ((div_y - i)/(div_y)) * vMin->tex_x); + + tmp_tey1 =( (i/(div_y)) * vMid10->tex_y) + + ( ((div_y - i)/(div_y)) * vMin->tex_y); + tmp_tey2 =( (i/(div_y)) * vMid->tex_y) + + ( ((div_y - i)/(div_y)) * vMin->tex_y); + + if (tmp_xpos > tmp_end) { + x = (int)tmp_end; + length = (int)(tmp_xpos)-(int)(tmp_end)+1; + start_z = tmp_zpos; + end_z = tmp_z; + start_tex_x = tmp_tex2; + end_tex_x = tmp_tex1; + start_tex_y = tmp_tey2; + end_tex_y = tmp_tey1; + } else { + x = (int)tmp_xpos; + length = (int)(tmp_end)-(int)(tmp_xpos)+1; + start_z = tmp_z; + end_z = tmp_zpos; + start_tex_x = tmp_tex1; + end_tex_x = tmp_tex2; + start_tex_y = tmp_tey1; + end_tex_y = tmp_tey2; + } + + // ここいる? load してその後必ず、wait してるように見える。 + // この wait に対応しているloadはないはずだ・・・きっと。 + //smanager->dma_wait(SPAN_PACK_LOAD); + + Span *span = &spack->span[spack->info.size++]; + + span->x = x; + span->y = y; + span->length_x = length; + span->start_z = start_z; + span->end_z = end_z; + span->tex_x1 = start_tex_x; + span->tex_x2 = end_tex_x; + span->tex_y1 = start_tex_y; + span->tex_y2 = end_tex_y; + + /* + * ここで頂点分法線ベクトルがあったんだけど、 + * 一つだけ取り出して、spanに一つの法線ベクトルを持たしている + */ + + span->normal_x = normal1->x; + span->normal_y = normal1->y; + span->normal_z = normal1->z; + + float tex_x_len = span->tex_x2 - span->tex_x1; + + span->tex_width = tex_info->width; + span->tex_height = tex_info->height; + + /** + * tex_x_len, tex_y_len を掛ける理由は + * Changelog の 2008-12-16 を参照 + */ + int scale = getScale(span->length_x, length_y, + (int)(span->tex_width*tex_x_len), + (int)(span->tex_height*tex_y_len), + tex_info->scale_max); + //scale = tex_info->scale_max; + + uint32 *tapestry = getTapestry(tex_info->width, + tex_info->height, scale, + tex_info->addr); + span->tex_addr = tapestry; + span->tex_width = tex_info->width/scale; + span->tex_height = tex_info->height/scale; + +} + /** * x軸に水平な辺を持つ三角形ポリゴンから、 * Span を抜き出す @@ -220,12 +323,8 @@ #endif int length_y, float tex_y_len) { - float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2; - float tmp_xpos,tmp_end,tmp_zpos; - float start_z, end_z; - float start_tex_x, end_tex_x, start_tex_y, end_tex_y; - int x, y, length; + int y; #if 1 // これじゃないと @@ -286,7 +385,6 @@ for (int i = k; i < (int)div_y+1; i++) { y = (int)vMin->y + i*l; -#if 1 /** * 担当 y 範囲内 @@ -352,8 +450,7 @@ if (spack->info.size >= MAX_SIZE_SPAN) { SpanPackPtr next; - - + smanager->mainMem_alloc(0, sizeof(SpanPack)); smanager->mainMem_wait(); next = (SpanPackPtr)smanager->mainMem_get(0); @@ -404,107 +501,20 @@ */ continue; } - - tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x); - tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); - tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); - tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); - - length = (tmp_xpos > tmp_end) - ? (int)tmp_xpos - (int)tmp_end : (int)tmp_end - (int)tmp_xpos; - if (length == 0) { - continue; - } - - tmp_tex1 =((i/(div_y)) * vMid10->tex_x) + - ( ((div_y - i)/(div_y)) * vMin->tex_x); - tmp_tex2 =( (i/(div_y)) * vMid->tex_x) + - ( ((div_y - i)/(div_y)) * vMin->tex_x); - - tmp_tey1 =( (i/(div_y)) * vMid10->tex_y) + - ( ((div_y - i)/(div_y)) * vMin->tex_y); - tmp_tey2 =( (i/(div_y)) * vMid->tex_y) + - ( ((div_y - i)/(div_y)) * vMin->tex_y); - - if (tmp_xpos > tmp_end) { - x = (int)tmp_end; - length = (int)(tmp_xpos)-(int)(tmp_end)+1; - start_z = tmp_zpos; - end_z = tmp_z; - start_tex_x = tmp_tex2; - end_tex_x = tmp_tex1; - start_tex_y = tmp_tey2; - end_tex_y = tmp_tey1; - } else { - x = (int)tmp_xpos; - length = (int)(tmp_end)-(int)(tmp_xpos)+1; - start_z = tmp_z; - end_z = tmp_zpos; - start_tex_x = tmp_tex1; - end_tex_x = tmp_tex2; - start_tex_y = tmp_tey1; - end_tex_y = tmp_tey2; - } - - // ここいる? load してその後必ず、wait してるように見える。 - // この wait に対応しているloadはないはずだ・・・きっと。 - smanager->dma_wait(SPAN_PACK_LOAD); - - Span *span = &spack->span[spack->info.size++]; - - span->x = x; - span->y = y; - span->length_x = length; - span->start_z = start_z; - span->end_z = end_z; - span->tex_x1 = start_tex_x; - span->tex_x2 = end_tex_x; - span->tex_y1 = start_tex_y; - span->tex_y2 = end_tex_y; - - /* - * ここで頂点分法線ベクトルがあったんだけど、 - * 一つだけ取り出して、spanに一つの法線ベクトルを持たしている - */ - - span->normal_x = normal1->x; - span->normal_y = normal1->y; - span->normal_z = normal1->z; - float tex_x_len = span->tex_x2 - span->tex_x1; - - span->tex_width = tex_info->width; - span->tex_height = tex_info->height; + span_calc(spack, vMid, vMid10, vMin, + normal1, normal2, normal3, + tex_info, length_y, tex_y_len, div_y, y, i); - /** - * tex_x_len, tex_y_len を掛ける理由は - * Changelog の 2008-12-16 を参照 - */ - int scale = getScale(span->length_x, length_y, - (int)(span->tex_width*tex_x_len), - (int)(span->tex_height*tex_y_len), - tex_info->scale_max); - //scale = tex_info->scale_max; - - uint32 *tapestry = getTapestry(tex_info->width, - tex_info->height, scale, - tex_info->addr); - span->tex_addr = tapestry; - span->tex_width = tex_info->width/scale; - span->tex_height = tex_info->height/scale; } -#else - - /** - * ここに SIMD 化した記述をしようとして断念 - */ -#endif } + + static int run(SchedTask *smanager, void *rbuf, void *wbuf) {