1. 程式人生 > >GPU程式設計與CG語言

GPU程式設計與CG語言

①Cg 支援 7 種基本的資料型別:
1、float。[32 位浮點資料,一個符號位。浮點資料型別被所有的 profile 支援(但是 DirectX8 pixel profiles 在一些操作中降低了浮點數的精度和範圍)];
2、half。[16 為浮點資料];
3、int。[32 位整形資料,有些 profile 會將 int 型別作為 float 型別使用];
4、fixed。[12 位定點數,被所有的 fragment profiles 所支援];
5、bool。[布林資料,通常用於 if 和條件操作符( ?:),布林資料型別被所有的profiles 支援];
6、sampler*。[紋理物件的控制代碼( the handle to a texture object),分為 6 類:sampler, sampler1D, sampler2D,sampler3D, samplerCUBE,和 samplerRECT。DirectX profiles 不支援 samplerRECT 型別, 除此之外這些型別被所有的 pixel profiles 和 NV40 vertex program profile 所支援( CgUsersManual 30 頁)。由此可見,在不遠的未來,頂點程式也將廣泛支援紋理操作];
7、string。[字元型別,該型別不被當前存在的 profile 所支援,實際上也沒有必要在 Cg 程式中用到字元型別,但是你可以通過 Cg runtime API 宣告該型別變數,並賦值;因此,該型別變數可以儲存 Cg 檔案的資訊]。