flat assembler
Message board for the users of flat assembler.
Index
> Windows > More fun with AVX (3D mandelbox) Goto page 1, 2 Next |
Author |
|
tthsqe 22 May 2013, 23:02
Randall's quaternion julia set renderer at http://board.flatassembler.net/topic.php?t=13676 inspired me try a 3D mandelbox(https://sites.google.com/site/mandelbox/what-is-a-mandelbox) renderer on windows.
Here is this program in action: http://www.youtube.com/watch?v=-Jo1TqpfpRw (latest version) http://www.youtube.com/watch?v=AoJcOxTGr4c (earlier version) Here are some results of the Mandelbox2 benchmark @ 1280x720 (press 'B'): Code: processor SSE AVX FMA3 FMA4 amd PhII N660(2C2T) 10250ms - - - intel i5-3320(2C2T) 7200ms 4750ms - - intel i5-3320(2C4T) 5100ms 3350ms - - intel i7-2600(4C8T) 2650ms 1850ms - - intel i7-4770(4C8T) 2250ms 1500ms ? - AVX is not showing a 2:1 improvement in sandy/ivy bridge because the vdivpd is split internally, but the difference is better on ivy bridge than sandy bridge. Mandelbox3 benchmark: Code: processor SSE AVX FMA3 FMA4 intel i5-3320(2C4T) 4800ms 3150ms - - intel i7-4770(4C8T) 2120ms 1420ms 1250ms - Please read the beginning of the source before using.
Last edited by tthsqe on 09 Nov 2013, 08:32; edited 53 times in total |
|||||||||||
22 May 2013, 23:02 |
|
HaHaAnonymous 23 May 2013, 01:26
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 20:20; edited 1 time in total |
|||
23 May 2013, 01:26 |
|
randall 25 May 2013, 13:44
Great work. Waiting for next versions with improved shading
|
|||
25 May 2013, 13:44 |
|
bitRAKE 27 May 2013, 02:24
tthsqe wrote: Are these enough to make a photo realistic scene? How would one do it? Code: // Mandelbox shader by Rrrola // http://rrrola.wz.cz/ // Blinn-Phong shading model with rim lighting (diffuse light bleeding to the other side). // `normal`, `view` and `light` should be normalized. vec3 blinn_phong(vec3 normal, vec3 view, vec3 light, vec3 diffuseColor) { vec3 halfLV = normalize(light + view); float spe = pow(max( dot(normal, halfLV), 0.0 ), 32.0); float dif = dot(normal, light) * 0.5 + 0.75; return dif*diffuseColor + spe*specularColor; } col = color(p); col = blinn_phong(n, -dp, normalize(eye+vec3(0,1,0)+dp), col); col = mix(aoColor, col, ambient_occlusion(p, n)); _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
27 May 2013, 02:24 |
|
HaHaAnonymous 27 May 2013, 14:49
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 20:18; edited 1 time in total |
|||
27 May 2013, 14:49 |
|
randall 30 May 2013, 11:23
Very impressive! Looks great.
Unfortunately I don't have AVX CPU yet but I am buying Haswell (AVX2) next month so i will try it. |
|||
30 May 2013, 11:23 |
|
Melissa 30 May 2013, 21:07
I have tried on Linux with Wine and it unfortunately
crashes on any input (resize, move, keypress). Mandel example that comes with fasmw works. |
|||
30 May 2013, 21:07 |
|
tthsqe 30 May 2013, 23:19
Here is my check list:
- If Wine is an emulator, then it needs to have the AVX instruction set not #UD. I also imagine that emulation of the AVX instructions on a non-AVX cpu is horribly slow...?? - Windows requires an update in order that the upper half of the ymm registers get saved to the thread context. - Does it draw the initial image correctly and crash after you give it some input? If that is the case, then more investigation is required. - Can you run it through a debugger and tell me the address on which it crashes? Has anybody else got this thing to work on their system? It works perfectly for me... |
|||
30 May 2013, 23:19 |
|
Melissa 31 May 2013, 00:59
Ok,
1. wine is not emulator rather translates windows calls to linux functions. It is a layer. cpu is avx capable (i5 3570k). 2. ymm registers are taken care by Linux (as program is natively executed) 3. Yes, it draws initial image correctly, I run it in 1024x768window. Ouptut is like picture you posted. It crashes when pressing key or resizing. 4. I have attached Wine debug output after crash.
|
|||||||||||
31 May 2013, 00:59 |
|
tthsqe 31 May 2013, 01:58
So does wine load completely different libraries into the program? For example, does wine load a completely rewritten user32 from the one that my real windows OS loads? In that case, there is no guarantee that wine will be as forgiving as windows is to the fact that my window callback function does not preserve all of the registers it should http://msdn.microsoft.com/en-us/library/9z1stfyw.aspx
You can see that "Paint:" in "MandelbrotExplorer.asm" calls "PlotMain:" and PlotMain destroys lots of registers While I investigation this further, you could in the mean time see if pushing all the nonvolatile registers at the beginning of my function Paint and then popping them in reverse order at the end of Paint fixes the problem. If it does/doesn't let me know |
|||
31 May 2013, 01:58 |
|
HaHaAnonymous 31 May 2013, 02:00
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 20:17; edited 1 time in total |
|||
31 May 2013, 02:00 |
|
tthsqe 31 May 2013, 02:03
HaHa, if it draws the initial image correctly, THEN IT IS WORKING!
I have no idea what wine is, but I suspect the problem is my fault. Quote: In other words: Avoid Wine when possible. Actually, this is not a bad idea here - this code is absolutely trivial to port to different OS's. The only OS specific code is mem allocation for pixel buffer and the bitmap display. Oh, and also thread management, but i suspect linux has a similar api for this. |
|||
31 May 2013, 02:03 |
|
HaHaAnonymous 31 May 2013, 02:07
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 20:17; edited 1 time in total |
|||
31 May 2013, 02:07 |
|
tthsqe 31 May 2013, 02:19
Well, I think I located the source of the problem - I did violate the register usage convention. We will have to wait to hear back from Melissa to see if this is the problem. Also, Melissa, make sure that you push an odd number of registers to keep the stack pointer dqword aligned. (at least some windows functions are sensitive to this.)
|
|||
31 May 2013, 02:19 |
|
revolution 31 May 2013, 02:22
tthsqe wrote: ... the fact that my window callback function does not preserve all of the registers it should ... Relying upon non-documented behaviour in the specific version of your OS is only going to give you problems. |
|||
31 May 2013, 02:22 |
|
tthsqe 31 May 2013, 02:37
Like I said, this is my fault. It's not reliance, it unawareness. It is amazing that it even works at all - my Paint function destroys EVERY register except rbp, r12, r13, and r14. OOPS
I have had programs crash when the callback didn't preserve rbp so I think that this is only one that needs to be preserved in my copy of windows. |
|||
31 May 2013, 02:37 |
|
Melissa 31 May 2013, 02:57
tthsqe wrote: So does wine load completely different libraries into the program? For example, does wine load a completely rewritten user32 from the one that my real windows OS loads? In that case, there is no guarantee that wine will be as forgiving as windows is to the fact that my window callback function does not preserve all of the registers it should http://msdn.microsoft.com/en-us/library/9z1stfyw.aspx Seems that wine has own version of libraries. It works now! Yeeeeeey! I have pushed all registers and aligned stack on 16 bytes (just in case) Program runs perfectly! |
|||
31 May 2013, 02:57 |
|
HaHaAnonymous 31 May 2013, 03:30
[ Post removed by author. ]
Last edited by HaHaAnonymous on 28 Feb 2015, 20:15; edited 1 time in total |
|||
31 May 2013, 03:30 |
|
revolution 31 May 2013, 03:56
tthsqe wrote: Like I said, this is my fault. It's not reliance, it unawareness. It is amazing that it even works at all - my Paint function destroys EVERY register except rbp, r12, r13, and r14. OOPS Anyhow, good to see bugs getting fixed and things improving. |
|||
31 May 2013, 03:56 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.