コンテンツにスキップ

High Level Shading Language

出典: フリー百科事典『ウィキペディア(Wikipedia)』
シェーダーモデルから転送)

High Level Shading Language  : HLSL[1]Direct3D (DirectX) 使High Level Shader Language [2][3][4]MSDNHigh Level Shader LanguageHigh Level Shading Language 使[5][6]

HLSLOpenGL使GLSLNVIDIACgC for Graphics

[]


Direct3D 7GPU使3DDirect3D 8[7]Direct3D 8使C/C++HLSLHLSLDirect3D 9Direct3D

GDC 2016DirectX 12DirectX6HLSL[8]6.0WaveSIMTNVIDIA GPUWarpAMD GPUWavefront[9]

[]


HLSLDirect3D

Direct3D 91.x-3.0OpenGL2

Direct3D 10.x4.xOpenGL3

Direct3D 11.x/125.xOpenGLOpenGL6

 (3) 

Direct3D 10/11/12Direct3D 10/11/12使

HLSL使noise()[10]

Windows 10 October 2018 Update (version 1809) DirectX Raytracing (DXR) [11]DXRGPU6.3HLSL[12]

[]


HLSLC/C++C/C++Direct3D 10APIDirect3D 9HLSLDirect3D 10HLSL[13]

Direct3D 10HLSLC++

Direct3D 11HLSLDynamic Shader Linkage[14]

[]


Direct3D 10/11HLSLHalf LambertPhongBlinn-Phonguber-shader
// Shader Constants.
matrix TrWorldViewProj;
matrix TrWorld;
float4 LightPosition;
float3 EyePosition;
float4 DiffuseColor;
float4 SpecularColor;
float SpecularPower;
bool IsPhongModel;

struct BasicVSOutput
{
	float4 Pos : SV_POSITION;
	float3 WPos : TEXCOORD1;
	float3 WNormal : NORMAL0;
};
typedef BasicVSOutput BasicPSInput;

// Vertex Shader Program.
BasicVSOutput BasicVS(float3 pos : POSITION0, float3 normal : NORMAL0)
{
	BasicVSOutput output = (BasicVSOutput)0;
	output.Pos = mul(float4(pos, 1), TrWorldViewProj);
	output.WPos = mul(float4(pos, 1), TrWorld).xyz;
	output.WNormal = mul(normal, (float3x3)TrWorld);
	return output;
}

float4 CalcLambert(float3 light, float3 wnormal)
{
	// Half Lambert.

	float lambert = dot(light, wnormal);
	lambert = lambert * 0.5f + 0.5f;
	lambert *= lambert;
	return lambert * DiffuseColor;
}

float4 BasicLambert(BasicPSInput input)
{
	const float3 light = normalize(LightPosition.xyz - input.WPos);
	const float3 normal = normalize(input.WNormal);
	return CalcLambert(light, normal);
}

float4 BasicPhong(BasicPSInput input)
{
	// Phong lighting with specular.

	const float3 eye = normalize(EyePosition - input.WPos);
	const float3 light = normalize(LightPosition.xyz - input.WPos);
	const float3 halfway = normalize(light + eye);
	const float3 normal = normalize(input.WNormal);
	const float specular = pow(max(dot(normal, halfway), 0.0), SpecularPower);
	return CalcLambert(light, normal) + specular * SpecularColor;
}

// Pixel Shader Program.
float4 BasicPS(BasicPSInput input) : SV_TARGET0
{
	if (IsPhongModel)
	{
		return BasicPhong(input);
	}
	else
	{
		return BasicLambert(input);
	}
}

Direct3D 7Per-Pixel 使HLSL3DDirect3D 11 (DirectCompute) 使GPUGPGPUHLSL

HLSL.hlsl.hlsli[15]

[]


HLSLC++Direct3D API使DirectX SDK8.0Windows SDKHLSLfxc.exe[16]HLSLDirect3D 9WindowsOSXbox 360XboxVulkanSPIR-VglslangValidator[17]GLSLHLSLHLSL

HLSLD3DCompiler[18]

UnityHLSL使Cg使[19][20]WindowsDirectCompute (DirectX 11) 使CgHLSL使[21]UnityCg/HLSLGLSLOpenGL 4.3OpenGL ES 3.1GLSLHLSL使[22]

LLVM/ClangHLSLdxc.exeGitHub[23]DirectX Intermediate Language (DXIL) [24]fxc.exe (DXBC) 

[]


HLSL使2VS1(), VS2()2PS1(), PS2()HLSL.fxVS1+PS1, VS2+PS2, VS1+PS2, VS2+PS1APIDirect3D 10Direct3D 9/11D3DXC++

WPF[]


Windows1WPFDirect3D使GUIWPFHLSL使[25]

WPF 3.52.0WPF 43.0使[26] [27]

Direct2D[]


DirectX12APIDirect2D1.1HLSL[28]

シェーダーモデル[編集]


Direct3DDirect3D 8Direct3D 9CPUD3DCREATE_SOFTWARE_VERTEXPROCESSINGDirect3D 7Direct3D 10.1WARPGPUCPUDirect3D

Direct3DGPU[29]2.0a/2.0b HLSLDirect3D92.0HLSL使HLSL使1.xDirect3D 10HLSL使[30]

3.0Vertex Texture Fetch, VTFDirectX 9.0cNVIDIAATINVIDIAATI[31] [32]DirectX 11[33]ATI[34] [35] [36]3.0DirectX 9.0c使Direct3DCaps (Capabilities) API使調Direct3D 10[37]

Direct3D 10.1 API4.x2.0使Direct3D 11/12 API5.x4.x2.0使3.0使[38] [39] [40] [41]

DirectX[]


DirectX
DirectX Version Pixel Shader Vertex Shader Geometry Shader Hull Shader Domain Shader Compute Shader
8.0 1.0, 1.1 1.0 - - - -
8.1 1.2, 1.3, 1.4 1.1 - - - -
9.0 2.0 2.0 - - - -
9.0a 2.0a 2.0a - - - -
9.0b 2.0b 2.0 - - - -
9.0c 3.0 3.0 - - - -
10.0 4.0 4.0 4.0 - - 4.0
10.1 4.1 4.1 4.1 - - 4.1
11.0-11.2 5.0 5.0 5.0 5.0 5.0 5.0
11.3, 12 5.1 5.1 5.1 5.1 5.1 5.1
12 6.0 6.0 6.0 6.0 6.0 6.0

DirectComputeDirectX 11DirectX 10 APIDirectX 10.xDirectX 11 API

5.1[42]DirectX 12 API11_0使Root SignatureDirectX 11.3使DirectX 12[43]ROV (Rasterizer Order View) ROV使[44]

6.0[9]12_0

ピクセルシェーダーの比較[編集]

  PS 1.0-1.3 PS 1.4 PS 2.0 PS 2.0a PS 2.0b PS 3.0[45] PS 4.0[46], 4.1, 5.0
依存テクスチャ制限 4 6 8 無制限 4 無制限 無制限
テクスチャ命令制限 4 6*2 32 無制限 無制限 無制限 無制限
Position register No No No No No Yes Yes
命令スロット数 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 無制限 無制限
Interpolated registers 2 + 8 2 + 8 2 + 8 2 + 8 2 + 8 10 32
命令予測 No No No Yes No Yes No
Index input registers No No No No No Yes Yes
一時レジスタ(Temp registers) 2 6   12から32 22 32 32 4096
定数レジスタ(Constant registers) 8 8 32 32 32 224 16x4096
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 No Yes Yes
動的フロー制御 No No No No No 24 Yes
ビット演算 No No No No No No Yes
整数演算 No No No No No No Yes

PS 2.0 = DirectX 9.02.0

PS 2.0a = NVIDIA GeForceFX

PS 2.0b = ATI Radeon X700, X800, X850DirectX 9.0b

PS 3.0 = 3.0

PS 4.0 = 4.0

PS 4.1 = 4.1

PS 5.0 = 5.0

"32 + 64""3264"

[]

  VS 1.1 VS 2.0 VS 2.0a VS 3.0[45] VS 4.0[46], 4.1, 5.0
命令スロット数 128 256 256 ≥ 512 4096
最大命令実行数 不明 65536 65536 65536 65536
命令予測 No No Yes Yes Yes
一時レジスタ(Temp registers) 12 12 13 32 4096
定数レジスタ(Constant registers) ≥ 96 ≥ 256 ≥ 256 ≥ 256 16x4096
静的フロー制御 不明 Yes Yes Yes Yes
動的フロー制御 No No Yes Yes Yes
動的フロー制御の深度 No No 24 24 Yes
Vertex Texture Fetch No No No Yes Yes
テクスチャサンプラーの数 N/A N/A N/A 4 128
Geometry instancing support No No No Yes Yes
ビット演算 No No No No Yes
整数演算 No No No No Yes

VS 2.0 = DirectX 9.02.0

VS 2.0a = NVIDIA GeForce FX

VS 3.0 = 3.0

VS 4.0 = 4.0

VS 4.1 = 4.1

VS 5.0 = 5.0

VS 2.0b[47]

[]


Direct3DDirectXPS 3.0PS 2.0PS 1.1

APIOpenGL/GLSL使Direct3D/HLSL便使
PS version DirectX version 3Dlabs AMD (旧ATI) インテル Matrox NVIDIA S3 Graphics SiS XGI
1.0/1.1 8.0 - - - - GeForce 3 series - Xabre-Series -
1.2 8.0a Wildcat VP - - - - - - -
1.3 8.0a - - - Parhelia-Series GeForce 4 Ti/Go series - Mirage 2(ソフトウェアエミュレーションで対応) -
1.4 8.1 - Radeon R200 (8500-9250) - - - - Mirage 3 Volari V3 series (V3XTを除く)
2.0 9.0 Wildcat Realizm Radeon R300 (9500-9800, X300-X600) Intel GMA 900 - GeForce FX Series DeltaChrome, GammaChrome, Chrome S2x series, Chrome9 HC Mirage 3+ Volari V3XT, Volari V5 series, Volari V8 series, Volari 8300, Volari XP10
2.0a 9.0a - - - - GeForce FX Series - - -
2.0b 9.0b - Radeon R420 (X700-X850) - - - - - -
3.0 9.0c - Radeon X1xxx Intel GMA 950(3.0はソフトウェアエミュレーション), 3000, 3100 M Series GeForce 6 series, GeForce 7 series - - -
4.0 10 - Radeon HD 2xxx Intel GMA X3100以降のシリーズ - GeForce 8 series, GeForce 9 series - - -
4.1 10.1 - Radeon HD 3xxx, Radeon HD 4xxx HD Graphics 2000/3000 - GeForce GT 200 Series Chrome400/500 - -
5.0 11 - Radeon HD 5xxx HD Graphics 2500/4000 - GeForce GTX 400 Series - - -

Shader Model 1.x[]


DirectX 8.x

NVIDIAATI1.11.21.31.4

GPU: AMD Radeon8xxxNVIDIA GeForce3-4Ti

XboxGPUSM1.x

Shader Model 2.0[]


DirectX 9

[]

NVIDIA2.0aATI2.0b

GPU: Radeon9500-X850GeForceFX 5xxx

Shader Model 3.0[]


DirectX 9.0c



GPU: RadeonX1000GeForce67

Xbox 3603GPUSM3.0

Shader Model 4.x[]


DirectX 10.x

GPGPUAPICUDAOpenCLSM 4.0





4.1[48]

GPU: RadeonHD 2xxx-HD 4xxxGeForce8xxx-GT 3xx

Wii UGPUSM4.0[49]

Shader Model 5.0[]


DirectX 11.x

GPGPUDirectCompute

GPU: RadeonHD 5xxx-HD 8xxxRx 2xx/3xxGeForceFermiKeplerMaxwell1

Xbox OnePlayStation 4GPUSM5.0[50]

Shader Model 6.0[]


DirectX 12

GPU: RadeonGCN2GeForceMaxwell2

OpenGLDirectX

OpenGL 2.x - Direct3D 9

OpenGL 3.x - Direct3D 10

OpenGL 4.x - Direct3D 11

[]


Microsoft DirectX

Direct3D

DirectCompute

GLSL

Cg ()

[]



(一)^ Programming guide for HLSL - Win32 apps | Microsoft Learn

(二)^ High-level shader language (HLSL) - Win32 apps | Microsoft Learn

(三)^ Writing HLSL Shaders in Direct3D 9 - Win32 apps | Microsoft Learn

(四)^ Interfaces and Classes - Win32 apps | Microsoft Learn

(五)^   | Microsoft Learn

(六)^ HLSL | Microsoft Learn

(七)^ Shader Models vs Shader Profiles - Win32 apps | Microsoft Learn

(八)^ GDC 20166.0 MicrosoftDirectX - 4Gamer.net

(九)^ abHLSL Shader Model 6.0 - Win32 apps | Microsoft Learn

(十)^ noise - Win32 apps | Microsoft Learn

(11)^ Windows 10DirectX RaytracingDXROctober 2018 Update

(12)^ Direct3D 12 Raytracing HLSL Shaders - Win32 apps | Microsoft Learn

(13)^ Direct3D 9  Direct3D 10  (Direct3D 10)

(14)^ 

(15)^ .hlsli Extension - List of programs that can open .hlsli files

(16)^ Direct3D 9 使 | Microsoft Learn

(17)^ GitHub - KhronosGroup/glslang: Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.

(18)^ HLSL, FXC, and D3DCompile | Games for Windows and the DirectX SDK blog

(19)^ Unity  HLSL - Unity 2020.3 

(20)^ Unity 5.0 - Manual: Writing vertex and fragment shaders

(21)^ Unity 5.0 - Manual: Compute Shaders

(22)^  - Unity 2017.4 

(23)^ Microsoft/DirectXShaderCompiler: This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.

(24)^ DirectXShaderCompiler/DXIL.rst at main · microsoft/DirectXShaderCompiler · GitHub

(25)^ ShaderEffect  (System.Windows.Media.Effects)

(26)^ ShaderEffect  (System.Windows.Media.Effects)

(27)^ WPF Version 4 

(28)^ Effects (Windows)

(29)^   

(30)^ Direct3D 10 使

(31)^ 3D (4) GPU(4) | 

(32)^ 4Gamer.netATINVIDIA20052006 ATI

(33)^  (Direct3D 9)

(34)^ 4Gamer.net AMDR600ATI Radeon HD 2000

(35)^ 西3DATI Radeon HD 2000GPU

(36)^ Game Developers ConferenceGDC 2010 - GAME Watch

(37)^ "PDC 2008:   Direct3D10", Microsoft Corporation, 200810

(38)^ D3D_FEATURE_LEVEL enumeration

(39)^ Direct3D feature levels

(40)^  Direct3D 11

(41)^ 10Level9 

(42)^ Shader Model 5.1

(43)^ HLSL Shader Model 5.1 Features for Direct3D 12

(44)^ Hardware Feature Levels

(45)^ abShader Model 3.0, Ashu Rege, NVIDIA Developer Technology Group, 2004.

(46)^ abThe Direct3D 10 System, David Blythe, Microsoft Corporation, 2006.

(47)^ "Shader Model 3.0 Unleashed", Randima (Randy) Fernando, NVIDIA Developer Technology Group

(48)^   (DirectX HLSL)

(49)^ 西3DE3.  Impress Watch (2011611). 2011611

(50)^ 西3D4.  Impress Watch (201338). 2014829

外部リンク[編集]