Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added buffer length; texture clone; clippy fix. #26

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions luisa_compute/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ impl<'a, T: Value> BufferView<'a, T> {
pub fn handle(&self) -> api::Buffer {
self.buffer.handle()
}
pub fn len(&self) -> usize {
self.len
}
pub fn copy_to_async<'b>(&'a self, data: &'b mut [T]) -> Command<'b, 'b> {
assert_eq!(data.len(), self.len);
let mut rt = ResourceTracker::new();
Expand Down Expand Up @@ -1075,6 +1078,7 @@ impl_storage_texel!([f16; 4], Byte4, f32, Float2, Float4, Int2, Int4, Uint2, Uin
// `T` is the read out type of the texture, which is not necessarily the same as
// the storage type In fact, the texture can be stored in any format as long as
// it can be converted to `T`
#[derive(Clone)]
pub struct Tex2d<T: IoTexel> {
#[allow(dead_code)]
pub(crate) width: u32,
Expand All @@ -1098,6 +1102,7 @@ impl<T: IoTexel + fmt::Debug> fmt::Debug for Tex2d<T> {
// `T` is the read out type of the texture, which is not necessarily the same as
// the storage type In fact, the texture can be stored in any format as long as
// it can be converted to `T`
#[derive(Clone)]
pub struct Tex3d<T: IoTexel> {
#[allow(dead_code)]
pub(crate) width: u32,
Expand Down
6 changes: 2 additions & 4 deletions luisa_compute_derive_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ impl Compiler {
#vis fn from_comps_expr(ctor: #ctor_proxy_name #ty_generics) -> #lang_path::types::Expr<#name #ty_generics> {
use #lang_path::*;
let node = #lang_path::__compose::<#name #ty_generics>(&[ #( #lang_path::ToNode::node(&ctor.#field_names.as_expr()).get() ),* ]);
let expr = <#lang_path::types::Expr::<#name> as #lang_path::FromNode>::from_node(node.into());
expr
<#lang_path::types::Expr::<#name> as #lang_path::FromNode>::from_node(node.into())
}
}
)
Expand Down Expand Up @@ -454,8 +453,7 @@ impl Compiler {
#vis fn new_expr(#(#field_names: impl #lang_path::types::AsExpr<Value = #field_types>),*) -> #lang_path::types::Expr::<#name> {
use #lang_path::*;
let node = #lang_path::__compose::<#name #ty_generics>(&[ #( #lang_path::ToNode::node(&#field_names.as_expr()).get() ),* ]);
let expr = <#lang_path::types::Expr::<#name> as #lang_path::FromNode>::from_node(node.into());
expr
<#lang_path::types::Expr::<#name> as #lang_path::FromNode>::from_node(node.into())
}
}
}
Expand Down
28 changes: 13 additions & 15 deletions luisa_compute_track/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,11 @@ impl VisitMut for TraceVisitor {
}
}
}
Stmt::Item(item) => match item {
Item::Const(c) => match c.expr.as_ref() {
Expr::Lit(_) => {}
_ => {
panic!("Please wrap CONST statments with `escape!`");
}
},
_ => {}
Stmt::Item(Item::Const(c)) => match c.expr.as_ref() {
Expr::Lit(_) => {}
_ => {
panic!("Please wrap CONST statments with `escape!`");
}
},
_ => {}
}
Expand Down Expand Up @@ -99,15 +96,15 @@ impl VisitMut for TraceVisitor {
if let Expr::Let(_) = **cond {
} else if let Some((_, else_branch)) = else_branch {
*node = parse_quote_spanned! {span=>
#debug_path::with_lineno("if",
#debug_path::with_lineno("if",
file!(),
line!(),
column!(),
|| <_ as #trait_path::SelectMaybeExpr<_>>::if_then_else(#cond, || #then_branch, || #else_branch))
}
} else {
*node = parse_quote_spanned! {span=>
#debug_path::with_lineno("if",
#debug_path::with_lineno("if",
file!(),
line!(),
column!(),
Expand All @@ -119,7 +116,7 @@ impl VisitMut for TraceVisitor {
let cond = &expr.cond;
let body = &expr.body;
*node = parse_quote_spanned! {span=>
#debug_path::with_lineno("while",
#debug_path::with_lineno("while",
file!(),
line!(),
column!(), ||<_ as #trait_path::LoopMaybeExpr>::while_loop(|| #cond, || #body))
Expand All @@ -128,7 +125,7 @@ impl VisitMut for TraceVisitor {
Expr::Loop(expr) => {
let body = &expr.body;
*node = parse_quote_spanned! {span=>
#debug_path::with_lineno("loop",
#debug_path::with_lineno("loop",
file!(),
line!(),
column!(), || #flow_path::loop_(|| #body))
Expand All @@ -144,14 +141,14 @@ impl VisitMut for TraceVisitor {
let unroll = attrs.iter().any(|attr| attr.path().is_ident("unroll"));
if unroll {
*node = parse_quote_spanned! {span=>
#debug_path::with_lineno("for range",
#debug_path::with_lineno("for range",
file!(),
line!(),
column!(), || #range.for_each(|#pat| #body))
}
} else {
*node = parse_quote_spanned! {span=>
#debug_path::with_lineno("for range",
*node = parse_quote_spanned! {span=>
#debug_path::with_lineno("for range",
file!(),
line!(),
column!(), ||#flow_path::for_range(#range, |#pat| #body))
Expand Down Expand Up @@ -380,6 +377,7 @@ pub fn tracked(
name.strip_suffix("::f").unwrap()
};
::luisa_compute::lang::debug::comment(&format!("begin fn {} at {}:{}:{}", __fn_name, file!(), line!(), column!()));
#[allow(clippy::let_unit_value)]
let __ret: #ret_type = #body;
#[allow(unreachable_code)]
{
Expand Down