mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2025-02-16 17:04:16 +00:00
fixed SampledImage::sample() fns being marked as unsafe
This commit is contained in:
parent
ff53483822
commit
9ae674aa76
@ -979,38 +979,29 @@ impl<
|
|||||||
>
|
>
|
||||||
{
|
{
|
||||||
/// Sample texels at `coord` from the sampled image with an implicit lod.
|
/// 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]
|
#[crate::macros::gpu_only]
|
||||||
pub unsafe fn sample<F>(
|
pub fn sample<F>(&self, coord: impl ImageCoordinate<F, DIM, ARRAYED>) -> SampledType::Vec4
|
||||||
&self,
|
|
||||||
coord: impl ImageCoordinate<F, DIM, ARRAYED>,
|
|
||||||
) -> SampledType::Vec4
|
|
||||||
where
|
where
|
||||||
F: Float,
|
F: Float,
|
||||||
{
|
{
|
||||||
let mut result = Default::default();
|
let mut result = Default::default();
|
||||||
asm!(
|
unsafe {
|
||||||
"%sampledImage = OpLoad typeof*{1} {1}",
|
asm!(
|
||||||
"%coord = OpLoad typeof*{2} {2}",
|
"%sampledImage = OpLoad typeof*{1} {1}",
|
||||||
"%result = OpImageSampleImplicitLod typeof*{0} %sampledImage %coord",
|
"%coord = OpLoad typeof*{2} {2}",
|
||||||
"OpStore {0} %result",
|
"%result = OpImageSampleImplicitLod typeof*{0} %sampledImage %coord",
|
||||||
in(reg) &mut result,
|
"OpStore {0} %result",
|
||||||
in(reg) self,
|
in(reg) &mut result,
|
||||||
in(reg) &coord
|
in(reg) self,
|
||||||
);
|
in(reg) &coord
|
||||||
|
);
|
||||||
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sample texels at `coord` from the sampled image with an explicit lod.
|
/// 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]
|
#[crate::macros::gpu_only]
|
||||||
pub unsafe fn sample_by_lod<F>(
|
pub fn sample_by_lod<F>(
|
||||||
&self,
|
&self,
|
||||||
coord: impl ImageCoordinate<F, DIM, ARRAYED>,
|
coord: impl ImageCoordinate<F, DIM, ARRAYED>,
|
||||||
lod: f32,
|
lod: f32,
|
||||||
@ -1019,17 +1010,19 @@ impl<
|
|||||||
F: Float,
|
F: Float,
|
||||||
{
|
{
|
||||||
let mut result = Default::default();
|
let mut result = Default::default();
|
||||||
asm!(
|
unsafe {
|
||||||
"%sampledImage = OpLoad typeof*{1} {1}",
|
asm!(
|
||||||
"%coord = OpLoad typeof*{2} {2}",
|
"%sampledImage = OpLoad typeof*{1} {1}",
|
||||||
"%lod = OpLoad typeof*{3} {3}",
|
"%coord = OpLoad typeof*{2} {2}",
|
||||||
"%result = OpImageSampleExplicitLod typeof*{0} %sampledImage %coord Lod %lod",
|
"%lod = OpLoad typeof*{3} {3}",
|
||||||
"OpStore {0} %result",
|
"%result = OpImageSampleExplicitLod typeof*{0} %sampledImage %coord Lod %lod",
|
||||||
in(reg) &mut result,
|
"OpStore {0} %result",
|
||||||
in(reg) self,
|
in(reg) &mut result,
|
||||||
in(reg) &coord,
|
in(reg) self,
|
||||||
in(reg) &lod,
|
in(reg) &coord,
|
||||||
);
|
in(reg) &lod,
|
||||||
|
);
|
||||||
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user