Jump to content
  • Advertisement
Sign in to follow this  
Axiverse

[hlsl 4, slimdx] Problems using shader with no input data

This topic is 3667 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

so I'm trying to get my shader to generate a quad without any inputs from the system. Right not it compiles (the shader that is), but throws and exception when i try to Draw(1, 0) relevant shader code
[maxvertexcount(4)]
void ScreenGS(inout TriangleStream<Vertex> stream)
{
	Vertex output = (Vertex)0;
	
	output.Position = float4(-1, -1, 0, 1);
	stream.Append(output);
	
	output.Position = float4(+1, -1, 0, 1);
	stream.Append(output);
	
	output.Position = float4(-1, +1, 0, 1);
	stream.Append(output);
	
	output.Position = float4(+1, +1, 0, 1);
	stream.Append(output);
	
	stream.RestartStrip();
}

...

technique10 AmbientPass
{
	pass P0
	{
		SetVertexShader( 0 );
		SetGeometryShader( CompileShader( gs_4_0, ScreenGS() ) );
		SetPixelShader( CompileShader( ps_4_0, AmbientPS() ) );
	}
}

and relevant application code

var e = new InputElement[0];
nullLayout = new InputLayout(Device, e, compositeEffect.GetTechniqueByName("AmbientPass").GetPassByIndex(0).Description.Signature);

...

Device.InputAssembler.SetInputLayout(nullLayout);
Device.InputAssembler.SetPrimitiveTopology(PrimitiveTopology.PointList);

EffectTechnique t = compositeEffect.GetTechniqueByName("AmbientPass");

for (int i = 0; i < technique.Description.PassCount; ++i)
{
    t.GetPassByIndex(i).Apply();
    Device.Draw(1, 0);
}

slimdx throws and AccessViolationException

Share this post


Link to post
Share on other sites
Advertisement
problem was that a vertex shader is required...

but you can have a vertex shader with no inputs, which looks quite funny since it requires an output for some reason and that input on the geometry shader as well.


struct NullVertex
{

};

NullVertex PassVS()
{
NullVertex output;
return output;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!