Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use separate samplers and sampled images in the examples #2354

Merged
merged 2 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions examples/src/bin/async-update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,11 @@ fn main() {
layout(location = 0) in vec2 tex_coords;
layout(location = 0) out vec4 f_color;

layout(set = 1, binding = 0) uniform sampler2D tex;
layout(set = 1, binding = 0) uniform sampler s;
layout(set = 1, binding = 1) uniform texture2D tex;

void main() {
f_color = texture(tex, tex_coords);
f_color = texture(sampler2D(tex, s), tex_coords);
}
",
}
Expand Down Expand Up @@ -505,11 +506,10 @@ fn main() {
PersistentDescriptorSet::new(
&descriptor_set_allocator,
pipeline.layout().set_layouts()[1].clone(),
[WriteDescriptorSet::image_view_sampler(
0,
ImageView::new_default(texture).unwrap(),
sampler.clone(),
)],
[
WriteDescriptorSet::sampler(0, sampler.clone()),
WriteDescriptorSet::image_view(1, ImageView::new_default(texture).unwrap()),
],
[],
)
.unwrap()
Expand Down
14 changes: 9 additions & 5 deletions examples/src/bin/gl-interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,10 @@ mod linux {
let set = PersistentDescriptorSet::new(
&descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::image_view_sampler(
0, image_view, sampler,
)],
[
WriteDescriptorSet::sampler(0, sampler),
WriteDescriptorSet::image_view(1, image_view),
],
[],
)
.unwrap();
Expand Down Expand Up @@ -798,9 +799,12 @@ mod linux {
#version 450
layout(location = 0) in vec2 tex_coords;
layout(location = 0) out vec4 f_color;
layout(set = 0, binding = 0) uniform sampler2D tex;

layout(set = 0, binding = 0) uniform sampler s;
layout(set = 0, binding = 1) uniform texture2D tex;

void main() {
f_color = texture(tex, tex_coords);
f_color = texture(sampler2D(tex, s), tex_coords);
}
",
}
Expand Down
10 changes: 7 additions & 3 deletions examples/src/bin/image-self-copy-blit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ fn main() {
let set = PersistentDescriptorSet::new(
&descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::image_view_sampler(0, texture, sampler)],
[
WriteDescriptorSet::sampler(0, sampler),
WriteDescriptorSet::image_view(1, texture),
],
[],
)
.unwrap();
Expand Down Expand Up @@ -578,10 +581,11 @@ mod fs {
layout(location = 0) in vec2 tex_coords;
layout(location = 0) out vec4 f_color;

layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 0) uniform sampler s;
layout(set = 0, binding = 1) uniform texture2D tex;

void main() {
f_color = texture(tex, tex_coords);
f_color = texture(sampler2D(tex, s), tex_coords);
}
",
}
Expand Down
10 changes: 7 additions & 3 deletions examples/src/bin/image/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ fn main() {
let set = PersistentDescriptorSet::new(
&descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::image_view_sampler(0, texture, sampler)],
[
WriteDescriptorSet::sampler(0, sampler),
WriteDescriptorSet::image_view(1, texture),
],
[],
)
.unwrap();
Expand Down Expand Up @@ -526,10 +529,11 @@ mod fs {
layout(location = 0) in vec2 tex_coords;
layout(location = 0) out vec4 f_color;

layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 0) uniform sampler s;
layout(set = 0, binding = 1) uniform texture2D tex;

void main() {
f_color = texture(tex, tex_coords);
f_color = texture(sampler2D(tex, s), tex_coords);
}
",
}
Expand Down
7 changes: 4 additions & 3 deletions examples/src/bin/immutable-sampler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ fn main() {
let set = PersistentDescriptorSet::new(
&descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::image_view(0, texture)],
[WriteDescriptorSet::image_view(1, texture)],
[],
)
.unwrap();
Expand Down Expand Up @@ -547,10 +547,11 @@ mod fs {
layout(location = 0) in vec2 tex_coords;
layout(location = 0) out vec4 f_color;

layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 0) uniform sampler s;
layout(set = 0, binding = 1) uniform texture2D tex;

void main() {
f_color = texture(tex, tex_coords);
f_color = texture(sampler2D(tex, s), tex_coords);
}
",
}
Expand Down
10 changes: 7 additions & 3 deletions examples/src/bin/interactive_fractal/pixels_draw_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ impl PixelsDrawPipeline {
PersistentDescriptorSet::new(
&self.descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::image_view_sampler(0, image, sampler)],
[
WriteDescriptorSet::sampler(0, sampler),
WriteDescriptorSet::image_view(1, image),
],
[],
)
.unwrap()
Expand Down Expand Up @@ -279,10 +282,11 @@ mod fs {

layout(location = 0) out vec4 f_color;

layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 0) uniform sampler s;
layout(set = 0, binding = 1) uniform texture2D tex;

void main() {
f_color = texture(tex, v_tex_coords);
f_color = texture(sampler2D(tex, s), v_tex_coords);
}
",
}
Expand Down
10 changes: 7 additions & 3 deletions examples/src/bin/multi_window_game_of_life/pixels_draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ impl PixelsDrawPipeline {
PersistentDescriptorSet::new(
&self.descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::image_view_sampler(0, image, sampler)],
[
WriteDescriptorSet::sampler(0, sampler),
WriteDescriptorSet::image_view(1, image),
],
[],
)
.unwrap()
Expand Down Expand Up @@ -275,10 +278,11 @@ mod fs {

layout(location = 0) out vec4 f_color;

layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 0) uniform sampler s;
layout(set = 0, binding = 1) uniform texture2D tex;

void main() {
f_color = texture(tex, v_tex_coords);
f_color = texture(sampler2D(tex, s), v_tex_coords);
}
",
}
Expand Down
16 changes: 11 additions & 5 deletions examples/src/bin/push-descriptors/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,14 @@ fn main() {
PipelineBindPoint::Graphics,
pipeline.layout().clone(),
0,
[WriteDescriptorSet::image_view(0, texture.clone())]
.into_iter()
.collect(),
[
// If the binding is an immutable sampler, using push descriptors
// you must write dummy value to the binding.
Rua marked this conversation as resolved.
Show resolved Hide resolved
WriteDescriptorSet::none(0),
WriteDescriptorSet::image_view(1, texture.clone()),
]
.into_iter()
.collect(),
)
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone())
Expand Down Expand Up @@ -522,10 +527,11 @@ mod fs {
layout(location = 0) in vec2 tex_coords;
layout(location = 0) out vec4 f_color;

layout(set = 0, binding = 0) uniform sampler2D tex;
layout(set = 0, binding = 0) uniform sampler s;
layout(set = 0, binding = 1) uniform texture2D tex;

void main() {
f_color = texture(tex, tex_coords);
f_color = texture(sampler2D(tex, s), tex_coords);
}
",
}
Expand Down
21 changes: 9 additions & 12 deletions examples/src/bin/runtime_array/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ fn main() {
let mut layout_create_info =
PipelineDescriptorSetLayoutCreateInfo::from_stages(&stages);

// Adjust the info for set 0, binding 0 to make it variable with 2 descriptors.
// Adjust the info for set 0, binding 1 to make it variable with 2 descriptors.
let binding = layout_create_info.set_layouts[0]
.bindings
.get_mut(&0)
.get_mut(&1)
.unwrap();
binding.binding_flags |= DescriptorBindingFlags::VARIABLE_DESCRIPTOR_COUNT;
binding.descriptor_count = 2;
Expand Down Expand Up @@ -458,14 +458,10 @@ fn main() {
&descriptor_set_allocator,
layout.clone(),
2,
[WriteDescriptorSet::image_view_sampler_array(
0,
0,
[
(mascot_texture as _, sampler.clone()),
(vulkano_texture as _, sampler),
],
)],
[
WriteDescriptorSet::sampler(0, sampler),
WriteDescriptorSet::image_view_array(1, 0, [mascot_texture as _, vulkano_texture as _]),
],
[],
)
.unwrap();
Expand Down Expand Up @@ -667,10 +663,11 @@ mod fs {

layout(location = 0) out vec4 f_color;

layout(set = 0, binding = 0) uniform sampler2D tex[];
layout(set = 0, binding = 0) uniform sampler s;
layout(set = 0, binding = 1) uniform texture2D tex[];

void main() {
f_color = texture(nonuniformEXT(tex[tex_i]), coords);
f_color = texture(nonuniformEXT(sampler2D(tex[tex_i], s)), coords);
}
",
}
Expand Down
10 changes: 7 additions & 3 deletions examples/src/bin/texture_array/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,10 @@ fn main() {
let set = PersistentDescriptorSet::new(
&descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::image_view_sampler(0, texture, sampler)],
[
WriteDescriptorSet::sampler(0, sampler),
WriteDescriptorSet::image_view(1, texture),
],
[],
)
.unwrap();
Expand Down Expand Up @@ -543,10 +546,11 @@ mod fs {
layout(location = 1) flat in uint layer;
layout(location = 0) out vec4 f_color;

layout(set = 0, binding = 0) uniform sampler2DArray tex;
layout(set = 0, binding = 0) uniform sampler s;
layout(set = 0, binding = 1) uniform texture2DArray tex;

void main() {
f_color = texture(tex, vec3(tex_coords, layer));
f_color = texture(sampler2DArray(tex, s), vec3(tex_coords, layer));
}
",
}
Expand Down
Loading