7 ms·
How much of modern demos is in the system libraries? Like, if you didn't have D3D or OGL but had to write code that drew at the per-pixel level, how much larger
by MichaelGG 12y ago
How much of modern demos is in the system libraries? Like, if you didn't have D3D or OGL but had to write code that drew at the per-pixel level, how much larger would these demos have to be?
- theandrewbailey 12y agoIt depends on how pretty you wanted those pixels to be and if you wanted to use the hardware (and which hardware) to it's fullest extent. Back in the DOS days, everyone more or less had to write their own rasterizers and write that data directly to the graphics controller (their own graphics driver), which probably took a few KB to do. Modern demos with full GPU acceleration use whichever 3D API/stack the OS provides, which (as a complete guess) is several hundred MB. Even that number pales in comparison to the amounts of data that the procedural generation within some 64k intros produce.
- skrebbel 12y agoMost demos don't push pixels but vertices. Graphics hardware turns that into pixels. If you'd do all pixel rendering on the CPU your code size would maybe, what, double, but you usually don't want that because the GPU is multiple orders of magnitude faster than that. Also, given that most size in demos is taken up by data, not code (except in 4k intros and the likes), it wouldn't make a significant size difference, really - just an effort difference. Additionally, many effects in modern demos run purely in shaders, written in HLSL or GLSL. The CPU part draws a single rectangle and the rest happens in a shader. Would you count that as depending on system libraries? Shader languages aren't much more high level than C, so its pretty close to the metal. In any case, you can't go more low level because GPU machine code (which HLSL etc compile down to) is pretty inaccessible in practice.
- je42 12y agoTake a look at fb08: https://www.youtube.com/watch?v=5PZ73nLZaqc https://www.youtube.com/watch?v=5PZ73nLZaqc .How much of the content do you expect to be generated by a system library ?
- MichaelGG 12y agoWell, that's what I'm asking. On a modern system, isn't most of the actual rendering being done by the gfx stack? Even lighting, right? So the app code might send out a definition of some polys and textures and the stack takes it from there. Right?
- theandrewbailey 12y agoSo the app code might send out a definition of some polys and textures and the stack takes it from there. Right? That's how modern 3D programming works in a nutshell, whether it's a game, demo, or CAD. A program provides data, parameters, and maybe small GPU programs (shaders). The stack takes it away, and does the nitty gritty math to transform triangles in 3D space, map them to 2D space, split into pixels, and apply images, lighting, etc. to them. https://en.wikipedia.org/wiki/Graphics_pipeline https://en.wikipedia.org/wiki/Graphics_pipeline http://www.arcsynthesis.org/gltut/Basics/Intro%20Graphics%20and%20Rendering.html http://www.arcsynthesis.org/gltut/Basics/Intro%20Graphics%20... If you really want to know what it does, I recommend you learn an API (Direct3D, OpenGL/WebGL). Everything underneath is handled by the stack. As for examples of what the program does and the system doesn't: for some demoscene stuff, the program uses procedural generation to generate models from mathematical descriptions, and textures by using noise functions and image filters. Here's a presentation of werkkzeug, the tool that Farbrausch uses: http://www.demoscene.tv/page.php?id=172&lang=uk&vsmaction=view_prod&id_prod=13597 http://www.demoscene.tv/page.php?id=172&lang=uk&vsmaction=vi...
- seanmcdirmid 12y agoWell, until you start doing really custom rendering in CUDA....
- theandrewbailey 12y agoAt that point, you know what the system does, and what the turtles are doing underneath you.
- 12y ago
- Svenstaro 12y agoI did the math for you and it comes down to about 8.6MiB on my Linux system. An OpenGL application that displays a triangle links to these libs: libc.so.6 libdl.so.2 libdrm.so.2 libgcc_s.so.1 libglapi.so.0 libGL.so.1 libm.so.6 libpthread.so.0 librt.so.1 libSDL2-2.0.so.0 libstdc++.so.6 libX11.so.6 libX11-xcb.so.1 libXau.so.6 libxcb-dri2.so.0 libxcb-dri3.so.0 libxcb-glx.so.0 libxcb-present.so.0 libxcb.so.1 libxcb-sync.so.1 libXdamage.so.1 libXdmcp.so.6 libXext.so.6 libXfixes.so.3 libxshmfence.so.1 libXxf86vm.so.1 Now to be fair, we'll only count those we directly link against: ibSDL2-2.0.so.0 libstdc++.so.6 libGL.so.1 libdl.so.2 libc.so.6 libgcc_c.so.1 libm.so.6 These few turn out to be the biggest in our bunch, totalling to 5.5MiB. So there you have it, by linking a minimal graphics demo on Linux, you are implicitly linking to about 5.5MiB of direct system libs and 8.6MiB of indirect system libs. These numbers will vary wildly for other OS, but I guess the DirectX stuff would be larger.
- MichaelGG 12y agoNeat! Although if you were just writing to a framebuffer you would probably use much less code. OTOH, the graphics drivers are doing the rasterizing right?
- Narishma 12y agoNo, the GPU is doing the rasterizing.
- pjc50 12y agoThe vast majority of that will be libstdc++ and libc, of which the app will be using a tiny corner. You could probably reduce that by half by sticking to C and then using a minimal libc.
- royjacobs 12y agoModern 64k intros typically use D3D or OGL but they still need to generate the meshes, textures and sound themselves. In the DOS days (mid/late 90s) this was no different except there also had to be all sorts of software rasterization code in there just to get the scenes rendered. OTOH there were plenty of effects done back then that were strictly 2d using clever lookup tables. The DOS 64k intros typically didn't link to any stdlib but would just provide their own implementation along with a few of the symbols that the C/C++ compiler (typically Watcom) would require. Combine that with a tiny DOS extender like PMODE/W and a compressor like UPX and you'd be off and running. A minimal intro (just showing a bouncing pixel or whatever) could be had with only just a few kilobytes. Nowadays intros typically rely on, as mentioned, D3D or OGL but also usually on the MSVC runtimes. Compression is still done using tools like UPX or kkrunchy but that actually's becoming difficult to do because virusscanners are usually flagging them as suspicious nowadays because of all the malware that also uses these compressors. Also, file size is not something that most people care about too much nowadays so the whole concept of the intro seems to have become less and less interesting over the years.