mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-22 06:45:13 +00:00
fixed SampledImage::sample() fns being marked as unsafe
This commit is contained in:
parent
ff53483822
commit
9ae674aa76
@ -979,19 +979,13 @@ impl<
|
||||
>
|
||||
{
|
||||
/// Sample texels at `coord` from the sampled image with an implicit lod.
|
||||
///
|
||||
/// # Safety
|
||||
/// Sampling with a type (`S`) that doesn't match the image's image format
|
||||
/// will result in undefined behaviour.
|
||||
#[crate::macros::gpu_only]
|
||||
pub unsafe fn sample<F>(
|
||||
&self,
|
||||
coord: impl ImageCoordinate<F, DIM, ARRAYED>,
|
||||
) -> SampledType::Vec4
|
||||
pub fn sample<F>(&self, coord: impl ImageCoordinate<F, DIM, ARRAYED>) -> SampledType::Vec4
|
||||
where
|
||||
F: Float,
|
||||
{
|
||||
let mut result = Default::default();
|
||||
unsafe {
|
||||
asm!(
|
||||
"%sampledImage = OpLoad typeof*{1} {1}",
|
||||
"%coord = OpLoad typeof*{2} {2}",
|
||||
@ -1001,16 +995,13 @@ impl<
|
||||
in(reg) self,
|
||||
in(reg) &coord
|
||||
);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/// Sample texels at `coord` from the sampled image with an explicit lod.
|
||||
///
|
||||
/// # Safety
|
||||
/// Sampling with a type (`S`) that doesn't match the image's image format
|
||||
/// will result in undefined behaviour.
|
||||
#[crate::macros::gpu_only]
|
||||
pub unsafe fn sample_by_lod<F>(
|
||||
pub fn sample_by_lod<F>(
|
||||
&self,
|
||||
coord: impl ImageCoordinate<F, DIM, ARRAYED>,
|
||||
lod: f32,
|
||||
@ -1019,6 +1010,7 @@ impl<
|
||||
F: Float,
|
||||
{
|
||||
let mut result = Default::default();
|
||||
unsafe {
|
||||
asm!(
|
||||
"%sampledImage = OpLoad typeof*{1} {1}",
|
||||
"%coord = OpLoad typeof*{2} {2}",
|
||||
@ -1030,6 +1022,7 @@ impl<
|
||||
in(reg) &coord,
|
||||
in(reg) &lod,
|
||||
);
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user