Re: Repeat efficiency
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 18, 2003
- 462 views
On Tue, 18 Feb 2003 12:30:21 -0800, <xerox_irs at lvcm.com> wrote: > > I'm making a large z-buffer for a 3d program is dos. > > "zbuffer=repeat(repeat(0,1024),768)" --works fast but when I > > "zbuffer[y][x]=something"--it slows down really bad, probably because it > allocates a new double every time i do that > > I've tried > > "zbuffer=repeat(repeat(0,1024),768)+0.0" --takes a minute but makes > > "zbuffer[y][x]=something" alot faster like multiple times faster > > but the problem is that zbuffer must clear every frame. > > so something like this still wouldn't work > > constant clear_buffer=repeat(repeat(0,1024),768)+0.0 > > while 1 do > zbuffer=clear_buffer --it would only be fast once !!!!! then make > the "zbuffer[y][x]=something" slow aagain > --do 3d stuff here > end while > > can you make the allocating cache bigger to whre if I allocate 8 megs > then free then it will not need to call the allocateing process for every > "zbuffer[y][x]=something", it would just take up the a part 8meg. > So euphoria would not give the 8meg back so quitly after allocateing it > so i could use it quickly. > > How should I make the zbuffer ???????? > > the only possibility is just to inverse the points every time, which > would slow it down alot > > zbuffer=repeat(repeat(0,1024),768)+0.0 > > while 1 do > zbuffer=-zbuffer > --do 3d stuff here > zbuffer=-zbuffer > --do inverse 3d stuff here > end while > > P.S. I want to keep it all in euphoria, and not use any asm so it can be > as readable and portable as possible. The following code takes 0.11 seconds on my Windows 2000 , Intel P3, 550MHz ----- sequence clearb sequence zbuffer atom e e = time() clearb = repeat(repeat(0.0, 1024), 768) zbuffer = clearb for i = 1 to 768 do for j = 1 to 1024 do zbuffer[i][j] = 2.34 -- any value end for end for zbuffer = clearb ? time() - e -- cheers, Derek Parnell