[shaderx7] 8.1 Cross-Platform Rendering Thread : Design and Implementation

1,518 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,518
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

[shaderx7] 8.1 Cross-Platform Rendering Thread : Design and Implementation

  1. 1. ShaderX7 8.1 Cross-Platform Rendering Thread : Design and Implementation shader study http://cafe.naver.com/shader ohyecloudy http://ohyecloudy.com
  2. 2. • Motivation • Overview • Implementation • Going Further • Conclusion
  3. 3. • 프로세서 코어 퍼포먼스는 향상 – 하지만 CPU bottleneck 해결은 여전히 문제 • GPU 퍼포먼스는 향상 – 플랫폼 그래픽스 API 호출에 여전히 CPU 파워가 필요.
  4. 4. • 렌더링 작업을 decoupling. – CPU bottleneck 최소화 – GPU 퍼포먼스 낭비를 최소화
  5. 5. • Motivation • Overview • Implementation • Going Further • Conclusion
  6. 6. Threading Design Game Thread Game Client DRIVER Command Buffer Server Server API (OpenGL, DirectX, ...) Thread Server-Client Model
  7. 7. Abstraction Design • platform-specific 구현을 숨김 • rendering pipeline stage 전체를 커버
  8. 8. Command Objects • client side – 실제 동작은 없음. request 역할. • server side 1. server-API 를 사용하는 오브젝트로 빌드. 2. command가 예약된 만큼 실행 • 재생성 필요 없음
  9. 9. Command Buffer • client와 server를 연결 – client, server는 각 쓰레드가 돌고 있음. • multi-threading issue가 발생하는 곳
  10. 10. State Machine • state cache – rendering pipeline 추상화 • binding – render target state – camera state – light state – material state – transform state – ...
  11. 11. Macro State Objects • one-to-many 관계 – client state와 server state • client state – RenderTarget • server state – clear information and operation (color, flags, ...) – render buffer characteristics (size, ...) – post-effects parameters and execution (blur,...)
  12. 12. Driver Execution Process Game Client State Command Server Platform Engine Cache Buffer Graphics API DirectX Bind Queue State OpenGL Swap PS3 Build & XDK Dispatch Queue ... Command Queue
  13. 13. • Motivation • Overview • Implementation • Going Further • Conclusion
  14. 14. Driver Objects Pattern <<interface>> <<interface>> Client Command Server Command <<interface>> Command +Queue() +Build = 0() +Dispatch = 0() +Queue() +Build = 0() +Dispatch = 0() Client Draw Command Server Draw Command <<interface>> Client Draw Command +SetColor() <<interface>> Command Data Server Draw Command +Build() +Dispatch() Draw Command Data +SetColor() A B
  15. 15. Driver Objects Pattern • one-to-one X <<interface>> <<interface>> • client code Client Command Server Command +Queue() +Build = 0() +Dispatch = 0() • server code Client Draw Command Server Draw Command • lifetime이 client, server <<interface>> Command Data 분리 Draw Command Data +SetColor()
  16. 16. Three Command Objects • client command – queuing – lifetime management • command data – server code 실행에 인자로 사용 • server command – platform graphics API-specific code
  17. 17. synchronization : command buffer • double buffering – client가 하나를 채우는 동안 – server는 하나를 실행하고 비움 • synchronization points – client frame end – server frame end
  18. 18. Thread Safety : Command Data Sharing Policy • command data에 접근 – client, server 둘 다 – 퍼포먼스가 중요 – thread safe를 보장하지 않음 • 수정이 필요하면 재생성 • refcount > 0 – 수정하려면 재생성.
  19. 19. Thread Safety : Command Locking Strategy // RAII Object sxCScopeLocker oLock(rCommand); sxCCommandData& rCommandData = oLock.GetData(); if (TestSomething()) { return; }
  20. 20. • Motivation • Overview • Implementation • Going Further • Conclusion
  21. 21. Optimization : Triple Buffering Client Buffer 2 Buffer 1 Buffer 3 Buffer 1 Server Buffer 3 Buffer 2 Buffer 3
  22. 22. Command Buffer Serialization-Based • 전체 rendering command sequence 저장 • debugging에 유용하게 사용할 수 있다.
  23. 23. • Motivation • Overview • Implementation • Going Further • Conclusion
  24. 24. • wait-free rendering thread 구현 • one-to-many 관계 – client, server state • client-server 접근으로 decoupling – platform 종속적인 코드는 server에만

×