MCPcopy Create free account
hub / github.com/carbonengine/trinity / SetAllState

Method SetAllState

trinityal/dx12/Tr2RenderContextDx12.cpp:808–878  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

806}
807
808ALResult Tr2RenderContextAL::SetAllState()
809{
810 if( ( m_dynamicVBs & m_psoDescription.m_vertexStreamMask ) != 0 )
811 {
812 D3D12_VERTEX_BUFFER_VIEW vb[4];
813 for( uint32_t i = 0; i < 4; ++i )
814 {
815 if( m_vertexBuffers[i].buffer.IsValid() )
816 {
817 vb[i].BufferLocation = m_vertexBuffers[i].buffer.m_buffer->GetGpuView() + m_vertexBuffers[i].offset;
818 vb[i].SizeInBytes = m_vertexBuffers[i].buffer.GetSize() - m_vertexBuffers[i].offset;
819 vb[i].StrideInBytes = m_vertexBuffers[i].stride;
820 }
821 else
822 {
823 vb[i].BufferLocation = 0;
824 vb[i].SizeInBytes = 0;
825 vb[i].StrideInBytes = 0;
826 }
827 }
828 m_commandList->IASetVertexBuffers( 0, 4, vb );
829 }
830
831 if( m_dynamicIB )
832 {
833 D3D12_INDEX_BUFFER_VIEW ib = { 0, 0, DXGI_FORMAT_UNKNOWN };
834 if( m_indexBuffer.m_buffer->IsValid() )
835 {
836 ib.BufferLocation = m_indexBuffer.m_buffer->GetGpuView();
837 ib.SizeInBytes = m_indexBuffer.GetSize();
838 ib.Format = m_indexBuffer.GetDesc().stride == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
839 }
840 m_commandList->IASetIndexBuffer( &ib );
841 }
842
843 if( m_dirtyPso )
844 {
845 auto pso = GetPipelineState();
846 if( !pso )
847 {
848 return E_FAIL;
849 }
850
851 m_commandList->SetPipelineState( pso );
852 if( m_psoDescription.m_shaderProgram.IsValid() )
853 {
854 if( m_psoDescription.m_shaderProgram.m_program->IsComputeProgramDx12() )
855 {
856 m_commandList->SetComputeRootSignature( m_psoDescription.m_shaderProgram.m_program->m_rootSignature.m_rootSignature );
857 }
858 else
859 {
860 m_commandList->SetGraphicsRootSignature( m_psoDescription.m_shaderProgram.m_program->m_rootSignature.m_rootSignature );
861 }
862 }
863 else
864 {
865 m_commandList->SetComputeRootSignature( nullptr );

Callers 1

RenderGdprBatchesMethod · 0.80

Calls 10

IASetVertexBuffersMethod · 0.80
IASetIndexBufferMethod · 0.80
IsComputeProgramDx12Method · 0.80
GetGlobalSrvUavHeapMethod · 0.80
GetGlobalSamplerHeapMethod · 0.80
IsValidMethod · 0.45
GetGpuViewMethod · 0.45
GetSizeMethod · 0.45
CommitMethod · 0.45

Tested by

no test coverage detected