Skip to content
Open
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
7 changes: 5 additions & 2 deletions kernels/builders/primrefgen_presplit.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace embree
const float area_aabb = area(ref.bounds());
const float area_prim = primitiveArea(ref);
if (area_prim == 0.0f) return 0.0f;
const unsigned int diff = 31 - lzcnt(mc.x^mc.y);
const int diff = 31 - lzcnt(mc.x^mc.y);
//assert(area_prim <= area_aabb); // may trigger due to numerical issues
const float area_diff = max(0.0f, area_aabb - area_prim);
//const float priority = powf(area_diff * powf(PRIORITY_SPLIT_POS_WEIGHT,(float)diff),1.0f/4.0f);
Expand Down Expand Up @@ -287,7 +287,10 @@ namespace embree
},[](const float& a, const float& b) -> float { return a+b; });

/* compute number of splits per primitive */
const float inv_psum = 1.0f / psum;
float inv_psum = 1.0f;
if (psum > 0.0) {
inv_psum = 1.0f / psum;
}
parallel_for( size_t(0), numPrimitives, size_t(MIN_STEP_SIZE), [&](const range<size_t>& r) -> void {
for (size_t i=r.begin(); i<r.end(); i++)
{
Expand Down
1 change: 1 addition & 0 deletions kernels/subdiv/half_edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ namespace embree
const Vec3fa v = vertices[p->getStartVertexIndex()];
if (!isvalid(v)) return false;
}
if (n < 2) return false;
N += n-2;
return n >= 3 && n <= MAX_PATCH_VALENCE;
}
Expand Down
15 changes: 10 additions & 5 deletions tutorials/buildbench/buildbench_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,14 @@ namespace embree {
FATAL("unknown flags");

if (iterations == 0) iterations = 1;
if (time != 0.0) {
std::cout << iterations << " iterations, " << primitives << " primitives, " << objects << " objects, "
<< time/iterations << " s, "
<< 1.0 / (time/iterations) * primitives / 1000000.0 << " Mprims/s" << std::endl;

}
else {
std::cout << "error: measured build time of 0!\n";
}
rtcReleaseScene (scene);
}

Expand Down Expand Up @@ -523,10 +527,11 @@ namespace embree {
}

if (iterations == 0) iterations = 1;
std::cout << primitives << " primitives, " << objects << " objects, "
<< time/iterations << " s, "
<< 1.0 / (time/iterations) * primitives / 1000000.0 << " Mprims/s" << std::endl;

if (time > 0.0) {
std::cout << primitives << " primitives, " << objects << " objects, "
<< time/iterations << " s, "
<< 1.0 / (time/iterations) * primitives / 1000000.0 << " Mprims/s" << std::endl;
}
rtcReleaseScene(helper.scene);
}

Expand Down
10 changes: 6 additions & 4 deletions tutorials/common/image/tinyexr.h
Original file line number Diff line number Diff line change
Expand Up @@ -6717,20 +6717,22 @@ int LoadEXRFromMemory(float **out_rgba, int *width, int *height,

if (idxR == -1) {
tinyexr::SetErrorMessage("R channel not found", err);

// @todo { free exr_image }
FreeEXRHeader(&exr_header);
FreeEXRImage(&exr_image);
return TINYEXR_ERROR_INVALID_DATA;
}

if (idxG == -1) {
tinyexr::SetErrorMessage("G channel not found", err);
// @todo { free exr_image }
FreeEXRHeader(&exr_header);
FreeEXRImage(&exr_image);
return TINYEXR_ERROR_INVALID_DATA;
}

if (idxB == -1) {
tinyexr::SetErrorMessage("B channel not found", err);
// @todo { free exr_image }
FreeEXRHeader(&exr_header);
FreeEXRImage(&exr_image);
return TINYEXR_ERROR_INVALID_DATA;
}

Expand Down
10 changes: 5 additions & 5 deletions tutorials/common/scenegraph/materials.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ namespace embree
map_d(nullptr), map_Ka(nullptr), map_Kd(nullptr), map_Ks(nullptr), map_Kt(nullptr), map_Ns(nullptr), map_Displ(nullptr) {}

OBJMaterial (float d, const std::shared_ptr<Texture> map_d,
const Vec3fa& Ka, const std::shared_ptr<Texture> map_Ka,
const Vec3fa& Kd, const std::shared_ptr<Texture> map_Kd,
const Vec3fa& Ks, const std::shared_ptr<Texture> map_Ks,
const Vec3fa& Kt, const std::shared_ptr<Texture> map_Kt,
const float Ns, const std::shared_ptr<Texture> map_Ns,
const Vec3fa& Ka, const std::shared_ptr<Texture> &map_Ka,
const Vec3fa& Kd, const std::shared_ptr<Texture> &map_Kd,
const Vec3fa& Ks, const std::shared_ptr<Texture> &map_Ks,
const Vec3fa& Kt, const std::shared_ptr<Texture> &map_Kt,
const float Ns, const std::shared_ptr<Texture> &map_Ns,
const std::shared_ptr<Texture> map_Displ)
: base(MATERIAL_OBJ), illum(0), d(d), Ns(Ns), Ni(1.f), Ka(Ka), Kd(Kd), Ks(Ks), Kt(Kt),
map_d(nullptr), map_Ka(nullptr), map_Kd(nullptr), map_Ks(nullptr), map_Kt(nullptr), map_Ns(nullptr), map_Displ(nullptr),
Expand Down
4 changes: 2 additions & 2 deletions tutorials/common/scenegraph/obj_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ namespace embree
face.push_back(vtx);
parseSepOpt(token);
}
curGroup.push_back(face);
curGroup.emplace_back(face);
continue;
}

Expand Down Expand Up @@ -230,7 +230,7 @@ namespace embree
hair[3*i+0].w = r;
if (i != N) hair[3*i+1].w = r;
}
curGroupHair.push_back(hair);
curGroupHair.emplace_back(hair);
}

/*! parse edge crease */
Expand Down
6 changes: 3 additions & 3 deletions tutorials/common/scenegraph/ply_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace embree
if (line == "end_header") break;
if (line.find_first_of('#') == 0) continue;
if (line == "") continue;
header.push_back(line);
header.emplace_back(line);
}

/* parse header */
Expand Down Expand Up @@ -191,7 +191,7 @@ namespace embree
Type ty = parseType(line);
std::string name; line >> name;
elt.type[name] = ty;
elt.properties.push_back(name);
elt.properties.emplace_back(name);
}

mesh.elements[name] = elt;
Expand Down Expand Up @@ -267,7 +267,7 @@ namespace embree
std::vector<size_t> lst;
size_t num = loadInteger(index_ty);
for (size_t i=0; i<num; i++) lst.push_back(loadInteger(data_ty));
vec.push_back(lst);
vec.emplace_back(lst);
}

/* load a data element */
Expand Down
2 changes: 1 addition & 1 deletion tutorials/common/scenegraph/scenegraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ namespace embree
struct AnimatedLightNode : public LightNode
{
AnimatedLightNode (const std::vector<Ref<LightNode>>&& lights, BBox1f time_range)
: lights(lights), time_range(time_range) {}
: lights(std::move(lights)), time_range(time_range) {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, semantics to destroy the input vector is odd. Maybe it works, but you would never expect a function you pass a value to destroy the passed object.


virtual LightType getType() const {
return lights[0]->getType();
Expand Down
4 changes: 2 additions & 2 deletions tutorials/common/scenegraph/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace embree
Texture::Texture ()
: width(-1), height(-1), format(INVALID), bytesPerTexel(0), width_mask(0), height_mask(0), data(nullptr) {}

Texture::Texture(Ref<Image> img, const std::string fileName)
: width(unsigned(img->width)), height(unsigned(img->height)), format(RGBA8), bytesPerTexel(4), width_mask(0), height_mask(0), data(nullptr), fileName(fileName)
Texture::Texture(Ref<Image> img, std::string &&fileName)
: width(unsigned(img->width)), height(unsigned(img->height)), format(RGBA8), bytesPerTexel(4), width_mask(0), height_mask(0), data(nullptr), fileName(std::move(fileName))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here is odd, why would one want to do this? The string object passed would get destroyed by that std::move. This should get reverted.

{
width_mask = isPowerOf2(width) ? width-1 : 0;
height_mask = isPowerOf2(height) ? height-1 : 0;
Expand Down
2 changes: 1 addition & 1 deletion tutorials/common/scenegraph/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace embree

public:
Texture ();
Texture (Ref<Image> image, const std::string fileName);
Texture (Ref<Image> image, std::string &&fileName);
Texture (unsigned width, unsigned height, const Format format, const char* in = nullptr);
~Texture ();

Expand Down
12 changes: 6 additions & 6 deletions tutorials/common/scenegraph/xml_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace embree
Variant (const std::string& str) : type(STRING), str(str) {}

/*! Constructs a variant object holding a texture value. */
Variant (const std::shared_ptr<Texture> tex) : type(TEXTURE), texture(tex) {}
Variant (const std::shared_ptr<Texture> tex) : type(TEXTURE), texture(std::move(tex)) {}

/*! Extracts a boolean from the variant type. */
bool getBool () const { return b[0]; }
Expand Down Expand Up @@ -1371,7 +1371,7 @@ namespace embree

data[i++] = Vec3fa(0, r, 0);
data[i++] = Vec3fa(0, -r, 0);
mesh->positions.push_back(data);
mesh->positions.emplace_back(data);
}

{
Expand Down Expand Up @@ -1500,10 +1500,10 @@ namespace embree
}
}

hairs->positions.push_back(pos);
if (is_normaloriented) hairs->normals.push_back(norm);
if (is_hermite) hairs->tangents.push_back(tans);
if (is_hermite && is_normaloriented) hairs->dnormals.push_back(dnorm);
hairs->positions.emplace_back(pos);
if (is_normaloriented) hairs->normals.emplace_back(norm);
if (is_hermite) hairs->tangents.emplace_back(tans);
if (is_hermite && is_normaloriented) hairs->dnormals.emplace_back(dnorm);

// linear uses 3 segments per hair
if (is_linear) {
Expand Down
2 changes: 1 addition & 1 deletion tutorials/common/tutorial/benchmark_render.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static void renderBenchmarkLegacy(BenchState& state, BenchParams& params ,int ar
if (numTotalFrames >= 1024 && (i % 64 == 0))
{
double rate = 0;
if (fpsStat.getAvg()) rate = 100.0f*fpsStat.getSigma()/fpsStat.getAvg();
if (fpsStat.getAvg() != 0.0) rate = 100.0f*fpsStat.getSigma()/fpsStat.getAvg();

std::cout << "frame [" << std::setw(3) << i << " / " << std::setw(3) << numTotalFrames << "]: "
<< std::setw(8) << fps << " fps, "
Expand Down
2 changes: 1 addition & 1 deletion tutorials/external/catch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4635,7 +4635,7 @@ namespace Catch {
TestSpec::PatternPtr pattern = std::make_shared<T>( token );
if( m_exclusion )
pattern = std::make_shared<TestSpec::ExcludedPattern>( pattern );
m_currentFilter.m_patterns.push_back( pattern );
m_currentFilter.m_patterns.emplace_back( pattern );
}
m_exclusion = false;
m_mode = None;
Expand Down
9 changes: 7 additions & 2 deletions tutorials/next_hit/next_hit_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ RTCFeatureFlags g_feature_mask;
struct HitList
{
HitList (const TutorialData& data)
: data(data), begin(0), end(0) {}
: data(data), begin(0), end(0) {
}

/* Hit structure that defines complete order over hits */
struct Hit
{
Hit() {}
Hit() : opaque(false), t(0.0f), primID(RTC_INVALID_GEOMETRY_ID), geomID(RTC_INVALID_GEOMETRY_ID), instID(RTC_INVALID_GEOMETRY_ID) {}

Hit (bool opaque, float t, unsigned int primID = 0xFFFFFFFF, unsigned int geomID = 0xFFFFFFFF, unsigned int instID = 0xFFFFFFFF)
: opaque(opaque), t(t), primID(primID), geomID(geomID), instID(instID) {}
Expand Down Expand Up @@ -317,6 +318,10 @@ Vec3ff renderPixelStandard(const TutorialData& data, float x, float y,

/* initialize ray */
Ray ray(Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf, 0.0f);
ray.Ng = {0.0f, 1.0f, 0.0f};
ray.flags = 0;
ray.id = 0;
ray.u = ray.v = 0.0f;

/* either gather hits in single pass or using multiple passes */
HitList hits(data);
Expand Down
15 changes: 8 additions & 7 deletions tutorials/verify/verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7074,15 +7074,16 @@ namespace embree
plot << "set title \"" << outFileName.name() << "\"" << std::endl;
plot << "set xlabel \"" + xlabel + "\"" << std::endl;
if (f != 1.0f) plot << "set logscale x" << std::endl;
if (benchmarks.size())
if (benchmarks.size()) {
plot << "set ylabel \"" << benchmarks[0]->unit << "\"" << std::endl;
plot << "set yrange [0:]" << std::endl;
plot << "set yrange [0:]" << std::endl;

plot << "plot \\" << std::endl;
for (size_t i=0; i<benchmarks.size(); i++) {
plot << "\"" << outFileName.name() << "." << benchmarks[i]->name << ".txt\" using 1:2 title \"" << benchmarks[i]->name << "\" with lines";
if (i != benchmarks.size()-1) plot << ",\\";
plot << std::endl;
plot << "plot \\" << std::endl;
for (size_t i=0; i<benchmarks.size(); i++) {
plot << "\"" << outFileName.name() << "." << benchmarks[i]->name << ".txt\" using 1:2 title \"" << benchmarks[i]->name << "\" with lines";
if (i != benchmarks.size()-1) plot << ",\\";
plot << std::endl;
}
}
plot << std::endl;
plot.close();
Expand Down