2010年4月30日 星期五

數學好的人較可能領高薪

過去一年中階人員平均最高薪的前五名是數學家、精算師、軟體工程師、電腦系統分析師、統計學家,他們平均年薪可以在七十三萬美元以上。不過要進這幾行,優異的數學能力將 是必備。

《華爾街日報》特別分析,在金融業紛紛裁員減薪時,數學家、精算師反而不怕。因為此 刻企業需要他們的精準的評估損失、計算風險報酬,反而穩坐高薪一族。

有好的數學頭腦進入金融、軟體、工程等領域,是未來要拿到高薪的保證。

http://tw.news.yahoo.com/article/url/d/a/100430/122/24tno.html

.....七十三萬美元會不會太多了一點,我懷疑是不是數字有問題。

老大請吃飯

今天老大說我們做的產品在北美已經通過發行認證了,所以中午請我們吃飯,吃的好飽喔~~這個產品其實我才幫忙兩個禮拜而已,個人貢獻度有限,有這樣的結果 多虧了同事們的努力,真是辛苦了!!

Shader use register constant array index

Today I wonder if using register constant array index will influence performance. I design my experiment is a three point light shading shader:
  1. Lighting color, intensity, and position all them use three constant floating to set into shader separately.
  2. Use color, intensity, and position array, their size is three for shader computing.
In the experiment result, they all have the same frame rate are 2725. So in my experiment, using register constant array index doesn't has performance penalty.

2010年4月29日 星期四

The experiment of shader programming with if-condition instruction

Today I make an experiment to talk about the if-else syntax in shader codes, how this way influences my application performance.
  1. The first one has three shaders are one point light, two point lights, and three point lights. We apply them to three different surface model.
  2. The second one, we use a shader code which writes three if condition instructions to show three types light which also be applied to three different surface model(same with upper experiment).
Finally, the experiment results show us the first one has 2639 FPS, the other is 1762 FPS. Although the second one use the same code, we can avoid reset shader to device. It tells us the if instruction will effect our performance, and it hurts degree more than reset shader to device. So all we can do is avoid to use if instruction possibly.

好想買ShaderX7

最近在研究如何規劃lighting系統,和實作shadow map的演算法。剛好這本書都有提到我想探知的topic。如果有誰有購買的可以借我翻一翻嗎?...最近的我有點窮

2010年4月25日 星期日

Shadow map develope (I)

Shadow map can help us generate full-screen shadow result. It can achieve natural self-shadow effect。But its bottleneck is hard shadow and resolution problem。
First, I want to use this dx9 sample to describe shadow map implement, shadow map is a multiple pass technique, so I divide into different term to decribe shadow map。
  1. The first pass, we need to generate the shadow map. Store the current render target and DepthStencil, then set render target to the shadow map texture, then tranform view space to lighting's view space(including projection space), write the depth value to the render target, finally resort previous render target and DepthStencil。
  2. The End pass, render the scene. Use camera's view space and projection space, set the shadow map texture, generate the shadow map martix that means transform from view space to lighting space. And in the pixel shader, we can at shadow map space to sink our shadow map texel, and using pcf(percentage closest filtering) to blur it, the texel color then compute with diffuse color is the output color.

NVemulate

NVemulate allows you to emulate the functionality of various GPUs (very slowly) in software. In addition, you can use it to control GLSL Support and Open GL 3.0 Support.

http://developer.nvidia.com/object/nvemulate.html

Dynamic Branching in Shader

Static branching vs. Dynamic branching:
  • Static one to switch on or off, based of a boolean shader constant, for disable or enable a code path。Between draw calls, you can decude which features you want to support, and set the Boolean flags to support this behavior。
  • Dynamic one the comparison condition resides in a variable, done for each vertex or each pixel at run time( not at compiling time or between two draw calls)。The performance hit is the cost of branch + the cost of the instructions on the side of the branch token。Implemented in shader model 3.0 or higher。
http://msdn.microsoft.com/en-us/library/bb944006%28VS.85%29.aspx

該討論串討論: 當GLSL在Nvidia的GPU時,遇到了雙層迴圈,執行8x8的braching運算,發生效能剩下2fps的問題。 當對於looping做unroll的動作,發現又可以回到30fps。
因此一開始猜想的內容是對於GPU的branching能力,後來發現arry index中使用了constant register index才是影響效能的關鍵,當將array的內容儲存在一個texture上,或是改用uniform array of vec3's都可以獲得改善。
http://www.gamedev.net/community/forums/topic.asp?topic_id=559196


此討論串:討論了使用if condition可能會造成執行了both branching的問題,因為compiler判斷的問題,此耗費的計算比手動切分shader code,讓flow趨向單一branching的計算相對來的多。
(result = cmp( condition, result_a, result_b ); compiler可能會用cmp的asm,而不是if - else)
http://www.gamedev.net/community/forums/topic.asp?topic_id=474592

能用static branch就別用dynamic branching,使用static branch需要將condition內使用boolean ,避免使用variable,否則會造成dyanmic branching。 如果用? : 就可以使用single instruction,而不會如if - else發生較多instruction。
http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=74db343e-e8ff-44e9-a43e-6f1615d9fce0&displayLang=en

當asm中未出現dyanmic branching的支援,反而使用cmp的instruction時,可以嘗試以下方法:
  • Texture using branch, have to use tex2Dlod rather than tex2D
  • D3DXSHADER_PREFER_FLOW_CONTROL when you call D3DXCompileShader... and of course specify ps_3_0

2010年4月11日 星期日

The first article

  這是我的第一篇文章,在這個空間我想要將我所學習到的程式經驗給記錄下來,記錄著自己一點一點進步留下的痕跡~~~