SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释
zhang shuren
 
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
changehee lee
 
[05][cuda 및 fermi 최적화 기술] hryu optimization
[05][cuda 및 fermi 최적화 기술] hryu optimization[05][cuda 및 fermi 최적화 기술] hryu optimization
[05][cuda 및 fermi 최적화 기술] hryu optimization
laparuma
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded Programming
Sri Prasanna
 
Dcom vs. corba
Dcom vs. corbaDcom vs. corba
Dcom vs. corba
Mohd Arif
 
UA Mobile 2012 (English)
UA Mobile 2012 (English)UA Mobile 2012 (English)
UA Mobile 2012 (English)
dmalykhanov
 

Mais procurados (20)

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

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

Shape12 6
Shape12 6Shape12 6
Shape12 6
pslulli
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
Stefan Marr
 
Windows Remote Management - EN
Windows Remote Management - ENWindows Remote Management - EN
Windows Remote Management - EN
Kirill Nikolaev
 

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

Shape12 6
Shape12 6Shape12 6
Shape12 6
 
[TECHCON 2019: MOBILE - iOS]4-1.ARKit, CoreML, Turi Create 삼형제
[TECHCON 2019: MOBILE - iOS]4-1.ARKit, CoreML, Turi Create 삼형제[TECHCON 2019: MOBILE - iOS]4-1.ARKit, CoreML, Turi Create 삼형제
[TECHCON 2019: MOBILE - iOS]4-1.ARKit, CoreML, Turi Create 삼형제
 
Beyond simple benchmarks—a practical guide to optimizing code
Beyond simple benchmarks—a practical guide to optimizing code Beyond simple benchmarks—a practical guide to optimizing code
Beyond simple benchmarks—a practical guide to optimizing code
 
Computer vision
Computer vision Computer vision
Computer vision
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools
 
Introduction of Android Camera1
Introduction of Android Camera1Introduction of Android Camera1
Introduction of Android Camera1
 
JVM code reading -- C2
JVM code reading -- C2JVM code reading -- C2
JVM code reading -- C2
 
Power ai image-pipeline
Power ai image-pipelinePower ai image-pipeline
Power ai image-pipeline
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine
 
Day 1
Day 1Day 1
Day 1
 
Windows Remote Management - EN
Windows Remote Management - ENWindows Remote Management - EN
Windows Remote Management - EN
 
Working in the multi-cloud with libcloud
Working in the multi-cloud with libcloudWorking in the multi-cloud with libcloud
Working in the multi-cloud with libcloud
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher - What’s new in ASP.NET Core 6Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher - What’s new in ASP.NET Core 6
 
Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overview
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
 
End to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux SagaEnd to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux Saga
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 

Mais de 종빈 오

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

Mais de 종빈 오 (20)

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

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

[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을 높임