Jump to content
  • Advertisement
Sign in to follow this  
hatch22

Efficient Geometry Usage with Index Buffers and Shaders

This topic is 5394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

MSDN has an article on Efficiently Drawing Multiple Instances of Geometry using vertex shaders with vertex or index buffers. What I don't understand is why they say the indexed buffered technique (the first one described) says "This technique requires a device that supports the 3_0 vertex shader model. This technique works with any programmable shader but not with the fixed function pipeline," but then the second non-indexed technique says "This technique is not supported by hardware acceleration on any device. It is only supported by software vertex processing and will work only with vs_3_0 shaders." Does this mean that the indexed technique only works with vs_3_0 supported in hardware or software but the non-indexed technique is not supported in any current hardware? I don't see why the indexed technique (which looks very useful) would only work with vs_3_0. Would not a vs_2_0 shader be able to handle inputs from two different index buffers and process the instance data in the second one effectively? I would like to be able to implement this indexed technique but I don't want to use vs_3_0 until it is more widely supported by hardware that most people would own.

Share this post


Link to post
Share on other sites
Advertisement
You need vs_3_0 because that is part of the DX9.0c model which is the only version that supports the stream frequency API. There was talk of vs_2_0 devices exposing it using some custom texture format hack, but I don't know whether that was just rumour or what.
You can still use vs_3_0 software to test your shaders I would expect, but it won't be too quick (should still be usable though).

-Mezz

Share this post


Link to post
Share on other sites
ATi exposes the instancing through a FOURCC format. I've the actual code at home (I'm at work) but I could post it here. Nevertheless, I would not rely on that snippet of code since it can be dropped anytime with any new driver version.

Theoretically, current 2_0 hardware could handle instancing. But Microsoft and the HW Vendors decided to put it into the vs_3_0 specs and make it a required feature. This is due to the fact that adding the feature to the vs_2_0 hardware specs would either need a new cap bit (where you cannot rely on) or on declaring it being vs_2_0 specs requirement (which is too late now) (or on a FOURCC hack).

In some way this reminds me of the early shadow buffer hacks that were available by NVidia where you had to set a specific set of renderstates to get write access to the shadow buffer.

Share this post


Link to post
Share on other sites
Thanks for the info guys. Now that I look at it again, the stream frequency issue is obvious. Thanks for pointing that out to me Mezz. I think I'll steer clear of the FOURCC hack, but its a nice little tid bit to know. Thanks Metron. I guess that answers my question. I stil wonder if there isn't some other way around it.

Share this post


Link to post
Share on other sites
Instancing is available on any ATI 9500 and above cards with driver Catalyst 4.8 or above. To use instancing you need to make following:

if (caps.VertexShaderVersion >= D3DVS_VERSION(3, 0))
{
supportsInstancing = true;
}
else if (d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_SURFACE,
(D3DFORMAT)MAKEFOURCC('I', 'N', 'S', 'T')) == D3D_OK)
{
supportsInstancing = true;
// Enable instancing on ATI cards
dev->SetRenderState(D3DRS_POINTSIZE, MAKEFOURCC('I', 'N', 'S', 'T'));
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!