gpu programming guide for g80(dx9)
生活随笔
收集整理的這篇文章主要介紹了
gpu programming guide for g80(dx9)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
為什么80%的碼農都做不了架構師?>>> ??
http://developer.nvidia.com/object/gpu_programming_guide.html
?
大量零散的coding tips:只是針對dx9的做些筆記
?
?
vertex processing
- indexed vertex buffer 最好nvstrip一下,可以有效提高post vertex cache hit rate
- vertex attribute什么的也是一個unit(vertex assembly),attribute多了(attribute/vertex or vertex number)也會bound
- 獲取vertex輸入的時候,gpu是一個clock里面獲得attribute數量固定的,所以一個float4的attribute比一個float3+float這樣的attribute要快。
- 必要的話,用uv從texture里讀取vertex attribute
?
?
shaders
- 用盡可能高的shader model來編譯----這個真沒想到,原來的建議是用盡可能低的,不過現在的編譯器進化到了盡可能高的最好
- prefer half to float----文中說用好了性能可以快3倍,以后就跟half哥混了,可以用/Gpp來使代碼中的都變成half,用來測試性能很方便,
- 復雜的計算如果能用texture來lookup table是一個不錯的選擇
- 但是sincos,exp,log是內部指令,算起來刷刷的,就不用了。
- driver做unified shader資源的分配
- pixel shader calculation轉到vertex shader中去的時候要考慮下post vertex cache,越多的attribute輸出會導致cache效率越低
- vs輸出attribute的時候很多不必要的pack需要避免,這樣可以讓compiler更好的來優化,attribute的效率在于scalar數量,也就是一個float4和2個float2是等量的,所以多余的pack不僅沒有加速計算,反而給compiler制造麻煩
- 有內部庫可用的時候就不要自己來寫了
?
?
rasterization
- double speed z
- z cull
texture
- mipmap是好東西,少見的quality和performance都提高的好東西
- 做mipmap不要自己就直接box filter,用一些dx給的工具,gauss filter這一類的會讓結果更棒
- 用的多的surface,rendertarget什么的,先allocate
?
?
降低cpu端的api性能消耗
api調的越少越好,基本都耳熟能詳了:
- texture atlas
- instancing
- batching
- group shader constants setting
?
anti aliasing
CSAA很好,有機會用就用。
?
others:
- 8以下的gpu架構和feature截然不同,所以最好可以寫多個方案,根據不同gpu來使用不同算法
- nv hardware shadow map
- DepthBoundTest, Geforece6系列以后都有這個東東在
- direct depth buffer access用一些特殊格式,可以直接訪問depth buffer
?
原文鏈接: http://blog.csdn.net/ccanan/article/details/5905626
轉載于:https://my.oschina.net/dtec/blog/44603
總結
以上是生活随笔為你收集整理的gpu programming guide for g80(dx9)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: http://www.raytraceg
- 下一篇: smart pointer in gam