huandzh / wgpu-hello-triangle-spirv

A hello triangle example with SpirV shaders

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wgpu-hello-triangle-spirv

A hello-triangle example using SpirV shaders in wgpu.

The example uses shaders from Vulkan Tutorial. and Vulkan backend.

The purpose of this repo is to give a direct example of using SpirV in wgpu, since it's not obvious for newcomer of wgpu.

Quick Q&A

Q: How to use a SpirV shader in wgpu?

A: Create shader source with wgpu::util::make_spirv or include it statically with wgpu::include_spirv!.

Please see comments in src/main.rs for more details.

Run example

cargo run

Screenshot

Hello Triangle Screenshot

Convert GLSL to SpirV

Install naga-cli:

cargo install naga-cli

Convert shaders:

naga shader.frag frag.spv
naga shader.vert vert.spv

Known Issue

  • Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageExtent-01274 ] - gfx-rs/wgpu#1958

About

A hello triangle example with SpirV shaders

License:MIT License


Languages

Language:Rust 88.6%Language:GLSL 11.4%