summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Dispersia <dispersias@gmail.com>2021-04-12 23:07:58 -0700
committerLibravatar Dispersia <dispersias@gmail.com>2021-04-12 23:07:58 -0700
commit0722d5e3ec307fd82a1cc76593d17d83cf828943 (patch)
treea77101fc3b316d7b1c8a6316aac03ec5d97a12c2 /wgpu
parentc719091c3d7b5f71899530437fde9b512bc2b0f3 (diff)
downloadiced-0722d5e3ec307fd82a1cc76593d17d83cf828943.tar.gz
iced-0722d5e3ec307fd82a1cc76593d17d83cf828943.tar.bz2
iced-0722d5e3ec307fd82a1cc76593d17d83cf828943.zip
add temporary fix for image wgsl
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/src/image.rs2
-rw-r--r--wgpu/src/shader/blit.wgsl2
-rw-r--r--wgpu/src/shader/image.wgsl14
-rw-r--r--wgpu/src/shader/quad.wgsl2
4 files changed, 11 insertions, 9 deletions
diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs
index 713af209..45b63701 100644
--- a/wgpu/src/image.rs
+++ b/wgpu/src/image.rs
@@ -183,7 +183,7 @@ impl Pipeline {
},
wgpu::VertexAttribute {
shader_location: 5,
- format: wgpu::VertexFormat::Uint32,
+ format: wgpu::VertexFormat::Sint32,
offset: 4 * 8,
},
],
diff --git a/wgpu/src/shader/blit.wgsl b/wgpu/src/shader/blit.wgsl
index 7a987c2c..694f192e 100644
--- a/wgpu/src/shader/blit.wgsl
+++ b/wgpu/src/shader/blit.wgsl
@@ -40,4 +40,4 @@ fn vs_main(input: VertexInput) -> VertexOutput {
[[stage(fragment)]]
fn fs_main(input: VertexOutput) -> [[location(0)]] vec4<f32> {
return textureSample(u_texture, u_sampler, input.uv);
-} \ No newline at end of file
+}
diff --git a/wgpu/src/shader/image.wgsl b/wgpu/src/shader/image.wgsl
index c623247e..a63ee8f6 100644
--- a/wgpu/src/shader/image.wgsl
+++ b/wgpu/src/shader/image.wgsl
@@ -5,7 +5,7 @@ struct Globals {
[[group(0), binding(0)]] var<uniform> globals: Globals;
[[group(0), binding(1)]] var u_sampler: sampler;
-[[group(0), binding(2)]] var u_texture: texture2d<f32>;
+[[group(1), binding(0)]] var u_texture: texture_2d_array<f32>;
struct VertexInput {
[[location(0)]] v_pos: vec2<f32>;
@@ -13,23 +13,25 @@ struct VertexInput {
[[location(2)]] scale: vec2<f32>;
[[location(3)]] atlas_pos: vec2<f32>;
[[location(4)]] atlas_scale: vec2<f32>;
- [[location(5)]] layer: u32;
+ [[location(5)]] layer: i32;
};
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
- [[location(0)]] uv: vec3<f32>;
+ [[location(0)]] uv: vec2<f32>;
+ [[location(1)]] layer: f32; // this should be an i32, but naga currently reads that as requiring interpolation.
};
[[stage(vertex)]]
fn vs_main(input: VertexInput) -> VertexOutput {
var out: VertexOutput;
- out.uv = vec3<f32>(input.v_pos * input.atlas_scale + input.atlas_pos, input.layer);
+ out.uv = vec2<f32>(input.v_pos * input.atlas_scale + input.atlas_pos);
+ out.layer = f32(input.layer);
var transform: mat4x4<f32> = mat4x4<f32>(
vec4<f32>(input.scale.x, 0.0, 0.0, 0.0),
- vec4<f32>(0.0, scale.y, 0.0, 0.0),
+ vec4<f32>(0.0, input.scale.y, 0.0, 0.0),
vec4<f32>(0.0, 0.0, 1.0, 0.0),
vec4<f32>(input.pos, 0.0, 1.0)
);
@@ -41,5 +43,5 @@ fn vs_main(input: VertexInput) -> VertexOutput {
[[stage(fragment)]]
fn fs_main(input: VertexOutput) -> [[location(0)]] vec4<f32> {
- return textureSample(u_texture, u_sampler, input.uv);
+ return textureSample(u_texture, u_sampler, input.uv, i32(input.layer));
}
diff --git a/wgpu/src/shader/quad.wgsl b/wgpu/src/shader/quad.wgsl
index c67b45e3..3c0aa9f2 100644
--- a/wgpu/src/shader/quad.wgsl
+++ b/wgpu/src/shader/quad.wgsl
@@ -120,4 +120,4 @@ fn fs_main(
dist);
return vec4<f32>(radius_alpha, radius_alpha, radius_alpha, radius_alpha);
-} \ No newline at end of file
+}