Sign in to follow this  
Plerion

Data clipped before Output Merger

Recommended Posts

Hello everyone
 
Im rendering a triangle and according to visual studios debug capabilities it gets clipped somewhere between the vertex shader and the output merger. Ill illustrate that with an image:
3LdAw.png
 
The data after the vertex shader (current image) looks as it should with the given data but in the output merger nothing gets drawn. Ive compared the initialization code to one of my other projects and i couldnt find any differences. Therefore im not quite sure what code you might need but if you need anything just post it and ill look for the code.
 
/Edit:
I've found some more information, maybe it helps:
3LeIl.png
 
3LeJv.png
 
3LeQh.png
 
Pixel-Shader:
 

struct PixelInput
{
float4 position : SV_POSITION;
float2 texCoord : TEXCOORD0;
};
 
float4 pixelMain(PixelInput input) : SV_TARGET {
return float4(1, 1, 1, 1);
}

Vertex-Shader:

struct VertexInput
{
	float4 position : POSITION0;
	float2 texCoord : TEXCOORD0;
};

struct VertexOutput
{
	float4 position : SV_POSITION;
	float2 texCoord : TEXCOORD0;
};

cbuffer MatrixBuffer : register(c0)
{
	matrix World;
	matrix View;
	matrix Projection;
};

VertexOutput vertexMain(VertexInput input) {
	float4 posWorld = mul(input.position, World);
	float4 posView = mul(posWorld, View);
	float4 posProj = mul(posView, Projection);

	VertexOutput output = (VertexOutput)0;
	output.position = posProj;
	output.texCoord = input.texCoord;

	return output;
}

                                  
Edited by Plerion

Share this post


Link to post
Share on other sites

I thought how it looks after the vertex shader is how it will be on the screen. However not a single pixel in the render target contains another history entry than the one from ClearRenderTargetView.

Share this post


Link to post
Share on other sites

Hmm. Things to try:

 

  • Make sure you pass the debug flag at shader creation: D3DCOMPILE_DEBUG
  • Make sure you pass the debug flag at dx creation: D3D11_CREATE_DEVICE_DEBUG
  • Make sure you compile the correct pixel shader, if you have more.
  • In the pixel shader try returning another color, like green, red or even blue.

 

Maybe your too close to the vertices, so they get clipped away?

 

When you create your perspective matrix, what's your znear and zfar?

 

When looking at this calls:

 

IASetIndexBuffer(NULL, DXGI_FORMAT_UNKNOWN, 0) 

IASetVertexBufer(0, 32, someobject(NULL, NULL, NULL, NULL.....

 

These two commands are the only commands that set the V/I buffers, and these are the only one you call before the rendering, so you don't set the vertex and index buffers after these two commands, so I guess you don't send the correct data?

Edited by Migi0027

Share this post


Link to post
Share on other sites

Hey Migi0027

 

Thanks for your tips, here is what ive got:

- Shaders are compiled with debug

- Device is created with debug (no errors/warnings in the output)

- Pixel shader i need to test a few things, because i also found it strange that it doesnt show up in the pipeline stages but in my other projects it does

 

I thought it was the clipping as for a test im using a very small triangle (inside the cube 0/0/0 to -2/-2/1) and zNear is set to 1 but my matrix looks from 1/0/0 to 0/0/0 with 0/0/1 as up). I changed it to be at 4/0/0, which changes the post-vertex-shader view in the debugger correctly but still, nothing in the output merger stage.

 

The data is correct, there are no indices and ive inspected the data in the debugger, it is the same as i pass in

	struct Vertex
	{
		float x, y, z, w;
		float u, v;
	} vertices[3] = {
		{ -2, 2, 1, 1, 0, 0 },
		{ -2, 2, 0, 1, 1, 0 },
		{ 0, 0, 1, 1, 1, 1 }
	};

Also the matrices in the cbuffer are set correctly when inspected using the GPU debugger.

Share this post


Link to post
Share on other sites
Hey

Thanks for your hint. In currently not at my computer but I think the problem ain't related to the vertex data. The post vertex shader view in the debugger shows the output of the vertex shader in projection space with the usual clipping already applied, e.g. clipping near and far plane.

So I think the problem is that the pixel shader never gets called. I'm not 100% sure but I thin that there are only two possible situations.
1) The rasterizer does not generate any fragments but as all checks are disabled in the rasterizerstate that should not be the case.

2) My pixel shader is not attached correctly even though it shows up in the debugger.

I will have a look at everything when I'm back home.

Thanks and a nice afternoon
Plerion

Share this post


Link to post
Share on other sites

Hey

Thanks for your hint. In currently not at my computer but I think the problem ain't related to the vertex data. The post vertex shader view in the debugger shows the output of the vertex shader in projection space with the usual clipping already applied, e.g. clipping near and far plane.

So I think the problem is that the pixel shader never gets called. I'm not 100% sure but I thin that there are only two possible situations.
1) The rasterizer does not generate any fragments but as all checks are disabled in the rasterizerstate that should not be the case.

2) My pixel shader is not attached correctly even though it shows up in the debugger.

I will have a look at everything when I'm back home.

Thanks and a nice afternoon
Plerion

Your problem is most likely related to your view transform, if the object is drawn outside of the view frustum or view port, the transformed vertices will not be going through the pixel shader. And this is also the reason that you can't find another pixel with a different pixel history then the clear call, objects that are not in the view port will not have a pixel shader run for them.

Share this post


Link to post
Share on other sites

Though that should show ip on the pixel history, check your blend state, especially RenderTargetWriteMask.

 

I still suspect some out of clip space trouble. I still use VS 2010 and PIX and now surfing the docs of the graphics debugger I really wonder: Is there no way to list the vertices' values in tabular form like in PIX ? (now that would be a step back)

 

If no, and you can't use PIX yourself, can you provide a minimal example project ? A working exe would suffice, I'd run it through PIX myself.

 

PS: Is there an official term for this kind of helping ? Remote group debugging ? Social debugging ? wink.png

Share this post


Link to post
Share on other sites

I have run into a few issues with the new graphics debugger that PIX didn't have and it is really annoying I had something fail a depth test but the depth test wasn't on for that particular drawcall it turned out that it actually failed a stencil test. I had to go through all the states for that particular draw call to figure out what was happening to it.

 

The other problem is that PIX no longer understands the DX11.1 runtime so even if the application is shared if it is build against the DX11.1 runtime PIX will fail to open the application, and seeing he is building his application with VS2012 it is very likely it's built against the DX11.1 runtime sadly.

 

Currently I am having to deal with GPUPerfStudio 2 and it is not perfect either and only works for AMD cards, there is another plugin for VS that might help you and it is called NSight but that only works for NVidia cards and you have to register as a developer with NVidia to get it.

Edited by NightCreature83

Share this post


Link to post
Share on other sites
And for both the graphics debugger and NSight one needs a non-Express version of  VS as it seems. And if that exe is 11.1 I couldn't help either. I feared as much. Thanks for the heads-up. Makes me even less inclined to get my hands on a Pro version. Pity, PIX was/is quite cool.
 
Rant over. Another alternative to try is Intel's GPA Frame Analyzer.
 
NightCreature also recommended NVidia's PerfHUD . Can't comment on that yet, I used it back on Win XP with DX9, but couldn't get it to work with my new system. The latest seems to support Fermi Architecture though. Edited by unbird

Share this post


Link to post
Share on other sites

Well seeing he has the graphics debugger up in VS2012 we don't have to worry about the OP having an express version. It is worth getting a pro version for VS if you don't have one btw, but try and get it through someone who works for MS as that saves hundreds of <your currency here>.

Edited by NightCreature83

Share this post


Link to post
Share on other sites

Well seeing he has the graphics debugger up in VS2012 we don't have to worry about the OP having an express version


Oh boy, what a brainfart on my part tongue.png

Thanks for the hint. I already touched one for a little freelancing. Amazing how convenient stuff gets, when you're normally used to Express.

Enough off topic: @Plerion other things to try: Disable transformation altogether (or transform on the CPU) so you know what you get.

Share this post


Link to post
Share on other sites

Hello everyone

 

Thanks for your answers, im not using PIX as it doesnt work on windows 8 with d3d11 (im not using 11.1) (known bug). Sadly NVIDIA NSight doesnt come for VS13 yet (i think they sent a newsletter that its for VS12 now, but not sure).

 

About the actual problem:
Seems the graphics debugger in visual studio is not really showing the real data, it much rather reads my mind and displays what id actually like to see :D. The matrices were not transposed and thus obviously the results were not right. Nevertheless the graphics debugger showed the resulting triangle exactly as it would look in projection space, weird...

However, now everything works, thanks a lot for all your hints and replies!

 

Greetings

Plerion

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this