Skip to main content
gamedev.net
🔒 Locked

Direct3D: how does it work? old source code?

Started by CPPNick Apr 2, 2009 at 1:40 PM 18 replies 3.1k views
Original Post
CPPNick
CPPNick
Does anyone know anything about how Direct3D actually works? do they use floats or fixed point math, 3d clipping or clipping in screenspace, ect...? If anyone could give me a URL to some info on this, I would appreciate it, or if someone knows where I can get the source code to an old version or something that would be great. I have seen the diagram poster thing btw...didn't find it at all helpful...more of an advertisement that isnt really meant to be understood =-/ anyways, Thx
Promit
Promit
For the most part it's just a translation layer that simplifies and does some front end checking, before forwarding calls to the driver. If you download the Windows DDK you can look up the interfaces that the driver exports to the D3D runtime. There's a bunch of rules and specifications about how the driver and D3D will interact.

Oh, I think I'll move this to DirectX.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
CPPNick
CPPNick
I guess I should be more specific..I am interested in these things:

-how directx transformation works
-where and how does it use SSE/MMX
-does it use fixed point math or just regular floats
-where it does trivial reject, and how
-does it clip in 3D, or in screen space
-the structure of its pipeline
-does it use multithreading
-is the rasterizer/transformation/clipping even done in CPP? or is it all made in assembly?
-source code!

thanks
Palidine
Palidine
Quote:
Original post by CPPNick
-how directx transformation works
-where and how does it use SSE/MMX
-does it use fixed point math or just regular floats
-where it does trivial reject, and how
-does it clip in 3D, or in screen space
-the structure of its pipeline
-does it use multithreading
-is the rasterizer/transformation/clipping even done in CPP? or is it all made in assembly?
-source code!


For most of that stuff Direct3D doesn't do anything. It gives the info to the graphics card which does all of that however it pleases. You don't get source code because it's secret to the various hardware vendors. The short is that most is done in very parallel hardware (not threads, just actual parallel circuits)

There's probably some white papers floating about somewhere describing how some particular graphics card chipset does it's business. Search around on NVidia or ATI's websites.

-me
CPPNick
CPPNick
I think I understand, but this is why I ask is that I downloaded the open source 3D engine from Irrlicht, and the quake3 map loader file reports about 350 frames per second at 640x480 with torches, dynamic lighting all over the place....
my project is a very basic rendering engine with static gouraud shading, no collision detection, no filtering, and I can barely squeeze 30-40 fps out of it at 640x480...even "burning's software rendering engine" that is in the Irrlicht project is pretty slow..it does also handle filtering, ect...but its still slow
What is it that makes Direct3D so fast?

btw: im on a laptop with an integrated ATI 200M graphics card, which I doubt has any hardware rendering capabilities...
Haladria
Haladria
Quote:
Original post by CPPNick
I think I understand, but this is why I ask is that I downloaded the open source 3D engine from Irrlicht, and the quake3 map loader file reports about 350 frames per second at 640x480 with torches, dynamic lighting all over the place....
my project is a very basic rendering engine with static gouraud shading, no collision detection, no filtering, and I can barely squeeze 30-40 fps out of it at 640x480...even "burning's software rendering engine" that is in the Irrlicht project is pretty slow..it does also handle filtering, ect...but its still slow
What is it that makes Direct3D so fast?

btw: im on a laptop with an integrated ATI 200M graphics card, which I doubt has any hardware rendering capabilities...


So you wonder why hardware rendering is faster than software? Well that's because the graphics cards are tailored for rendering, while the CPU is not.
HuntsMan
HuntsMan
Quote:
Original post by CPPNick
What is it that makes Direct3D so fast?


It uses dedicated hardware to do the rendering, such as your GPU. The CPU is used for minimal processing.

Quote:
Original post by CPPNick
btw: im on a laptop with an integrated ATI 200M graphics card, which I doubt has any hardware rendering capabilities...


It actually does...
MJP
MJP
Quote:
Original post by CPPNick
I guess I should be more specific..I am interested in these things:

-how directx transformation works
-where and how does it use SSE/MMX
-does it use fixed point math or just regular floats
-where it does trivial reject, and how
-does it clip in 3D, or in screen space
-the structure of its pipeline
-does it use multithreading
-is the rasterizer/transformation/clipping even done in CPP? or is it all made in assembly?
-source code!

thanks


These days almost all of those things you've mentioned are done entirely on the GPU. Like it's been said several times already, D3D is mostly just an interface layer that lets your app talk to different hardware types using a consistent API.

Direct3D does come with a math/utility library called D3DX, which allows you do to some of these operations on the CPU. However no source code is available for this. You might want to check out the brand new XNA Math library available in the March 2009 SDK...it's a brand-new SSE-accelerated math library with full source code included (no libraries or DLL's, just headers you can include).

InvalidPointer
InvalidPointer
Quote:
Original post by CPPNick
I think I understand, but this is why I ask is that I downloaded the open source 3D engine from Irrlicht, and the quake3 map loader file reports about 350 frames per second at 640x480 with torches, dynamic lighting all over the place....
my project is a very basic rendering engine with static gouraud shading, no collision detection, no filtering, and I can barely squeeze 30-40 fps out of it at 640x480...even "burning's software rendering engine" that is in the Irrlicht project is pretty slow..it does also handle filtering, ect...but its still slow
What is it that makes Direct3D so fast?

btw: im on a laptop with an integrated ATI 200M graphics card, which I doubt has any hardware rendering capabilities...

Short answer: You do/it does.
Long answer: It can beat the hell out of a CPU any day, but integrated graphics hardware gets shown the door by more or less any modern dedicated solution. Just because it's *relatively* weak doesn't mean it lacks any sort of capability. Chances are you're doing things in a serial fashion. GFX cards are fast because they do things in a *massively* parallel fashion. Like, several hundred 'cores' at once on fairly modern/capable silicon.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
CPPNick
CPPNick
okay, but: I remeber years and years ago, when I had a Pentium I 200Mhz, and was able to run Dave Mirra Freestyle BMX (
) at 800x600...I have a 1.6ghz processor now, which can out-perform (x3) the Pentium I AND any graphics hardware I may have been lucky enough to have in whatever junky video card I had at the time...It just boggles my mind how they could have gotten that to work...they have at least some kind of filtering...I can't image how they got it that fast..
Palidine
Palidine
Quote:
Original post by CPPNick
I can't image how they got it that fast..


Cause they're better at programming than you [smile]

If you're curious why your program is slow, run it through a profiling tool and/or use NVidia's performance tools to see where the slowdown is. Often for beginners it's "dumb" things: like: loading a mesh every time you use it instead of caching it, using immediate mode instead of VBOs or whatever, or using an O(n^2) algorithm when a constant time one exists.

Even for "good" programmers you can often get a 2-4x speed in your "good" coode by changing a few small things once the profiler points them out as big problems.

-me
CPPNick
CPPNick
my absolute first attempt at textured 3d bjects, were two triangles, with a 100x100 bitmap on them. when I zoomed in so the triangles were full screen, it got so slow the program froze... I have gained more speed than I thought possible after that first attempt..I'm wondering if its futil to go on any further, and if I should just start using Direct3D. I was hoping for a much better result without it.
MJP
MJP
Wait...a you writing a software renderer?
CPPNick
CPPNick
yes, software renderer. I was asking about source code for an older version of direct3D or something because I thought it had a built in software renderer..but it looks like direct3D doesn't actually have any internat rendering code, and only forwards the info to the appropriate hardware, right?
Promit
Promit
It has the reference rasterizer, but that's strictly for testing purposes and tends to run at 2-3 FPS at best. There's the new WARP softrast coming in, but I'm not sure when that gets out of beta.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
CPPNick
CPPNick
neither WARP or the reference rasterizer are open source though =/
Promit
Promit
It's unfortunate that SwShader is no longer open...maybe source code for it is still floating around?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
CPPNick
CPPNick
hey...thanks guys! I found a few different versions of swShader here, and Fog's manual looks interesting too. I havn't had much time to look it over yet, but swShader looks pretty impressive so far...I read some posts somewhere while looking for the source code that suggested the project kinda fell through, and that it wouldn't be able to compete with the new Pixomatic engine, which is being worked on by the Zen master himself..is this still true? anywho, thanks again. hopefully swShader wont be as complicated to look through as irrlicht's engine..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.