How do they choose the right path for a card ?

Rodéric

a.k.a. Ingenu
Moderator
Veteran
Most if not every game engine out there have many render path depending on the hardware capabilities, I wonder how it is managed in the code.

Anyone know ?

I came with something not too ugly but still far from nice, unfortunately :(
 
I would imagine something similar to this?

Code:
UINT hardwareTL = ( d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT ) ? D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING;
 
ARB_Vertex_Program
ARB_Vertex_Blending
ARB_matrix_palette...

Those extensions change the way I would do vertex skinning...
I would write different functions depending on those extensions to get the most out of the graphic card, if/then in the code seems unefficient and rather ugly, to me.
 
At start up time detect what card you have.
Then set up some function pointers for the vertex skinning routine.

When you come to the call to the vertex skinning section call through your pointer.

e.g.





Code:
void	FuncA(void);
void	FuncB(void);

Init()
{
	
	void (* function)(void);
	if(card==R300)
	{
		function=  FuncA;
	}
	else
	{
		function=FuncB;
	}

.
.
.
}


render()
{
.
.
.
.
	function();
.
.
.
.
}

void FuncA(void)
{
	//ATI Code Path
}

void FuncB(void)
{
	// NVidia Code path
}



CC
 
That's what I'm doing :)
(Well, there's a small difference in what I'm doing, but I set function pointers)

I was wondering if there was anything clever/better/cleaner...
 
I considered that a reasonably tidy way of doing it

I suppose you could get all C++ and declare a render class with some virtual functions which you can override with card specific ones, but that sounds like a headache to me.

CC
 
Captain Chickenpants said:
I considered that a reasonably tidy way of doing it

I suppose you could get all C++ and declare a render class with some virtual functions which you can override with card specific ones, but that sounds like a headache to me.

CC
I agree. :) the function pointers are the way to go.

later,
 
As an alternate method you could have your card specific code stored in DLL's, and decide which DLL to load at runtime.
This has the advantage that you can update the DLL without touching the main engine.

CC
 
Back
Top