From 76b5a3a331aebb1ee3c271ab3605f23329a130c5 Mon Sep 17 00:00:00 2001 From: Ivan Mironov Date: Sat, 29 Aug 2020 22:41:14 +0500 Subject: [PATCH 1/2] [rs] Use `wgpu::include_spirv!()` for all shaders in examples/texture-arrays `wgpu::include_spirv!()` writes file name into log. This is useful to understand which fragment shader is used (choice depends on device features). --- wgpu/examples/texture-arrays/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wgpu/examples/texture-arrays/main.rs b/wgpu/examples/texture-arrays/main.rs index bb92d8ca15..b0178dc4bc 100644 --- a/wgpu/examples/texture-arrays/main.rs +++ b/wgpu/examples/texture-arrays/main.rs @@ -103,23 +103,23 @@ impl framework::Example for Example { ) -> Self { let mut uniform_workaround = false; let vs_module = device.create_shader_module(wgpu::include_spirv!("shader.vert.spv")); - let fs_bytes: Vec = match device.features() { + let fs_source = match device.features() { f if f.contains(wgpu::Features::UNSIZED_BINDING_ARRAY) => { - include_bytes!("unsized-non-uniform.frag.spv").to_vec() + wgpu::include_spirv!("unsized-non-uniform.frag.spv") } f if f.contains(wgpu::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING) => { - include_bytes!("non-uniform.frag.spv").to_vec() + wgpu::include_spirv!("non-uniform.frag.spv") } f if f.contains(wgpu::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING) => { uniform_workaround = true; - include_bytes!("uniform.frag.spv").to_vec() + wgpu::include_spirv!("uniform.frag.spv") } f if f.contains(wgpu::Features::SAMPLED_TEXTURE_BINDING_ARRAY) => { - include_bytes!("constant.frag.spv").to_vec() + wgpu::include_spirv!("constant.frag.spv") } _ => unreachable!(), }; - let fs_module = device.create_shader_module(wgpu::util::make_spirv(&fs_bytes)); + let fs_module = device.create_shader_module(fs_source); let vertex_size = std::mem::size_of::(); let vertex_data = create_vertices(); From 39c5153f2ffc0fe90289514f511e008eb913127b Mon Sep 17 00:00:00 2001 From: Ivan Mironov Date: Sat, 29 Aug 2020 23:50:16 +0500 Subject: [PATCH 2/2] [rs] Add nonuniformEXT qualifier in examples/texture-arrays This fixes corruption of output on some AMD GPUs. --- wgpu/examples/texture-arrays/non-uniform.frag | 2 +- .../texture-arrays/non-uniform.frag.spv | Bin 868 -> 976 bytes .../texture-arrays/unsized-non-uniform.frag | 2 +- .../texture-arrays/unsized-non-uniform.frag.spv | Bin 872 -> 948 bytes 4 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wgpu/examples/texture-arrays/non-uniform.frag b/wgpu/examples/texture-arrays/non-uniform.frag index 994c50a664..30cfba0fa6 100644 --- a/wgpu/examples/texture-arrays/non-uniform.frag +++ b/wgpu/examples/texture-arrays/non-uniform.frag @@ -3,7 +3,7 @@ #extension GL_EXT_nonuniform_qualifier : require layout(location = 0) in vec2 v_TexCoord; -layout(location = 1) flat in int v_Index; // dynamically non-uniform +layout(location = 1) nonuniformEXT flat in int v_Index; // dynamically non-uniform layout(location = 0) out vec4 o_Color; layout(set = 0, binding = 0) uniform texture2D u_Textures[2]; diff --git a/wgpu/examples/texture-arrays/non-uniform.frag.spv b/wgpu/examples/texture-arrays/non-uniform.frag.spv index 1c0be40cdb5a83a0fe26ece28382653f8ff7aab4..caba8fc91ff7d7343b76feb6171b59067b5d399f 100644 GIT binary patch delta 118 zcmaFDc7c6@jJ_ZP6T?;!1_ltl8%T38a4-Z1gvGl?gv6($7AF^F7L?={#b@TFq*i3+ krB9TeZ^6tU#K6F?1*q7a0hKL`Brb}?76Y?4Zd=C$04fp~7ytkO delta 14 Wcmcb>{)BCU%tW7go7EUsF#!NA7X@zs diff --git a/wgpu/examples/texture-arrays/unsized-non-uniform.frag b/wgpu/examples/texture-arrays/unsized-non-uniform.frag index c1013f6ab0..cd6068144e 100644 --- a/wgpu/examples/texture-arrays/unsized-non-uniform.frag +++ b/wgpu/examples/texture-arrays/unsized-non-uniform.frag @@ -3,7 +3,7 @@ #extension GL_EXT_nonuniform_qualifier : require layout(location = 0) in vec2 v_TexCoord; -layout(location = 1) flat in int v_Index; // dynamically non-uniform +layout(location = 1) nonuniformEXT flat in int v_Index; // dynamically non-uniform layout(location = 0) out vec4 o_Color; layout(set = 0, binding = 0) uniform texture2D u_Textures[]; diff --git a/wgpu/examples/texture-arrays/unsized-non-uniform.frag.spv b/wgpu/examples/texture-arrays/unsized-non-uniform.frag.spv index 995f84d62dbf0502380cb5e0e77775c5be3c3ce6..1c0688ff7c127f35d9c4883a21264dfabe582496 100644 GIT binary patch delta 88 zcmaFCwuOCyg5XvW1_nU}CWdWLdiO-dgBHvT0t^fcTYy6D45(~DBynLRHc%;0{l