Advertisement
snake5

D3D11Renderer::DrawImmediate

Dec 21st, 2015
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. void D3D11Renderer::DrawImmediate( SGRX_ImmDrawData& idd )
  2. {
  3.     LOG_FUNCTION;
  4.    
  5.     SGRX_ScopedMtxLock LOCK( &m_mutex );
  6.    
  7.     SetVertexShader( idd.vertexShader );
  8.     SetPixelShader( idd.pixelShader );
  9.     SetRenderState( idd.renderState );
  10.    
  11.     m_vertbuf_batchverts.Upload( m_dev, m_ctx, idd.vertices, idd.vertexDecl->m_info.size * idd.vertexCount );
  12.     if( idd.shdata && idd.shvcount )
  13.         m_cbuf_ps_batchverts.Upload( m_dev, m_ctx, idd.shdata, sizeof(*idd.shdata) * idd.shvcount );
  14.    
  15.     m_ctx->VSSetConstantBuffers( 0, 1, &m_cbuf_vs_batchverts );
  16.    
  17.     m_ctx->PSSetConstantBuffers( 0, 1, m_cbuf_ps_batchverts.PPBuf() );
  18.    
  19.     ID3D11ShaderResourceView* srvs[ SGRX_MAX_TEXTURES ];
  20.     ID3D11SamplerState* smps[ SGRX_MAX_TEXTURES ];
  21.     for( int i = 0; i < SGRX_MAX_TEXTURES; ++i )
  22.     {
  23.         SGRX_ITexture* tex = idd.textures[ i ];
  24.         srvs[ i ] = tex ? ((D3D11Texture*)tex)->m_rsrcView : NULL;
  25.         smps[ i ] = tex ? ((D3D11Texture*)tex)->m_sampState : m_sampState;
  26.     }
  27.     m_ctx->PSSetShaderResources( 0, SGRX_MAX_TEXTURES, srvs );
  28.     m_ctx->PSSetSamplers( 0, SGRX_MAX_TEXTURES, smps );
  29.    
  30.     m_ctx->IASetPrimitiveTopology( conv_prim_type( idd.primType ) );
  31.     m_ctx->IASetInputLayout( ((D3D11VertexInputMapping*) idd.vertexInputMapping)->m_inputLayout );
  32.     ID3D11Buffer* vbufs[2] = { m_vertbuf_batchverts, m_vertbuf_defaults };
  33.     static const UINT strides[2] = { idd.vertexDecl->m_info.size, sizeof(BackupVertexData) }; // [2015-12-21 14:46] wat
  34.     static const UINT offsets[2] = { 0, 0 };
  35.     m_ctx->IASetVertexBuffers( 0, 2, vbufs, strides, offsets );
  36.    
  37.     m_ctx->Draw( idd.vertexCount, 0 );
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement