Jump to content

  • Log In with Google      Sign In   
  • Create Account


Checking d3d caps, best approach?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
16 replies to this topic

#1 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 30 December 2012 - 03:06 PM

Hi,

Like any other enthousiast, before releasing my top selling FPS game, I'd like to make my 3d engine/ apps hardware variants proof smile.png

I see doing this with the following steps:

1. Check top 5 items while creating device and select 'lower' value if a specific adapter or bufferformat is not available (same for MSAA). Let's call this the basics (i.e. if MSAA not available, though requested, I select no MSAA and let the user continue). In place today and working fine.

2. Create a list of D3D (related) caps that are needed for the current functionalities, and check if these are available.
For now not available means, too bad. Application quits. I keep these up to date as soon as I add new functionality in my engine.

3. Create backwards compability variances for situaties in '2' where a device doesn't meet the requirements.
Same for the vertex and pixel shaders.

Step 3 is something I'll postpone for now, since I'm using D3D9 and PS/VS 2.0, which most devices today support.

I really to hear your advice and tips to make step 2 more efficient, I've posted the code I have now
(accepting that I send away users with hardware that doesn't meet the requirements smile.png)

 

bool CD3d::CheckDeviceCaps()
{
	int nrReqDevCaps = 9;
	DWORD reqDevCaps[9] =	{	D3DDEVCAPS_DRAWPRIMTLVERTEX,	D3DDEVCAPS_HWRASTERIZATION,		D3DDEVCAPS_TLVERTEXSYSTEMMEMORY, 
								D3DDEVCAPS_TLVERTEXVIDEOMEMORY, D3DPRASTERCAPS_ZBUFFERLESSHSR,	D3DPRASTERCAPS_ZTEST,
								D3DDEVCAPS_EXECUTESYSTEMMEMORY, D3DDEVCAPS_EXECUTEVIDEOMEMORY,  D3DDEVCAPS_TEXTUREVIDEOMEMORY };
	int nrReqPresentCaps = 3;
	DWORD reqPresentCaps[3] = {	D3DPRESENT_INTERVAL_ONE,		D3DPRESENT_INTERVAL_TWO,		D3DPRESENT_INTERVAL_IMMEDIATE };
	int nrReqTexFilterCaps = 4; 
	DWORD reqTexFilterCaps[4]= {D3DPTFILTERCAPS_MAGFLINEAR,		D3DPTFILTERCAPS_MINFLINEAR,		D3DPTFILTERCAPS_MIPFLINEAR,
								D3DPTFILTERCAPS_MINFANISOTROPIC };
	int nrReqPrimMiscCaps =3;
	DWORD reqPrimMiscCaps[3] = {D3DPMISCCAPS_CULLNONE,			D3DPMISCCAPS_CULLCW,			D3DPMISCCAPS_CULLCCW };
	int nrReqTextureCaps = 2;
	DWORD reqTextureCaps[2] = {	D3DPTEXTURECAPS_MIPMAP,			D3DPTEXTURECAPS_ALPHA };		// CUBEMAP and VOLUMEMAP later
	int nrReqTexAddrCaps = 5;
	DWORD reqTexAddrCaps[5] = {	D3DPTADDRESSCAPS_BORDER,		D3DPTADDRESSCAPS_CLAMP,			D3DPTADDRESSCAPS_WRAP,
								D3DPTADDRESSCAPS_INDEPENDENTUV,	D3DPTADDRESSCAPS_MIRROR  };
	int nrReqRasterCaps = 2;
	DWORD reqRasterCaps[2] = {	D3DPRASTERCAPS_ANISOTROPY,		D3DPRASTERCAPS_DITHER };
	int nrReqShadeCaps = 3;
	DWORD reqShadeCaps[3] = {	D3DPSHADECAPS_ALPHAGOURAUDBLEND,D3DPSHADECAPS_SPECULARGOURAUDRGB,
								D3DPSHADECAPS_COLORGOURAUDRGB };
	
	if(mD3d != NULL)
	{
		D3DCAPS9	caps;
		if(D3D_OK != mD3d->GetDeviceCaps(D3DADAPTER_DEFAULT, mDevType, &caps)) return false;
		
		for(cc=0;cc<nrReqDevCaps;++cc)		{ if(!(caps.DevCaps & reqDevCaps[cc])) return false; }
		for(cc=0;cc<nrReqPresentCaps;++cc)	{ if(!(caps.PresentationIntervals & reqPresentCaps[cc])) return false; }
		for(cc=0;cc<nrReqTexFilterCaps;++cc){ if(!(caps.VertexTextureFilterCaps & reqTexFilterCaps[cc])) return false; }
		for(cc=0;cc<nrReqTexAddrCaps;++cc)	{ if(!(caps.TextureAddressCaps & reqTexAddrCaps[cc])) return false; }
		for(cc=0;cc<nrReqPrimMiscCaps;++cc) { if(!(caps.PrimitiveMiscCaps & reqPrimMiscCaps[cc])) return false; }
		for(cc=0;cc<nrReqRasterCaps;++cc)	{ if(!(caps.RasterCaps & reqRasterCaps[cc])) return false; }
		for(cc=0;cc<nrReqShadeCaps;++cc)	{ if(!(caps.ShadeCaps & reqShadeCaps[cc])) return false; }

		if(D3D_OK != mD3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, mDevType, mAdapterFormat, D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8)) return false;
		if(!(caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP)) return false;

		if(caps.VertexShaderVersion < D3DVS_VERSION(2,0)) return false;
		if(caps.PixelShaderVersion < D3DPS_VERSION(2,0)) return false;
		if(caps.MaxAnisotropy < 4) return false;
		if(caps.MaxTextureWidth < 256) return false;
		if(caps.MaxTextureHeight < 256) return false;
		if(caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) return false;

		return true;
	}
	else return false;
}

 

Can this be done, easier? (i.e. with an array of DWORD values / caps and the corresponding caps.'' etc.)


Edited by cozzie, 30 December 2012 - 03:08 PM.


Sponsor:

#2 NewDisplayName   Members   -  Reputation: 351

Like
1Likes
Like

Posted 31 December 2012 - 03:12 AM

Use multimaps to store possible caps values for a particular d3dcap (Use d3dcap name as the key, if you please). It has several advantages.

 

1) No more iterations to find out a particular capacity. Just a "find" will do.

2) Easy to take different combinations from various multimaps to support different combos in future.

3) Looks much more systematic and better than static arrays and for loops. :-)



#3 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 31 December 2012 - 07:28 AM

Thanks, that sounds like something I could use.

Is this basically an error which says:

 

Col1                                        Col2

caps.DevCaps                        D3DDEVCAPS_.....

caps.DevCaps                        D3DDEVCAPS_....somethingelse

caps.PresentationsInverals    D3DPRESENT_...something

 

So I can loop through all of them?

 

Do you maybe have a simple example how multimaps would do the above?

Will also try to find out in the mean time (googling :))



#4 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 31 December 2012 - 07:36 AM

was bit too lazy I suppose, already made a bit of a start:

 

multimap <???, DWORD> capsTable;

 

capsTable.insert(pair<???, DWORD>(caps.DevCaps, D3DDEVCAPS_..something));

and so on

 

- what type should I use for caps.DevCaps? (it's basically also a DWORD I suppose)

- how do I 'use them'; like if(!(capsTable.1st col[0] & capsTable.2nd col[1]) ......



#5 NewDisplayName   Members   -  Reputation: 351

Like
0Likes
Like

Posted 31 December 2012 - 07:43 AM

Don't rush/panic buddy. Multimaps are very easy to figure out and there is tons of reference on google that will always do better than any of my explanations on the same.

As for your query about type of DevCaps, it is a DWORD like almost all other attributes of the structure. Still, MSDN lists all of them with their values. Best would be to define some key of your own. You might very well use a string as a key for different attributes to map and check.

Play around with this a bit, you will get a hang of it and eventually like it. :-)



#6 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 31 December 2012 - 08:18 AM

Thanks, I think you're right, it is kinda fun :)

 

Up till now I have:

void just4fun()
{
	D3DCAPS9	caps;
	std::multimap <DWORD, DWORD> capsTable;

	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_DRAWPRIMTLVERTEX));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_HWRASTERIZATION));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TLVERTEXSYSTEMMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TLVERTEXVIDEOMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DPRASTERCAPS_ZBUFFERLESSHSR));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DPRASTERCAPS_ZTEST));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_EXECUTESYSTEMMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_EXECUTEVIDEOMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TEXTUREVIDEOMEMORY));

	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_ONE));
	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_TWO));
	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_IMMEDIATE));

	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MAGFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MINFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MIPFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MINFANISOTROPIC));

	std::ofstream test("multimap.txt");

	for (std::multimap<DWORD, DWORD, std::less<DWORD> >::const_iterator iter =capsTable.begin();
      iter != capsTable.end(); ++iter )
	{
		test << iter->first << " " << iter->second << std::endl;
	}

The output though says that the "first" values are all the same..

Will play around to find how it works, maybe this is correct.

 

Output:

3435973836 1024
3435973836 524288
3435973836 64
3435973836 128
3435973836 32768
3435973836 16
3435973836 16
3435973836 32
3435973836 512
3435973836 1
3435973836 2
3435973836 2147483648
3435973836 33554432
3435973836 512
3435973836 131072
3435973836 1024
 



#7 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 31 December 2012 - 08:31 AM

This post is almost becoming a live chatbox ;-)

Got it working now, maybe not optimal yet, but the result is OK (Tested it by passing a faulty D3D caps value in the 2nd 'colom', and this gives a correct 'not found' back).

 

Here's the code:

void just4fun()
{
	LPDIRECT3D9	mD3d;

	mD3d = Direct3DCreate9(D3D_SDK_VERSION);

	D3DCAPS9	caps;
	mD3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps);

	std::multimap <DWORD, DWORD> capsTable;

	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_DRAWPRIMTLVERTEX));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_HWRASTERIZATION));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TLVERTEXSYSTEMMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TLVERTEXVIDEOMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DPRASTERCAPS_ZBUFFERLESSHSR));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DPRASTERCAPS_ZTEST));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_EXECUTESYSTEMMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_EXECUTEVIDEOMEMORY));
	capsTable.insert(std::make_pair(caps.DevCaps, D3DDEVCAPS_TEXTUREVIDEOMEMORY));

	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRASTERCAPS_ZTEST));
	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_TWO));
	capsTable.insert(std::make_pair(caps.PresentationIntervals, D3DPRESENT_INTERVAL_IMMEDIATE));

	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MAGFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MINFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MIPFLINEAR));
	capsTable.insert(std::make_pair(caps.VertexTextureFilterCaps, D3DPTFILTERCAPS_MINFANISOTROPIC));

	std::ofstream test("multimap.txt");

	for (std::multimap<DWORD, DWORD, std::less<DWORD> >::const_iterator iter =capsTable.begin();
      iter != capsTable.end(); ++iter )
	{
//		test << iter->first << " " << iter->second << std::endl;
		if(iter->first & iter->second) MessageBox(NULL, L"Cap found", L"test", MB_OK);
		else MessageBox(NULL, L"Cap not found", L"Test", MB_OK);
	}
	mD3d->Release();
}

 

Maybe I'll put the definition of the capsTable and contents in my header file, to keep code/ function clean.

Thanks for your hints, really looks better and cleaner this way.

 

Any pointers on improving it more, always welcome ;)



#8 NewDisplayName   Members   -  Reputation: 351

Like
0Likes
Like

Posted 31 December 2012 - 08:59 AM

Like I mentioned earlier, you may define your multimap like this :

 

std::multimap <std::string, DWORD> capsTable;

 

This way your key values can be "DevCaps" or "PresentationIntervals" or "VertexTextureFilterCaps" or XYZ", with their associated values always mapped uniquely to them.

Currently you have just associated the structure reference, that's why all the key values came out to be the same.

 

Later on you can expand upon above multimap, by making several distinct multimaps for different attributes and then do some combos. Many ways to make this work elegantly now, its all upto how you want to design this.



#9 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 31 December 2012 - 09:45 AM

Thanks, I partially understand.

Say I make a multimap which holds i.e.:

 

DevCaps            D3DDEVCAP_something

 

And I want to to a comparison:

 

if(Caps.Devcaps & D3DDEVCAP_something)

 

I got it working now with the reference, but how do I add the D3DCAPS9 structure (say Caps) with a string, to be a valid member indication of Caps?

(Caps.Devcaps)?



#10 NewDisplayName   Members   -  Reputation: 351

Like
0Likes
Like

Posted 31 December 2012 - 10:21 AM

Ok, I will try to give you a use-case which has some real implication and should be in line with your requirements.

 

So what we want to achieve is a container that holds Device cap attributes and possible values for each of these capacities.

 

Now, multimap has a method called equal_range that returns all the values associated to a particular key.

 

Eg.

 

typedef std::multimap<std::string, DWORD> xyzMap;
xyzMap capsTable;

capsTable.insert(std::make_pair("PresentationIntervals", D3DPRASTERCAPS_ZTEST));
capsTable.insert(std::make_pair("PresentationIntervals", D3DPRESENT_INTERVAL_TWO));
capsTable.insert(std::make_pair("PresentationIntervals", D3DPRESENT_INTERVAL_IMMEDIATE));

std::pair<xyzMap::iterator, xyzMap::iterator> range;

range = capsTable.equal_range("PresentationIntervals");

for (xyzMap::iterator it = range.first; it != range.second; ++it)
{
    // Do something with PresentationIntervals values
}

 

 

As it is, you don't have to do anything with the attribute name itself, but the value it holds. So the way I have mentioned above, you can use and expand your implementation to dynamically hold, add and configure your Device cap attributes as you please.



#11 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 01 January 2013 - 07:07 AM

Thanks, that makes things clear on how to use multimaps.

I'll go play around with it.

 

The only thing I haven't figured out yet, is how I can make a link from the 'fírst' values, say PresentationsIntervals, to the real checking of the caps.

Example:

 

D3DCAPS9 caps;

GetDeviceCaps(&caps).

 

Before multimap:

if(!(caps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO)) return false;

 

With multimap, I don't know how to link the 'caps' var with the member which is in the multimap:

if(!caps.iter->first & iter->lsecond)) return false;

 

The "caps.iter->first" will logically not compile..

Tried this to confirm/ test:

 

std::string test = "MaxAnisotropy";

if(mCaps.test & 4) return false;



#12 NewDisplayName   Members   -  Reputation: 351

Like
0Likes
Like

Posted 01 January 2013 - 07:16 AM

Can you try using some other conditional approach than this one :

if(!(caps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO))

 

You're trying to design around your code, which is wrong. You should always code around your design.



#13 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 01 January 2013 - 08:49 AM

This feels like tutoring smile.png

(and is really appreciated)

 

I'll go think about it and come back with a solution



#14 cozzie   Members   -  Reputation: 1541

Like
1Likes
Like

Posted 01 January 2013 - 10:29 AM

I believe I'm getting there, got it all working now, but probably not optimal yet.

The part where I go through the loops for checking each group of 'caps', just feels like it's possible to do it more efficient.


To be honest, code is not cleaner then when I filled the multimap with the references to the Caps var, but definitely this brings a lot more flexibility, also for future use.

What do you think?

 

Here are the 2 resulting functions:

 

/**************************************************************************************/
/***						SET REQUIRED DEVICE CAPS								***/
/*** ==> usage: during initalization, before creating d3d device and loading scene	***/
/*** ==> fill mReqCapsTable with all caps needed for existing functionality			***/
/**************************************************************************************/

void CD3d::SetRequiredDeviceCaps()
{
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_DRAWPRIMTLVERTEX));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_HWRASTERIZATION));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_TLVERTEXSYSTEMMEMORY));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_TLVERTEXVIDEOMEMORY));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_EXECUTESYSTEMMEMORY));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_EXECUTEVIDEOMEMORY));
	mReqCapsTable.insert(std::make_pair("DevCaps",					D3DDEVCAPS_TEXTUREVIDEOMEMORY));
	mReqCapsTable.insert(std::make_pair("RasterCaps",				D3DPRASTERCAPS_ANISOTROPY));
	mReqCapsTable.insert(std::make_pair("RasterCaps",				D3DPRASTERCAPS_DITHER));
	mReqCapsTable.insert(std::make_pair("RasterCaps",				D3DPRASTERCAPS_ZTEST));
	mReqCapsTable.insert(std::make_pair("PrimitiveMiscCaps",		D3DPMISCCAPS_CULLNONE));
	mReqCapsTable.insert(std::make_pair("PrimitiveMiscCaps",		D3DPMISCCAPS_CULLCW));
	mReqCapsTable.insert(std::make_pair("PrimitiveMiscCaps",		D3DPMISCCAPS_CULLCCW));
	mReqCapsTable.insert(std::make_pair("PrimitiveMiscCaps",		D3DPMISCCAPS_BLENDOP));
	mReqCapsTable.insert(std::make_pair("PresentationIntervals",	D3DPRESENT_INTERVAL_ONE));
	mReqCapsTable.insert(std::make_pair("PresentationIntervals",	D3DPRESENT_INTERVAL_TWO));
	mReqCapsTable.insert(std::make_pair("PresentationIntervals",	D3DPRESENT_INTERVAL_IMMEDIATE));

	mReqCapsTable.insert(std::make_pair("VertexTextureFilterCaps",	D3DPTFILTERCAPS_MAGFLINEAR));
	mReqCapsTable.insert(std::make_pair("VertexTextureFilterCaps",	D3DPTFILTERCAPS_MINFLINEAR));
	mReqCapsTable.insert(std::make_pair("VertexTextureFilterCaps",	D3DPTFILTERCAPS_MIPFLINEAR));
	mReqCapsTable.insert(std::make_pair("VertexTextureFilterCaps",	D3DPTFILTERCAPS_MINFANISOTROPIC));
	mReqCapsTable.insert(std::make_pair("TextureCaps",				D3DPTEXTURECAPS_MIPMAP));
	mReqCapsTable.insert(std::make_pair("TextureCaps",				D3DPTEXTURECAPS_ALPHA));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_BORDER));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_CLAMP));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_WRAP));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_INDEPENDENTUV));
	mReqCapsTable.insert(std::make_pair("TextureAddressCaps",		D3DPTADDRESSCAPS_MIRROR));

	mReqCapsTable.insert(std::make_pair("ShadeCaps",				D3DPSHADECAPS_ALPHAGOURAUDBLEND));
	mReqCapsTable.insert(std::make_pair("ShadeCaps",				D3DPSHADECAPS_SPECULARGOURAUDRGB));
	mReqCapsTable.insert(std::make_pair("ShadeCaps",				D3DPSHADECAPS_COLORGOURAUDRGB));
}

/**************************************************************************************/
/***						CHECK DEVICE CAPS										***/
/*** ==> usage: during initalization, before creating d3d device and loading scene	***/
/*** ==> check if device meets required caps for current functionality				***/
/**************************************************************************************/

bool CD3d::CheckDeviceCaps()
{
	if(mD3d != NULL)
	{
		if(D3D_OK != mD3d->GetDeviceCaps(D3DADAPTER_DEFAULT, mDevType, &mCaps)) return false;
		std::pair<CapsTable::iterator, CapsTable::iterator> range;
		
		range = mReqCapsTable.equal_range("DevCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.DevCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("RasterCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.RasterCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("PrimitiveeMiscCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.PrimitiveMiscCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("PresentationIntervals");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.PresentationIntervals & it->second)) return false;
		range = mReqCapsTable.equal_range("VertexTextureFilterCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.VertexTextureFilterCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("TextureCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.TextureCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("TextureAddressCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.TextureAddressCaps & it->second)) return false;
		range = mReqCapsTable.equal_range("ShadeCaps");
		for(CapsTable::iterator it=range.first;it!=range.second;++it) if(!(mCaps.ShadeCaps & it->second)) return false;
		
		if(D3D_OK != mD3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, mDevType, mAdapterFormat, D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8)) return false;
		if(!(mCaps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP)) return false;

		if(mCaps.VertexShaderVersion < D3DVS_VERSION(2,0)) return false;
		if(mCaps.PixelShaderVersion < D3DPS_VERSION(2,0)) return false;
		if(mCaps.MaxAnisotropy < 4) return false;
		if(mCaps.MaxTextureWidth < 256) return false;
		if(mCaps.MaxTextureHeight < 256) return false;	
		return true;
	}
	else return false;
}


#15 NewDisplayName   Members   -  Reputation: 351

Like
0Likes
Like

Posted 01 January 2013 - 10:55 AM

I can still see a lot of ways in which this can be made cleaner, but then it won't be your code. :-)

Still if it helps, this does look much better than before.

I would say that now your initial query is solved and what remains is how well you can utilise the solution.

Have fun!



#16 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 01 January 2013 - 01:25 PM

Will work on it :)

To be honest I'm really in a flow with my engine, will be posting more.

Next is playing around with skyboxes using cubemap textures.

 

Thanks again for the help.



#17 cozzie   Members   -  Reputation: 1541

Like
0Likes
Like

Posted 05 January 2013 - 03:33 PM

Hi, Could you maybe give me some direction? Been thinking about it, but there must be a way to prevent/clean the part where i loop through all types of 'caps'. Maybe seeking for unique values or something, in the first 'column'.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS