Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET DirectX stream geometry , +
Hi folks,
 

 
I've been trying to generate shadow volumes with the gpu.
But can't get the geometry shader to produce output.
So how can I create a shader with stream output in slimdx? Can someone give me an example with code in hlsl and slimdx?
 

Edit:
 
@ CHill60
here's some code
 
Shader
struct GSPS_INPUT
{
    float4 Pos : POSITION;
    float2 Tex : TEXCOORD;
    float3 Norm : NORMAL;
};
 
struct GSPS_INPUTO
{
    float4 Pos : SV_POSITION;
};
 
struct GSPS_OUT
{
    float4 Pos : SV_POSITION;
};
 
GSPS_INPUTO VS(GSPS_INPUT input)
{
    GSPS_INPUTO oput;
    oput.Pos = input.Pos;
    return oput;
}
 
[maxvertexcount(3)]
void GS( triangle GSPS_INPUTO input[3], inout TriangleStream<GSPS_OUT> TriStream )
{
    //Test geometry shader
    GSPS_OUT output;
    output.Pos = input[0].Pos;
    TriStream.Append(output);
 
    output.Pos = input[1].Pos;
    TriStream.Append(output);
 
    output.Pos = input[2].Pos;
    TriStream.Append(output);
 
    TriStream.RestartStrip();
}
 
technique10 Technique1
{
    pass Pass1
    {
        SetGeometryShader(ConstructGSWithSO(CompileShader(gs_5_0, GS()), "SV_POSITION.xyzw;"));
	SetVertexShader(CompileShader(vs_5_0, VS()));
	SetPixelShader(NULL);
    }
}
 
This is the initialization:
 
ShaderBytecode effectByteCode = ShaderBytecode.CompileFromFile("geoTest.fx", "fx_5_0", ShaderFlags.Debug | ShaderFlags.SkipOptimization, EffectFlags.None);
geoEf = new Effect(_device, effectByteCode);
buffer = new StreamOutputBufferBinding();
BufferDescription bdesc = new BufferDescription()
{
     BindFlags = BindFlags.StreamOutput | BindFlags.VertexBuffer,
     CpuAccessFlags = CpuAccessFlags.None,
     OptionFlags = ResourceOptionFlags.None,
     SizeInBytes = 1024 * 1024 * 4,
     Usage = ResourceUsage.Default
};
buffer.Buffer = new SlimDX.Direct3D11.Buffer(_device, bdesc);
EffectPass p = geoEf.GetTechniqueByIndex(0).GetPassByIndex(0);
L = new InputLayout(_device, p.Description.Signature, new[] {
new InputElement("POSITION", 0, Format.R32G32B32A32_Float, InputElement.AppendAligned, 0,
    InputClassification.PerVertexData, 0),
new InputElement("TEXCOORD", 0, Format.R32G32_Float, InputElement.AppendAligned, 0,
    InputClassification.PerVertexData, 0),
new InputElement("NORMAL", 0, Format.R32G32B32_Float, InputElement.AppendAligned,0,
    InputClassification.PerVertexData, 0)
});
effectByteCode.Dispose();
buffers = new SlimDX.Direct3D11.Buffer[1];
 
This is the draw call:
 
device.ImmediateContext.StreamOutput.SetTargets(buffer);
EffectPass m_effectPass = geoEf.GetTechniqueByIndex(0).GetPassByIndex(0);
device.ImmediateContext.InputAssembler.InputLayout = L;
device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
device.ImmediateContext.InputAssembler.SetIndexBuffer(m_indexBuffer2d,
   SlimDX.DXGI.Format.R16_UInt, 0);
device.ImmediateContext.InputAssembler.SetVertexBuffers(
   0,
   new VertexBufferBinding(m_vertexBuffer, Marshal.SizeOf(typeof(Vertex)), 0));
 
m_effectPass.Apply(device.ImmediateContext);
device.ImmediateContext.DrawIndexed(count, 0, 0);
device.ImmediateContext.StreamOutput.GetTargets(1).CopyTo(buffers, 0);
device.ImmediateContext.StreamOutput.SetTargets(null);
 
And I ceep getting no stream output.
Posted 11-Feb-13 3:42am
Edited 11-Feb-13 4:46am
v2
Comments
CHill60 at 11-Feb-13 8:57am
   
If you post the code that wouldn't produce the output you're more likely to get someone to help you
CHill60 at 11-Feb-13 17:00pm
   
Good one IDominator. Wish I could help in detail but not my area of expertise. At least now no-one can moan at you for not trying :-) It also pops your question back up in the list. Good Luck

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 385
1 Sergey Alexandrovich Kryukov 329
2 CPallini 270
3 DamithSL 214
4 Maciej Los 192
0 OriginalGriff 5,515
1 DamithSL 4,451
2 Maciej Los 3,902
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100