hzqst / MetaHookSv

MetaHook (https://github.com/nagist/metahook) porting for SvEngine (GoldSrc engine modified by Sven-Coop)
MIT License
148 stars 37 forks source link

[Renderer] Roadmap #416

Open hzqst opened 8 months ago

hzqst commented 8 months ago
hzqst commented 6 days ago
void CDiligentBaseRenderPass::BeginPass() override
{
  m_iCurrentSubpassIndex = 0;
  for(int i = 0;i < DILIGENT_MAX_SUBPASSES; ++i)
    m_CommandLists[i].clear();
}

void CDiligentBaseRenderPass::EndPass() override
{
   auto pCommand = new CDiligentDrawRenderPassCommand(this, m_CommandLists);
   DiligentRenderer()->AddToCommandList(pCommand);
}

void CDiligentBaseRenderPass::AddToCommandList(IDiligentCommand* pCommand) override
{
  m_CommandLists[m_iCurrentSubpassIndex].emplace_back(pCommand);
}

void CDiligentDrawRenderPassCommand::Commit(RESOURCE_STATE_TRANSITION_MODE ResourceTransitionMode)
{
  auto pImmediateContext = DiligentRenderer()->GetImmediateContext();

if(m_bNeedRestoreRenderTargets){
//TODO
}

for(auto desc : m_UsedResources){
  pImmediateContext->TransitionResourceState(desc.Resource, Diligent::RESOURCE_STATE_UNKNOWN, desc.NewResourceState, desc.StateTransitionFlags);
/*
class CDiligentResourceTransitionDesc
{
public:
RefCntAutoPtr<IDeviceObject> Resource;
RESOURCE_STATE NewResourceState { RESOURCE_STATE_UNKNOWN };
STATE_TRANSITION_FLAGS StateTransitionFlags{ STATE_TRANSITION_FLAG_NONE };
};
*/
}

  pImmediateContext->BeginRenderPass(RPBeginInfo);

  int i = 0;
  while(1)
  {
  for(auto pCommand : m_CommandList[i]){
    pCommand->Commit(Diligent::RESOURCE_STATE_TRANSITION_MODE_VERIFY);
    pCommand ->Destroy();
   }

   if(i< m_iSubpassCount)
      pImmediateContext->NextSubpass();
   else
      break;
  }

  pImmediateContext->EndRenderPass();

  if(m_bNeedRestoreRenderTargets){
    //TODO
  }
}