Unused parameters, lifetime issues in sampling
This commit is contained in:
parent
9a8ec13728
commit
1e21cc64f9
16 changed files with 62 additions and 77 deletions
|
|
@ -1019,7 +1019,7 @@ pub struct Bin {
|
|||
#[repr(C)]
|
||||
#[derive(Copy, Debug, Clone)]
|
||||
pub struct AliasTable {
|
||||
pub bins: *const Bin,
|
||||
pub bins: Ptr<Bin>,
|
||||
pub size: u32,
|
||||
}
|
||||
|
||||
|
|
@ -1028,12 +1028,12 @@ unsafe impl Sync for AliasTable {}
|
|||
|
||||
impl AliasTable {
|
||||
#[inline(always)]
|
||||
fn bin(&self, idx: u32) -> &Bin {
|
||||
unsafe { &*self.bins.add(idx as usize) }
|
||||
fn bin(&self, idx: u32) -> Ptr<Bin> {
|
||||
unsafe { self.bins.add(idx as usize) }
|
||||
}
|
||||
|
||||
pub fn size(&self) -> u32 {
|
||||
self.size as u32
|
||||
self.size
|
||||
}
|
||||
|
||||
pub fn pmf(&self, index: u32) -> Float {
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ const SWATCH_REFLECTANCES: LazyLock<[Spectrum; N_SWATCH_REFLECTANCES]> = LazyLoc
|
|||
});
|
||||
|
||||
pub trait PixelSensorHost {
|
||||
pub fn get_swatches() -> &'static [Spectrum; N_SWATCH_REFLECTANCES] {
|
||||
&*SWATCH_REFLECTANCES
|
||||
pub fn get_swatches() -> Arc<[Spectrum; N_SWATCH_REFLECTANCES]> {
|
||||
Arc::new(SWATCH_REFLECTANCES)
|
||||
}
|
||||
|
||||
pub fn create(
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ use shared::Float;
|
|||
use shared::core::color::ColorEncoding;
|
||||
use shared::core::color::LINEAR;
|
||||
use shared::core::geometry::{Bounds2f, Point2f, Point2i};
|
||||
use shared::core::image::{
|
||||
DeviceImage, ImageAccess, ImageBase, PixelFormat, Pixels, WrapMode, WrapMode2D,
|
||||
};
|
||||
use shared::core::image::{DeviceImage, ImageBase, PixelFormat, Pixels, WrapMode, WrapMode2D};
|
||||
use shared::utils::containers::Array2D;
|
||||
use shared::utils::math::square;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use crate::core::spectrum::SPECTRUM_CACHE;
|
||||
use crate::core::texture::FloatTexture;
|
||||
use crate::lights::*;
|
||||
use crate::utils::containers::InternCache;
|
||||
use crate::utils::{Arena, FileLoc, ParameterDictionary};
|
||||
use log::error;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ mod pipeline;
|
|||
|
||||
use shared::core::bsdf::BSDF;
|
||||
use shared::core::bssrdf::{BSSRDFTrait, SubsurfaceInteraction};
|
||||
use shared::core::bxdf::{BxDFFlags, BxDFTrait, FArgs, TransportMode};
|
||||
use shared::core::bxdf::{BxDFFlags, FArgs, TransportMode};
|
||||
use shared::core::camera::Camera;
|
||||
use shared::core::film::VisibleSurface;
|
||||
use shared::core::geometry::{Bounds2i, Point2f, Point2i, Point3fi, Ray, Vector3f, VectorLike};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use crate::core::image::{Image, ImageIO};
|
|||
use crate::core::light::{CreateLight, lookup_spectrum};
|
||||
use crate::core::spectrum::spectrum_to_photometric;
|
||||
use crate::core::texture::FloatTexture;
|
||||
use crate::lights::distant::CreateDistantLight;
|
||||
use crate::utils::sampling::PiecewiseConstant2D;
|
||||
use crate::utils::{Arena, FileLoc, ParameterDictionary, resolve_filename};
|
||||
use log::error;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ use shared::Float;
|
|||
use shared::core::geometry::{
|
||||
Bounds2f, Point2f, Point2i, Point3f, Vector3f, VectorLike, cos_theta,
|
||||
};
|
||||
use shared::core::image::ImageAccess;
|
||||
use shared::core::light::{Light, LightBase, LightType};
|
||||
use shared::core::medium::{Medium, MediumInterface};
|
||||
use shared::core::shape::Shape;
|
||||
|
|
|
|||
|
|
@ -66,9 +66,6 @@ impl CreateMaterial for HairMaterial {
|
|||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct MeasuredMaterial;
|
||||
impl MaterialTrait for MeasuredMaterial {
|
||||
fn get_bsdf<T: TextureEvaluator>(
|
||||
&self,
|
||||
|
|
@ -101,16 +98,13 @@ impl MaterialTrait for MeasuredMaterial {
|
|||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct SubsurfaceMaterial;
|
||||
impl CreateMaterial for SubsurfaceMaterial {
|
||||
fn create(
|
||||
parameters: &TextureParameterDictionary,
|
||||
normal_map: Option<Arc<Image>>,
|
||||
named_materials: &HashMap<String, Material>,
|
||||
loc: &FileLoc,
|
||||
arena: &mut Arena,
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<Material, Error> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ use std::sync::Arc;
|
|||
|
||||
impl CreateMaterial for ConductorMaterial {
|
||||
fn create(
|
||||
parameters: &TextureParameterDictionary,
|
||||
normal_map: Option<Arc<Image>>,
|
||||
named_materials: &std::collections::HashMap<String, shared::core::material::Material>,
|
||||
loc: &crate::utils::FileLoc,
|
||||
arena: &mut crate::Arena,
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_named_materials: &std::collections::HashMap<String, shared::core::material::Material>,
|
||||
_loc: &crate::utils::FileLoc,
|
||||
_arena: &mut crate::Arena,
|
||||
) -> Result<Material, std::fmt::Error> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ use std::sync::Arc;
|
|||
|
||||
impl CreateMaterial for DielectricMaterial {
|
||||
fn create(
|
||||
parameters: &TextureParameterDictionary,
|
||||
normal_map: Option<Arc<Image>>,
|
||||
named_materials: &HashMap<String, Material>,
|
||||
loc: &FileLoc,
|
||||
arena: &mut Arena,
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<Material, Error> {
|
||||
todo!()
|
||||
}
|
||||
|
|
@ -22,11 +22,11 @@ impl CreateMaterial for DielectricMaterial {
|
|||
|
||||
impl CreateMaterial for ThinDielectricMaterial {
|
||||
fn create(
|
||||
parameters: &TextureParameterDictionary,
|
||||
normal_map: Option<Arc<Image>>,
|
||||
named_materials: &HashMap<String, Material>,
|
||||
loc: &FileLoc,
|
||||
arena: &mut Arena,
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<Material, Error> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ use std::sync::Arc;
|
|||
|
||||
impl CreateMaterial for DiffuseMaterial {
|
||||
fn create(
|
||||
parameters: &TextureParameterDictionary,
|
||||
normal_map: Option<Arc<Image>>,
|
||||
named_materials: &HashMap<String, Material>,
|
||||
loc: &FileLoc,
|
||||
arena: &mut Arena,
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<Material, Error> {
|
||||
todo!()
|
||||
}
|
||||
|
|
@ -22,11 +22,11 @@ impl CreateMaterial for DiffuseMaterial {
|
|||
|
||||
impl CreateMaterial for DiffuseTransmissionMaterial {
|
||||
fn create(
|
||||
parameters: &TextureParameterDictionary,
|
||||
normal_map: Option<Arc<Image>>,
|
||||
named_materials: &HashMap<String, Material>,
|
||||
loc: &FileLoc,
|
||||
arena: &mut Arena,
|
||||
_parameters: &TextureParameterDictionary,
|
||||
_normal_map: Option<Arc<Image>>,
|
||||
_named_materials: &HashMap<String, Material>,
|
||||
_loc: &FileLoc,
|
||||
_arena: &mut Arena,
|
||||
) -> Result<Material, Error> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ impl CreateShape for CylinderShape {
|
|||
object_from_render: Transform,
|
||||
reverse_orientation: bool,
|
||||
parameters: ParameterDictionary,
|
||||
float_textures: HashMap<String, FloatTexture>,
|
||||
loc: FileLoc,
|
||||
_float_textures: HashMap<String, FloatTexture>,
|
||||
_loc: FileLoc,
|
||||
arena: &mut Arena,
|
||||
) -> Result<Vec<Shape>, String> {
|
||||
let radius = parameters.get_one_float("radius", 1.);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ impl CreateShape for DiskShape {
|
|||
object_from_render: Transform,
|
||||
reverse_orientation: bool,
|
||||
parameters: ParameterDictionary,
|
||||
float_textures: HashMap<String, FloatTexture>,
|
||||
loc: FileLoc,
|
||||
_float_textures: HashMap<String, FloatTexture>,
|
||||
_loc: FileLoc,
|
||||
arena: &mut Arena,
|
||||
) -> Result<Vec<Shape>, String> {
|
||||
let height = parameters.get_one_float("height", 0.);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ impl CreateShape for SphereShape {
|
|||
object_from_render: Transform,
|
||||
reverse_orientation: bool,
|
||||
parameters: ParameterDictionary,
|
||||
float_textures: HashMap<String, FloatTexture>,
|
||||
loc: FileLoc,
|
||||
_float_textures: HashMap<String, FloatTexture>,
|
||||
_loc: FileLoc,
|
||||
arena: &mut Arena,
|
||||
) -> Result<Vec<Shape>, String> {
|
||||
let radius = parameters.get_one_float("radius", 1.);
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@ impl DenselySampledSpectrumBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn sample(&self, lambda: &SampledWavelengths) -> SampledSpectrum {
|
||||
self.sample(lambda)
|
||||
}
|
||||
|
||||
pub fn new_zero(lambda_min: i32, lambda_max: i32) -> Self {
|
||||
let n_values = (lambda_max - lambda_min + 1).max(0) as usize;
|
||||
let values = vec![0.0; n_values];
|
||||
|
|
|
|||
|
|
@ -18,18 +18,18 @@ pub struct PiecewiseConstant1D {
|
|||
impl PiecewiseConstant1D {
|
||||
// Constructors
|
||||
pub fn new(f: &[Float]) -> Self {
|
||||
Self::new_with_bounds(f, 0.0, 1.0)
|
||||
Self::new_with_bounds(f.to_vec(), 0.0, 1.0)
|
||||
}
|
||||
|
||||
pub fn to_shared(&self, arena: &mut Arena) -> DevicePiecewiseConstant1D {
|
||||
let func_ptr = arena.alloc_slice(&self.func);
|
||||
let cdf_ptr = arena.alloc_slice(&self.cdf);
|
||||
let (func_ptr, _) = arena.alloc_slice(&self.func);
|
||||
let (cdf_ptr, _) = arena.alloc_slice(&self.cdf);
|
||||
|
||||
DevicePiecewiseConstant1D {
|
||||
func: func_ptr,
|
||||
cdf: cdf_ptr,
|
||||
func_integral: self.func_integral,
|
||||
n: self.func.len(),
|
||||
n: self.func.len() as u32,
|
||||
min: self.min,
|
||||
max: self.max,
|
||||
}
|
||||
|
|
@ -73,8 +73,8 @@ impl PiecewiseConstant1D {
|
|||
let cdf: Box<[Float]> = cdf.into_boxed_slice();
|
||||
|
||||
let device = DevicePiecewiseConstant1D {
|
||||
func: func.as_ptr(),
|
||||
cdf: cdf.as_ptr(),
|
||||
func: func.as_ptr().into(),
|
||||
cdf: cdf.as_ptr().into(),
|
||||
min,
|
||||
max,
|
||||
n: n as u32,
|
||||
|
|
@ -303,10 +303,10 @@ impl<const N: usize> PiecewiseLinear2DHost<N> {
|
|||
inv_patch_size,
|
||||
param_size,
|
||||
param_strides,
|
||||
param_values,
|
||||
data: std::ptr::null(),
|
||||
marginal_cdf,
|
||||
conditional_cdf,
|
||||
param_values: param_values.each_ref().map(|x| x.as_ptr().into()),
|
||||
data: Ptr::null(),
|
||||
marginal_cdf: marginal_cdf.as_ptr().into(),
|
||||
conditional_cdf: conditional_cdf.as_ptr().into(),
|
||||
};
|
||||
|
||||
let storage = Arc::new(PiecewiseLinear2DStorage {
|
||||
|
|
@ -317,11 +317,11 @@ impl<const N: usize> PiecewiseLinear2DHost<N> {
|
|||
});
|
||||
|
||||
let mut final_view = view;
|
||||
final_view.data = storage.data.as_ptr();
|
||||
final_view.marginal_cdf = storage.marginal_cdf.as_ptr();
|
||||
final_view.conditional_cdf = storage.conditional_cdf.as_ptr();
|
||||
final_view.data = storage.data.as_ptr().into();
|
||||
final_view.marginal_cdf = storage.marginal_cdf.as_ptr().into();
|
||||
final_view.conditional_cdf = storage.conditional_cdf.as_ptr().into();
|
||||
for i in 0..N {
|
||||
final_view.param_values[i] = storage.param_values[i].as_ptr();
|
||||
final_view.param_values[i] = storage.param_values[i].as_ptr().into();
|
||||
}
|
||||
|
||||
Self {
|
||||
|
|
@ -383,7 +383,7 @@ impl AliasTableHost {
|
|||
let ov = over.pop().unwrap();
|
||||
|
||||
bins[un.index].q = un.p_hat as Float;
|
||||
bins[un.index].alias = ov.index;
|
||||
bins[un.index].alias = ov.index as u32;
|
||||
|
||||
let p_excess = un.p_hat + ov.p_hat - 1.0;
|
||||
|
||||
|
|
@ -402,16 +402,16 @@ impl AliasTableHost {
|
|||
|
||||
while let Some(ov) = over.pop() {
|
||||
bins[ov.index].q = 1.0;
|
||||
bins[ov.index].alias = ov.index;
|
||||
bins[ov.index].alias = ov.index as u32;
|
||||
}
|
||||
|
||||
while let Some(un) = under.pop() {
|
||||
bins[un.index].q = 1.0;
|
||||
bins[un.index].alias = un.index;
|
||||
bins[un.index].alias = un.index as u32;
|
||||
}
|
||||
|
||||
let view = AliasTable {
|
||||
bins: bins.as_ptr(),
|
||||
bins: bins.as_ptr().into(),
|
||||
size: bins.len() as u32,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue