Search found 46 matches

by Manpcnin
Aug 07, 2022 13:57
Forum: Community Discussion
Topic: Cursed Code.
Replies: 1
Views: 642

Cursed Code.

So today I found out that you can "pass" a single quote to a #macro parameter and prepend it to macro lines with ## to conditionally exclude them from the macro. (#if doesn't seem to work in macros) #macro mymacro(p1,COND) callalways(p1) COND##callSometimes(p1) 'cursed #endmacro mymacro(x,...
by Manpcnin
Jul 15, 2022 12:40
Forum: Community Discussion
Topic: Realtime CPU Raytracing.
Replies: 13
Views: 2616

Re: Realtime CPU Raytracing.

I believe a real-time ray tracing renderer can be developed to run on a laptop cpu. Euclideon's Unlimited Detail comes to mind. I guarantee there are at least a dozen undiscovered techniques, each one capable of increasing performance by 10% I've tested it on a puny 2 core 1.1Ghz Celeron at interac...
by Manpcnin
Sep 02, 2021 0:08
Forum: Community Discussion
Topic: Realtime CPU Raytracing.
Replies: 13
Views: 2616

Re: Realtime CPU Raytracing.

Does your algorithm do that, currently? On the CPU? Not yet. That's what I would break out the hand coded assembly for. Too slow for what? It always depends on the complexity of what you are trying to render... Sure. Any performance numbers will always be dependent on the scene complexity. Too slow...
by Manpcnin
Sep 01, 2021 21:49
Forum: Community Discussion
Topic: Realtime CPU Raytracing.
Replies: 13
Views: 2616

Re: Realtime CPU Raytracing.

1) don't waste your time with ASM... Do you really think the compiler is going to 8 x vectorize a core loop, into a pseudo "warp" with per-pixel early exit detection using branchless SIMD? Even if this requires algorithmic changes elsewhere? The kind ASM I'm looking at doing is, I think, ...
by Manpcnin
Sep 01, 2021 11:09
Forum: Community Discussion
Topic: Realtime CPU Raytracing.
Replies: 13
Views: 2616

Re: Realtime CPU Raytracing.

Got it.
by Manpcnin
Sep 01, 2021 10:30
Forum: Community Discussion
Topic: Realtime CPU Raytracing.
Replies: 13
Views: 2616

Re: Realtime CPU Raytracing.

That seems like way more work TBH. But maybe the compiler can optimize better like that? What do you mean by "just declare them"? I am using the GCC back-end, but I get a "fake:...:undefined reference" error if I just do that. Testing code: declare sub __builtin_cpu_init cdecl() ...
by Manpcnin
Sep 01, 2021 4:44
Forum: Community Discussion
Topic: Realtime CPU Raytracing.
Replies: 13
Views: 2616

Realtime CPU Raytracing.

For a while now I've been playing with a voxel-based, hybrid, raytracing/raymarching renderer. It's CPU based, and the point was to explore the performance bounds of CPU rendering with clever coding and algorithms. At some point I should stop and just port the damn thing to GPU, but every time I thi...
by Manpcnin
Sep 01, 2021 4:29
Forum: Documentation
Topic: Wiki improvements
Replies: 764
Views: 298210

Re: Wiki improvements

Added __FB_OPTIMIZE__ intrinisic define: - KeyPgDdfboptimize → fxm [new page '__FB_OPTIMIZE__'] - CatPgDddefines → fxm [added link to new page '__FB_OPTIMIZE__'] - CatPgFullIndex → fxm [added link to new page '__FB_OPTIMIZE__'] - CatPgFunctIndex → fxm [added link to new page '__FB_OPTIMIZE__'] - Pr...
by Manpcnin
Aug 14, 2021 7:04
Forum: Community Discussion
Topic: FreeBASIC 1.09.0 Release
Replies: 256
Views: 52375

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Hey I have a minor feature request. Could we get a compiler intrinsic for "-O <level>"? I've been writing a macro that detects if a sourcefile was compiled from FBIDE with -gen GCC and automatically re-compiles itself, translating -vec to -O (To get around that annoying IDE bug.) I'm reall...
by Manpcnin
Mar 24, 2021 23:59
Forum: General
Topic: Duffs Device & similar
Replies: 23
Views: 2142

Re: Duffs Device & similar

@coderJeff
Thank you! Thank you!
This is perfect!

How did I not know about this language feature?! I've been messing around in FreeBasic since 2006!

The fact that "On ... Gosub" is also supported implies that it's been in the language since BASIC.
by Manpcnin
Mar 24, 2021 21:44
Forum: General
Topic: Duffs Device & similar
Replies: 23
Views: 2142

Re: Duffs Device & similar

I do some SSE/AVX programming now and then, and when you operate on more values at the same time, doing ifs per value defeats the purpose of SSE. Then you learn a bit about branchless programming. Fairly simple stuff like recording the result of an operation in a register and multiplying or ANDing ...
by Manpcnin
Mar 24, 2021 21:04
Forum: General
Topic: Duffs Device & similar
Replies: 23
Views: 2142

Re: Duffs Device & similar

return (4 and a<b) or (2 and b<c) or (1 and c<a) '... while x<10 and y<10 and z<10 Aren't each of these Compares being translated into a JL (Jump if Less than) instruction? So this code now has 6 extra branches in it, to save one. Look; I've done a lot of performance testing on this code. The whole...
by Manpcnin
Mar 24, 2021 19:53
Forum: General
Topic: Duffs Device & similar
Replies: 23
Views: 2142

Re: Duffs Device & similar

Here is the original wanted, with C (loosly similar to switch) type code, cascading through the cases, visiting each one in turn Except the control flow graph of your program is completely different. The cmp3() function now gets executed every time an alternate loop is selected. What if the functio...
by Manpcnin
Mar 24, 2021 9:58
Forum: General
Topic: Duffs Device & similar
Replies: 23
Views: 2142

Re: Duffs Device & similar

fxm wrote:When I see code with GOTO(s), I go to another new post immediately ;-(
If you need code with interleaving execution paths, there really is no other option. I could remove a bunch of them if SELECT CASE worked like C SWITCH though (which is the point of my post).
by Manpcnin
Mar 24, 2021 9:55
Forum: General
Topic: Duffs Device & similar
Replies: 23
Views: 2142

Re: Duffs Device & similar

Oh I'm aware of the original purpose, and that modern compilers will unroll loops for you. I'm going to have to disagree with your argument for "design failure" though. (You aren't one of those "GOTO is harmful" coders are you?) C's switch was wonderfully orthogonal and it's beha...