# How do i use PureDevice?

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

## Recommended Posts

I am trying to enable PureDevice for testing purposes, but i can´t seem to get it to work.
Is there sometihng i need to set it to for it to work?



{
DeviceWindowHandle = form.Handle,
PresentFlags = SharpDX.Direct3D9.PresentFlags.None,
BackBufferCount = 1,
PresentationInterval = SharpDX.Direct3D9.PresentInterval.Immediate,
SwapEffect = SharpDX.Direct3D9.SwapEffect.FlipEx,
BackBufferFormat = SharpDX.Direct3D9.Format.X8R8G8B8,
MultiSampleType = MultisampleType.None,
Windowed = true,
};

device = new SharpDX.Direct3D9.DeviceEx(new SharpDX.Direct3D9.Direct3DEx(), 0, SharpDX.Direct3D9.DeviceType.Hardware, form.Handle, SharpDX.Direct3D9.CreateFlags.PureDevice, presentParams);

##### Share on other sites

What does "cannot seen to get it to work" mean? Please describe it better - are you getting an error? Is the app crashing? Is the code otherwise fine and working and problems come only when you include the PureDevice flag?

You also should check whether the device actually supports puredevice, in DirectX it's done by testing the DeviceCaps against D3DDEVCAPS_PUREDEVICE, but I have no idea how is this implemented in SharpDX.

Edited by Tom KQT

##### Share on other sites

Well it errors, when creating the device, it´s something either in the Device implementation, or in the Present.

And yeah i am trying to find that in SharpDX, and the only thing i can find is: http://sharpdx.org/documentation/api/f-sharpdx-direct3d9-capabilities-devicecaps

And well, i can use, SharpDX.Direct3D9.DeviceCaps.PureDevice , but that doesn´t return anything.

I thought it would be something like True, False. But then again, i don´t know how DirectX itself does in C++.

##### Share on other sites

On native side, the pure device is enabled simply by using the correct device creation flag.

What do you mean, "doesn't return anything"? The device caps are represented as bit flags (enum), and you should see whether the pure device value is set in the field (among other possible values). This can be done by using the & (AND operator), or using Enum.HasFlag, if you use modern enough version of .net.

Note that pure device can actually (and easily) decrease your performance, if you are not very careful about redundant state changes. The "non-pure" device caches device states, so if you set the same state multiple times in a row, you don't incur hardware calls every time - only when the state actually changes. Pure device, by contrast, removes this caching so you need to avoid device state calls even more vigorously than usual.

If you have the DirectX SDK installed, you can use the "DirectX Caps Viewer" to verify all your hardware capabilities from a single place. This tool essentially works by checking cap bits of your devices against all known possible bits.

Edited by Nik02

##### Share on other sites

Can you please show an example of how to check if  i support it.
I am brain dead when it comes to this. But it does hav, HasFlag, but don´t get how i am supposed to, let it tell me if it supports or not.

Yeah i know, or well, i know that it´s a very, Delicate state. Meaning, it turns blind eye to everything, and you have to be more vigilant.

But that being said, my "Rendering" if i even can call it that, only have 1 purpose.

Render an Image. No 3D, no effect etc.

So there shouldn´t be any problem

I don´t have DirecX SDK, never got it to work for me, and it said (It´s in Windows SDK now!) and i got that one, but no DirectX SDK anyway;P

##### Share on other sites

I'm more of a native D3D guy, but I would go about it as follows in SharpDX:

• Create the Direct3D object.
• Get the adapter collection from it.
• For each adapter in the collection:
• Use AdapterInformation.GetCaps to obtain a Capabilities structure for the given adapter.
• Read the DeviceCaps field from the Capabilities structure.
• bool SupportsPureDevice = DeviceCaps.HasFlag(SharpDX.Direct3D9.DeviceCaps.PureDevice)

or

• bool SupportsPureDevice = (0 != (DeviceCaps & SharpDX.Direct3D9.DeviceCaps.PureDevice))
Edited by Nik02

##### Share on other sites

Also note that in such a simple scenario as you describe, you won't likely see any (or very small) performance implications on pure versus non-pure device. The difference would arise if API calls would be your bottleneck.

##### Share on other sites

I did:

using (device = new SharpDX.Direct3D9.DeviceEx(new SharpDX.Direct3D9.Direct3DEx(), 0, SharpDX.Direct3D9.DeviceType.Hardware, form.Handle, SharpDX.Direct3D9.CreateFlags.HardwareVertexProcessing, presentParams))
{
bool support = device.Capabilities.DeviceCaps.HasFlag(SharpDX.Direct3D9.DeviceCaps.PureDevice);

}

And, it give True.

Edit:

Probably true, but would atleast want to get it working just for the heck of it.

Edited by ZeroWalker

##### Share on other sites

Unless SharpDX has a bug in the device constructor, you should be able to use the pure device flag.

You will want to check the caps before creating the device, as per my approach. Device context creation is potentially expensive; you don't want to create a new device just to test a cap bit.

Edited by Nik02

##### Share on other sites

Hopefully it´s not.

And well i am trying to do that, but i don´t get how to check device capabilities before, setting the device.

Maybe like this:

CreateFlags devFlags = CreateFlags.HardwareVertexProcessing;
if (cap.DeviceCaps.HasFlag(DeviceCaps.PureDevice))
{

devFlags |= CreateFlags.PureDevice;

Though, that returns false for some reason.

Edited by ZeroWalker

• 13
• 18
• 29
• 11
• 27