
FreeBASIC's Official Forums
|
| View previous topic :: View next topic |
| Author |
Message |
|
|
|
| Back to top |
|
 |
|
|
Posted: Jun 29, 2005 0:57 Post subject: |
|
|
| Looks nize! Got abit dizzy there for a second |
| |
|
| Back to top |
|
 |
|
|
Posted: Jun 29, 2005 6:16 Post subject: |
|
|
| Great, the textures seem perspective-correct, it runs fast enough here, a 1.8 Athlon.. i guess you used 90% of inline asm anyway. Btw, why not hardware accel, because the challenge? ;) |
| |
|
| Back to top |
|
 |
|
|
Posted: Jun 29, 2005 18:11 Post subject: |
|
|
(sorry bad english!)
Hi Stonemonkey,
i write an software shader too i was intersting how you make the h-line loop i have tryed read your code with an disambler (from nasm) and it seams that you are use th single data type in the loop. You can speed it up if you are use an fixed point data type. the result can be an power of 2.
80 fps > 160 fps
currently i'm writing the color spotlight part. will your shader support color lightning too?
Good work Joshy |
| |
|
| Back to top |
|
 |
|
Hexadecimal Dude! Sr. Member
|
|
Posted: Jun 29, 2005 18:27 Post subject: |
|
|
well, it completely froze my (rubbish) computer, had to cold boot it!
ah well, it was worth it for the first frame ;-)..... |
| |
|
| Back to top |
|
 |
|
|
Posted: Jun 30, 2005 16:47 Post subject: |
|
|
HI,
Sorry about the freeze hexadecimal dude, i've not really got any explanation for that.
D.J.Peters, I use singles for interpolating U/Z,V/Z and 1/Z. I've tried using fixed point for those but 32 bits doesn't quite give enough accuracy with the way I do the perspective correction although i have played around with using an extra integer for the z buffer instead of the single which has improved things a bit.
v1ctor, been asked that a few times and tbh don't really know, probably the challenge and the satisfaction when it's all finally working. The vertex/shading calculations and some of the tri drawing routine are done in asm but i think i need to learn more about optimising asm.
btw, what's the best way to clear an area of memory in freebasic?
Sorry about the dizzyness Sotvart.
EDIT:
Hexadecimal dude, i think i can explain the freeze. I use a method of keeping the control of programs at a constant rate independant of the framerate but it can sometimes get stuck in a never ending loop if there's too much for it to do or if it's run on a slow pc, sorry about that.
Last edited by Stonemonkey on Jun 30, 2005 18:03; edited 1 time in total |
| |
|
| Back to top |
|
 |
|
|
Posted: Jun 30, 2005 18:00 Post subject: |
|
|
To clear an area of memory, you can use the built-in CLEAR, or libc's memset(), or write your own (faster :) routine. For example, if you know that your memory area is always a multiple of 4 bytes in length, you can do a very fast rep stosd: | Code:
|
|
Sub memset_dword(Byval addr As Any Ptr, Byval fill_with As Byte, Byval num_bytes As Integer) asm Xor eax, eax mov al, [fill_with] mov ah, al mov bx, ax Shl ebx, 16 Or eax, ebx mov ecx, [num_bytes] Shr ecx, 2 mov edi, [addr] cld rep stosd End asm End Sub
'' example usage
Dim mem As Any Ptr Const mem_size As Integer = 1024
mem = allocate(mem_size)
memset_dword(mem, 255, mem_size)
deallocate mem |
|
| |
|
| Back to top |
|
 |
|
|
Posted: Jun 30, 2005 18:32 Post subject: |
|
|
| Thanks DrV. |
| |
|
| Back to top |
|
 |
|
|
Posted: Jun 30, 2005 19:45 Post subject: |
|
|
| Quote: | | Sorry about the dizzyness Sotvart. |
Hehe no need to say sorry, good demos should make you dizzy =) |
| |
|
| Back to top |
|
 |
|
|
Posted: Jul 01, 2005 1:43 Post subject: |
|
|
hey nice work there. i felt the need to duck on several occasions when a block was heading straight for me! and thats a hard feeling to replicate in software.
it runs very well on my intel celeron 2.8 GHz, just to let you know. nice smooth animation and movement. |
| |
|
| Back to top |
|
 |
|
|
Posted: Jul 01, 2005 9:11 Post subject: |
|
|
Thanks jupiter.
v1ctor and D.J.Peters, thought you might be interested so here's the source with only the buffer clearing written in asm, it still runs pretty well. I've also removed the delta timing so it wont have problems on slower comps other than just running slow
http://freespace.virgin.net/r.fryer/soft3d.bas |
| |
|
| Back to top |
|
 |
|
|
Posted: Jul 02, 2005 3:51 Post subject: |
|
|
| Nice!!!!! |
| |
|
| Back to top |
|
 |
|
|
Posted: Jul 02, 2005 22:41 Post subject: |
|
|
Cool, not bad for an almost "pure" FB implementation, i thought you were using fixed-point and interpolation inside the inner-loop every n-texels, what could make it way more complex and look not too great, but at least twice as fast.
I changed it to 320x240 and got dizzy after 3 secs ;). Btw, to compile with the latest FB changes, the pointer operations must be changed.. "p += expr" is now like in C to make type-casting supported. |
| |
|
| Back to top |
|
 |
|
|
Posted: Jul 04, 2005 7:07 Post subject: |
|
|
(Sorry bad english!)
Yes and without fixedpoint math you can speed up the 3 add parts too.
| Code:
|
|
uc+=ustep:vc+=vstep:zc+=zstep |
in assembler
| Code:
|
|
fld [uc] '1 fadd [ustep] '3 fstp [uc] '2+1!!! broken pipeline fld [vc] '1 fadd [vstep] '3 fstp [vc] '2+1!!! broken pipeline fld [zc] '1 fadd [zstep] '3 fstp [zc] '2+1 |
This will use 20-21 cycles
| Code:
|
|
fld [uc] '1 fadd [ustep] '1 fld [vc] '1 fadd [vstep] '1 fld [zc] '1 fadd [zstep] '1 fxch st(2) ' 0 fstp [uc] '2 fstp [vc] '2 fstp [zc] '2 |
and now it use only 12 cycles.
I must test it with AMD and Intel too
Joshy |
| |
|
| Back to top |
|
 |
|
|
Posted: Jul 04, 2005 9:30 Post subject: |
|
|
| Ah, thanks D.J.Peters. As i said before i need to look into how to optimise asm and that's a start. |
| |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|