[solved]My tessellation pipeline that draws nothing.

Started by
27 comments, last by Jason Z 11 years ago

dxdude, I have turned off any other draw calls for now such as skybox etc. so what you mentioned should not be an issue.

Jason, I have a blend state, and a depthstencil state. I didn't know about the rasterizer state or the output merger state! So those are in some default condition. I'll have to look into that. As for pixel history, the only thing that shows up on the render window is the background color, so I'm not sure which pixel to click on. I'll try a few when I get a chance.

EDIT: Ok, I've now set this rasterizer state, but I still get no drawing:


            RasterizerStateDescription renderStateDesc = new RasterizerStateDescription();
            renderStateDesc.CullMode = CullMode.None;
            renderStateDesc.IsFrontCounterClockwise = false;
            renderStateDesc.FillMode = FillMode.Solid;
            RasterizerState rasterState = new RasterizerState(Game.GraphicsDevice, renderStateDesc);
            Game.GraphicsDevice.ImmediateContext.Rasterizer.State = rasterState;

As for the output merger state, I can't find that exact terminology in SharpDX. Does it go by another name?

EDIT2: also, I am clearing the depthstencil buffer with this command for every frame:


       public static void Render()
        {
            elapsedTime += GameTime.ElapsedTimeLastUpdate;
            if (maxFrameRate > 0 && ticksPerFrame > elapsedTime.Ticks)
                return;
            context.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0);
            context.ClearRenderTargetView(renderTarget, new Color4(0.25f, 0.5f, 1.0f, 1.0f));
            //device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0);
            //device.BeginScene();

            foreach (DrawableGameComponent comp in drawableGameComponents)
            {
                if(comp.Enabled)
                    comp.Render();
            }

            //device.EndScene();
            swapChain.Present(0, PresentFlags.None);

            elapsedTime = TimeSpan.Zero;

        }

I'm not sure if these values are carried over from DX9, and that maybe they are not valid anymore.

Advertisement
There are a couple of differences, sometimes more, sometimes less options (no alpha test anymore, and of course no fixed function stuff). But the main difference is that the states come now in whole blocks, are - more logically - set to the corresponding pipeline stage and you can't change single values atomically. But IMO most of it is quite similar.

There's no output merger state. There are two states: blend state and depth stencil state. Jason probably meant that.

Hmmm, ah yeah. I think I found something. Please allow a little detour first.

The parameterless constructor for c# structs will set everything to default ("zero", depending on type to 0, 0.0f, 0.0, null, "none" for flags and enums, etc.).
And: There's no way to change that - you have to know !

This is where object initializers and intellisense come in handy.
Example:

var renderTargetBlendDescription = new RenderTargetBlendDescription()
{
	BlendEnable = true,
	BlendOperation = BlendOperation.Add,
	x                                       // <- cursor position, type any letter here
};
Intellisense will then list all properties you haven't used so far. This way you won't miss any.

Long story short: If you're still using that blendstate here, you got a problem: It has a RenderTargetWriteMask of "None", meaning you don't write anything at all. You probably want ColorWriteMaskFlags.All.

Check your other state creations too.


PS: Grrrr, I'm so close to kill that forum editor, it even changes non-WISIWIG previews

Wow that's good to know. I assumed that stuff I didn't set would have some sensible default value. The problem here is that there are tons of parameters, and I only know what a few of them are for. I did my best guess on what to put in there, and I still see nothing. Here are the new state creations, the first is in my initialization method and the second two are in my draw call:


            RasterizerStateDescription renderStateDesc = new RasterizerStateDescription 
            { 
                CullMode = CullMode.None,
                DepthBias = 0,
                DepthBiasClamp = 0,
                FillMode = FillMode.Solid,
                IsAntialiasedLineEnabled = false,
                IsDepthClipEnabled = true,
                IsFrontCounterClockwise = false,
                IsMultisampleEnabled = true,
                IsScissorEnabled = false,
                SlopeScaledDepthBias = 0
            };
            RasterizerState rasterState = new RasterizerState(Game.GraphicsDevice, renderStateDesc);
            Game.GraphicsDevice.ImmediateContext.Rasterizer.State = rasterState;

...

            RenderTargetBlendDescription rendBlendDesc = new RenderTargetBlendDescription
            {
                AlphaBlendOperation = BlendOperation.Add,
                BlendOperation = BlendOperation.Add,
                DestinationAlphaBlend = BlendOption.Zero,
                DestinationBlend = BlendOption.Zero,
                IsBlendEnabled = true,
                RenderTargetWriteMask = ColorWriteMaskFlags.All,
                SourceAlphaBlend = BlendOption.One,
                SourceBlend = BlendOption.One
            };
            BlendStateDescription blendDesc = new BlendStateDescription
            {
                AlphaToCoverageEnable = false,
                IndependentBlendEnable = false
            };
            blendDesc.RenderTarget[0] = rendBlendDesc;
            BlendState blendState = new BlendState(Game.GraphicsDevice, blendDesc);
            Game.GraphicsDevice.ImmediateContext.OutputMerger.SetBlendState(blendState);

            DepthStencilStateDescription depthDesc = new DepthStencilStateDescription
            {
                BackFace = new DepthStencilOperationDescription
                {
                    Comparison = Comparison.Less,
                    DepthFailOperation = StencilOperation.Keep,
                    FailOperation = StencilOperation.Keep,
                    PassOperation = StencilOperation.Keep
                },
                DepthComparison = Comparison.Less,
                DepthWriteMask = DepthWriteMask.All,
                FrontFace = new DepthStencilOperationDescription
                {
                    Comparison = Comparison.Less,
                    DepthFailOperation = StencilOperation.Keep,
                    FailOperation = StencilOperation.Keep,
                    PassOperation = StencilOperation.Keep
                },
                IsDepthEnabled = true,
                IsStencilEnabled = true,
                StencilReadMask = 0xff,
                StencilWriteMask = 0xff
            };
            DepthStencilState depthState = new DepthStencilState(Game.GraphicsDevice, depthDesc);
            Game.GraphicsDevice.ImmediateContext.OutputMerger.SetDepthStencilState(depthState);

Unbird is right - I meant the depth/stencil state and blend state combined when I referred to the output merger state. Sorry for the confusion.

Regarding the default parameters, you can take a look at the description pages for each of the states, and they list the true defaults that should be sensible. For example, here is the blend state description. Once you get those initialized, it should be fairly easy to proceed with the debugging.

One thing: Disable stencil.


IsStencilEnabled = false,
Also, try setting all states to null for once, maybe the default states will give you at least something. One at a time. Then all.

Edit: Sort of ninja'ed wink.png

One thing: Disable stencil.



IsStencilEnabled = false,

I can see! I was blind and now I can see! You guys are friggen miracle workers. Thanks so much! Ahhhh I feel much better now.

[attachment=14904:ICanSee.jpg]

This is cool. The DX9 version was extremely complex and used far too much video memory. DX11 offers features that allow me to use 1/100th of the memory and probably at a higher framerate, maybe even with some displacement mapping! Thanks again everyone.

Ugh. Finally.

Thanks for the flowers.

Oh, by the way, I liked that DX9 "Hexcraft" screenshot. Don't forget to post one when your DX11 version produces something so nice.

Wow, I turned on my pixel shading, and as you can see, my normal calculations are completely nonsensical. Still, after extending the hex map to 120x120 hexes, without any optimization of the tessellation for distance, the framerate I'm getting makes me giggle with glee! I don't have a working framerate counter yet (not so easy in DX11) but the camera controls feel like buttah!

[attachment=14905:FunkyShading.jpg]

the framerate I'm getting makes me giggle with glee!

That makes it all worth it :) Nice work for sticking with it, and remember for next time - explicit initialization FTW!

This topic is closed to new replies.

Advertisement