Direct10 StreamOut如何追加顶点数据到尾部?
void SOSetTargets(
[in] UINT NumBuffers,
[in] ID3D10Buffer *const *ppSOTargets,
[in] const UINT *pOffsets
);
An offset of -1 will cause the stream output buffer to be appended, continuing after the last location written to the buffer in a previous stream output pass.
//=================================================
我有4个顶点数据放在g_pVertexBuffer_SO里(bytewidth很大,D3D10_BIND_VERTEX_BUFFER|D3D10_BIND_STREAM_OUTPUT)
offset[1] = { -1 };
pd3dDevice->SOSetTargets( 1, g_pVertexBuffer_SO, offset );
g_Tech->GetPassByIndex(1)->Apply( 0 );//pass1
pd3dDevice->DrawIndexed(4, 0, 0);
做完这步按理说g_pVertexBuffer_SO应该不止4个顶点了,但是
offset = 0;
pd3dDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP);
pd3dDevice->IASetVertexBuffers( 0, 1, &g_pVertexBuffer_SO, &stride, &offset );
g_Tech->GetPassByIndex( 0 )->Apply( 0 );//pass0
pd3dDevice->DrawAuto()的时候一个线段都画不出,不知道错在哪里。。。
//===================
[maxvertexcount(2)]
void GS1( line VS_Input input[2], inout LineStream<VS_Input> gzStream )
{
if( input[1].UV.x < 0.5 && input[1].UV.y >0.5)
{
VS_Input mid = (VS_Input)0;
gzStream.Append( mid );
mid.Pos = float4(0.1f, 0.1f, 0.0f, 0.0f);
gzStream.Append( mid );
gzStream.RestartStrip();
}
}
GeometryShader gsStreamOut1 = ConstructGSWithSO( CompileShader( gs_4_0, GS1() ), "POSITION.xyz; TEXCOORD.xy" );
technique10 myTech
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VSfunc() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PSfunc() ) );
}
pass P1
{
SetVertexShader( CompileShader( vs_4_0, VS_nochange() ) );
SetGeometryShader( gsStreamOut1 );
SetPixelShader( NULL );
}
}