Skip to content

Commit 00be05b

Browse files
jorge-ortegaLegNeato
authored andcommitted
Continue replacing vek with glam
1 parent 644d2ed commit 00be05b

File tree

30 files changed

+182
-108
lines changed

30 files changed

+182
-108
lines changed

crates/cuda_std/src/thread.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub fn grid_dim_z() -> u32 {
154154
#[inline(always)]
155155
pub fn thread_idx() -> UVec3 {
156156
unsafe {
157-
Vec3::new(
157+
UVec3::new(
158158
__nvvm_thread_idx_x(),
159159
__nvvm_thread_idx_y(),
160160
__nvvm_thread_idx_z(),
@@ -167,7 +167,7 @@ pub fn thread_idx() -> UVec3 {
167167
#[inline(always)]
168168
pub fn block_idx() -> UVec3 {
169169
unsafe {
170-
Vec3::new(
170+
UVec3::new(
171171
__nvvm_block_idx_x(),
172172
__nvvm_block_idx_y(),
173173
__nvvm_block_idx_z(),
@@ -181,7 +181,7 @@ pub fn block_idx() -> UVec3 {
181181
#[inline(always)]
182182
pub fn block_dim() -> UVec3 {
183183
unsafe {
184-
Vec3::new(
184+
UVec3::new(
185185
__nvvm_block_dim_x(),
186186
__nvvm_block_dim_y(),
187187
__nvvm_block_dim_z(),
@@ -195,7 +195,7 @@ pub fn block_dim() -> UVec3 {
195195
#[inline(always)]
196196
pub fn grid_dim() -> UVec3 {
197197
unsafe {
198-
Vec3::new(
198+
UVec3::new(
199199
__nvvm_grid_dim_x(),
200200
__nvvm_grid_dim_y(),
201201
__nvvm_grid_dim_z(),
@@ -206,7 +206,7 @@ pub fn grid_dim() -> UVec3 {
206206
/// Gets the overall thread index, accounting for 1d/2d/3d block/grid dimensions. This
207207
/// value is most commonly used for indexing into data and this index is guaranteed to
208208
/// be unique for every single thread executing this kernel no matter the launch configuration.
209-
///
209+
///
210210
/// For very simple kernels it may be faster to use a more simple index calculation, however,
211211
/// it will be unsound if the kernel launches in a 2d/3d configuration.
212212
#[gpu_only]
@@ -218,10 +218,10 @@ pub fn index() -> u32 {
218218
let block_dim = block_dim();
219219
let thread_idx = thread_idx();
220220

221-
let block_id = block_idx.x + block_idx.y * grid_dim.x
221+
let block_id = block_idx.x + block_idx.y * grid_dim.x
222222
+ grid_dim.x * grid_dim.y * block_idx.z;
223223

224-
block_id * block_dim.product()
224+
block_id * block_dim.element_product()
225225
+ (thread_idx.z * (block_dim.x * block_dim.y))
226226
+ (thread_idx.y * block_dim.x) + thread_idx.x
227227
}

crates/cust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cust_core = { path = "../cust_core", version = "0.1.0"}
1717
cust_raw = { path = "../cust_raw", default-features = false, features = ["driver"] }
1818
bitflags = "2.8"
1919
cust_derive = { path = "../cust_derive", version = "0.2" }
20-
glam = { version = "0.29.2", features=["cuda"], optional = true }
20+
glam = { version = "0.30", features=["cuda"], optional = true }
2121
mint = { version = "^0.5", optional = true }
2222
num-complex = { version = "0.4.6", optional = true }
2323
vek = { version = "0.17.1", optional = true, default-features = false }

crates/cust/src/function.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,31 @@ impl From<vek::Vec3<usize>> for GridSize {
8888
}
8989
}
9090

91+
#[cfg(feature = "glam")]
92+
impl From<glam::UVec2> for GridSize {
93+
fn from(vec: glam::UVec2) -> Self {
94+
GridSize::xy(vec.x, vec.y)
95+
}
96+
}
97+
#[cfg(feature = "glam")]
98+
impl From<glam::UVec3> for GridSize {
99+
fn from(vec: glam::UVec3) -> Self {
100+
GridSize::xyz(vec.x, vec.y, vec.z)
101+
}
102+
}
103+
#[cfg(feature = "glam")]
104+
impl From<glam::USizeVec2> for GridSize {
105+
fn from(vec: glam::USizeVec2) -> Self {
106+
GridSize::xy(vec.x as u32, vec.y as u32)
107+
}
108+
}
109+
#[cfg(feature = "glam")]
110+
impl From<glam::USizeVec3> for GridSize {
111+
fn from(vec: glam::USizeVec3) -> Self {
112+
GridSize::xyz(vec.x as u32, vec.y as u32, vec.z as u32)
113+
}
114+
}
115+
91116
/// Dimensions of a thread block, or the number of threads in a block.
92117
///
93118
/// Each component of a `BlockSize` must be at least 1. The maximum size depends on your device's
@@ -168,6 +193,31 @@ impl From<vek::Vec3<usize>> for BlockSize {
168193
}
169194
}
170195

196+
#[cfg(feature = "glam")]
197+
impl From<glam::UVec2> for BlockSize {
198+
fn from(vec: glam::UVec2) -> Self {
199+
BlockSize::xy(vec.x, vec.y)
200+
}
201+
}
202+
#[cfg(feature = "glam")]
203+
impl From<glam::UVec3> for BlockSize {
204+
fn from(vec: glam::UVec3) -> Self {
205+
BlockSize::xyz(vec.x, vec.y, vec.z)
206+
}
207+
}
208+
#[cfg(feature = "glam")]
209+
impl From<glam::USizeVec2> for BlockSize {
210+
fn from(vec: glam::USizeVec2) -> Self {
211+
BlockSize::xy(vec.x as u32, vec.y as u32)
212+
}
213+
}
214+
#[cfg(feature = "glam")]
215+
impl From<glam::USizeVec3> for BlockSize {
216+
fn from(vec: glam::USizeVec3) -> Self {
217+
BlockSize::xyz(vec.x as u32, vec.y as u32, vec.z as u32)
218+
}
219+
}
220+
171221
/// All supported function attributes for [Function::get_attribute](struct.Function.html#method.get_attribute)
172222
#[repr(u32)]
173223
#[non_exhaustive]

crates/cust_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ readme = "../../README.md"
99

1010
[dependencies]
1111
vek = { version = "0.17.1", default-features=false, features=["libm"], optional = true }
12-
glam = { version = "0.29.2", features=["cuda", "libm"], default-features=false, optional=true }
12+
glam = { version = "0.30", features=["cuda", "libm"], default-features=false, optional=true }
1313
mint = { version = "^0.5", optional = true }
1414
half = { version = "2.4.1", optional = true }
1515
num-complex = { version = "0.4.6", optional = true }

crates/cust_core/src/lib.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![no_std]
2-
31
pub use _hidden::*;
42
pub use cust_derive::DeviceCopyCore as DeviceCopy;
53

@@ -143,6 +141,7 @@ pub mod _hidden {
143141
{
144142
}
145143

144+
#[allow(unused_macros)]
146145
macro_rules! impl_device_copy_generic {
147146
($($($strukt:ident)::+),* $(,)?) => {
148147
$(
@@ -151,6 +150,7 @@ pub mod _hidden {
151150
}
152151
}
153152

153+
#[allow(unused_macros)]
154154
macro_rules! impl_device_copy {
155155
($($strukt:ty),* $(,)?) => {
156156
$(
@@ -172,7 +172,22 @@ pub mod _hidden {
172172

173173
#[cfg(feature = "glam")]
174174
impl_device_copy! {
175-
glam::Vec2, glam::Vec3, glam::Vec4, glam::IVec2, glam::IVec3, glam::IVec4,
175+
glam::BVec2, glam::BVec3, glam::BVec3A, glam::BVec4, glam::BVec4A,
176+
glam::U8Vec2, glam::U8Vec3, glam::U8Vec4,
177+
glam::I8Vec2, glam::I8Vec3, glam::I8Vec4,
178+
glam::U16Vec2, glam::U16Vec3, glam::U16Vec4,
179+
glam::I16Vec2, glam::I16Vec3, glam::I16Vec4,
180+
glam::UVec2, glam::UVec3, glam::UVec4,
181+
glam::IVec2, glam::IVec3, glam::IVec4,
182+
glam::U64Vec2, glam::U64Vec3, glam::U64Vec4,
183+
glam::I64Vec2, glam::I64Vec3, glam::I64Vec4,
184+
glam::USizeVec2, glam::USizeVec3, glam::USizeVec4,
185+
glam::Vec2, glam::Vec3, glam::Vec3A, glam::Vec4,
186+
glam::DVec2, glam::DVec3, glam::DVec4,
187+
glam::Mat2, glam::Mat3, glam::Mat3A, glam::Mat4,
188+
glam::DMat2, glam::DMat3, glam::DMat4,
189+
glam::Quat, glam::DQuat,
190+
glam::Affine2, glam::Affine3A,
176191
}
177192

178193
#[cfg(feature = "mint")]

crates/gpu_rand/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![deny(missing_docs)]
1313
#![deny(missing_debug_implementations)]
1414
#![allow(clippy::unreadable_literal)]
15-
#![cfg_attr(target_os = "cuda", no_std)]
1615
#![feature(doc_cfg)]
1716

1817
pub mod xoroshiro;

crates/optix/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cust = { version = "0.3", path = "../cust", features=["impl_mint"] }
1212
cust_raw = { path = "../cust_raw", features=["driver"] }
1313
cfg-if = "1.0.0"
1414
bitflags = "2.9.0"
15-
glam = { version = "0.29", features=["cuda", "libm"], default-features=false, optional=true }
15+
glam = { version = "0.30", features=["cuda", "libm"], default-features=false, optional=true }
1616
half = { version = "2.4.1", optional = true }
1717
memoffset = "0.9.1"
1818
mint = "0.5.9"

crates/optix/examples/ex04_mesh/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ anyhow = "1.0.44"
1212
glfw = "0.42.0"
1313
gl = "0.14.0"
1414
num-traits = "0.2.14"
15-
glam = { version = "0.29.2", features=["cuda"] }
15+
glam = { version = "0.30", features=["cuda"] }
1616

1717
[build-dependencies]
1818
cuda_builder = { version = "0.3", path = "../../../cuda_builder" }

crates/optix_device/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,3 @@ cuda_std = { version = "0.2", path = "../cuda_std" }
1313
paste = "1.0.15"
1414
seq-macro = "0.3.5"
1515
cust_core = { version = "0.1", path = "../cust_core" }
16-
17-
[target.'cfg(not(target_os = "cuda"))'.dependencies]
18-
glam = { version = "0.29", features = ["cuda"], default-features = false }

crates/optix_device/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ pub mod trace;
1414
pub mod transform;
1515
pub mod util;
1616

17-
use cuda_std::{glam, *};
17+
pub use cuda_std::glam;
18+
use cuda_std::*;
1819
use glam::UVec3;
1920
pub use misc::*;
2021

0 commit comments

Comments
 (0)