# [SOLVED] SlimDX - Instancing problem

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

## Recommended Posts

I have succesfully implementted HW SM3 instancing. However, i got this error
error: [5220] Direct3D9: (ERROR) :Frequency divider is not allowed with hardware vertex processing for non-indexed primitives. DrawPrimitive fails. (DrawIndexedPrimitive may work better.)

After instancing i do this:
device.SetStreamSource(0, null, 0, 0);
device.SetStreamSource(1, null, 0, 0);

device.SetStreamSourceFrequency(0, 0, StreamSource.IndexedData);
device.SetStreamSourceFrequency(1, 0, StreamSource.InstanceData);

When i want to draw pointList in particle engine... what can i do about it ? If I turn off DX Debug mode, everything look correct and worked, but in debug mode its error.. I am using latest SlimDX under C# [Edited by - martinperry on March 8, 2010 9:52:43 AM]

##### Share on other sites
You have to use indexed primitives with hw instancing. In other words, you need to use an index buffer.

##### Share on other sites
So if i use instancing i can never use primitives without IB ? Even if i am done with instancing ?

I want to draw particles at the end of the scene as point list, but there can not be used IB :/

##### Share on other sites
Sorry, I misunderstood what the problem was. I think you're just not properly deactivating instancing. Try setting the frequency to 1 instead of 0.

##### Share on other sites
Didnt help... but if i turn off DX Debug mode, it works...Just its not only clear "solution" :(

##### Share on other sites
Okay so I'm looking through the SlimDX source code, and it looks like it's an issue with their SetStreamSourceFrequency wrapper. In native DX9 to deactivate instancing you do something like this:
device->SetStreamSourceFreq(0, 1);device->SetStreamSourceFreq(1, 1);

However in SlimDX you have this:
        Result Device::SetStreamSourceFrequency( int stream, int frequency, StreamSource source )        {                int value;                if( source == StreamSource::IndexedData )                        value = D3DSTREAMSOURCE_INDEXEDDATA;                else                        value = D3DSTREAMSOURCE_INSTANCEDATA;                HRESULT hr = InternalPointer->SetStreamSourceFreq( stream, value | frequency );                return RECORD_D3D9( hr );        }

The problem here is that you could never get that function to pass a value of 1 to the native implementation. I'm not super-familiar with SlimDX so it's possible that I'm not aware of something that would allow you do that, but from my cursory glance it looks like this functionality is missing.

I would suggest that you edit the title of your thread to include "SlimDX", so that one of the SlimDX developers can come in here and comment on this. I'll also PM one of them to ask about it.

##### Share on other sites
Hm.. thats not really good... maybe there is something for reseting, but i cant find it

##### Share on other sites
We added the Device.ResetStreamSourceFrequency method to automatically pass a '1' for the second parameter.

##### Share on other sites
Thank you... that does the "magic" :)

• 10
• 12
• 10
• 10
• 11