Кіріспе
Шатырлау тілі – Microsoft компаниясы Direct3D 9 API үшін шатырлау құрастыру тілін кеңейту үшін әзірлеген, сонымен қатар Direct3D 10 және одан жоғары нұсқаларының біріктірілген шатырлау үлгісі үшін қажетті шатырлау тілі болып табылатын, Microsoft компаниясының меншікті шатырлау тілі. HLSL OpenGL стандартында қолданылатын GLSL көлеңкелеу тіліне ұқсас. Ол Nvidia Cg көлеңкелеу тіліне өте ұқсас, өйткені онымен қатар жасалды. Екі тілдің алғашқы нұсқалары бірдей деп саналды, тек әртүрлі сатылды. HLSL шейдерлері жылдамдық пен егжей-тегжейлілікті арттырады, сондай-ақ 2D және 3D компьютерлік графикада көптеген арнайы эффекттерді қамтамасыз етеді. HLSL бағдарламалары алты түрге бөлінеді: пиксельдік шейдерлер (GLSL-дегі фрагмент), vertex shaderлер, геометриялық шейдерлер, есептеу шейдерлері, тесселяция шейдерлері (Hull және Domain shaderлер) және сәулелік шейдерлер (Ray Generation Shader, Intersection Shader, Any Hit/Closest Hit/Miss Shader). Vertex shader әр vertex үшін орындалады, ол негізінен vertex-ті объект кеңістігінен көру кеңістігіне түрлендіруге, текстуралық координаттарды шығаруға және vertex-тің нормальді, тангенстік және битангенстік векторлары сияқты жарық коэффициенттерін есептеуге жауапты. Түйіндер тобы (әдетте үшбұрышты қалыптастыру үшін 3) vertex shader арқылы өткенде, олардың шығыс орны оның ауданында пиксельдерді қалыптастыру үшін интерполяцияланады; бұл процесс растерлеу деп аталады. Direct3D 10/11/12 интерфейсін және Direct3D 10/11/12 аппараттық құралын пайдаланатын қосымша геометриялық шейдерді де таңдай алады. Бұл шейдер бастапқы (үшбұрышты / сызықты / нүкте) кейбір түбірлерін енгізу ретінде алады және осы деректерді қосымша примитивтерді өндіруге / бүлдіруге (немесе теселлаттауға) немесе примитивтердің түрін өзгертуге пайдаланады, олардың әрқайсысы растерлеушіге жіберіледі. D3D11.3 және D3D12 Shader Model 5.1 және одан кейінгі 6.0-ды енгізді.
The High Level Shader Language or High Level Shading Language (HLSL) is a proprietary shading language developed by Microsoft for the Direct3D 9 API to augment the shader assembly language, and went on to become the required shading language for the unified shader model of Direct3D 10 and higher. HLSL is analogous to the GLSL shading language used with the OpenGL standard. It is very similar to the Nvidia Cg shading language, as it was developed alongside it. Early versions of the two languages were considered identical, only marketed differently. HLSL shaders can enable profound speed and detail increases as well as many special effects in both 2D and 3D computer graphics. HLSL programs come in six forms: pixel shaders (fragment in GLSL), vertex shaders, geometry shaders, compute shaders, tessellation shaders (Hull and Domain shaders), and ray tracing shaders (Ray Generation Shaders, Intersection Shaders, Any Hit/Closest Hit/Miss Shaders). A vertex shader is executed for each vertex that is submitted by the application, and is primarily responsible for transforming the vertex from object space to view space, generating texture coordinates, and calculating lighting coefficients such as the vertex's normal, tangent, and bitangent vectors. When a group of vertices (normally 3, to form a triangle) come through the vertex shader, their output position is interpolated to form pixels within its area; this process is known as rasterization. Optionally, an application using a Direct3D 10/11/12 interface and Direct3D 10/11/12 hardware may also specify a geometry shader. This shader takes as its input some vertices of a primitive (triangle/line/point) and uses this data to generate/degenerate (or tessellate) additional primitives or to change the type of primitives, which are each then sent to the rasterizer. D3D11.3 and D3D12 introduced Shader Model 5.1 and later 6.0.
Шадерлік модельді салыстыру
Тізімде көрсетілген GPU-лар – берілген ерекшеліктерді алғашқы рет қолдаған аппараттық құралдар. Өндірушілер драйверлер арқылы әдетте барлық төменгі деңгейдегі көлеңкелік модельдерді қолдайды. Ойындар DirectX-тің белгілі бір нұсқасын қажет ететінін көрсетуі мүмкін, бірақ бұл нұсқаның толық ерекшеліктеріне сәйкес GPU міндетті емес, себебі әзірлеушілер Direct3D-нің төменгі деңгейдегі аппараттық құралдарын қолдау үшін DirectX API-нің жоғары нұсқасын пайдалана алады. Мысалы, DirectX 9, DirectX7 деңгейіндегі аппараттық мүмкіндіктерді ұсынады, олар DirectX7-де болмаған, олардың бекітілген функциялық T&L құбырларын қолдайды.
Пиксельдік шадер салыстыруы
Пиксельный шейдер версии 1.0 – 1.3
1.42.0a2.0b3.04.0 4.1 5.0Предел зависимых текстур4 6 8 Неограниченно 8 Неограниченно НеограниченноПредел инструкций текстур4 6*2 32 Неограниченно Неограниченно Неограниченно НеограниченноРегистр позиции ✔ ✔Слоты инструкций8+4 8+4 32 + 64 512 512 ≥ 512 ≥ 65536Выполненные инструкции8+4 6*2+8*2 32 + 64 512 512 65536 НеограниченноКосвенные обращения к текстурам4 4 4 Неограниченно 4 Неограниченно НеограниченноИнтерполированные регистры2 + 4 2 + 6 2 + 8 2 + 8 2 + 8 10 32Предсказание инструкций ✔ ✔ Входные регистры индексов ✔ ✔Временные регистры2 6 12–32 22 32 32 4096Константные регистры8 8 32 32 32 224 16×4096Произвольное перемешивание ✔ ✔ ✔Инструкции градиента ✔ ✔ ✔Регистр количества циклов ✔ ✔Регистр грани (двустороннее освещение) ✔ ✔ ✔Динамическое управление потоком ✔ (24) ✔ (64)Побитовые операторы ✔Нативные целые числа ✔
1.42.0a2.0b3.04.0 4.1 5.0Dependent texture limit4 6 8 Unlimited 8 Unlimited UnlimitedTexture instruction limit4 6*2 32 Unlimited Unlimited Unlimited UnlimitedPosition register ✔ ✔Instruction slots8+4 8+4 32 + 64 512 512 ≥ 512 ≥ 65536Executed instructions8+4 6*2+8*2 32 + 64 512 512 65536 UnlimitedTexture indirections4 4 4 Unlimited 4 Unlimited UnlimitedInterpolated registers2 + 4 2 + 6 2 + 8 2 + 8 2 + 8 10 32Instruction predication ✔ ✔ Index input registers ✔ ✔Temp registers2 6 12 to 32 22 32 32 4096Constant registers8 8 32 32 32 224 16×4096Arbitrary swizzling ✔ ✔ ✔Gradient instructions ✔ ✔ ✔Loop count register ✔ ✔Face register (2 sided lighting) ✔ ✔ ✔Dynamic flow control ✔ (24) ✔ (64)Bitwise Operators ✔Native Integers ✔
PS 1.0 — Невыпущенный 3dfx Rampage, DirectX 8
PS 1.1 — GeForce 3, DirectX 8
PS 1.2 — 3Dlabs Wildcat VP, DirectX 8.1
PS 1.3 — GeForce 4 Ti, DirectX 8.1
PS 1.4 — Radeon 8500 9250, Matrox Parhelia, DirectX 8.1
Shader Model 2.0 — Radeon 9500 9800/X300 X600, DirectX 9
Shader Model 2.0a — Оптимизированная модель GeForce FX/PCX, DirectX 9.0a
Shader Model 2.0b — Модель шейдера Radeon X700 X850, DirectX 9.0b
Shader Model 3.0 — Radeon X1000 и GeForce 6, DirectX 9.0c
Shader Model 4.0 — Radeon HD 2000 и GeForce 8, DirectX 10
Shader Model 4.1 — Radeon HD 3000 и GeForce 200, DirectX 10.1
Shader Model 5.0 — Radeon HD 5000 и GeForce 400, DirectX 11
Shader Model 5.1 — GCN 1+, Fermi+, DirectX 12 (11 0+) с WDDM 2.0
Shader Model 6.0 — GCN 1+, Kepler+, DirectX 12 (11 0+) с WDDM 2.1
Shader Model 6.1 — GCN 1+, Kepler+, DirectX 12 (11 0+) с WDDM 2.3
Shader Model 6.2 — GCN 1+, Kepler+, DirectX 12 (11 0+) с WDDM 2.4
Shader Model 6.3 — GCN 1+, Kepler+, DirectX 12 (11 0+) с WDDM 2.5
Shader Model 6.4 — GCN 1+, Kepler+, Skylake+, DirectX 12 (11 0+) с WDDM 2.6
Shader Model 6.5 — GCN 1+, Kepler+, Skylake+, DirectX 12 (11 0+) с WDDM 2.7
Shader Model 6.6 — GCN 4+, Maxwell+, DirectX 12 (11 0+) с WDDM 3.0
Shader Model 6.7 — GCN 4+, Maxwell+, DirectX 12 (12 0+) с WDDM 3.1
PS 1.1 — GeForce 3, DirectX 8
PS 1.2 — 3Dlabs Wildcat VP, DirectX 8.1
PS 1.3 — GeForce 4 Ti, DirectX 8.1
PS 1.4 — Radeon 8500 9250, Matrox Parhelia, DirectX 8.1
Shader Model 2.0 — Radeon 9500 9800/X300 X600, DirectX 9
Shader Model 2.0a — GeForce FX/PCX optimized model, DirectX 9.0a
Shader Model 2.0b — Radeon X700 X850 shader model, DirectX 9.0b
Shader Model 3.0 — Radeon X1000 and GeForce 6, DirectX 9.0c
Shader Model 4.0 — Radeon HD 2000 and GeForce 8, DirectX 10
Shader Model 4.1 — Radeon HD 3000 and GeForce 200, DirectX 10.1
Shader Model 5.0 — Radeon HD 5000 and GeForce 400, DirectX 11
Shader Model 5.1 — GCN 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
Shader Model 6.6 — GCN 4+, Maxwell+, DirectX 12 (11 0+) with WDDM 3.0
Shader Model 6.7 — GCN 4+, Maxwell+, DirectX 12 (12 0+) with WDDM 3.1
"32 + 64" для Выполненных инструкций означает "32 инструкции текстур и 64 арифметические инструкции."
Vertex шадера салыстыруы
Vertex shader нұсқасы VS 1.1 VS 2.0 VS 2.0a VS 3.0 VS 4.0 VS 4.1 VS 5.0
Нұсқау слоттарының саны 128 256 256 ≥ 512 ≥ 65536
Орындалған нұсқаулардың максималды саны 128 1024 65536 65536 Шегі жоқ
Нұсқаулардың болжауы ✔ ✔ ✔
Уақытша регистрлер 12 12 16 32 4096
Тұрақты регистрлер саны ≥ 96 ≥ 256 256 ≥ 256 16×4096
Статикалық ағынды басқару ✔ ✔ ✔
Динамикалық ағынды басқару ✔ ✔ ✔
Динамикалық ағынды басқару тереңдігі 24 24 64
Вертекс текстурасын алу ✔ ✔
Текстура үлгілеушілер саны 4 128
Геометрия инстанциялау қолдауы ✔ ✔
Биттік операторлар ✔
Нәтиве бүтін сандар ✔
VS 2.0 VS 2.0a VS 3.0 VS 4.0 VS 4.1 VS 5.0# of instruction slots128 256 256 ≥ 512 ≥ 65536Max # of instructions executed128 1024 65536 65536 UnlimitedInstruction predication ✔ ✔ ✔Temp registers12 12 16 32 4096# constant registers≥ 96 ≥ 256 256 ≥ 256 16×4096Static flow control ✔ ✔ ✔ ✔Dynamic flow control ✔ ✔ ✔Dynamic flow control depth 24 24 64Vertex texture fetch ✔ ✔# of texture samplers 4 128Geometry instancing support ✔ ✔Bitwise operators ✔Native integers ✔