mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[rs] Merge #540
540: Improve and fix examples/texture-arrays r=cwfitzgerald a=im-0 Original examples/texture-arrays produces following output on my machine (Linux, Mesa/RADV 20.2-rc3, Radeon VII):  Quick investigation showed that only shaders with non-uniform indexing are problematic (first commit helped with this). Then, after searching on the web, I figured out that the problem is in missing `nonuniformEXT`. Second commit fixes this. I am new to graphics programming, and `nonuniformEXT` may work just by accident. So please confirm my finding before merging. Co-authored-by: Ivan Mironov <mironov.ivan@gmail.com>
This commit is contained in:
@@ -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<u8> = 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::<Vertex>();
|
||||
let vertex_data = create_vertices();
|
||||
|
||||
@@ -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];
|
||||
|
||||
Binary file not shown.
@@ -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[];
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user