How do i use PureDevice?

Started by
86 comments, last by ZeroWalker 10 years, 8 months ago

Can't help you with that queue stuff (network ?), but as it looks the loop will continue without rendering (TryTake probably returns false after the last image). Is listening ever set to false anywhere ?

Yep, the DX SDK is now part of the Windows Kit. I still recommend installing the DX 2010 June SDK for convenience (especially for D3D9).

Edit: Slowing down ? Sounds like a leak. Check that. Lucky guess: TextureData is a stream, you likely need to dispose it manually (e.g. after the surface loading).

Advertisement

Seems correct, it does return false. hmm. which means it´s the other loop which is the netwrok. But nothing is happening there either. My sendind loops are continuing like normal, so the connection isn´t broken. IT´s just that the Receiver doesn´t take the data that´s being sent i guess. Very Weird.

Yes Listening is set to false if i uncheck a button (and true if i check it).

Ah will install that.

Can't help you with the network stuff, sorry. See if you can get some diagnostics (like package loss or something).

There's also a network subforum for such questions around here. Recommendation: Isolate the problem by decoupling it completely from the rendering (say, dumping the image to disk). And again: Watch for leaks, e.g. with CLR profiler or for rough measures ProcessExplorer (google these tools).

PS: This thread is really well nourished laugh.png

Okay, will do, have isolated the problem so far to being at the receiving part, it locks the Thread waiting for new data (even though data is being sent), so will have to solve it somehow;P


Well, it´s all Around thread;)
Love how the Topic of the Thread was solved in the beginning, and now it´s a whole different story;P

Okay probably solved it, i had made a mistake (hopefully) with a PInvoke that i use.

dc2 = NativeMethods.GetWindowDC(hwnd);

I called that all the time, so eventually, it would break causing the program to fail some way or the other.
But now i moved it from the loop, and added this for safety:

if (dc2 != null)
NativeMethods.ReleaseDC(hwnd, dc2);
dc2 = NativeMethods.GetWindowDC(hwnd);

So hopefully that will solve it and Release if necessary.

Not the first time i make mistakes;)

A question, do i need to really Dispose of surface ever loop?
Can´t i just do like this:


                        using (var texture = new Texture(device, wid, heg, 0, Usage.None, Format.X8R8G8B8, Pool.Default))
                        using (var surface = texture.GetSurfaceLevel(0))
                        using (var sprite = new Sprite(device))
                        {
                                SharpDX.Windows.RenderLoop.Run(form, () =>
                                {
                                    if (CTS.IsCancellationRequested)
                                        form.Dispose();

                                    if (Queue.TryTake(out TextureData, 300))
                                    {
                                        device.BeginScene();
                                        sprite.Begin(SpriteFlags.None);
                                        Surface.FromFileInMemory(surface, TextureData, SharpDX.Direct3D9.Filter.None, 0);
                                        sprite.Draw(texture, new ColorBGRA(0xffffffff));

                                     }
                              });
                          }

Or is there an issue with doing like this?

Actually you're disposing the sprite, the surface and the texture already because of the using keyword (read here).

So, your code is fine. I see only one issue here: As stated earlier you don't need to create a texture (and a sprite) every time you draw. E.g. create them at startup, and dispose of them only when the app terminates.

Good, but, i am only creating the texutre one time when i start it, the render thread.
I am then keeping it all the time. I am only disposing them if i end the thread, and then i also end other stuff in the other thread.


Or is it a problem with doing that?
Cause i try to always only have disposable objects when i need them.

EDIT:

I don´t know how i am supposed to initialze them on startup, as Sprite needs Device, and Device needs a form. And a form needs to be created on the thread it´s used on.

This topic is closed to new replies.

Advertisement