본문 바로가기

진리는어디에

DrawPrimitive와 DrawPrimitiveUP의 차이

Which should I use - the DrawPrimitive family of functions, or the DrawPrimitiveUP family?

Both construct primitives for the pipeline. However, the big difference is in their
source data - DrawPrimitive takes it from the current streams (vertex buffers),
which DrawPrimitiveUP takes it from a pointer you pass in (your own array).

둘다 얼주 비슷해 보이기는 한다. 하지만 두 함수계열의 함수가 그리는 것에 있어서는 상당한 차이점을 보인다. 바로 소스 데이터에 있어서의 차이다. DrawPrimitive 는 현재 버텍스 버퍼에있는 데이터를 가지고 그림을 그린다. 하지만 DrawPrimitiveUp함수는 일반 메모리(그러니까 RAM 정도?)에 있는 자료를 기준을 도형을 그린다.

If you're drawing less than around 100 vertices,
Direct3D automatically copies the vertices into it's own private vertex buffer,
so the DrawPrimitiveUP call is actually 'translated' into a DrawPrimitive call,
plus a memcpy (and if it's less than 100 vertices, that memcpy probably
won't be significant).

만일 100개 미만의 버텍스가 있는 오브젝트를 그릴 경우에는 Direct3D는 자동적으로 버텍스들을 독립적인 버텍스 버퍼로 카피한다. 따러서 DreawPrimitiveUp 호출은 실질적으로는 DrawPrimitive 호출로 변형 된다. 게다가 memcpy(음..그리고 그게 100개 미만의 버텍스들이라면 별로 시간이 안걸릴것 같다.)

Dan Baker (on the Microsoft Direct3D team) says: "Using DrawPrimUP for very small loads
isn't any different then creating a Dynamic Vertex Buffer And filling it yourself
- except an extra memcopy (that is negligable since the loads are small).
If you are just using it to do UI quads or sprites, then its fine.
Think of it as the 2D interface to D3D."

Dan Baker는 이렇게 말한다 : , 만약에 아주 작은 로드가 걸리는 일이라면 Dynamic Vertex Buffer 만들고 채우는 비용과 DrawPrimitiveUp을 쓰는 것은 별로 다를 바가 없다. -예외적으로 따로 메모리 카피가 필요한 경우가 있다면 모르겠다.

만약에 UI를 위한 사각형이나 스프라이트를 쓰기 위해서라면 DrawPrimitiveUp을 쓰는것이 좋을 것이다.

Javier Arevalo (at Pyro Studios) says: "In Praetorians we used DPUP for the icon-heavy in-game UI; due to a certain driver bug we ended up rewriting the display functions to use dynamic VBs, and noticed absolutely no performance improvement in any of the card / driver configurations we tried."

Tom Forsyth (at RAD Game Tools) also points out:
"DIPUP is not a bad call to make if the data is already in the CPU cache
 - for example if you have just generated the data for a particle system or something.

In that case, DIPUP is a pretty good call to use."

유익한 글이었다면 공감(❤) 버튼 꾹!! 추가 문의 사항은 댓글로!!