mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[naga wgsl-in] Convert textureStore values correctly.
Apply necessary automatic conversions to the `value` argument of `textureStore`.
This commit is contained in:
parent
de1b9a0899
commit
a9a3ea3a41
@ -176,6 +176,7 @@ pub(crate) enum Error<'a> {
|
|||||||
from_type: String,
|
from_type: String,
|
||||||
to_type: String,
|
to_type: String,
|
||||||
},
|
},
|
||||||
|
NotStorageTexture(Span),
|
||||||
BadTextureSampleType {
|
BadTextureSampleType {
|
||||||
span: Span,
|
span: Span,
|
||||||
scalar: Scalar,
|
scalar: Scalar,
|
||||||
@ -536,6 +537,11 @@ impl<'a> Error<'a> {
|
|||||||
labels: vec![(bad_span, "unknown scalar type".into())],
|
labels: vec![(bad_span, "unknown scalar type".into())],
|
||||||
notes: vec!["Valid scalar types are f32, f64, i32, u32, bool".into()],
|
notes: vec!["Valid scalar types are f32, f64, i32, u32, bool".into()],
|
||||||
},
|
},
|
||||||
|
Error::NotStorageTexture(bad_span) => ParseError {
|
||||||
|
message: "textureStore can only be applied to storage textures".to_string(),
|
||||||
|
labels: vec![(bad_span, "not a storage texture".into())],
|
||||||
|
notes: vec![],
|
||||||
|
},
|
||||||
Error::BadTextureSampleType { span, scalar } => ParseError {
|
Error::BadTextureSampleType { span, scalar } => ParseError {
|
||||||
message: format!(
|
message: format!(
|
||||||
"texture sample type must be one of f32, i32 or u32, but found {}",
|
"texture sample type must be one of f32, i32 or u32, but found {}",
|
||||||
|
|||||||
@ -2681,15 +2681,21 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
|||||||
|
|
||||||
let coordinate = self.expression(args.next()?, ctx)?;
|
let coordinate = self.expression(args.next()?, ctx)?;
|
||||||
|
|
||||||
let (_, arrayed) = ctx.image_data(image, image_span)?;
|
let (class, arrayed) = ctx.image_data(image, image_span)?;
|
||||||
let array_index = arrayed
|
let array_index = arrayed
|
||||||
.then(|| {
|
.then(|| {
|
||||||
args.min_args += 1;
|
args.min_args += 1;
|
||||||
self.expression(args.next()?, ctx)
|
self.expression(args.next()?, ctx)
|
||||||
})
|
})
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
let scalar = if let ir::ImageClass::Storage { format, .. } = class {
|
||||||
|
format.into()
|
||||||
|
} else {
|
||||||
|
return Err(Box::new(Error::NotStorageTexture(image_span)));
|
||||||
|
};
|
||||||
|
|
||||||
let value = self.expression(args.next()?, ctx)?;
|
let value =
|
||||||
|
self.expression_with_leaf_scalar(args.next()?, scalar, ctx)?;
|
||||||
|
|
||||||
args.finish()?;
|
args.finish()?;
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,4 @@
|
|||||||
targets = "METAL"
|
targets = "METAL"
|
||||||
|
|
||||||
|
[msl]
|
||||||
|
lang_version = [1, 2]
|
||||||
|
|||||||
@ -18,3 +18,9 @@ fn depth() {
|
|||||||
_ = textureSampleCompare(d, c, vec2(1,2), 0);
|
_ = textureSampleCompare(d, c, vec2(1,2), 0);
|
||||||
_ = textureGatherCompare(d, c, vec2(1,2), 0);
|
_ = textureGatherCompare(d, c, vec2(1,2), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@group(0) @binding(4) var st: texture_storage_2d<rgba8unorm, read_write>;
|
||||||
|
|
||||||
|
fn storage() {
|
||||||
|
textureStore(st, vec2(0,1), vec4(2,3,4,5));
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// language: metal1.0
|
// language: metal1.2
|
||||||
#include <metal_stdlib>
|
#include <metal_stdlib>
|
||||||
#include <simd/simd.h>
|
#include <simd/simd.h>
|
||||||
|
|
||||||
@ -28,3 +28,10 @@ void depth(
|
|||||||
metal::float4 phony_8 = d.gather_compare(c, metal::float2(1.0, 2.0), 0.0);
|
metal::float4 phony_8 = d.gather_compare(c, metal::float2(1.0, 2.0), 0.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void storage(
|
||||||
|
metal::texture2d<float, metal::access::read_write> st
|
||||||
|
) {
|
||||||
|
st.write(metal::float4(2.0, 3.0, 4.0, 5.0), metal::uint2(metal::int2(0, 1)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user