mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
[wgsl-in] Reject invalid texture types for textureSampleBias (#6566)
Non-sampled textures are not allowed, and neither are 1 dimensional textures.
This commit is contained in:
parent
baecb5fbf1
commit
6f528e2ebc
@ -110,6 +110,8 @@ pub enum ExpressionError {
|
||||
InvalidSampleLevelExactType(Handle<crate::Expression>),
|
||||
#[error("Sample level (bias) type {0:?} is not a scalar float")]
|
||||
InvalidSampleLevelBiasType(Handle<crate::Expression>),
|
||||
#[error("Bias can't be done for image dimension {0:?}")]
|
||||
InvalidSampleLevelBiasDimension(crate::ImageDimension),
|
||||
#[error("Sample level (gradient) of {1:?} doesn't match the image dimension {0:?}")]
|
||||
InvalidSampleLevelGradientType(crate::ImageDimension, Handle<crate::Expression>),
|
||||
#[error("Unable to cast")]
|
||||
@ -558,6 +560,19 @@ impl super::Validator {
|
||||
}) => {}
|
||||
_ => return Err(ExpressionError::InvalidSampleLevelBiasType(expr)),
|
||||
}
|
||||
match class {
|
||||
crate::ImageClass::Sampled {
|
||||
kind: Sk::Float,
|
||||
multi: false,
|
||||
} => {
|
||||
if dim == crate::ImageDimension::D1 {
|
||||
return Err(ExpressionError::InvalidSampleLevelBiasDimension(
|
||||
dim,
|
||||
));
|
||||
}
|
||||
}
|
||||
_ => return Err(ExpressionError::InvalidImageClass(class)),
|
||||
}
|
||||
ShaderStages::FRAGMENT
|
||||
}
|
||||
crate::SampleLevel::Gradient { x, y } => {
|
||||
|
@ -45,17 +45,18 @@ void testTex1D(in float coord) {
|
||||
int levels = textureQueryLevels(sampler1D(tex1D, samp));
|
||||
vec4 c;
|
||||
c = texture(sampler1D(tex1D, samp), coord);
|
||||
c = texture(sampler1D(tex1D, samp), coord, 2.0);
|
||||
/* 1 dimensional textures are not supported in the WGSL specification with `textureSampleBias()` */
|
||||
// c = texture(sampler1D(tex1D, samp), coord, 2.0);
|
||||
c = textureGrad(sampler1D(tex1D, samp), coord, 4.0, 4.0);
|
||||
c = textureGradOffset(sampler1D(tex1D, samp), coord, 4.0, 4.0, 5);
|
||||
c = textureLod(sampler1D(tex1D, samp), coord, 3.0);
|
||||
c = textureLodOffset(sampler1D(tex1D, samp), coord, 3.0, 5);
|
||||
c = textureOffset(sampler1D(tex1D, samp), coord, 5);
|
||||
c = textureOffset(sampler1D(tex1D, samp), coord, 5, 2.0);
|
||||
// c = textureOffset(sampler1D(tex1D, samp), coord, 5, 2.0);
|
||||
c = textureProj(sampler1D(tex1D, samp), vec2(coord, 6.0));
|
||||
c = textureProj(sampler1D(tex1D, samp), vec4(coord, 0.0, 0.0, 6.0));
|
||||
c = textureProj(sampler1D(tex1D, samp), vec2(coord, 6.0), 2.0);
|
||||
c = textureProj(sampler1D(tex1D, samp), vec4(coord, 0.0, 0.0, 6.0), 2.0);
|
||||
// c = textureProj(sampler1D(tex1D, samp), vec2(coord, 6.0), 2.0);
|
||||
// c = textureProj(sampler1D(tex1D, samp), vec4(coord, 0.0, 0.0, 6.0), 2.0);
|
||||
c = textureProjGrad(sampler1D(tex1D, samp), vec2(coord, 6.0), 4.0, 4.0);
|
||||
c = textureProjGrad(sampler1D(tex1D, samp), vec4(coord, 0.0, 0.0, 6.0), 4.0, 4.0);
|
||||
c = textureProjGradOffset(sampler1D(tex1D, samp), vec2(coord, 6.0), 4.0, 4.0, 5);
|
||||
@ -66,8 +67,8 @@ void testTex1D(in float coord) {
|
||||
c = textureProjLodOffset(sampler1D(tex1D, samp), vec4(coord, 0.0, 0.0, 6.0), 3.0, 5);
|
||||
c = textureProjOffset(sampler1D(tex1D, samp), vec2(coord, 6.0), 5);
|
||||
c = textureProjOffset(sampler1D(tex1D, samp), vec4(coord, 0.0, 0.0, 6.0), 5);
|
||||
c = textureProjOffset(sampler1D(tex1D, samp), vec2(coord, 6.0), 5, 2.0);
|
||||
c = textureProjOffset(sampler1D(tex1D, samp), vec4(coord, 0.0, 0.0, 6.0), 5, 2.0);
|
||||
// c = textureProjOffset(sampler1D(tex1D, samp), vec2(coord, 6.0), 5, 2.0);
|
||||
// c = textureProjOffset(sampler1D(tex1D, samp), vec4(coord, 0.0, 0.0, 6.0), 5, 2.0);
|
||||
c = texelFetch(sampler1D(tex1D, samp), int(coord), 3);
|
||||
c = texelFetchOffset(sampler1D(tex1D, samp), int(coord), 3, 5);
|
||||
}
|
||||
@ -101,13 +102,13 @@ void testTex1DArray(in vec2 coord) {
|
||||
int levels = textureQueryLevels(sampler1DArray(tex1DArray, samp));
|
||||
vec4 c;
|
||||
c = texture(sampler1DArray(tex1DArray, samp), coord);
|
||||
c = texture(sampler1DArray(tex1DArray, samp), coord, 2.0);
|
||||
// c = texture(sampler1DArray(tex1DArray, samp), coord, 2.0);
|
||||
c = textureGrad(sampler1DArray(tex1DArray, samp), coord, 4.0, 4.0);
|
||||
c = textureGradOffset(sampler1DArray(tex1DArray, samp), coord, 4.0, 4.0, 5);
|
||||
c = textureLod(sampler1DArray(tex1DArray, samp), coord, 3.0);
|
||||
c = textureLodOffset(sampler1DArray(tex1DArray, samp), coord, 3.0, 5);
|
||||
c = textureOffset(sampler1DArray(tex1DArray, samp), coord, 5);
|
||||
c = textureOffset(sampler1DArray(tex1DArray, samp), coord, 5, 2.0);
|
||||
// c = textureOffset(sampler1DArray(tex1DArray, samp), coord, 5, 2.0);
|
||||
c = texelFetch(sampler1DArray(tex1DArray, samp), ivec2(coord), 3);
|
||||
c = texelFetchOffset(sampler1DArray(tex1DArray, samp), ivec2(coord), 3, 5);
|
||||
}
|
||||
|
@ -49,115 +49,89 @@ fn testTex1D(coord: f32) {
|
||||
let _e30 = coord_1;
|
||||
let _e31 = textureSample(tex1D, samp, _e30);
|
||||
c = _e31;
|
||||
let _e34 = coord_1;
|
||||
let _e36 = textureSampleBias(tex1D, samp, _e34, 2f);
|
||||
c = _e36;
|
||||
let _e40 = coord_1;
|
||||
let _e43 = textureSampleGrad(tex1D, samp, _e40, 4f, 4f);
|
||||
c = _e43;
|
||||
let _e48 = coord_1;
|
||||
let _e52 = textureSampleGrad(tex1D, samp, _e48, 4f, 4f, 5i);
|
||||
let _e35 = coord_1;
|
||||
let _e38 = textureSampleGrad(tex1D, samp, _e35, 4f, 4f);
|
||||
c = _e38;
|
||||
let _e43 = coord_1;
|
||||
let _e47 = textureSampleGrad(tex1D, samp, _e43, 4f, 4f, 5i);
|
||||
c = _e47;
|
||||
let _e50 = coord_1;
|
||||
let _e52 = textureSampleLevel(tex1D, samp, _e50, 3f);
|
||||
c = _e52;
|
||||
let _e55 = coord_1;
|
||||
let _e57 = textureSampleLevel(tex1D, samp, _e55, 3f);
|
||||
c = _e57;
|
||||
let _e61 = coord_1;
|
||||
let _e64 = textureSampleLevel(tex1D, samp, _e61, 3f, 5i);
|
||||
let _e56 = coord_1;
|
||||
let _e59 = textureSampleLevel(tex1D, samp, _e56, 3f, 5i);
|
||||
c = _e59;
|
||||
let _e62 = coord_1;
|
||||
let _e64 = textureSample(tex1D, samp, _e62, 5i);
|
||||
c = _e64;
|
||||
let _e67 = coord_1;
|
||||
let _e69 = textureSample(tex1D, samp, _e67, 5i);
|
||||
c = _e69;
|
||||
let _e73 = coord_1;
|
||||
let _e76 = textureSampleBias(tex1D, samp, _e73, 2f, 5i);
|
||||
c = _e76;
|
||||
let _e77 = coord_1;
|
||||
let _e65 = coord_1;
|
||||
let _e68 = coord_1;
|
||||
let _e70 = vec2<f32>(_e68, 6f);
|
||||
let _e74 = textureSample(tex1D, samp, (_e70.x / _e70.y));
|
||||
c = _e74;
|
||||
let _e75 = coord_1;
|
||||
let _e80 = coord_1;
|
||||
let _e82 = vec2<f32>(_e80, 6f);
|
||||
let _e86 = textureSample(tex1D, samp, (_e82.x / _e82.y));
|
||||
c = _e86;
|
||||
let _e87 = coord_1;
|
||||
let _e92 = coord_1;
|
||||
let _e96 = vec4<f32>(_e92, 0f, 0f, 6f);
|
||||
let _e102 = textureSample(tex1D, samp, (_e96.xyz / vec3(_e96.w)).x);
|
||||
c = _e102;
|
||||
let _e103 = coord_1;
|
||||
let _e107 = coord_1;
|
||||
let _e109 = vec2<f32>(_e107, 6f);
|
||||
let _e114 = textureSampleBias(tex1D, samp, (_e109.x / _e109.y), 2f);
|
||||
c = _e114;
|
||||
let _e115 = coord_1;
|
||||
let _e121 = coord_1;
|
||||
let _e125 = vec4<f32>(_e121, 0f, 0f, 6f);
|
||||
let _e132 = textureSampleBias(tex1D, samp, (_e125.xyz / vec3(_e125.w)).x, 2f);
|
||||
c = _e132;
|
||||
let _e133 = coord_1;
|
||||
let _e138 = coord_1;
|
||||
let _e140 = vec2<f32>(_e138, 6f);
|
||||
let _e146 = textureSampleGrad(tex1D, samp, (_e140.x / _e140.y), 4f, 4f);
|
||||
c = _e146;
|
||||
let _e147 = coord_1;
|
||||
let _e154 = coord_1;
|
||||
let _e158 = vec4<f32>(_e154, 0f, 0f, 6f);
|
||||
let _e166 = textureSampleGrad(tex1D, samp, (_e158.xyz / vec3(_e158.w)).x, 4f, 4f);
|
||||
c = _e166;
|
||||
let _e84 = vec4<f32>(_e80, 0f, 0f, 6f);
|
||||
let _e90 = textureSample(tex1D, samp, (_e84.xyz / vec3(_e84.w)).x);
|
||||
c = _e90;
|
||||
let _e91 = coord_1;
|
||||
let _e96 = coord_1;
|
||||
let _e98 = vec2<f32>(_e96, 6f);
|
||||
let _e104 = textureSampleGrad(tex1D, samp, (_e98.x / _e98.y), 4f, 4f);
|
||||
c = _e104;
|
||||
let _e105 = coord_1;
|
||||
let _e112 = coord_1;
|
||||
let _e116 = vec4<f32>(_e112, 0f, 0f, 6f);
|
||||
let _e124 = textureSampleGrad(tex1D, samp, (_e116.xyz / vec3(_e116.w)).x, 4f, 4f);
|
||||
c = _e124;
|
||||
let _e125 = coord_1;
|
||||
let _e131 = coord_1;
|
||||
let _e133 = vec2<f32>(_e131, 6f);
|
||||
let _e140 = textureSampleGrad(tex1D, samp, (_e133.x / _e133.y), 4f, 4f, 5i);
|
||||
c = _e140;
|
||||
let _e141 = coord_1;
|
||||
let _e149 = coord_1;
|
||||
let _e153 = vec4<f32>(_e149, 0f, 0f, 6f);
|
||||
let _e162 = textureSampleGrad(tex1D, samp, (_e153.xyz / vec3(_e153.w)).x, 4f, 4f, 5i);
|
||||
c = _e162;
|
||||
let _e163 = coord_1;
|
||||
let _e167 = coord_1;
|
||||
let _e173 = coord_1;
|
||||
let _e175 = vec2<f32>(_e173, 6f);
|
||||
let _e182 = textureSampleGrad(tex1D, samp, (_e175.x / _e175.y), 4f, 4f, 5i);
|
||||
c = _e182;
|
||||
let _e183 = coord_1;
|
||||
let _e191 = coord_1;
|
||||
let _e195 = vec4<f32>(_e191, 0f, 0f, 6f);
|
||||
let _e204 = textureSampleGrad(tex1D, samp, (_e195.xyz / vec3(_e195.w)).x, 4f, 4f, 5i);
|
||||
c = _e204;
|
||||
let _e205 = coord_1;
|
||||
let _e209 = coord_1;
|
||||
let _e211 = vec2<f32>(_e209, 6f);
|
||||
let _e216 = textureSampleLevel(tex1D, samp, (_e211.x / _e211.y), 3f);
|
||||
c = _e216;
|
||||
let _e217 = coord_1;
|
||||
let _e223 = coord_1;
|
||||
let _e227 = vec4<f32>(_e223, 0f, 0f, 6f);
|
||||
let _e234 = textureSampleLevel(tex1D, samp, (_e227.xyz / vec3(_e227.w)).x, 3f);
|
||||
c = _e234;
|
||||
let _e235 = coord_1;
|
||||
let _e240 = coord_1;
|
||||
let _e242 = vec2<f32>(_e240, 6f);
|
||||
let _e248 = textureSampleLevel(tex1D, samp, (_e242.x / _e242.y), 3f, 5i);
|
||||
c = _e248;
|
||||
let _e249 = coord_1;
|
||||
let _e256 = coord_1;
|
||||
let _e260 = vec4<f32>(_e256, 0f, 0f, 6f);
|
||||
let _e268 = textureSampleLevel(tex1D, samp, (_e260.xyz / vec3(_e260.w)).x, 3f, 5i);
|
||||
c = _e268;
|
||||
let _e269 = coord_1;
|
||||
let _e273 = coord_1;
|
||||
let _e275 = vec2<f32>(_e273, 6f);
|
||||
let _e280 = textureSample(tex1D, samp, (_e275.x / _e275.y), 5i);
|
||||
c = _e280;
|
||||
let _e281 = coord_1;
|
||||
let _e287 = coord_1;
|
||||
let _e291 = vec4<f32>(_e287, 0f, 0f, 6f);
|
||||
let _e298 = textureSample(tex1D, samp, (_e291.xyz / vec3(_e291.w)).x, 5i);
|
||||
c = _e298;
|
||||
let _e299 = coord_1;
|
||||
let _e304 = coord_1;
|
||||
let _e306 = vec2<f32>(_e304, 6f);
|
||||
let _e312 = textureSampleBias(tex1D, samp, (_e306.x / _e306.y), 2f, 5i);
|
||||
c = _e312;
|
||||
let _e313 = coord_1;
|
||||
let _e320 = coord_1;
|
||||
let _e324 = vec4<f32>(_e320, 0f, 0f, 6f);
|
||||
let _e332 = textureSampleBias(tex1D, samp, (_e324.xyz / vec3(_e324.w)).x, 2f, 5i);
|
||||
c = _e332;
|
||||
let _e333 = coord_1;
|
||||
let _e336 = coord_1;
|
||||
let _e339 = textureLoad(tex1D, i32(_e336), 3i);
|
||||
c = _e339;
|
||||
let _e340 = coord_1;
|
||||
let _e344 = coord_1;
|
||||
let _e348 = textureLoad(tex1D, i32(_e344), 3i);
|
||||
c = _e348;
|
||||
let _e169 = vec2<f32>(_e167, 6f);
|
||||
let _e174 = textureSampleLevel(tex1D, samp, (_e169.x / _e169.y), 3f);
|
||||
c = _e174;
|
||||
let _e175 = coord_1;
|
||||
let _e181 = coord_1;
|
||||
let _e185 = vec4<f32>(_e181, 0f, 0f, 6f);
|
||||
let _e192 = textureSampleLevel(tex1D, samp, (_e185.xyz / vec3(_e185.w)).x, 3f);
|
||||
c = _e192;
|
||||
let _e193 = coord_1;
|
||||
let _e198 = coord_1;
|
||||
let _e200 = vec2<f32>(_e198, 6f);
|
||||
let _e206 = textureSampleLevel(tex1D, samp, (_e200.x / _e200.y), 3f, 5i);
|
||||
c = _e206;
|
||||
let _e207 = coord_1;
|
||||
let _e214 = coord_1;
|
||||
let _e218 = vec4<f32>(_e214, 0f, 0f, 6f);
|
||||
let _e226 = textureSampleLevel(tex1D, samp, (_e218.xyz / vec3(_e218.w)).x, 3f, 5i);
|
||||
c = _e226;
|
||||
let _e227 = coord_1;
|
||||
let _e231 = coord_1;
|
||||
let _e233 = vec2<f32>(_e231, 6f);
|
||||
let _e238 = textureSample(tex1D, samp, (_e233.x / _e233.y), 5i);
|
||||
c = _e238;
|
||||
let _e239 = coord_1;
|
||||
let _e245 = coord_1;
|
||||
let _e249 = vec4<f32>(_e245, 0f, 0f, 6f);
|
||||
let _e256 = textureSample(tex1D, samp, (_e249.xyz / vec3(_e249.w)).x, 5i);
|
||||
c = _e256;
|
||||
let _e257 = coord_1;
|
||||
let _e260 = coord_1;
|
||||
let _e263 = textureLoad(tex1D, i32(_e260), 3i);
|
||||
c = _e263;
|
||||
let _e264 = coord_1;
|
||||
let _e268 = coord_1;
|
||||
let _e272 = textureLoad(tex1D, i32(_e268), 3i);
|
||||
c = _e272;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -176,37 +150,31 @@ fn testTex1DArray(coord_2: vec2<f32>) {
|
||||
let _e32 = coord_3;
|
||||
let _e36 = textureSample(tex1DArray, samp, _e32.x, i32(_e32.y));
|
||||
c_1 = _e36;
|
||||
let _e39 = coord_3;
|
||||
let _e44 = textureSampleBias(tex1DArray, samp, _e39.x, i32(_e39.y), 2f);
|
||||
c_1 = _e44;
|
||||
let _e48 = coord_3;
|
||||
let _e54 = textureSampleGrad(tex1DArray, samp, _e48.x, i32(_e48.y), 4f, 4f);
|
||||
c_1 = _e54;
|
||||
let _e59 = coord_3;
|
||||
let _e66 = textureSampleGrad(tex1DArray, samp, _e59.x, i32(_e59.y), 4f, 4f, 5i);
|
||||
let _e40 = coord_3;
|
||||
let _e46 = textureSampleGrad(tex1DArray, samp, _e40.x, i32(_e40.y), 4f, 4f);
|
||||
c_1 = _e46;
|
||||
let _e51 = coord_3;
|
||||
let _e58 = textureSampleGrad(tex1DArray, samp, _e51.x, i32(_e51.y), 4f, 4f, 5i);
|
||||
c_1 = _e58;
|
||||
let _e61 = coord_3;
|
||||
let _e66 = textureSampleLevel(tex1DArray, samp, _e61.x, i32(_e61.y), 3f);
|
||||
c_1 = _e66;
|
||||
let _e69 = coord_3;
|
||||
let _e74 = textureSampleLevel(tex1DArray, samp, _e69.x, i32(_e69.y), 3f);
|
||||
c_1 = _e74;
|
||||
let _e78 = coord_3;
|
||||
let _e84 = textureSampleLevel(tex1DArray, samp, _e78.x, i32(_e78.y), 3f, 5i);
|
||||
let _e70 = coord_3;
|
||||
let _e76 = textureSampleLevel(tex1DArray, samp, _e70.x, i32(_e70.y), 3f, 5i);
|
||||
c_1 = _e76;
|
||||
let _e79 = coord_3;
|
||||
let _e84 = textureSample(tex1DArray, samp, _e79.x, i32(_e79.y), 5i);
|
||||
c_1 = _e84;
|
||||
let _e87 = coord_3;
|
||||
let _e92 = textureSample(tex1DArray, samp, _e87.x, i32(_e87.y), 5i);
|
||||
c_1 = _e92;
|
||||
let _e96 = coord_3;
|
||||
let _e102 = textureSampleBias(tex1DArray, samp, _e96.x, i32(_e96.y), 2f, 5i);
|
||||
c_1 = _e102;
|
||||
let _e103 = coord_3;
|
||||
let _e106 = coord_3;
|
||||
let _e107 = vec2<i32>(_e106);
|
||||
let _e111 = textureLoad(tex1DArray, _e107.x, _e107.y, 3i);
|
||||
c_1 = _e111;
|
||||
let _e112 = coord_3;
|
||||
let _e116 = coord_3;
|
||||
let _e117 = vec2<i32>(_e116);
|
||||
let _e122 = textureLoad(tex1DArray, _e117.x, _e117.y, 3i);
|
||||
c_1 = _e122;
|
||||
let _e85 = coord_3;
|
||||
let _e88 = coord_3;
|
||||
let _e89 = vec2<i32>(_e88);
|
||||
let _e93 = textureLoad(tex1DArray, _e89.x, _e89.y, 3i);
|
||||
c_1 = _e93;
|
||||
let _e94 = coord_3;
|
||||
let _e98 = coord_3;
|
||||
let _e99 = vec2<i32>(_e98);
|
||||
let _e104 = textureLoad(tex1DArray, _e99.x, _e99.y, 3i);
|
||||
c_1 = _e104;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user