snake5 icon

D3D11Renderer::DrawImmediate

snake5 | PRO | 12/21/15 11:30:37 AM UTC | 0 ⭐ | 862 👁️ | Never ⏰ | []
C++ |

1.54 KB

|

None

|

0 👍

/

0 👎

void D3D11Renderer::DrawImmediate( SGRX_ImmDrawData& idd )
{
    LOG_FUNCTION;
    
    SGRX_ScopedMtxLock LOCK( &m_mutex );
    
    SetVertexShader( idd.vertexShader );
    SetPixelShader( idd.pixelShader );
    SetRenderState( idd.renderState );
    
    m_vertbuf_batchverts.Upload( m_dev, m_ctx, idd.vertices, idd.vertexDecl->m_info.size * idd.vertexCount );
    if( idd.shdata && idd.shvcount )
        m_cbuf_ps_batchverts.Upload( m_dev, m_ctx, idd.shdata, sizeof(*idd.shdata) * idd.shvcount );
    
    m_ctx->VSSetConstantBuffers( 0, 1, &m_cbuf_vs_batchverts );
    
    m_ctx->PSSetConstantBuffers( 0, 1, m_cbuf_ps_batchverts.PPBuf() );
    
    ID3D11ShaderResourceView* srvs[ SGRX_MAX_TEXTURES ];
    ID3D11SamplerState* smps[ SGRX_MAX_TEXTURES ];
    for( int i = 0; i < SGRX_MAX_TEXTURES; ++i )
    {
        SGRX_ITexture* tex = idd.textures[ i ];
        srvs[ i ] = tex ? ((D3D11Texture*)tex)->m_rsrcView : NULL;
        smps[ i ] = tex ? ((D3D11Texture*)tex)->m_sampState : m_sampState;
    }
    m_ctx->PSSetShaderResources( 0, SGRX_MAX_TEXTURES, srvs );
    m_ctx->PSSetSamplers( 0, SGRX_MAX_TEXTURES, smps );
    
    m_ctx->IASetPrimitiveTopology( conv_prim_type( idd.primType ) );
    m_ctx->IASetInputLayout( ((D3D11VertexInputMapping*) idd.vertexInputMapping)->m_inputLayout );
    ID3D11Buffer* vbufs[2] = { m_vertbuf_batchverts, m_vertbuf_defaults };
    static const UINT strides[2] = { idd.vertexDecl->m_info.size, sizeof(BackupVertexData) }; // [2015-12-21 14:46] wat
    static const UINT offsets[2] = { 0, 0 };
    m_ctx->IASetVertexBuffers( 0, 2, vbufs, strides, offsets );
    
    m_ctx->Draw( idd.vertexCount, 0 );
}

Comments