mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[wgsl-in] support textureSampleCompareLevel
This commit is contained in:
committed by
Dzmitry Malyshau
parent
1366546645
commit
8a1d883ba5
@@ -880,6 +880,38 @@ impl Parser {
|
||||
}
|
||||
}
|
||||
"textureSampleCompare" => {
|
||||
lexer.open_arguments()?;
|
||||
let (image_name, image_span) = lexer.next_ident_with_span()?;
|
||||
lexer.expect(Token::Separator(','))?;
|
||||
let (sampler_name, sampler_span) = lexer.next_ident_with_span()?;
|
||||
lexer.expect(Token::Separator(','))?;
|
||||
let coordinate = self.parse_general_expression(lexer, ctx.reborrow())?;
|
||||
let sc = ctx.prepare_sampling(image_name, image_span)?;
|
||||
let array_index = if sc.arrayed {
|
||||
lexer.expect(Token::Separator(','))?;
|
||||
Some(self.parse_general_expression(lexer, ctx.reborrow())?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
lexer.expect(Token::Separator(','))?;
|
||||
let reference = self.parse_general_expression(lexer, ctx.reborrow())?;
|
||||
let offset = if lexer.skip(Token::Separator(',')) {
|
||||
Some(self.parse_const_expression(lexer, ctx.types, ctx.constants)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
lexer.close_arguments()?;
|
||||
crate::Expression::ImageSample {
|
||||
image: sc.image,
|
||||
sampler: ctx.lookup_ident.lookup(sampler_name, sampler_span)?,
|
||||
coordinate,
|
||||
array_index,
|
||||
offset,
|
||||
level: crate::SampleLevel::Auto,
|
||||
depth_ref: Some(reference),
|
||||
}
|
||||
}
|
||||
"textureSampleCompareLevel" => {
|
||||
lexer.open_arguments()?;
|
||||
let (image_name, image_span) = lexer.next_ident_with_span()?;
|
||||
lexer.expect(Token::Separator(','))?;
|
||||
|
||||
@@ -30,7 +30,7 @@ fn fetch_shadow(light_id: u32, homogeneous_coords: vec4<f32>) -> f32 {
|
||||
}
|
||||
let flip_correction = vec2<f32>(0.5, -0.5);
|
||||
let light_local = homogeneous_coords.xy * flip_correction / homogeneous_coords.w + vec2<f32>(0.5, 0.5);
|
||||
return textureSampleCompare(t_shadow, sampler_shadow, light_local, i32(light_id), homogeneous_coords.z / homogeneous_coords.w);
|
||||
return textureSampleCompareLevel(t_shadow, sampler_shadow, light_local, i32(light_id), homogeneous_coords.z / homogeneous_coords.w);
|
||||
}
|
||||
|
||||
let c_ambient: vec3<f32> = vec3<f32>(0.05, 0.05, 0.05);
|
||||
|
||||
Reference in New Issue
Block a user