File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 - name : Install deps
1313 run : |
1414 sudo apt-get update
15- sudo apt-get install -y cmake g++ libvulkan-dev clang-format
15+ sudo apt-get install -y cmake g++ libvulkan-dev clang-format curl ca-certificates
16+ - name : Install slangc
17+ run : |
18+ SLANG_VERSION=2024.17.2
19+ curl -fsSL -o slang.tar.gz https://github.com/shader-slang/slang/releases/download/v${SLANG_VERSION}/slang-${SLANG_VERSION}-linux-x86_64.tar.gz
20+ tar -xzf slang.tar.gz
21+ sudo install -m 0755 slang-${SLANG_VERSION}/bin/slangc /usr/local/bin/slangc
1622 - name : Build
1723 run : |
1824 cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
66set (CMAKE_CXX_EXTENSIONS OFF )
77
88find_package (Vulkan REQUIRED )
9- find_program (GLSLANG_VALIDATOR glslangValidator REQUIRED )
9+ find_program (SLANGC slangc REQUIRED )
1010
1111set (SHADER_DIR ${CMAKE_CURRENT_SOURCE_DIR} /shaders)
1212set (SPIRV_DIR ${CMAKE_CURRENT_BINARY_DIR} /shaders)
@@ -19,14 +19,14 @@ set(SHADER_OUTPUTS
1919
2020add_custom_command (
2121 OUTPUT ${SPIRV_DIR} /triangle.vert.spv
22- COMMAND ${GLSLANG_VALIDATOR } -V ${SHADER_DIR} /triangle.vert -o ${SPIRV_DIR} /triangle.vert.spv
23- DEPENDS ${SHADER_DIR} /triangle.vert
22+ COMMAND ${SLANGC } -target spirv -profile glsl_460 -entry main -stage vertex ${SHADER_DIR} /triangle.vert.slang -o ${SPIRV_DIR} /triangle.vert.spv
23+ DEPENDS ${SHADER_DIR} /triangle.vert.slang
2424)
2525
2626add_custom_command (
2727 OUTPUT ${SPIRV_DIR} /triangle.frag.spv
28- COMMAND ${GLSLANG_VALIDATOR } -V ${SHADER_DIR} /triangle.frag -o ${SPIRV_DIR} /triangle.frag.spv
29- DEPENDS ${SHADER_DIR} /triangle.frag
28+ COMMAND ${SLANGC } -target spirv -profile glsl_460 -entry main -stage fragment ${SHADER_DIR} /triangle.frag.slang -o ${SPIRV_DIR} /triangle.frag.spv
29+ DEPENDS ${SHADER_DIR} /triangle.frag.slang
3030)
3131
3232add_custom_target (vk-bench-shaders DEPENDS ${SHADER_OUTPUTS} )
Original file line number Diff line number Diff line change @@ -5,17 +5,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
55 cmake \
66 pkg-config \
77 vulkan-tools \
8- glslang-tools \
8+ curl \
9+ ca-certificates \
910 && rm -rf /var/lib/apt/lists/*
1011
12+ ARG SLANG_VERSION=2024.17.2
13+ RUN curl -fsSL -o /tmp/slang.tar.gz https://github.com/shader-slang/slang/releases/download/v${SLANG_VERSION}/slang-${SLANG_VERSION}-linux-x86_64.tar.gz \
14+ && tar -xzf /tmp/slang.tar.gz -C /tmp \
15+ && install -m 0755 /tmp/slang-${SLANG_VERSION}/bin/slangc /usr/local/bin/slangc \
16+ && rm -rf /tmp/slang.tar.gz /tmp/slang-${SLANG_VERSION}
17+
1118WORKDIR /workspace
1219COPY CMakeLists.txt /workspace/CMakeLists.txt
1320COPY src /workspace/src
1421COPY include /workspace/include
1522COPY shaders /workspace/shaders
1623RUN cmake -S /workspace -B /workspace/build -DCMAKE_BUILD_TYPE=Release \
1724 && cmake --build /workspace/build --config Release -j"$(nproc)" \
18- && install -m 0755 /workspace/build/vk-bench /usr/local/bin/vk-bench
25+ && install -m 0755 /workspace/build/vk-bench /usr/local/bin/vk-bench \
26+ && install -d /usr/local/share/vk-bench/shaders \
27+ && cp /workspace/build/shaders/*.spv /usr/local/share/vk-bench/shaders/
1928
2029COPY docker/entrypoint.sh /entrypoint.sh
2130ENTRYPOINT ["/entrypoint.sh" ]
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ This Level 0 repo intentionally scopes to **one executable** (`vk-bench`) and **
1414
1515No assets, textures, or engine features are included.
1616
17+ Shaders are authored in ** Slang** and compiled to SPIR-V during build.
18+
1719## How to run
1820
1921``` bash
Original file line number Diff line number Diff line change @@ -5,17 +5,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
55 cmake \
66 pkg-config \
77 vulkan-tools \
8- glslang-tools \
8+ curl \
9+ ca-certificates \
910 && rm -rf /var/lib/apt/lists/*
1011
12+ ARG SLANG_VERSION=2024.17.2
13+ RUN curl -fsSL -o /tmp/slang.tar.gz https://github.com/shader-slang/slang/releases/download/v${SLANG_VERSION}/slang-${SLANG_VERSION}-linux-x86_64.tar.gz \
14+ && tar -xzf /tmp/slang.tar.gz -C /tmp \
15+ && install -m 0755 /tmp/slang-${SLANG_VERSION}/bin/slangc /usr/local/bin/slangc \
16+ && rm -rf /tmp/slang.tar.gz /tmp/slang-${SLANG_VERSION}
17+
1118WORKDIR /workspace
1219COPY CMakeLists.txt /workspace/CMakeLists.txt
1320COPY src /workspace/src
1421COPY include /workspace/include
1522COPY shaders /workspace/shaders
1623RUN cmake -S /workspace -B /workspace/build -DCMAKE_BUILD_TYPE=Release \
1724 && cmake --build /workspace/build --config Release -j"$(nproc)" \
18- && install -m 0755 /workspace/build/vk-bench /usr/local/bin/vk-bench
25+ && install -m 0755 /workspace/build/vk-bench /usr/local/bin/vk-bench \
26+ && install -d /usr/local/share/vk-bench/shaders \
27+ && cp /workspace/build/shaders/*.spv /usr/local/share/vk-bench/shaders/
1928
2029COPY docker/entrypoint.sh /entrypoint.sh
2130ENTRYPOINT ["/entrypoint.sh" ]
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ struct PSInput {
2+ float4 position : SV_Position;
3+ float3 color : COLOR0;
4+ };
5+
6+ [shader(" fragment" )]
7+ float4 main(PSInput input) : SV_Target0
8+ {
9+ return float4(input .color , 1 . 0 );
10+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ struct VSOutput {
2+ float4 position : SV_Position;
3+ float3 color : COLOR0;
4+ };
5+
6+ [shader(" vertex" )]
7+ VSOutput main(uint vertexID : SV_VertexID)
8+ {
9+ float2 positions [3 ] = {
10+ float2(0 . 0 , - 0 . 5 ),
11+ float2(0 . 5 , 0 . 5 ),
12+ float2(- 0 . 5 , 0 . 5 )
13+ };
14+
15+ float3 colors [3 ] = {
16+ float3(1 . 0 , 0 . 1 , 0 . 1 ),
17+ float3(0 . 1 , 1 . 0 , 0 . 1 ),
18+ float3(0 . 1 , 0 . 2 , 1 . 0 )
19+ };
20+
21+ VSOutput o;
22+ o .position = float4(positions [vertexID], 0 . 0 , 1 . 0 );
23+ o .color = colors [vertexID];
24+ return o;
25+ }
You can’t perform that action at this time.
0 commit comments