Jump to content

  • Log In with Google      Sign In   
  • Create Account

[SharpDX] Understanding DX11 blend states


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 cephalo   Members   -  Reputation: 542

Like
0Likes
Like

Posted 05 April 2013 - 01:11 PM

In dx9, the blend state was fairly simple. In dx11, it's a lot more complicated and I'm having trouble understanding how I need to have it set. I have a small app that is supposed to draw several instances of tessellated bezier triangles, and even though I have the pixel shader set to just paint one color, I'm not seeing that color on my screen at all. I've looked at my app with PIX (I use VS 2012 Express so it's my only debugging option for now.) and my vertex buffers seem to be doing what they are supposed to.

 

Right now I'm wondering about the blend state because I don't fully understand it. Here is how I have it set in my render method:

 

            RenderTargetBlendDescription rendBlendDesc = new RenderTargetBlendDescription();
            rendBlendDesc.SourceAlphaBlend = BlendOption.One;
            rendBlendDesc.DestinationAlphaBlend = BlendOption.Zero;
            rendBlendDesc.BlendOperation = BlendOperation.Add;
            rendBlendDesc.SourceBlend = BlendOption.One;
            rendBlendDesc.DestinationBlend = BlendOption.Zero;

            BlendStateDescription blendDesc = new BlendStateDescription();
            blendDesc.AlphaToCoverageEnable = false;
            blendDesc.IndependentBlendEnable = false;
            blendDesc.RenderTarget[0] = rendBlendDesc;

            BlendState blendState = new BlendState(Game.GraphicsDevice, blendDesc);
            Game.GraphicsDevice.ImmediateContext.OutputMerger.SetBlendState(blendState);

 

Do you see anything here that would prevent drawing from being visible?



Sponsor:

#2 MJP   Moderators   -  Reputation: 11347

Like
2Likes
Like

Posted 05 April 2013 - 03:25 PM

Your blend state will result in the pixel shader value being written to the render target(s), and completely overwriting any existing contents of the render target. This is pretty standard for rendering without any blending. If you're not seeing your primitives, then the problem is probably somewhere else.

I would recommend enabling device debug messages if you haven't already, and checking for any warning or messages. Pass the "Debug" flag when creating your device to specify that you want messages, and then enable native debugging for your project. You should then get messages in your debugger output window. If you're using an express version of VS or you don't want to turn on native debugging, you can use a program like DebugView to view the native debugger output stream.



#3 cephalo   Members   -  Reputation: 542

Like
0Likes
Like

Posted 06 April 2013 - 07:31 AM

I used to use DebugView for my dx9 stuff and it was very useful. This time though I'm not seeing any warnings in the DebugView window even though I have created my device with the debug option. Does dx11 have a messaging level like dx9 had? I haven't used DebugView for a couple of years, and I can't remember all the steps necessary to capture messages from my app.



#4 hunpro   Members   -  Reputation: 851

Like
1Likes
Like

Posted 06 April 2013 - 02:16 PM

Do you see the triangles without this blending turned on?
If not, then 2 quick tips: forgot to transpose the viewprojection matrix, or forgot to set some constant buffer to the proper shaders. At least those are my main 2 sources of pain nowadays. rolleyes.gif

You can turn on dx debug in sdk->utilities->Directx control panel, if you haven't already. I got some usefull info about not setting the proper patch type for my hull shader, which made the driver reset, so it can be usefull,but not a magic bullet.



#5 MJP   Moderators   -  Reputation: 11347

Like
1Likes
Like

Posted 06 April 2013 - 04:34 PM

I used to use DebugView for my dx9 stuff and it was very useful. This time though I'm not seeing any warnings in the DebugView window even though I have created my device with the debug option. Does dx11 have a messaging level like dx9 had? I haven't used DebugView for a couple of years, and I can't remember all the steps necessary to capture messages from my app.


There's not really a "message level" anymore. There's functionality to filter out certain warnings/errors using the ID3D11InfoQueue interface, but by default you get all possible warnings and errors.

If you're not getting any messages, then it's possible you're not causing any errors or warnings. To find out for sure, you could try to deliberately cause an error by passing an incorrect parameter to a function, or something like that.



#6 xoofx   Members   -  Reputation: 881

Like
2Likes
Like

Posted 07 April 2013 - 06:44 AM

You will be able to see D3D11 messages directly from the output window if you check "Enable native code debugging" in the Project Properties/Debug tab (you need to use the debugger to see the messages) otherwise DebugView is still an option.



#7 cephalo   Members   -  Reputation: 542

Like
0Likes
Like

Posted 07 April 2013 - 07:45 AM

Thanks everyone, of course things are made worse by the fact that I have to stick with express version of VS for now. Very hard to learn dx11 with express.



#8 cephalo   Members   -  Reputation: 542

Like
0Likes
Like

Posted 07 April 2013 - 07:50 AM

You will be able to see D3D11 messages directly from the output window if you check "Enable native code debugging" in the Project Properties/Debug tab (you need to use the debugger to see the messages) otherwise DebugView is still an option.

 Oh my gosh! This is working with express! Somebody told me it wouldn't. Now I have about 100 pages of warnings to examine. Thanks!



#9 Adam_42   Crossbones+   -  Reputation: 2506

Like
1Likes
Like

Posted 07 April 2013 - 11:41 AM

You may find it useful to have the debugger break on those warnings, in which case take a look at http://blogs.msdn.com/b/chuckw/archive/2012/11/30/direct3d-sdk-debug-layer-tricks.aspx

 

I'm not sure how easy it would be to interface with that API from C# though, as the SharpDX implementation looks incomplete.



#10 xoofx   Members   -  Reputation: 881

Like
1Likes
Like

Posted 08 April 2013 - 09:09 AM

I'm not sure how easy it would be to interface with that API from C# though, as the SharpDX implementation looks incomplete.

It is not incomplete, the class is marked as "partial" so the other part of the code is generated at built time by the DirectX C++ to C# code generator used in SharpDX.

 

Edit: Though there are here some NotImplementedException for GetStorageFilter/GetRetrievalFilter, will have to double check :D


Edited by xoofx, 08 April 2013 - 09:11 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS