DirectX 12 ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง(Multi-Thread Rendering)

2020. 8. 1. 19:03ใ†PROGRAMMING/DirectX 12

 

 

 

 

 

[ DirectX 12 ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง(Multi-Thread Rendering ]

 

๊ตฌํ˜„ ๊ธฐ๊ฐ„์€ ์ƒ˜ํ”Œ ์ฝ”๋“œ ๋ถ„์„ 3์ผ, ํ”„๋กœ์ ํŠธ์— ์ ์šฉ 4์ผ. ์•ฝ ์ผ์ฃผ์ผ ์ •๋„ ์‹œ๊ฐ„์ด ์†Œ์š”๋๋‹ค.

ํ˜„์žฌ ํ”„๋กœ์ ํŠธ์—์„œ ์‚ฌ์šฉ ์ค‘์ธ ์Šค๋ ˆ๋“œ์˜ ๊ฐœ์ˆ˜๋Š” 4๊ฐœ์ด๋‹ค.

์‹ฑ๊ธ€ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง๊ณผ ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง์˜ ์„ฑ๋Šฅ์„ ๋น„๊ตํ•ด๋ณด๊ฒ ๋‹ค.

์šฐ์„  ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ๋ฉ”์‰ฌ ๋ชจ๋ธ ๋ฐ์ดํ„ฐ์˜ ์ •๋ณด์ด๋‹ค.

 

StaticMesh Info

์• ๋‹ˆ๋ฉ”์ด์…˜ ์ •๋ณด๊ฐ€ ์—†๋Š” ์Šคํƒœํ‹ฑ ๋ฉ”์‰ฌ์˜ ๊ฒฝ์šฐ

vertex ์ •์  11,400๊ฐœ / index 3,800๊ฐœ์ด๋‹ค.

 

DynamicMesh Info

์• ๋‹ˆ๋ฉ”์ด์…˜ ์Šคํ‚ค๋‹์„ ํ•ด์•ผ ํ•˜๋Š” ๋‹ค์ด๋‚˜๋ฏน ๋ฉ”์‰ฌ์˜ ๊ฒฝ์šฐ

vertex ์ •์  51,294๊ฐœ / index 17,096๊ฐœ์ด๋‹ค. 

 

๋ชจ๋“  ์˜ค๋ธŒ์ ํŠธ์— ๋Œ€ํ•ด์„œ ์ธ์Šคํ„ด์‹ฑ์€ ์ ์šฉ X.

๋ชจ๋“  ์˜ค๋ธŒ์ ํŠธ๋Š” vertex ์…ฐ์ด๋”์™€ pixel ์…ฐ์ด๋”๋ฅผ ํ†ตํ•ด ๋ Œ๋”๋ง ํ•œ๋‹ค.

 

๋…ธํŠธ๋ถ ๊ธฐ๊ธฐ ์‚ฌ์–‘.

 

[ 1. StaticMesh x 1,000 ]  

 

ํ•œ ๋ฒˆ ์žฅ๋ฉด์„ ๊ทธ๋ฆด ๋•Œ๋งˆ๋‹ค ๊ทธ๋ฆฌ๋Š” vertex์˜ ๊ฐœ์ˆ˜๋Š” 11,400 * 1,000 = 11,400,000๊ฐœ.

๊ทธ๋ฆผ์ž ๊นŠ์ด๊นŒ์ง€ ์ด 2๋ฒˆ์„ ๊ทธ๋ฆฌ๋ฏ€๋กœ 11,400,000 * 2 = 22,800,000๊ฐœ ์ด๋‹ค.

 

์‹ฑ๊ธ€์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

์Šคํƒœํ‹ฑ ๋ฉ”์‹œ 1,000๊ฐœ๋ฅผ ์‹ฑ๊ธ€ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง ํ•  ๊ฒฝ์šฐ ์•ฝ 50 FPS๊ฐ€ ๋‚˜์˜จ๋‹ค.

(์ขŒ์ธก ํ•˜๋‹จ or ์šฐ์ธก ์ƒ๋‹จ์˜ FPS ์ •๋ณด ์ถœ๋ ฅ)

 

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

์Šคํƒœํ‹ฑ ๋ฉ”์‹œ 1,000๊ฐœ๋ฅผ ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋งํ•  ๊ฒฝ์šฐ ์•ฝ 55 FPS๊ฐ€ ๋‚˜์˜จ๋‹ค.

(์ขŒ์ธก ํ•˜๋‹จ or ์šฐ์ธก ์ƒ๋‹จ์˜ FPS ์ •๋ณด ์ถœ๋ ฅ)

์„ฑ๋Šฅ์ด ์•ฝ 10% ํ–ฅ์ƒ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. (50 FPS --> 55 FPS)

 

 

 

[ 2. StaticMesh x 3,000 ]  

 

ํ•œ ๋ฒˆ ์žฅ๋ฉด์„ ๊ทธ๋ฆด ๋•Œ๋งˆ๋‹ค ๊ทธ๋ฆฌ๋Š” vertex์˜ ๊ฐœ์ˆ˜๋Š” 11,400 * 3,000 = 34,200,000๊ฐœ.

๊ทธ๋ฆผ์ž ๊นŠ์ด๊นŒ์ง€ ์ด 2๋ฒˆ์„ ๊ทธ๋ฆฌ๋ฏ€๋กœ 34,200,000 * 2 = 68,400,000๊ฐœ์ด๋‹ค.

 

์‹ฑ๊ธ€์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

์Šคํƒœํ‹ฑ ๋ฉ”์‹œ 3,000๊ฐœ๋ฅผ ์‹ฑ๊ธ€ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง ํ•  ๊ฒฝ์šฐ ์•ฝ 20 FPS๊ฐ€ ๋‚˜์˜จ๋‹ค.

(์ขŒ์ธก ํ•˜๋‹จ or ์šฐ์ธก ์ƒ๋‹จ์˜ FPS ์ •๋ณด ์ถœ๋ ฅ)

 

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

์Šคํƒœํ‹ฑ ๋ฉ”์‹œ 3,000๊ฐœ๋ฅผ ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋งํ•  ๊ฒฝ์šฐ ์•ฝ 24 FPS๊ฐ€ ๋‚˜์˜จ๋‹ค.

(์ขŒ์ธก ํ•˜๋‹จ or ์šฐ์ธก ์ƒ๋‹จ์˜ FPS ์ •๋ณด ์ถœ๋ ฅ)

์„ฑ๋Šฅ์ด ์•ฝ 20% ํ–ฅ์ƒ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. (20 FPS --> 24 FPS)

 

 

 


 

 

 

[ 1. DynamicMesh x 100 ] 

 

ํ•œ ๋ฒˆ ์žฅ๋ฉด์„ ๊ทธ๋ฆด ๋•Œ๋งˆ๋‹ค ๊ทธ๋ฆฌ๋Š” vertex์˜ ๊ฐœ์ˆ˜๋Š” 51,294 * 100 = 5,129,400๊ฐœ.

๊ทธ๋ฆผ์ž ๊นŠ์ด๊นŒ์ง€ ์ด 2๋ฒˆ์„ ๊ทธ๋ฆฌ๋ฏ€๋กœ 5,129,400 * 2 = 10,258,800๊ฐœ์ด๋‹ค.

 

์‹ฑ๊ธ€ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

๋‹ค์ด๋‚˜๋ฏน ๋ฉ”์‹œ 100๊ฐœ๋ฅผ ์‹ฑ๊ธ€ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง ํ•  ๊ฒฝ์šฐ ์•ฝ 36 ~ 37 FPS๊ฐ€ ๋‚˜์˜จ๋‹ค.

(์ขŒ์ธก ํ•˜๋‹จ or ์šฐ์ธก ์ƒ๋‹จ์˜ FPS ์ •๋ณด ์ถœ๋ ฅ)

 

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

๋‹ค์ด๋‚˜๋ฏน ๋ฉ”์‹œ 100๊ฐœ๋ฅผ ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋งํ•  ๊ฒฝ์šฐ ์•ฝ 40 ~ 41 FPS๊ฐ€ ๋‚˜์˜จ๋‹ค.

(์ขŒ์ธก ํ•˜๋‹จ or ์šฐ์ธก ์ƒ๋‹จ์˜ FPS ์ •๋ณด ์ถœ๋ ฅ)

์„ฑ๋Šฅ์ด ์•ฝ 10% ํ–ฅ์ƒ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. (36 FPS --> 40 FPS)

 

 

 

[ 2. DynamicMesh x 200 ] 

 

ํ•œ ๋ฒˆ ์žฅ๋ฉด์„ ๊ทธ๋ฆด ๋•Œ๋งˆ๋‹ค ๊ทธ๋ฆฌ๋Š” vertex์˜ ๊ฐœ์ˆ˜๋Š” 51,294 * 200 = 10,258,800๊ฐœ.

๊ทธ๋ฆผ์ž ๊นŠ์ด๊นŒ์ง€ ์ด 2๋ฒˆ์„ ๊ทธ๋ฆฌ๋ฏ€๋กœ 10,258,800 * 2 = 20,517,600๊ฐœ์ด๋‹ค.

 

์‹ฑ๊ธ€์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

๋‹ค์ด๋‚˜๋ฏน ๋ฉ”์‹œ 200๊ฐœ๋ฅผ ์‹ฑ๊ธ€ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง ํ•  ๊ฒฝ์šฐ ์•ฝ 19 ~ 20 FPS๊ฐ€ ๋‚˜์˜จ๋‹ค.

(์ขŒ์ธก ํ•˜๋‹จ or ์šฐ์ธก ์ƒ๋‹จ์˜ FPS ์ •๋ณด ์ถœ๋ ฅ)

 

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

๋‹ค์ด๋‚˜๋ฏน ๋ฉ”์‹œ 200๊ฐœ๋ฅผ ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋งํ•  ๊ฒฝ์šฐ ์•ฝ 22 ~ 23 FPS๊ฐ€ ๋‚˜์˜จ๋‹ค.

(์ขŒ์ธก ํ•˜๋‹จ or ์šฐ์ธก ์ƒ๋‹จ์˜ FPS ์ •๋ณด ์ถœ๋ ฅ)

์„ฑ๋Šฅ์ด ์•ฝ 10% ~ 15% ํ–ฅ์ƒ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. (20 FPS --> 23 FPS)

 

 

 

[ ์ •๋ฆฌ ]

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง์„ ํ•  ๊ฒฝ์šฐ ์•ฝ 10% ~ 20%์˜ ๋ Œ๋”๋ง ์„ฑ๋Šฅ ํ–ฅ์ƒ์„ ๊ธฐ๋Œ€ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

 

์Šค๋ ˆ๋“œ๋ฅผ 4๊ฐœ๋ฅผ ์‚ฌ์šฉํ•˜์˜€์ง€๋งŒ ์„ฑ๋Šฅ ํ–ฅ์ƒ์ด 4๋ฐฐ๊ฐ€ ๋˜์ง€ ์•Š๋Š” ์ด์œ ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

1. DirectX 12์—์„œ CommandList์— ๋ Œ๋”๋ง ๋ช…๋ น์„ ๋™์‹œ์— 4๊ฐœ์˜ ์Šค๋ ˆ๋“œ์—์„œ ๋‹ด๋Š” ๊ฒƒ์ด์ง€

๋™์‹œ์— ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

์‹ฑ๊ธ€์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

์ฆ‰, ์‹ฑ๊ธ€ ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง์—์„œ๋Š” ๋ Œ๋”๋ง ๋ช…๋ น๋“ค์ด ๋ชจ๋‘ ๋“ค์–ด์˜จ ์ดํ›„์— GPU๊ฐ€ ์ž‘์—…์„ ์‹œ์ž‘ํ•œ๋‹ค.

๋ช…๋ น์ด ์ถ”๊ฐ€๋˜๋Š” ๋™์•ˆ์—๋Š” GPU๋Š” ์ผ์„ ์•ˆ ํ•˜๊ณ  ๋†€๊ณ  ์žˆ๋Š” ๊ฒƒ์ด๋‹ค.

 

 

 

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง

DirectX 12 ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ๋ Œ๋”๋ง์€

์Šค๋ ˆ๋“œ(Thread)๋ฅผ ํ†ตํ•ด ๋ช…๋ น๋“ค์„ ๋น ๋ฅด๊ฒŒ GPU์— ๋„ฃ์–ด์ค˜์„œ ์‹คํ–‰์‹œํ‚ค๊ณ ,

๋ช…๋ น๋“ค์ด ์‹คํ–‰๋˜๋Š” ๋™์‹œ์— ์•„์ง ๋‚จ์•„์žˆ๋Š” ๋ช…๋ น๋“ค์„ GPU๋กœ ๋‹ค์‹œ ๋ณด๋ƒ„์œผ๋กœ์จ

GPU๊ฐ€ ๋ Œ๋”๋ง ์‹œ์ž‘ ์‹œ ์‰ฌ๊ณ  ์žˆ๋Š” ์‹œ๊ฐ„์„ ์ตœ์†Œํ™”ํ•˜๋Š” ๊ฒƒ์ด ๋ชฉ์ ์ด๋‹ค.

 

 

2. ๋ Œ๋”๋ง ์ˆœ์„œ ๋™๊ธฐํ™”๋ฅผ ์œ„ํ•œ ExecuteCommandLists() ํ•จ์ˆ˜ ํ˜ธ์ถœ ํšŸ์ˆ˜.

๊ทธ๋ฆผ์ž ๊นŠ์ด ๋งต์ด ๋จผ์ € ๊ทธ๋ ค์ง€๊ณ , ์ดํ›„์— ์˜ค๋ธŒ์ ํŠธ๋“ค์ด ๊ทธ๋ ค์ ธ์•ผ ํ•˜๋ฏ€๋กœ

์ด ๋™๊ธฐํ™” ์ˆœ์„œ๋ฅผ ๋งž์ถ”๊ธฐ ์œ„ํ•ด ExecuteCommandLists() ํ•จ์ˆ˜ ํ˜ธ์ถœ ํšŸ์ˆ˜๊ฐ€ ๋งŽ์•„์กŒ๋‹ค.

ExecuteCommandLists()๋Š” ๊ต‰์žฅํžˆ ๋ฌด๊ฑฐ์šด ์ž‘์—…์„ ํ•˜๋Š” ํ•จ์ˆ˜์ด๊ธฐ ๋•Œ๋ฌธ์—

ํ˜ธ์ถœ ํšŸ์ˆ˜๊ฐ€ ๋งŽ์•„์ง€๋ฉด ์„ฑ๋Šฅ์ด ๋–จ์–ด์ง€๊ฒŒ ๋œ๋‹ค.

 

 

 

 

 

microsoft/DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows. - microsoft/DirectX-Graphics-Samples

github.com

์Šค๋ ˆ๋“œ ์ˆœ์„œ ๋™๊ธฐํ™” - MicroSoft์˜ DirectX 12 ์ƒ˜ํ”Œ ์˜ˆ์ œ๋ฅผ ์ฐธ์กฐ.

 

 

Tips and experience of DX12 Engine development .

Tips and experience of DX12 Engine development .

www.slideshare.net

CommandList ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ๋ชจ๋ธ - ์œ ์˜์ฒœ ๋‹˜์˜ PPT ์Šฌ๋ผ์ด๋“œ๋ฅผ ์ฐธ์กฐ.

 

 

Understanding DirectX* Multithreaded Rendering Performance by...

This article disclosed the performance characteristics of DirectX multithreading with a series of experiments based on the modified and extended workload of official DirectX samples.

software.intel.com

์ด ์™ธ ์ฐธ๊ณ  ์ž๋ฃŒ ์‚ฌ์ดํŠธ.