Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't get this to work with DepthStencilBuffer #17

Open
malixg opened this issue Jan 12, 2016 · 7 comments
Open

can't get this to work with DepthStencilBuffer #17

malixg opened this issue Jan 12, 2016 · 7 comments

Comments

@malixg
Copy link

malixg commented Jan 12, 2016

I got D3D11Image working with SharpDX, following some of the advice in the other thread and digging through the source code, but it only works with a single RenderTarget (the RenderTargetView that's wrapping the shard handle from D3D11Image). When I try to create a DepthStencilView and call OutputMerger.SetTargets(DepthStencilView, RenderTargetView) my image just winds up being blank. As I am working with 3d, I need depth, or else the layering in the image resorts to whatever was last drawn. Please advise. Thanks and have a great day.

@weltkante
Copy link

Did you make sure that your rendering code works when rendering against a different SharpDX render target? If you turn on depth and suddenly the image gets blank it more likely sounds like the device is configured wrong and just discards all pixels.

If you have Win10 and VS2015 you may want to try the graphic tools debugger to see what exactly is sent to the GPU and may be able to discover at which stage the pixels are discarded.

You also could setup a different render target with SharpDX and first get your rendering code working there, before trying to render against D3D11Image. Just to eliminate possibilities for errors.

(Sorry if you already did any of this, just trying to give some general advice. I have depth working with D3DImage, though not with this library. As far as I understand it, only the render target is shared with D3DImage and not the depth buffer, so it shouldn't care if you set one through SharpDX or not.)

@malixg
Copy link
Author

malixg commented Jan 12, 2016

Thanks for the quick response! If I don't use D3D11Image and set up my SwapChain using the WindowInteropHelper.Handle, then just call SwapChain.Present after Drawing my Scene, it works perfectly; but then I have the airspace issues and can't put anything on top of my directx output, which is why I'd like to use D3D11Image.

@weltkante
Copy link

Ok I tried it myself with D3D11Image from the nuget package and depth buffer works. You must be doing something wrong setting up the device. Can't really tell what it could be without seeing any code, there are many things to get wrong with DirectX rendering.

@ZyJChen
Copy link

ZyJChen commented Jan 15, 2016

Hello, weltkante. Could you please provide a simple example that show D3D11Image from the nuget package and depth buffer works? I had the same problem to get DepthStencilBuffer work, but I am using C++

@weltkante
Copy link

https://gist.github.com/weltkante/13b41a0289339ebf80e7

Here's my (reduced) test code I wrote a few days ago to check if the depth buffer works. It draws two intersecting rectangles, which is only possible to render correctly with a depth buffer (otherwise either the red or the blue would be in foreground, which you can verify by turning off the depth buffer).

Maybe you can find out what you did wrong by compring the calls I make vs. the calls you make. I think I reduced it to the minimum amount of calls necessary to render an image.

screenshot

@ZyJChen
Copy link

ZyJChen commented Jan 15, 2016

Thank you, weltkante.

@jameson75
Copy link

jameson75 commented Nov 11, 2019

I had the exact same issue before finding this post - weltkante's code made me realize that I simply forgot to clear the depth/stencil buffer via DeviceContext.ClearDepthStencilView

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants