Skip to content

Commit

Permalink
[JP] Add shader comparison page (#266)
Browse files Browse the repository at this point in the history
* Add Japanese version of high level shader lang comparison

* Remove tabs

* Unify indent size
  • Loading branch information
yknishidate authored Jul 15, 2024
1 parent ee34eee commit e4109bd
Show file tree
Hide file tree
Showing 3 changed files with 1,054 additions and 28 deletions.
56 changes: 28 additions & 28 deletions chapters/high_level_shader_language_comparison.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ float4x3 mat = (float4x3)(ubo.view);

[NOTE]
====
An imporant difference: Matrices in GLSL are column-major, while matrices in HLSL are row-major. This affects things like matrix construction.
An important difference: Matrices in GLSL are column-major, while matrices in HLSL are row-major. This affects things like matrix construction.
====

== Implicit vk Namespace

For Vulkan concepts that are not available in DirectX, an link:https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#the-implicit-vk-namespace)[implicit namespace] has been added that marks Vulkan specific features.
For Vulkan concepts that are not available in DirectX, an link:https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#the-implicit-vk-namespace[implicit namespace] has been added that marks Vulkan specific features.

== SPIR-V macro

Expand Down Expand Up @@ -128,14 +128,14 @@ HLSL
struct VSOutput
{
// The SV_POSITION semantic declares the Pos member as the vertex output position
float4 Pos : SV_POSITION;
float4 Pos : SV_POSITION;
};
VSOutput main(VSInput input)
{
VSOutput output = (VSOutput)0;
output.Pos = mul(ubo.projectionMatrix, mul(ubo.viewMatrix, mul(ubo.modelMatrix, input.Pos)));
return output;
VSOutput output = (VSOutput)0;
output.Pos = mul(ubo.projectionMatrix, mul(ubo.viewMatrix, mul(ubo.modelMatrix, input.Pos)));
return output;
}
----

Expand All @@ -162,9 +162,9 @@ struct VSInput
VSOutput main(VSInput input)
{
VSOutput output = (VSOutput)0;
output.UV = float2((input.VertexIndex << 1) & 2, input.VertexIndex & 2);
return output;
VSOutput output = (VSOutput)0;
output.UV = float2((input.VertexIndex << 1) & 2, input.VertexIndex & 2);
return output;
}
----

Expand Down Expand Up @@ -217,14 +217,16 @@ It's possible to use both the `vk::binding[]` and `register()` syntax for one de
[source, glsl]
----
layout (set = 1, binding = 0) uniform Node {
mat4 matrix;
mat4 matrix;
} node;
----

===== HLSL

[source, hlsl]
----
struct Node {
float4x4 transform;
float4x4 transform;
};
// HLSL style
Expand Down Expand Up @@ -353,15 +355,13 @@ VSOutput main(VSInput input) {
| COLOR[n] | Diffuse and specular color | float4
| NORMAL[n] | Normal vector | float4
| POSITION[n] | Vertex position in object space. | float4
| POSITIONT | Transformed vertex position | float4
| POSITIONT | Transformed vertex position | float4
| PSIZE[n] | Point size | float
| TANGENT[n] | Tangent | float4
| TEXCOORD[n] | Texture coordinates | float4
|====

`+n+` is an optional integer between 0 and the number of resources supported.

link:https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics[source]
`+n+` is an optional integer between 0 and the number of resources supported. (link:https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics[source])

=== Shader outputs

Expand Down Expand Up @@ -402,7 +402,7 @@ Example:
----
struct VSOutput
{
float4 Pos : SV_POSITION;
float4 Pos : SV_POSITION;
[[vk::location(0)]] float3 Normal : NORMAL;
[[vk::location(1)]] float3 Color : COLOR;
[[vk::location(2)]] float2 UV : TEXCOORD0;
Expand Down Expand Up @@ -454,9 +454,9 @@ Example:
----
struct FSOutput
{
float4 Position : SV_TARGET0;
float4 Normal : SV_TARGET1;
float4 Albedo : SV_TARGET2;
float4 Position : SV_TARGET0;
float4 Normal : SV_TARGET1;
float4 Albedo : SV_TARGET2;
};
FSOutput main(VSOutput input) {
Expand Down Expand Up @@ -485,7 +485,7 @@ Example:
[source,glsl]
----
layout (push_constant) uniform PushConsts {
mat4 matrix;
mat4 matrix;
} pushConsts;
----

Expand Down Expand Up @@ -644,7 +644,7 @@ RWTexture2D<float4> resultImage : register(u0, space0);

[NOTE]
====
Currently, HLSL only supports a link:https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#rawbufferload-and-rawbufferstore[subset] of VK_KHR_buffer_device_address.
Currently, HLSL only supports a link:https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#rawbufferload-and-rawbufferstore[subset] of `VK_KHR_buffer_device_address`.
====

==== GLSL
Expand All @@ -653,7 +653,7 @@ Example:
[source,glsl]
----
layout(push_constant) uniform PushConstants {
uint64_t bufferAddress;
uint64_t bufferAddress;
} pushConstants;
layout(buffer_reference, scalar) buffer Data {vec4 f[]; };
Expand All @@ -669,12 +669,12 @@ Example:
[source,hlsl]
----
struct PushConstants {
uint64_t bufferAddress;
uint64_t bufferAddress;
};
[[vk::push_constant]] PushConstants pushConstants;
void main() {
float4 data = vk::RawBufferLoad<float4>(pushConstants.bufferAddress);
float4 data = vk::RawBufferLoad<float4>(pushConstants.bufferAddress);
}
----

Expand Down Expand Up @@ -702,7 +702,7 @@ Example:
[source,glsl]
----
layout(shaderRecordEXT, std430) buffer SBT {
float data;
float data;
};
----

Expand All @@ -712,7 +712,7 @@ Example:
[source,hlsl]
----
struct SBT {
float data;
float data;
};
[[vk::shader_record_ext]]
ConstantBuffer<SBT> sbt;
Expand Down Expand Up @@ -745,7 +745,7 @@ ConstantBuffer<SBT> sbt;
| gl_WorldRayOriginEXT | WorldRayOrigin |
| gl_WorldRayDirectionEXT | WorldRayDirection |
| gl_ObjectRayOriginEXT | ObjectRayOrigin |
| gl_ObjectRayDirectionEXT | ObjectRayDirection |
| gl_ObjectRayDirectionEXT | ObjectRayDirection |
| gl_RayTminEXT | RayTMin |
| gl_RayTmaxEXT | RayTCurrent |
| gl_IncomingRayFlagsEXT | RayFlags |
Expand Down Expand Up @@ -932,7 +932,7 @@ These shader stages share several functions and built-ins
| gl_SubgroupGeMask | n.a.
| gl_SubgroupGtMask | n.a.
| gl_SubgroupLeMask | n.a.
| gl_SubgroupLtMask | SubgroupLtMask decorated OpVariablen.a.
| gl_SubgroupLtMask | SubgroupLtMask decorated OpVariable
| subgroupElect | WaveIsFirstLane
| subgroupAny | WaveActiveAnyTrue
| subgroupAll | WaveActiveAllTrue
Expand Down
3 changes: 3 additions & 0 deletions lang/jp/README-jp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ Vulkan Guide は、`asciidoctor guide.adoc` を使って1つのページとし

// include::{chapters}hlsl.adoc[]

== xref:{chapters}high_level_shader_language_comparison.adoc[高レベルシェーダ言語の比較]

// include::{chapters}high_level_shader_language_comparison.adoc[]

= 拡張機能を使うタイミングと理由

Expand Down
Loading

0 comments on commit e4109bd

Please sign in to comment.