SlideShare a Scribd company logo
Game Engine Gems 1

Chap 10.
Camera-Centric Engine Design
for Multithreaded Rendering
ohyecloudy http://ohyecloudy.com
shader café http://cafe.naver.com/shader
                               2011.04.11
Uses of Multi-Core in Video Games
Multithreaded Command Buffers
Device-Independent Command Buffers
A Camera-Centric Design
Future Work
frame

Main      Sim                          Shadow   Reflect   Main    Post-
thread   Update                         Maps     Maps     View   Process



                   Anim
                            Particle
                  Physics
                            Update
Thread            Update
Pool
frame

Main      Sim                          Shadow   Reflect   Main    Post-
thread   Update                         Maps     Maps     View   Process



                   Anim
                            Particle
                                       Rendering API를
                  Physics
                  Update
                            Update     호출할 필요가 없는 작업만
Thread
Pool                                   multithread
frame

Main      Sim                        Shadow   Reflect   Main    Post-
thread   Update                       Maps     Maps     View   Process


                  Stage 별로 그룹화
                    Anim
                  각Physics Particle 직접 device call
                     스테이지에서
                            Update
Thread             Update
Pool
                  그래서 device를 소유하는
                  thread에서 대부분 일을 처리
Uses of Multi-Core in Video Games
Multithreaded Command Buffers
Device-Independent Command Buffers
A Camera-Centric Design
Future Work
• 그리기 명령을 수행하는데 필요한 정보
  – device level


• rendering API 내부에 존재
  – API를 호출하면 버퍼를 채움
  – CPU 사용
• command buffer를 추상화
  – multithread로 command buffer를 채울 수 있게
  – device 독립

• DX9
  – multithread command buffer 불가능
  – device를 소유한 thread에서만 API call
  – multithread를 지원 옵션이 있긴 있다
    • 모든 call에 베타제어
    • 성능 저하가 심함
    • 제외
Uses of Multi-Core in Video Games
Multithreaded Command Buffers
Device-Independent Command Buffers
A Camera-Centric Design
Future Work
struct RenderCommand {
        ResourceHandle   VertexBufferHandle;
        uint32           VertexDeclEnumIndex;
        uint32           NumTriangles;
        uint32           NumVerts;

       enum PrimType {
               kTriList,
               kTriStrip
       };
       PrimType        PrimitiveType;
                                                RenderCommand
       enum BlendType {
               kBlend_None,                     드로우 콜 단위
               kBlend_Standard,
               kBlend_Additive,
               kBlend_Subtractive
       };
       BlendType       BlendType;

       // and so on…
};
void RenderObject::fillCommandBuffer (RenderCommand *RC)
{
       ThreadAssert(ThreadPoolThread);

      if (ObjectType == kTypeOpaqueMesh)
      {
             RC->VertexBufferHandle = mVBHandle;
             RC->VertexDeclEnumIndex = kVD_Mesh;
             RC->PrimitiveType = kTriList;
             RC->BlendType = kBlend_None;
             RC->NumTriangles = numTrisFromPrimType();
             RC->NumVerts = mNumVerts;
      }
      else if (ObjectType == kTypeTransparentMesh)
      {
             // and so on…
      }
}
void RenderObject::fillCommandBuffer (RenderCommand *RC)
{
       ThreadAssert(ThreadPoolThread);
              렌더링 리소스 수명을 제어하는 객체
              오브젝트 하나가
       if (ObjectType == kTypeOpaqueMesh)
              여러 개 RenderCommand를 만들 수 있음
       {
              RC->VertexBufferHandle = mVBHandle;
              character,
              RC->VertexDeclEnumIndex = kVD_Mesh;
              terrain,
              RC->PrimitiveType = kTriList;
              …
              RC->BlendType = kBlend_None;
              RC->NumTriangles = numTrisFromPrimType();
              RC->NumVerts = mNumVerts;
       }
       else if (ObjectType == kTypeTransparentMesh)
       {
              // and so on…
       }
}
void RenderObject::fillCommandBuffer (RenderCommand *RC)
{            RenderObject 상태를 단지 읽기만 한다.
       ThreadAssert(ThreadPoolThread);
             thread safe
       if (ObjectType == kTypeOpaqueMesh)
       {
              RC->VertexBufferHandle = mVBHandle;
              RC->VertexDeclEnumIndex = kVD_Mesh;
              RC->PrimitiveType = kTriList;
              RC->BlendType = kBlend_None;
              RC->NumTriangles = numTrisFromPrimType();
              RC->NumVerts = mNumVerts;
       }
       else if (ObjectType == kTypeTransparentMesh)
       {
              // and so on…
       }
}
void renderControl::executeDrawCommandDx9 (const RenderCommand *params)
{
        ThreadAssert(DeviceOwningThread);

        const VertexBufferContainer *vbc =
                mManagedVBs.getElement(params->vbHandle);
        DX9Dev->SetStreamSource(
                0,
                (IDirect3DVertexBuffer9 *)vbc->devicehandle,
                0,
                vbc->perVertSizeInBytes);

        SetShaderData(params);
        SetRenderStates(params);

        DX9Dev->SetVertexDeclaration(
                StaticVDeclHandles[params->vDecl]);
        D3DPRIMITIVETYPE type =
                PrimTypeMappingLUT[params->PrimitiveType];

        DX9Dev->DrawPrimitive(type, 0, params->NumTriangles);
}
Uses of Multi-Core in Video Games
Multithreaded Command Buffers
Device-Independent Command Buffers
A Camera-Centric Design
Future Work
• load balancing 필요
  – command buffer 채우는 작업을 할당
  – thread 별로 어떻게 할당?


• 최종 장면이 나오기 전까지 여러 장면을 렌더링
  – shadow map, reflection, post processing, …
  – 카메라
    • 장면마다 공유
• camera 단위
  – command buffer 생성을 쪼갠다.


• draw call 묶기
  – API 호출에 따른 오버헤드 최소화
  – render state 변경 최소화
  – batch
frame

                                                 Submit
Main      Sim
                                                   to
thread   Update                                  Device




                   Anim                Render
                            Particle
                  Physics              View
                            Update
Thread            Update               Filling
Pool
struct Camera {
        Float3 at, up, right;
        float   aspectRatio;
};

struct RenderView {
        Camera                  ViewCamera;
        Frustum                 Frust;
        RenderTargetHandle      DestColorRTT;
        RenderTargetHandle      DestDepthRTT;

        List<RenderCommand *>   RenderCommands;

        enum ViewType {
                kVT_ShadowMap,
                kVT_ReflectionMap,
                kVT_MainCamera,
                kVT_PostProcessing,
                kVT_Count
        };
        ViewType        ViewType;
};
void renderControl::CreateRenderViews()
{
         List<RenderView *>          currentViews;

         for (int i = 0; i < mCameras.size(); ++i) {
                  currentViews.add(
                           new RenderView(mCameras[i], kVT_MainCamera));
         }

         for (int i = 0; i < mLights.size(); ++i) {
                  if (mLights[i].IsShadowCasting()) {
                           currentViews.add(
                                    new RenderView(
                                              mLights[i].getShadowCamera(),
                                              kVT_ShadowMap));
                  }
         }

         for (int i = 0; i < currentViews.size(); ++i) {
                  ThreadPool.QueueWork(
                           procThreadedFillRenderView, currentViews[i]);
         }

         ThreadPool.waitForWorkToFinish();
}
void renderControl::procThreadedFillRenderView (
       void *DataPacket) {

      RenderView *currView = (RenderView *)DataPacket;

      List<RenderObject *> objects =
             gObjectManager.giveFrustumCollision(
                    currView->frustum);

      for (int q = 0; q < objects.size(); ++q) {
             RenderCommand *RC = new RenderCommand();
             Objects[q]->fillCommandBuffer(RC);
             currentViews[i].RenderCommands.add(RC);
      }
}
void renderControl::serializeRenderView (List<RenderView *> Views) {
    for (int viewType = 0; viewType < Count; ++viewType) {
        for (int i = 0; i < Views.size(); ++i) {
            if (Views[i].mViewType != viewType) continue;

            BindRenderTarget(
                Views[i]->renderTarget,
                Views[i]->DepthTarget);

            if (Views[i]->clearTargets) {
                ClearTarget(
                    Views[i]->clearFlags,
                    Views[i]->clearColor,
                    Views[i]->clearDepths);
            }

            for (int k = 0; k < Views[i]->commands.size(); ++k) {
                executeDrawCommand(Views[i]->commands[k]);
            }
        }
    }
}
Uses of Multi-Core in Video Games
Multithreaded Command Buffers
Device-Independent Command Buffers
A Camera-Centric Design
Future Work
• Sorting and Instancing
  – material index, vertex data, object type…
  – instancing command
    • draw command 여러 개를


• Better Load Balancing
  – draw call을 job 하나로
  – job을 잘게 나눠 thread utilization을 높임
[GEG1] 10.camera-centric engine design for multithreaded rendering
[GEG1] 10.camera-centric engine design for multithreaded rendering

More Related Content

PDF
Android RenderScript on LLVM
PPT
Enhancing the region model of RTSJ
PPT
Simple asynchronous remote invocations for distributed real-time Java
PPT
No Heap Remote Objects for Distributed real-time Java
PDF
05 - Qt External Interaction and Graphics
PPT
A synchronous scheduling service for distributed real-time Java
PPTX
Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019
PPT
Android RenderScript on LLVM
Enhancing the region model of RTSJ
Simple asynchronous remote invocations for distributed real-time Java
No Heap Remote Objects for Distributed real-time Java
05 - Qt External Interaction and Graphics
A synchronous scheduling service for distributed real-time Java
Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019

What's hot (20)

PPT
6.1.1一步一步学repast代码解释
PDF
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
PDF
04 - Qt Data
PPTX
NvFX GTC 2013
PDF
Qt on Real Time Operating Systems
PDF
The Future of Qt Widgets
PDF
[05][cuda 및 fermi 최적화 기술] hryu optimization
PPT
Threaded Programming
PDF
Qt Widget In-Depth
PPTX
vkFX: Effect(ive) approach for Vulkan API
PPTX
Java Jit. Compilation and optimization by Andrey Kovalenko
PPT
Dcom vs. corba
PDF
Qt Animation
PPT
Using QString effectively
PDF
Copy Your Favourite Nokia App with Qt
PPTX
Lecture1 classes3
PDF
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
PDF
The Unicorn Getting Interested in KDE
PDF
UA Mobile 2012 (English)
PDF
Modern OpenGL Usage: Using Vertex Buffer Objects Well
6.1.1一步一步学repast代码解释
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
04 - Qt Data
NvFX GTC 2013
Qt on Real Time Operating Systems
The Future of Qt Widgets
[05][cuda 및 fermi 최적화 기술] hryu optimization
Threaded Programming
Qt Widget In-Depth
vkFX: Effect(ive) approach for Vulkan API
Java Jit. Compilation and optimization by Andrey Kovalenko
Dcom vs. corba
Qt Animation
Using QString effectively
Copy Your Favourite Nokia App with Qt
Lecture1 classes3
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
The Unicorn Getting Interested in KDE
UA Mobile 2012 (English)
Modern OpenGL Usage: Using Vertex Buffer Objects Well
Ad

Similar to [GEG1] 10.camera-centric engine design for multithreaded rendering (20)

PDF
GPU - how can we use it?
PDF
The Explanation the Pipeline design strategy.pdf
PDF
Gdce 2010 dx11
PPTX
Mantle for Developers
PPT
CS 354 GPU Architecture
PPTX
Surface flingerservice(서피스플링거서비스초기화)
PPTX
Shader model 5 0 and compute shader
PDF
Casing3d opengl
PDF
Gdc2011 direct x 11 rendering in battlefield 3
KEY
Why Graphics Is Fast, and What It Can Teach Us About Parallel Programming
PDF
Keynote (Johan Andersson) - Mantle for Developers - by Johan Andersson, Techn...
PDF
OpenGL 4.4 - Scene Rendering Techniques
PPTX
Approaching zero driver overhead
PDF
Modern Graphics Pipeline Overview
PDF
The Ring programming language version 1.9 book - Part 176 of 210
PPTX
Penn graphics
KEY
openFrameworks 007 - 3D
PDF
Getting Started with 3D Game Development on Nokia Series 40 Asha Phones
PPTX
DirectX 11 Rendering in Battlefield 3
PPTX
Low-level Graphics APIs
GPU - how can we use it?
The Explanation the Pipeline design strategy.pdf
Gdce 2010 dx11
Mantle for Developers
CS 354 GPU Architecture
Surface flingerservice(서피스플링거서비스초기화)
Shader model 5 0 and compute shader
Casing3d opengl
Gdc2011 direct x 11 rendering in battlefield 3
Why Graphics Is Fast, and What It Can Teach Us About Parallel Programming
Keynote (Johan Andersson) - Mantle for Developers - by Johan Andersson, Techn...
OpenGL 4.4 - Scene Rendering Techniques
Approaching zero driver overhead
Modern Graphics Pipeline Overview
The Ring programming language version 1.9 book - Part 176 of 210
Penn graphics
openFrameworks 007 - 3D
Getting Started with 3D Game Development on Nokia Series 40 Asha Phones
DirectX 11 Rendering in Battlefield 3
Low-level Graphics APIs
Ad

More from 종빈 오 (20)

PDF
트위터 봇 개발 후기
PDF
적당한 스터디 발표자료 만들기 2.0
PDF
페리 수열(Farey sequence)
PDF
내가 본 미드 이야기
PDF
비트 경제와 공짜
PDF
[NDC12] 게임 물리 엔진의 내부 동작 원리 이해
PDF
[Windows via c/c++] 4장 프로세스
PDF
Intrusive data structure 소개
PDF
2011 아꿈사 오전반 포스트모템
PDF
[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81
PDF
[GEG1] 3.volumetric representation of virtual environments
PDF
넘쳐나는 정보 소화 노하우
PDF
[Domain driven design] 17장 전략의 종합
PDF
LevelDB 간단한 소개
PDF
[GEG1] 2.the game asset pipeline
PDF
[TAOCP] 2.5 동적인 저장소 할당
PDF
[GEG1] 24. key value dictionary
PDF
[TAOCP] 2.2.3 연결된 할당 - 위상정렬
PDF
[TAOCP] 1.3.1 MIX 설명
PDF
[TAOCP] 1.3.1 MIX 설명, 짝수 연습문제 풀이
트위터 봇 개발 후기
적당한 스터디 발표자료 만들기 2.0
페리 수열(Farey sequence)
내가 본 미드 이야기
비트 경제와 공짜
[NDC12] 게임 물리 엔진의 내부 동작 원리 이해
[Windows via c/c++] 4장 프로세스
Intrusive data structure 소개
2011 아꿈사 오전반 포스트모템
[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81
[GEG1] 3.volumetric representation of virtual environments
넘쳐나는 정보 소화 노하우
[Domain driven design] 17장 전략의 종합
LevelDB 간단한 소개
[GEG1] 2.the game asset pipeline
[TAOCP] 2.5 동적인 저장소 할당
[GEG1] 24. key value dictionary
[TAOCP] 2.2.3 연결된 할당 - 위상정렬
[TAOCP] 1.3.1 MIX 설명
[TAOCP] 1.3.1 MIX 설명, 짝수 연습문제 풀이

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Spectroscopy.pptx food analysis technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Programs and apps: productivity, graphics, security and other tools
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Empathic Computing: Creating Shared Understanding
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Unlocking AI with Model Context Protocol (MCP)
MIND Revenue Release Quarter 2 2025 Press Release
Spectroscopy.pptx food analysis technology
Building Integrated photovoltaic BIPV_UPV.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Digital-Transformation-Roadmap-for-Companies.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf

[GEG1] 10.camera-centric engine design for multithreaded rendering

  • 1. Game Engine Gems 1 Chap 10. Camera-Centric Engine Design for Multithreaded Rendering ohyecloudy http://ohyecloudy.com shader café http://cafe.naver.com/shader 2011.04.11
  • 2. Uses of Multi-Core in Video Games Multithreaded Command Buffers Device-Independent Command Buffers A Camera-Centric Design Future Work
  • 3. frame Main Sim Shadow Reflect Main Post- thread Update Maps Maps View Process Anim Particle Physics Update Thread Update Pool
  • 4. frame Main Sim Shadow Reflect Main Post- thread Update Maps Maps View Process Anim Particle Rendering API를 Physics Update Update 호출할 필요가 없는 작업만 Thread Pool multithread
  • 5. frame Main Sim Shadow Reflect Main Post- thread Update Maps Maps View Process Stage 별로 그룹화 Anim 각Physics Particle 직접 device call 스테이지에서 Update Thread Update Pool 그래서 device를 소유하는 thread에서 대부분 일을 처리
  • 6. Uses of Multi-Core in Video Games Multithreaded Command Buffers Device-Independent Command Buffers A Camera-Centric Design Future Work
  • 7. • 그리기 명령을 수행하는데 필요한 정보 – device level • rendering API 내부에 존재 – API를 호출하면 버퍼를 채움 – CPU 사용
  • 8. • command buffer를 추상화 – multithread로 command buffer를 채울 수 있게 – device 독립 • DX9 – multithread command buffer 불가능 – device를 소유한 thread에서만 API call – multithread를 지원 옵션이 있긴 있다 • 모든 call에 베타제어 • 성능 저하가 심함 • 제외
  • 9. Uses of Multi-Core in Video Games Multithreaded Command Buffers Device-Independent Command Buffers A Camera-Centric Design Future Work
  • 10. struct RenderCommand { ResourceHandle VertexBufferHandle; uint32 VertexDeclEnumIndex; uint32 NumTriangles; uint32 NumVerts; enum PrimType { kTriList, kTriStrip }; PrimType PrimitiveType; RenderCommand enum BlendType { kBlend_None, 드로우 콜 단위 kBlend_Standard, kBlend_Additive, kBlend_Subtractive }; BlendType BlendType; // and so on… };
  • 11. void RenderObject::fillCommandBuffer (RenderCommand *RC) { ThreadAssert(ThreadPoolThread); if (ObjectType == kTypeOpaqueMesh) { RC->VertexBufferHandle = mVBHandle; RC->VertexDeclEnumIndex = kVD_Mesh; RC->PrimitiveType = kTriList; RC->BlendType = kBlend_None; RC->NumTriangles = numTrisFromPrimType(); RC->NumVerts = mNumVerts; } else if (ObjectType == kTypeTransparentMesh) { // and so on… } }
  • 12. void RenderObject::fillCommandBuffer (RenderCommand *RC) { ThreadAssert(ThreadPoolThread); 렌더링 리소스 수명을 제어하는 객체 오브젝트 하나가 if (ObjectType == kTypeOpaqueMesh) 여러 개 RenderCommand를 만들 수 있음 { RC->VertexBufferHandle = mVBHandle; character, RC->VertexDeclEnumIndex = kVD_Mesh; terrain, RC->PrimitiveType = kTriList; … RC->BlendType = kBlend_None; RC->NumTriangles = numTrisFromPrimType(); RC->NumVerts = mNumVerts; } else if (ObjectType == kTypeTransparentMesh) { // and so on… } }
  • 13. void RenderObject::fillCommandBuffer (RenderCommand *RC) { RenderObject 상태를 단지 읽기만 한다. ThreadAssert(ThreadPoolThread); thread safe if (ObjectType == kTypeOpaqueMesh) { RC->VertexBufferHandle = mVBHandle; RC->VertexDeclEnumIndex = kVD_Mesh; RC->PrimitiveType = kTriList; RC->BlendType = kBlend_None; RC->NumTriangles = numTrisFromPrimType(); RC->NumVerts = mNumVerts; } else if (ObjectType == kTypeTransparentMesh) { // and so on… } }
  • 14. void renderControl::executeDrawCommandDx9 (const RenderCommand *params) { ThreadAssert(DeviceOwningThread); const VertexBufferContainer *vbc = mManagedVBs.getElement(params->vbHandle); DX9Dev->SetStreamSource( 0, (IDirect3DVertexBuffer9 *)vbc->devicehandle, 0, vbc->perVertSizeInBytes); SetShaderData(params); SetRenderStates(params); DX9Dev->SetVertexDeclaration( StaticVDeclHandles[params->vDecl]); D3DPRIMITIVETYPE type = PrimTypeMappingLUT[params->PrimitiveType]; DX9Dev->DrawPrimitive(type, 0, params->NumTriangles); }
  • 15. Uses of Multi-Core in Video Games Multithreaded Command Buffers Device-Independent Command Buffers A Camera-Centric Design Future Work
  • 16. • load balancing 필요 – command buffer 채우는 작업을 할당 – thread 별로 어떻게 할당? • 최종 장면이 나오기 전까지 여러 장면을 렌더링 – shadow map, reflection, post processing, … – 카메라 • 장면마다 공유
  • 17. • camera 단위 – command buffer 생성을 쪼갠다. • draw call 묶기 – API 호출에 따른 오버헤드 최소화 – render state 변경 최소화 – batch
  • 18. frame Submit Main Sim to thread Update Device Anim Render Particle Physics View Update Thread Update Filling Pool
  • 19. struct Camera { Float3 at, up, right; float aspectRatio; }; struct RenderView { Camera ViewCamera; Frustum Frust; RenderTargetHandle DestColorRTT; RenderTargetHandle DestDepthRTT; List<RenderCommand *> RenderCommands; enum ViewType { kVT_ShadowMap, kVT_ReflectionMap, kVT_MainCamera, kVT_PostProcessing, kVT_Count }; ViewType ViewType; };
  • 20. void renderControl::CreateRenderViews() { List<RenderView *> currentViews; for (int i = 0; i < mCameras.size(); ++i) { currentViews.add( new RenderView(mCameras[i], kVT_MainCamera)); } for (int i = 0; i < mLights.size(); ++i) { if (mLights[i].IsShadowCasting()) { currentViews.add( new RenderView( mLights[i].getShadowCamera(), kVT_ShadowMap)); } } for (int i = 0; i < currentViews.size(); ++i) { ThreadPool.QueueWork( procThreadedFillRenderView, currentViews[i]); } ThreadPool.waitForWorkToFinish(); }
  • 21. void renderControl::procThreadedFillRenderView ( void *DataPacket) { RenderView *currView = (RenderView *)DataPacket; List<RenderObject *> objects = gObjectManager.giveFrustumCollision( currView->frustum); for (int q = 0; q < objects.size(); ++q) { RenderCommand *RC = new RenderCommand(); Objects[q]->fillCommandBuffer(RC); currentViews[i].RenderCommands.add(RC); } }
  • 22. void renderControl::serializeRenderView (List<RenderView *> Views) { for (int viewType = 0; viewType < Count; ++viewType) { for (int i = 0; i < Views.size(); ++i) { if (Views[i].mViewType != viewType) continue; BindRenderTarget( Views[i]->renderTarget, Views[i]->DepthTarget); if (Views[i]->clearTargets) { ClearTarget( Views[i]->clearFlags, Views[i]->clearColor, Views[i]->clearDepths); } for (int k = 0; k < Views[i]->commands.size(); ++k) { executeDrawCommand(Views[i]->commands[k]); } } } }
  • 23. Uses of Multi-Core in Video Games Multithreaded Command Buffers Device-Independent Command Buffers A Camera-Centric Design Future Work
  • 24. • Sorting and Instancing – material index, vertex data, object type… – instancing command • draw command 여러 개를 • Better Load Balancing – draw call을 job 하나로 – job을 잘게 나눠 thread utilization을 높임