-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ray query expressions and special types
- Loading branch information
Showing
25 changed files
with
388 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/*! | ||
Type generators. | ||
*/ | ||
|
||
use crate::{arena::Handle, span::Span}; | ||
|
||
impl crate::Module { | ||
pub(super) fn generate_ray_desc_type(&mut self) -> Handle<crate::Type> { | ||
if let Some(handle) = self.special_types.ray_desc { | ||
return handle; | ||
} | ||
|
||
let width = 4; | ||
let ty_flag = self.types.insert( | ||
crate::Type { | ||
name: None, | ||
inner: crate::TypeInner::Scalar { | ||
width, | ||
kind: crate::ScalarKind::Uint, | ||
}, | ||
}, | ||
Span::UNDEFINED, | ||
); | ||
let ty_scalar = self.types.insert( | ||
crate::Type { | ||
name: None, | ||
inner: crate::TypeInner::Scalar { | ||
width, | ||
kind: crate::ScalarKind::Float, | ||
}, | ||
}, | ||
Span::UNDEFINED, | ||
); | ||
let ty_vector = self.types.insert( | ||
crate::Type { | ||
name: None, | ||
inner: crate::TypeInner::Vector { | ||
size: crate::VectorSize::Tri, | ||
kind: crate::ScalarKind::Float, | ||
width, | ||
}, | ||
}, | ||
Span::UNDEFINED, | ||
); | ||
|
||
let handle = self.types.insert( | ||
crate::Type { | ||
name: Some("RayDesc".to_string()), | ||
inner: crate::TypeInner::Struct { | ||
members: vec![ | ||
crate::StructMember { | ||
name: Some("flags".to_string()), | ||
ty: ty_flag, | ||
binding: None, | ||
offset: 0, | ||
}, | ||
crate::StructMember { | ||
name: Some("cull_mask".to_string()), | ||
ty: ty_flag, | ||
binding: None, | ||
offset: 4, | ||
}, | ||
crate::StructMember { | ||
name: Some("tmin".to_string()), | ||
ty: ty_scalar, | ||
binding: None, | ||
offset: 8, | ||
}, | ||
crate::StructMember { | ||
name: Some("tmax".to_string()), | ||
ty: ty_scalar, | ||
binding: None, | ||
offset: 12, | ||
}, | ||
crate::StructMember { | ||
name: Some("origin".to_string()), | ||
ty: ty_vector, | ||
binding: None, | ||
offset: 16, | ||
}, | ||
crate::StructMember { | ||
name: Some("dir".to_string()), | ||
ty: ty_vector, | ||
binding: None, | ||
offset: 32, | ||
}, | ||
], | ||
span: 48, | ||
}, | ||
}, | ||
Span::UNDEFINED, | ||
); | ||
|
||
self.special_types.ray_desc = Some(handle); | ||
handle | ||
} | ||
|
||
pub(super) fn generate_ray_intersection_type(&mut self) -> Handle<crate::Type> { | ||
if let Some(handle) = self.special_types.ray_intersection { | ||
return handle; | ||
} | ||
|
||
let width = 4; | ||
let ty_flag = self.types.insert( | ||
crate::Type { | ||
name: None, | ||
inner: crate::TypeInner::Scalar { | ||
width, | ||
kind: crate::ScalarKind::Uint, | ||
}, | ||
}, | ||
Span::UNDEFINED, | ||
); | ||
let ty_scalar = self.types.insert( | ||
crate::Type { | ||
name: None, | ||
inner: crate::TypeInner::Scalar { | ||
width, | ||
kind: crate::ScalarKind::Float, | ||
}, | ||
}, | ||
Span::UNDEFINED, | ||
); | ||
|
||
let handle = self.types.insert( | ||
crate::Type { | ||
name: Some("RayIntersection".to_string()), | ||
inner: crate::TypeInner::Struct { | ||
members: vec![ | ||
crate::StructMember { | ||
name: Some("kind".to_string()), | ||
ty: ty_flag, | ||
binding: None, | ||
offset: 0, | ||
}, | ||
crate::StructMember { | ||
name: Some("t".to_string()), | ||
ty: ty_scalar, | ||
binding: None, | ||
offset: 4, | ||
}, | ||
//TODO: the rest | ||
], | ||
span: 8, | ||
}, | ||
}, | ||
Span::UNDEFINED, | ||
); | ||
|
||
self.special_types.ray_intersection = Some(handle); | ||
handle | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.