为什么第一次没有出血| 手足口是什么引起的| 最近我和你都有一样的心情什么歌| 为什么会长瘊子| 喜鹊叫有什么兆头| 喝茶对身体有什么好处| 粳米是什么米| 棚改是什么意思| ssg是什么意思| 二黑是什么意思| 手足口病有什么危害| 学名是什么意思| 为什么要拔掉智齿| 氯吡格雷治什么病| 梦到自己掉牙齿是什么预兆| 李宁是什么牌子| bella是什么意思| 别来无恙什么意思| 流产是什么意思| 小孩手指脱皮是什么原因| 肠子有问题有什么症状| 不胜感激是什么意思| 血压偏低有什么症状| 儿童鼻窦炎吃什么药| 小处男是什么意思| edd什么意思| 叉烧是什么肉做的| 肝主疏泄是什么意思| 透析什么意思| 冰激凌和冰淇淋有什么区别| 被利用的信任是什么歌| 五月二十四号是什么星座| 生普洱和熟普洱有什么区别| 19岁属什么生肖| 周海媚什么病| 调理是什么意思| 没什么好怕| plcc是什么意思| enne是什么烟| 效果图是什么意思| 什么是化学| 为什么不能打死飞蛾| 巨蟹座与什么星座最配| acb是什么意思| 啪啪啪是什么意思| 遗留是什么意思| 奔富红酒属于什么档次| 月亮象征着什么| 什么是甲状腺结节| 玛瑙五行属什么| 为什么尽量抽混合型烟| 老古董是什么意思| 鱼鳔是什么| 精液是什么颜色的| 间歇性跛行见于什么病| 心烦意乱吃什么药| vintage是什么牌子| 3p什么意思| 一个虫一个夫念什么| 九二共识是什么| 十面埋伏是什么生肖| 岔气了吃什么药| 今天中国什么节日| 6月五行属什么| 多喝水有什么好处| 颠是什么意思| 神经是什么意思| 法令纹深是什么原因| ooc什么意思| 指责的意思是什么| s1隐裂是什么意思| 1007是什么星座| 手指腱鞘炎是什么原因造成的| 支气管炎挂什么科| 梅花鹿吃什么食物| 胎儿头围偏大什么原因| 怀孕可以吃什么| 胃不舒服吃什么| 蚕豆病不能吃什么药| 为什么流褐色分泌物| 广州白云区有什么好玩的地方| 小腹胀是什么原因女性| 高血脂看什么科| 男生生日礼物送什么| 女性掉发严重是什么原因| 308什么意思| 2月12日什么星座| 3月6号是什么星座的| 正值当年什么意思| 考试前吃什么好| 区级以上医院是什么意思| 慢慢地什么填词语| 氟利昂是什么味道| 脚心发热是什么原因| 扁桃体是什么样子图片| 劝酒什么意思| 一直想吐是什么原因| diss是什么意思| 看破不说破什么意思| 中位数什么意思| 土耳其浴是什么意思| 广州有什么玩的| 宫颈癌是什么| 血浓度高是什么原因| 怀孕拉肚子吃什么药| 凯撒沙拉酱是什么口味| 舌头干燥是什么原因| 鹿柴什么意思| 昙花一现是什么生肖| 监督的近义词是什么| 扶摇是什么意思| 路虎为什么叫奇瑞路虎| 孕检唐筛是检查什么的| 唐筛都检查什么| 咳嗽一直不好是什么原因| 淋巴细胞数偏高是什么意思| 养猫有什么好处| 什么事情只能用一只手去做| 家乡是什么意思| 做nt需要准备什么| 十月十一是什么星座| 中暑不能吃什么| est.是什么意思| 什么样的男人不能嫁| 吃天麻对身体有什么好处| 毛的部首是什么| 药店属于什么行业| ev71是什么疫苗| 羊冲什么生肖| 夺嫡是什么意思| 好逸恶劳什么意思| 太瘦的人吃什么能长胖| 1月18日什么星座| 追求是什么意思| 银杯子喝水有什么好处与坏处| 变爻是什么意思| 尿路感染吃什么药| 什么样的人容易垂体瘤| 女生肚子大是什么原因| 什么是量子力学| 7月15日是什么节日| 圣水是什么| 梦到别人结婚是什么意思| 少年班是什么意思| 我俩太不公平这是什么歌| 婴儿第一次发烧叫什么| 灰度是什么意思| 陌上花开可缓缓归矣什么意思| 奎字五行属什么| 1年是什么朝代| 暗网是什么| 抑郁症是什么原因造成| 下午四点多是什么时辰| 双恋是什么意思| 什么品种的鸡肉最好吃| 牛蒡是什么东西| ganni是什么牌子| 口腔检查挂什么科| 右眼袋跳动是什么原因| 乙肝两对半15阳性是什么意思| 手脚脱皮是什么原因导致的| 长高吃什么钙片| 咳嗽是什么原因| 舌头麻木吃什么药| 水瓶座是什么星座| 六月初一是什么日子| 禁果什么意思| 淋巴结发炎挂什么科| 4月20是什么星座| 支原体阳性是什么意思| 吃无花果有什么好处| 虫离念什么| 肛瘘是什么情况| 经常梳头有什么好处| 尿毒症有什么症状| 油菜花是什么颜色| 神经纤维瘤是什么病| 墨池为什么不爱柔嘉了| 滴虫长什么样子图片| 女性漏尿吃什么药最好| 胸口疼应该挂什么科| 肚子里面跳动是什么原因| 反复是什么意思| 一什么河| 舌头麻是什么病的前兆| 为什么会长扁平疣| 乳腺病是什么意思| 排除是什么意思| 银耳是什么| 马上风为什么拔不出来| 头发汗多是什么原因| 喉咙老是有白痰是什么原因| 中盐是什么盐| 为什么学习| 为什么不能摸猫的肚子| 不值一提是什么意思| 可见原始心管搏动是什么意思| 对偶是什么| 肝在五行中属什么| mrsa是什么细菌| 隐性梅毒是什么意思| 交警大队长是什么级别| 男士私处用什么清洗| 牛什么饭| 肾结石吃什么水果好| vmd是什么意思| 暧昧什么意思| 718什么星座| 婴儿放屁多是什么原因| 自渡是什么意思| 多汗症吃什么药| 车前草有什么作用| 精氨酸是什么| 水晶和玻璃有什么区别| 鸡奸是什么意思| 离退休是什么意思| 胃部检查除了胃镜还有什么方法| 鼻子老是出血是什么原因| 外阴溃烂用什么药| sd是什么意思| hpv6阳性是什么意思| 刮脸有什么好处与坏处| 得道是什么意思| 腰疼贴什么膏药| 查肝功能能查出什么病| 5月16日是什么星座| 男人地盘是什么生肖| 头孢喝酒有什么反应| 今年16岁属什么生肖| 什么眼镜框最轻最舒服| 吃什么东西减肥最快| 吃烧烤后吃什么水果可以帮助排毒| 肠胃炎应该注意什么| 野生刺猬吃什么| 7.13什么星座| 醪糟是什么| 团购是什么意思| 祈祷是什么意思| 百合有什么功效| 生是什么生肖| 安踏高端品牌叫什么| 什么叫代孕| 十月一日是什么星座| 属狗女和什么属相最配| 逆光是什么意思| 绿色加什么颜色是蓝色| ev71是什么疫苗| penguin是什么意思| 呦呦鹿鸣什么意思| 赶尽杀绝什么意思| 流沙是什么意思| 易孕体质是什么意思| 什么是白平衡| 琳琅是什么意思| 吃驼奶粉有什么好处| 路人甲什么意思| 黑金刚是什么药| 硬卧代硬座是什么意思| 液蜡是什么| 减肥期间吃什么水果| 艾附暖宫丸什么时候吃| 为什么睾丸一边大一边小| 佩戴貔貅有什么讲究与禁忌| 什么是癫痫| 百度Jump to content

【奥迪Q5幻影黑外观图片】奥迪Q5

From Wikipedia, the free encyclopedia
Cg/HLSL
A scene containing several different 2D HLSL shaders. Distortion of the statue is achieved purely physically, while the texture of the rectangular frame beside it is based on color intensity. The square in the background has been transformed and rotated. The partial transparency and reflection of the water in the foreground are added by a shader applied finally to the entire scene.
Familyshading language
DevelopernVIDIA, Microsoft
Websitedeveloper.nvidia.com/cg-toolkit
Dialects
Cg, HLSL, Playstation Shading Language
Influenced by
C, RenderMan Shading Language
Influenced
GLSL
百度 如果说,一家企业领跑行业的发展状态容易在人们心中固化,那么,持续的优秀也就成为了人们眼中自然而然的期许。

Cg (short for C for Graphics) and High-Level Shader Language (HLSL) are two names given to a high-level shading language developed by Nvidia and Microsoft for programming shaders. Cg/HLSL is based on the C programming language and although they share the same core syntax, some features of C were modified and new data types were added to make Cg/HLSL more suitable for programming graphics processing units.[1][2]

Two main branches of the Cg/HLSL language exist: the Nvidia Cg compiler (cgc) which outputs DirectX or OpenGL and the Microsoft HLSL which outputs DirectX shaders in bytecode format.[3][4] Nvidia's cgc was deprecated in 2012, with no additional development or support available.[5]

HLSL shaders can enable many special effects in both 2D and 3D computer graphics. The Cg/HLSL language originally only included support for vertex shaders and pixel shaders, but other types of shaders were introduced gradually as well:

Background

[edit]

Due to technical advances in graphics hardware, some areas of 3D graphics programming have become quite complex. To simplify the process, new features were added to graphics cards, including the ability to modify their rendering pipelines using vertex and pixel shaders.

In the beginning, vertex and pixel shaders were programmed at a very low level with only the assembly language of the graphics processing unit. Although using the assembly language gave the programmer complete control over code and flexibility, it was fairly hard to use. A portable, higher level language for programming the GPU was needed, so Cg was created to overcome these problems and make shader development easier.

Some of the benefits of using Cg over assembly are:

  • High level code is easier to learn, program, read, and maintain than assembly code.
  • Cg code is portable to a wide range of hardware and platforms, unlike assembly code, which usually depends on hardware and the platforms it's written for.
  • The Cg compiler can optimize code and do lower level tasks automatically, which are hard to do and error prone in assembly.

Language

[edit]

Data types

[edit]

Cg has six basic data types. Some of them are the same as in C, while others are especially added for GPU programming. These types are:

  • float - a 32bit floating point number
  • half - a 16bit floating point number
  • int - a 32bit integer
  • fixed - a 12bit fixed point number
  • bool - a Boolean variable
  • sampler* - represents a texture object

Cg also features vector and matrix data types that are based on the basic data types, such as float3 and float4x4. Such data types are quite common when dealing with 3D graphics programming. Cg also has struct and array data types, which work in a similar way to their C equivalents.

Operators

[edit]

Cg supports a wide range of operators, including the common arithmetic operators from C, the equivalent arithmetic operators for vector and matrix data types, and the common logical operators.

Functions and control structures

[edit]

Cg shares the basic control structures with C, like if/else, while, and for. It also has a similar way of defining functions.

Semantics

[edit]

Preprocessor

[edit]

Cg implements many C preprocessor directives and its macro expansion system. It implements #include.[7]

HLSL features

[edit]
  • Namespace
  • Annotation

Environment

[edit]

Compilation targets

[edit]

Cg programs are built for different shader profiles that stand for GPUs with different capabilities.[8] These profiles decide, among others, how many instructions can be in each shader, how many registers are available, and what kind of resources a shader can use. Even if a program is correct, it might be too complex to work on a profile.[7]

As the number of profile and shader types cropped up, Microsoft has switched to use the term "Shader Model" to group a set of profiles found in a generation of GPUs.[9] Cg supports some of the newer profiles up to Shader Model 5.0 as well as translation to glsl or hlsl.[8]

Comparison of HLSL pixel shaders
Pixel shader version 1.0 to 1.3[10] 1.4[10] 2.0[10][11] 2.0a[10][11][12] 2.0b[10][11][13] 3.0[10][14] 4.0[15]
4.1[16]
5.0[17]
Dependent texture limit 4 6 8 Unlimited 8 Unlimited Unlimited
Texture instruction limit 4 6*2 32 Unlimited Unlimited Unlimited Unlimited
Position register No No No No No Yes Yes
Instruction slots 8+4 8+4 32 + 64 512 512 ≥ 512 ≥ 65536
Executed instructions 8+4 6*2+8*2 32 + 64 512 512 65536 Unlimited
Texture indirections 4 4 4 Unlimited 4 Unlimited Unlimited
Interpolated registers 2 + 4 2 + 6 2 + 8 2 + 8 2 + 8 10 32
Instruction predication No No No Yes No Yes No
Index input registers No No No No No Yes Yes
Temp registers 2 6 12 to 32 22 32 32 4096
Constant registers 8 8 32 32 32 224 16×4096
Arbitrary swizzling No No No Yes No Yes Yes
Gradient instructions No No No Yes No Yes Yes
Loop count register No No No No No Yes Yes
Face register (2-sided lighting) No No No No Yes Yes Yes
Dynamic flow control No No No No No Yes (24) Yes (64)
Bitwise Operators No No No No No No Yes
Native Integers No No No No No No Yes
  • PS 1.0 — Unreleased 3dfx Rampage, DirectX 8.
  • PS 1.1GeForce 3, DirectX 8.
  • PS 1.23Dlabs Wildcat VP, DirectX 8.0a.
  • PS 1.3GeForce 4 Ti, DirectX 8.0a.
  • PS 1.4Radeon 8500-9250, Matrox Parhelia, DirectX 8.1.
  • Shader Model 2.0Radeon 9500-9800/X300-X600, DirectX 9.
  • Shader Model 2.0aGeForce FX/PCX-optimized model, DirectX 9.0a.
  • Shader Model 2.0bRadeon X700-X850 shader model, DirectX 9.0b.
  • Shader Model 3.0Radeon X1000 and GeForce 6, DirectX 9.0c.
  • Shader Model 4.0Radeon HD 2000 and GeForce 8, DirectX 10.
  • Shader Model 4.1Radeon HD 3000 and GeForce 200, DirectX 10.1.
  • Shader Model 5.0Radeon HD 5000 and GeForce 400, DirectX 11.
  • Shader Model 5.1GCN 1+, Fermi+, DirectX 12 (11_0+) with WDDM 2.0.
  • Shader Model 6.0 — GCN 1+, Kepler+, DirectX 12 (11_0+) with WDDM 2.1.
  • Shader Model 6.1 — GCN 1+, Kepler+, DirectX 12 (11_0+) with WDDM 2.3.
  • Shader Model 6.2 — GCN 1+, Kepler+, DirectX 12 (11_0+) with WDDM 2.4.
  • Shader Model 6.3 — GCN 1+, Kepler+, DirectX 12 (11_0+) with WDDM 2.5.
  • Shader Model 6.4 — GCN 1+, Kepler+, Skylake+, DirectX 12 (11_0+) with WDDM 2.6.
  • Shader Model 6.5 — GCN 1+, Kepler+, Skylake+, DirectX 12 (11_0+) with WDDM 2.7.

"32 + 64" for Executed Instructions means "32 texture instructions and 64 arithmetic instructions."

Comparison of HLSL Vertex shaders
Vertex shader version VS 1.1[18] VS 2.0[11][18][19] VS 2.0a[11][18][19] VS 3.0[14][18] VS 4.0[15]
VS 4.1[20]
VS 5.0[17]
# of instruction slots 128 256 256 ≥ 512 ≥ 65536
Max # of instructions executed 128 1024 65536 65536 Unlimited
Instruction predication No No Yes Yes Yes
Temp registers 12 12 16 32 4096
# constant registers ≥ 96 ≥ 256 256 ≥ 256 16×4096
Static flow control No Yes Yes Yes Yes
Dynamic flow control No No Yes Yes Yes
Dynamic flow control depth 24 24 64
Vertex texture fetch No No No Yes Yes
# of texture samplers 4 128
Geometry instancing support No No No Yes Yes
Bitwise operators No No No No Yes
Native integers No No No No Yes

The standard library

[edit]

As in C, Cg/HLSL features a set of functions for common tasks in GPU programming. Some of the functions have equivalents in C, like the mathematical functions abs and sin, while others are specialized in GPU programming tasks, like the texture mapping functions tex1D and tex2D.

The Cg runtime library

[edit]

Cg programs are merely vertex and pixel shaders, and they need supporting programs that handle the rest of the rendering process. Cg can be used with two graphics APIs: OpenGL or DirectX. Each has its own set of Cg functions to communicate with the Cg program, like setting the current Cg shader, passing parameters, and such tasks.

In addition to being able to compile Cg source to assembly code, the Cg runtime also has the ability to compile shaders during execution of the supporting program. This allows the runtime to compile the shader using the latest optimizations available for hardware that the program is currently executing on. However, this technique requires that the source code for the shader be available in plain text to the compiler, allowing the user of the program to access the source-code for the shader. Some developers view this as a major drawback of this technique.

To avoid exposing the source code of the shader, and still maintain some of the hardware specific optimizations, the concept of profiles was developed. Shaders can be compiled to suit different graphics hardware platforms (according to profiles). When executing the supporting program, the best/most optimized shader is loaded according to its profile. For instance there might be a profile for a graphics card that supports complex pixel shaders, and another profile for one that supports only minimal pixel shaders. By creating a pixel shader for each of these profiles a supporting program enlarges the number of supported hardware platforms without sacrificing picture quality on powerful systems.'

Compilers and dialects

[edit]

The Cg dialect has only ever had one compiler, in the form of Nvidia's Cg toolkit.

Microsoft has released two compilers for HLSL. The original compiler was the closed-source FXC (Effect Compiler), supported until 2015. It was deprecated in favor of the open-source LLVM-based DXC (DirectXShaderCompiler) with support for newer HLSL features.[21] Both compilers generate bytecode: while the older FXC used DXBC, DXC now uses DXIL. DXC can also emit SPIR-V bytecode.[22]

The Khronos Group has also written a LLVM-based HLSL compiler, in the form of a frontend for glslang, their GLSL-to-SPIR_V compiler. Support for SPIR-V means that the shaders can be cross-platform, no longer limiting them to a DirectX stack.[23] This task was previously performed by source-level converters like HLSL2GLSL, but the resulting code is often bloated.[24]

Derived languages

[edit]

The PlayStation Shader Language (PSSL) is based on Cg/HLSL.[25]

The ReshadeFX shading language is also based on Cg/HLSL. Shaders written in ReshadeFX are compiled to OpenGL, DX, or Vulkan and injected into games to act as post-processing filters.[26]

Applications and games that use Cg or HLSL

[edit]

See also

[edit]

References

[edit]
  1. ^ "Fusion Industries :: Cg and HLSL FAQ ::". 24 August 2012. Archived from the original on 24 August 2012.
  2. ^ "The Cg Tutorial - Chapter 1. Introduction". developer.download.nvidia.cn.
  3. ^ "Writing HLSL Shaders in Direct3D 9 (Windows)". msdn.microsoft.com. 24 May 2021.
  4. ^ "Cg FAQ". NVIDIA DesignWorks. 8 March 2011. Retrieved 25 May 2017.
  5. ^ "Cg Toolkit | NVIDIA Developer". 8 March 2011.
  6. ^ "Cg 2.0 Release Notes" (PDF). nvidia.com. January 2008.
  7. ^ a b Mark J. Kilgard, Cg in Two Pages, 2003.
  8. ^ a b "Cg Profile Documentation". Nvidia developer.
  9. ^ "Shader Models vs Shader Profiles - Win32 apps". docs.microsoft.com. 30 June 2021.
  10. ^ a b c d e f "Pixel Shader Differences". msdn.microsoft.com. 2025-08-06.
  11. ^ a b c d e Peeper, Craig (2025-08-06). "Microsoft DirectX High Level Shader Language (HLSL)" (PPT). microsoft.com. pp. 5–8, 24–25.
  12. ^ Shimpi, Anand Lal. "NVIDIA Introduces GeForce FX (NV30)".
  13. ^ Wilson, Derek. "ATI Radeon X800 Pro and XT Platinum Edition: R420 Arrives".
  14. ^ a b Shader Model 3.0, Ashu Rege, NVIDIA Developer Technology Group, 2004.
  15. ^ a b The Direct3D 10 System, David Blythe, Microsoft Corporation, 2006.
  16. ^ "Registers - ps_4_1 (Windows)". msdn.microsoft.com. 23 August 2019.
  17. ^ a b "Registers - ps_5_0 (Windows)". msdn.microsoft.com. 23 August 2019.
  18. ^ a b c d "Vertex Shader Differences". msdn.microsoft.com. 2025-08-06.
  19. ^ a b Shimpi, Anand Lal. "NVIDIA Introduces GeForce FX (NV30)".
  20. ^ "Registers - vs_4_1 (Windows)". msdn.microsoft.com. 23 August 2019.
  21. ^ "Porting from FXC to DXC". GitHub.
  22. ^ "microsoft/DirectXShaderCompiler: This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang". Microsoft. 21 October 2020.
  23. ^ "glslang: Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator". The Khronos Group. 21 October 2020.
  24. ^ Matt Turner. Video on YouTube.
  25. ^ Stenson, Richard; Ho, Chris. "PlayStation Shading Language for PS4". GDC Europe 2013.
  26. ^ "ReShade FX shading language". GitHub. 15 February 2022.
  27. ^ "Maya Cg Plug-in | NVIDIA".
  28. ^ "LightWave - 11.6 Features Overview".
  29. ^ "Unity - Manual: Writing Shaders".

Further reading

[edit]
[edit]
灰指甲用什么药好 什么什么的沙滩 指甲有条纹是什么原因 afar是什么意思 芙蓉花长什么样
梦见摘辣椒是什么意思 苏麻为什么不嫁给康熙 吃什么能 手脱皮是缺什么维生素 拍大腿内侧有什么好处
凤冈锌硒茶属于什么茶 危机四伏是什么生肖 心急如焚是什么意思 孟姜女属什么生肖 世界上最多笔画的字是什么字
黄瓜可以和什么一起榨汁 什么是天葬 历经是什么意思 吃菠萝蜜有什么好处 四月初七是什么星座
毛囊是什么样子图片hcv9jop2ns2r.cn 女人气血不足吃什么补hcv9jop7ns0r.cn 百年好合什么意思hcv7jop6ns8r.cn 半月板损伤吃什么药hcv7jop5ns2r.cn as是什么元素hcv9jop0ns9r.cn
德国为什么发动二战hcv8jop0ns7r.cn 系统性红斑狼疮是什么病hcv9jop3ns1r.cn 称呼是什么意思shenchushe.com 甘油三酯指什么hcv7jop6ns5r.cn 帕金森吃什么药最好luyiluode.com
天外有天人外有人是什么意思hcv8jop0ns8r.cn 腿肿是什么原因引起的怎么办hcv9jop0ns5r.cn 热毛巾敷眼睛有什么好处hcv8jop9ns2r.cn 虎父无犬子什么意思tiangongnft.com 什么病不能吃玉米hcv8jop4ns3r.cn
负面影响是什么意思hcv9jop6ns8r.cn 2月29号是什么星座hcv9jop5ns6r.cn 氧分压是什么意思hcv9jop3ns6r.cn pe什么材质hcv9jop6ns9r.cn darling什么意思zhiyanzhang.com
百度