pouët.net

Go to bottom

software rendering using gpu?

category: code [glöplog]
hi there,

i was wondering if its feasable to build a software rendering engine using gpu acceleration like cuda or openCL or whatever api is hot at the moment? maybe even for sound? would it make any sense?
added on the 2023-11-09 03:14:50 by wysiwtf wysiwtf
I think Unreal's Nanite feature uses compute shaders to render when triangle density is really high (like 1 triangle per pixel). But please don't take my word for it and rather read up on official Nanite Powerpoints/videos/papers instead.

Not sure if you will have any luck with this method on mobile though, but I guess you are targeting destkop GPUs
added on the 2023-11-09 06:25:21 by rloaderro rloaderro
Nanite uses compute shaders rather than hardware rasterization up to surprisingly big sizes (IIRC something like 64x64). Of course, a GPU “software” renderer will look very different from a single-threaded CPU software renderer, but it is doable, as Nanite shows. The presentation is fantastic (there's also a video).
added on the 2023-11-09 11:52:05 by Sesse Sesse
The answer is yes, but whether it would "make any sense" (which likely means that the result has good performance and quality) depends on what you want to render. Generally though, a software rasterizer running on GPU is written for parallel execution and usually doesn't resemble the scanline-conversion type of rasterizer. That said, you can totally execute a CUDA kernel with just one active thread and do it that way if you want to.
added on the 2023-11-09 12:21:00 by fizzer fizzer
I should clarify: It doesn't resemble the typical scanline-conversion type of rasterizer from the 90s.
added on the 2023-11-09 12:37:24 by fizzer fizzer
GPUs are pretty good at this, so it only makes practical sense if you can exploit something the GPU can't or if you hit the GPU's limitations (e.g. lots and lots of tiny - perhaps subpixel - tris).

that said, i wrote a compute based rasteriser a few weeks ago :) it was for a special reason (rendering to lots of small buffers in parallel) and could use the advantage of only filling bit masks, not shading pixels - so it was worth doing in "software" compute.
added on the 2023-11-09 14:19:16 by smash smash
See also: directx work graphs. AMD has a proof of concept polygon renderer on top of that.
added on the 2023-11-09 14:49:50 by sol_hsa sol_hsa
Another way in which it would make sense if you want to render to a target which isn't the usual 2D framebuffer and would be too costly to force the GPU's pinhole-camera projection into rendering to. An example would be a 3D texture for a voxelisation. Also, there are hybrid approaches where the hardware-accelerated rasterisation is used essentially for coarse scheduling while the pixel shader does the per-pixel work, for example this can be used to quickly cull tiles of pixels for primary raytracing of implicit surfaces. As mentioned though, dynamic work generation in modern APIs provides a way to do that in compute anyway.
added on the 2023-11-09 18:51:49 by fizzer fizzer
"Software rendering using GPU" ... this could be a big thing!! Instead of triangles etc you could do all kinds of things like raymarching, implicit surfaces, write your own shading and stuff. It could even be suitable for 4k intros. Someone should definitely try that.
added on the 2023-11-09 21:25:44 by yzi yzi
*cough*larrabee*cough*
added on the 2023-11-10 08:39:45 by sol_hsa sol_hsa
Just carve out the 3D-accelerator chip out of your graphics card and throw it in the bin. Then use directdraw to blit stuff to the drawing context directly.
added on the 2023-11-10 23:19:27 by rudi rudi
You were probably thinking 3d but here's a 2D software gpu render

https://github.com/linebender/vello
added on the 2023-11-12 14:59:13 by greggman greggman
Quote:
Just carve out the 3D-accelerator chip out of your graphics card and throw it in the bin. Then use directdraw to blit stuff to the drawing context directly.

are you saying that ddraw bypasses the gpu
added on the 2023-11-12 20:57:53 by Gargaj Gargaj
I think we are confusing a Renderer with an Engine.

Unless you haven't paid attention to the last decade+ of intros and demos, you know you can implement a renderer in software in the GPU. Not only raymarchers, but people often do software rasterizers (for conservative z-prepasses), bypass their HW bilinear texture filtering with their own, same with custom blending modes etc. Basically, developers regularly bypass any piece of hardware with a custom software version, as needed.

An Engine on the other hand is a lot more than a renderer; it loads assets, builds a scenegraph, performs collisions, has an animation system... I imagine this is what the original question is about?

If so, I understand GPUs can do their own scheduling these days, but I haven't used it myself yet. But maybe one can indeed implement some sort of engine in the GPU, except for the asset loading since GPUs can't see the hard drive?
added on the 2023-11-12 21:48:39 by iq iq
Quote:
Just carve out the 3D-accelerator chip out of your graphics card and throw it in the bin. Then use directdraw to blit stuff to the drawing context directly.

Hasn't Direct Draw been emulated in software since Windows Vista? My understanding is that this "direct blit to the drawing context" essentially is the CPU rendering to a buffer in system memory, which is then uploaded to video memory as a texture so the GPU can render it.
added on the 2023-11-12 22:34:56 by absence absence
my question was mainly about skipping apis like dx/ogl or even vulkan while still using the gpu resources, but i see now its not that simple. some things are already calculated by other means on the gpu regardless of the gfx api and that may be more than it tought it is...

still one question remains: is it feasable to softsynth audio on the gpu? on the one hand its kinda linear and sequential but on the other hand its also pretty predictable so why not chunk it up and precalc everything into ram and then play the song? ;=)
added on the 2023-11-12 23:57:06 by wysiwtf wysiwtf
Quote:
Hasn't Direct Draw been emulated in software since Windows Vista?

Yes, yes it was, but never let reality intrude a comfortable delusion.
added on the 2023-11-13 01:57:43 by Gargaj Gargaj
Quote:
is it feasable to softsynth audio on the gpu?


Yes, has been done in intros before afaik. I don't remember which ones exactly, though.
added on the 2023-11-13 09:59:18 by arm1n arm1n
One of several examples: DC Offset
added on the 2023-11-13 11:36:49 by Sesse Sesse
The earliest one that I could remember (from 2010): Bubblin Under (IIRC, it was written on the partyslide, but the comments also alude to it)
added on the 2023-11-13 11:40:23 by Sesse Sesse
cpu:s are so crazy fast that it's hard to think of an audio case that would benefit from gpu rendering. I'm probably wrong, though.
added on the 2023-11-13 11:45:49 by sol_hsa sol_hsa
Large FIR reverbs, for one.
added on the 2023-11-13 12:12:49 by Sesse Sesse
Yes Adapt - Bubbin Under used a GPU based FM synth, though we ran out of time with it.
added on the 2023-11-13 14:09:22 by leGend leGend

login

Go to top