Page 4 of 5

Re: speed

Posted: Sun Jun 23, 2024 3:07 pm
by 1Minus2P1Stringer2
UnixRoot wrote: Sun Jun 23, 2024 10:59 am
1Minus2P1Stringer2 wrote: Sat Jun 22, 2024 11:07 pm
dusoft wrote: Sat Jun 22, 2024 10:11 pm It is much more difficult, @UnixRoot is right. In what (existing) language are you going to write it, anyway?
Not if the language you were using was confusing you. Which, right now, lua is kinda confusing me. Love2d is fine, but lua's framework confuses me. like how does lua render slower then scratch? Scratch can render an image from an image scanner in 3 seconds. Why is lua rendering at 2 minutes per frame, at real time? I get love2d has a function to load multiple pixels at once, which speeds it up by alot but still?
I don't know what you're doing wrong. I can easily render a world, consisting of multiple 4096x4096 height maps with raw 32 bit floating point data and textures of the same resolution on top. Even on my Potato PC, I get hundreds or even thousand of FPS in my CPU based software renderer. Love2D is FAST, if you optimize your code.

love 2024-06-23 12-52-15-55.png

Edit:

Even with thousands of sprites, checked against a depth buffer, the performace is great. Note, thats an old shot with pretty unoptimized code. It's around two times faster by now. As is said before, thats without using GPU features. It would be even faster with GPU.

love 2024-06-18 17-31-19-39.png
Thats the thing, I dont know what im doing wrong either. Thats why im saying lua confuses me. Unless the code im calling isnt running at real time, which is possible. But How am i supposed to get around that?

Re: speed

Posted: Sun Jun 23, 2024 3:07 pm
by 1Minus2P1Stringer2
UnixRoot wrote: Sun Jun 23, 2024 10:59 am
1Minus2P1Stringer2 wrote: Sat Jun 22, 2024 11:07 pm
dusoft wrote: Sat Jun 22, 2024 10:11 pm It is much more difficult, @UnixRoot is right. In what (existing) language are you going to write it, anyway?
Not if the language you were using was confusing you. Which, right now, lua is kinda confusing me. Love2d is fine, but lua's framework confuses me. like how does lua render slower then scratch? Scratch can render an image from an image scanner in 3 seconds. Why is lua rendering at 2 minutes per frame, at real time? I get love2d has a function to load multiple pixels at once, which speeds it up by alot but still?
I don't know what you're doing wrong. I can easily render a world, consisting of multiple 4096x4096 height maps with raw 32 bit floating point data and textures of the same resolution on top. Even on my Potato PC, I get hundreds or even thousand of FPS in my CPU based software renderer. Love2D is FAST, if you optimize your code.

love 2024-06-23 12-52-15-55.png

Edit:

Even with thousands of sprites, checked against a depth buffer, the performace is great. Note, thats an old shot with pretty unoptimized code. It's around two times faster by now. As is said before, thats without using GPU features. It would be even faster with GPU.

love 2024-06-18 17-31-19-39.png
Thats the thing, I dont know what im doing wrong either. Thats why im saying lua confuses me. Unless the code im calling isnt running at real time, which is possible. But How am i supposed to get around that? Its only running 6400 lines a second so it must be doing it at non real time.

Re: speed

Posted: Sun Jun 23, 2024 3:36 pm
by UnixRoot
1Minus2P1Stringer2 wrote: Sun Jun 23, 2024 3:07 pm Thats the thing, I dont know what im doing wrong either. Thats why im saying lua confuses me. Unless the code im calling isnt running at real time, which is possible. But How am i supposed to get around that? Its only running 6400 lines a second so it must be doing it at non real time.
Without posting some code, nobody can help you. And what do you mean with 6400 lines per second, scanlines? At what resolution? CPU or GPU?

Re: speed

Posted: Sun Jun 23, 2024 4:11 pm
by 1Minus2P1Stringer2
UnixRoot wrote: Sun Jun 23, 2024 3:36 pm
1Minus2P1Stringer2 wrote: Sun Jun 23, 2024 3:07 pm Thats the thing, I dont know what im doing wrong either. Thats why im saying lua confuses me. Unless the code im calling isnt running at real time, which is possible. But How am i supposed to get around that? Its only running 6400 lines a second so it must be doing it at non real time.
Without posting some code, nobody can help you. And what do you mean with 6400 lines per second, scanlines? At what resolution? CPU or GPU?
I did post the code. Lines of code for each pixel. The full res is 640x360. Idk which. As i dont know how to allocate to gpu. It could automatically be gpu but idk.

Re: speed

Posted: Sun Jun 23, 2024 4:48 pm
by pgimeno
It appears that you missed my post.
pgimeno wrote: Sun Jun 23, 2024 9:58 am Graphically speaking, Love2D could be defined as a fancy wrapper around OpenGL using Lua. The important takeaway of that definition is that if you use Löve, you have to play by the rules of using the GPU. In particular, if you're rendering pixel by pixel and not using either ImageData:mapPixel or ImageData:getFFIPointer to draw the pixels, and (Image):replacePixels to put these pixels into an intermediate Image object to draw to the screen, then you're doing it wrong, in the sense that you can't expect the speed to be reasonable. See for example this thread for someone using FFI to draw into a framebuffer at over 60 FPS.

Of course, the fact that Löve uses OpenGL under the hood means that it's capable of using GPU acceleration, meaning you don't need to bother writing a full 3D engine, at least not the rendering part. I understand it can be fun to do that, but you won't get the full advantage of GPU acceleration, and even if it's written in assembly, bandwidth issues will prevent it from working fast enough for anything complex (CPUs can't draw nearly as many triangles per frame as GPUs), not to mention you would lose one of the salient point of using Löve: cross-platform compatibility.

Re: speed

Posted: Sun Jun 23, 2024 5:12 pm
by 1Minus2P1Stringer2
pgimeno wrote: Sun Jun 23, 2024 4:48 pm It appears that you missed my post.
pgimeno wrote: Sun Jun 23, 2024 9:58 am Graphically speaking, Love2D could be defined as a fancy wrapper around OpenGL using Lua. The important takeaway of that definition is that if you use Löve, you have to play by the rules of using the GPU. In particular, if you're rendering pixel by pixel and not using either ImageData:mapPixel or ImageData:getFFIPointer to draw the pixels, and (Image):replacePixels to put these pixels into an intermediate Image object to draw to the screen, then you're doing it wrong, in the sense that you can't expect the speed to be reasonable. See for example this thread for someone using FFI to draw into a framebuffer at over 60 FPS.

Of course, the fact that Löve uses OpenGL under the hood means that it's capable of using GPU acceleration, meaning you don't need to bother writing a full 3D engine, at least not the rendering part. I understand it can be fun to do that, but you won't get the full advantage of GPU acceleration, and even if it's written in assembly, bandwidth issues will prevent it from working fast enough for anything complex (CPUs can't draw nearly as many triangles per frame as GPUs), not to mention you would lose one of the salient point of using Löve: cross-platform compatibility.
Ahhhhhhhh. So Is the code just repeatedly asking the cpu, to ask the gpu to draw a pixel, Over and over again? If so I get why its going so slow. Yes, Cross platform is what I am going for. Ok Ok. So. Thats why. That makes me wonder, why is turbowarp so fast at drawing then? Does it use gpu acellaration?

Re: speed

Posted: Sun Jun 23, 2024 5:36 pm
by UnixRoot
I'm sorry, but I still don't understand what you're trying to achieve.

Do you want to write a software renderer, where you can draw per pixel to a framebuffer? If yes, you should try the FFI approach someone posted earlier.

With the GPU, you usually don't draw per pixel stuff, but polygons or sprites (which are just 2 polygons forming a quad), maybe using shaders, etc.

Re: speed

Posted: Sun Jun 23, 2024 5:46 pm
by 1Minus2P1Stringer2
UnixRoot wrote: Sun Jun 23, 2024 5:36 pm I'm sorry, but I still don't understand what you're trying to achieve.

Do you want to write a software renderer, where you can draw per pixel to a framebuffer? If yes, you should try the FFI approach someone posted earlier.

With the GPU, you usually don't draw per pixel stuff, but polygons or sprites (which are just 2 polygons forming a quad), maybe using shaders, etc.
Me? I want to make a full 3d engine from scratch.

Re: speed

Posted: Sun Jun 23, 2024 5:48 pm
by UnixRoot
You didn't even answer my question

Re: speed

Posted: Sun Jun 23, 2024 5:55 pm
by 1Minus2P1Stringer2
UnixRoot wrote: Sun Jun 23, 2024 5:48 pm You didn't even answer my question
I want to make a z buffer from scratch.