Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
how to compile embree ??
Browse files Browse the repository at this point in the history
  • Loading branch information
椎名深雪 committed Nov 3, 2019
1 parent 3f718ad commit 24d0929
Show file tree
Hide file tree
Showing 26 changed files with 249 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ include/

# Imported mesh files
*.mesh
external/embree3
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ cmake_minimum_required(VERSION 3.1)
project(MiyukiRenderer)
set(CMAKE_CXX_STANDARD 17)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target x86_64-pc-windows-gnu -femulated-tls ")
ENDIF()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()

find_package(Python3 REQUIRED)
find_package(PythonLibs 3 REQUIRED)


include_directories(${PYTHON_INCLUDE_DIRS})
include_directories(src)

add_subdirectory(external/pybind11)
add_subdirectory(external/fmt)
include_directories(external/pybind11/include)
include_directories(external/linalg)
Expand All @@ -35,6 +41,8 @@ file(GLOB libcoreSource src/core/*.cpp
external/lodepng/lodepng.cpp

)
#include(ExternalProject)
#include(${PROJECT_SOURCE_DIR}/cmake/cmake-embree)
add_library(core ${MiyukiAPI} ${libcoreSource})
target_link_libraries(core fmt)
add_executable(myk-cli src/standalone-renderer/main.cpp ${MiyukiAPI})
Expand Down
78 changes: 78 additions & 0 deletions cmake/cmake-embree
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# I'm not famiilar with cmake
# Largely based on https://github.com/AirGuanZ/Atrc/blob/master/cmake/cmake-embree
IF(MSVC)
SET(EMBREE_IGNORE_CMAKE_CXX_FLAGS "-DEMBREE_IGNORE_CMAKE_CXX_FLAGS=ON")
ELSE()
SET(EMBREE_IGNORE_CMAKE_CXX_FLAGS "-DEMBREE_IGNORE_CMAKE_CXX_FLAGS=OFF")
ENDIF()

if(NOT DEFINED EMBREE_MAX_ISA)
set(EMBREE_MAX_ISA AVX2)
endif()

set(Embree3_VERSION "3.6.1")


ExternalProject_Add(
Embree3
PREFIX "${PROJECT_SOURCE_DIR}/external/embree3"
URL "https://github.com/embree/embree/archive/v${Embree3_VERSION}.tar.gz"
URL_MD5 d6e043321df048a427eff337eba04cf1
CMAKE_ARGS
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DEMBREE_TUTORIALS=OFF"
"-DEMBREE_FILTER_FUNCTION=OFF"
"-DEMBREE_RAY_PACKETS=OFF"
"-DEMBREE_TASKING_SYSTEM=INTERNAL"
"-DEMBREE_GEOMETRY_QUAD=OFF"
"-DEMBREE_GEOMETRY_CURVE=OFF"
"-DEMBREE_GEOMETRY_SUBDIVISION=OFF"
"-DEMBREE_GEOMETRY_INSTANCE=OFF"
"-DEMBREE_GEOMETRY_USER=OFF"
"-DEMBREE_GEOMETRY_POINT=OFF"
"-DEMBREE_ISPC_SUPPORT=OFF"
"-DEMBREE_STATIC_LIB=ON"
"-DEMBREE_MAX_ISA=${EMBREE_MAX_ISA}"
"${EMBREE_IGNORE_CMAKE_CXX_FLAGS}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
INSTALL_COMMAND ""
)

set(EMBREE_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/external/embree3//src/Embree3/include/)

IF(WIN32)
SET(EMBREE_LIBRARIES
optimized "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Release/embree3.lib"
optimized "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Release/embree_sse42.lib"
optimized "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Release/embree_avx.lib"
optimized "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Release/embree_avx2.lib"
optimized "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Release/lexers.lib"
optimized "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Release/math.lib"
optimized "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Release/simd.lib"
optimized "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Release/tasking.lib"
optimized "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Release/sys.lib"
debug "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Debug/embree3.lib"
debug "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Debug/embree_sse42.lib"
debug "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Debug/embree_avx.lib"
debug "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Debug/embree_avx2.lib"
debug "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Debug/lexers.lib"
debug "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Debug/math.lib"
debug "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Debug/simd.lib"
debug "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Debug/tasking.lib"
debug "${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/Debug/sys.lib"
)
ELSE()
SET(EMBREE_LIBRARIES
"${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/libembree3.a"
"${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/libembree_sse42.a"
"${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/libembree_avx.a"
"${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/libembree_avx2.a"
"${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/liblexers.a"
"${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/libmath.a"
"${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/libsimd.a"
"${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/libtasking.a"
"${PROJECT_SOURCE_DIR}/lib/embree3/src/Embree3-build/libsys.a"
)
ENDIF()
Binary file modified data/fireplace_room/out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
70 changes: 70 additions & 0 deletions external/embree3/src/Embree3-build/CMakeFiles/CMakeError.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/msys64/mingw64/bin/clang++.exe
Build flags: ;--verbose;-target;x86_64-pc-windows-gnu;-stdlib=libc++;-pthread
Id flags:

The output was:
1
clang version 9.0.0 (https://github.com/msys2/MINGW-packages.git fdafa4d8c4022588676c8ec0985dafaf834258ae)
Target: x86_64-pc-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/mingw64/bin
"C:\\msys64\\mingw64\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerId.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -v -resource-dir "C:\\msys64\\mingw64\\lib\\clang\\9.0.0" -internal-isystem "C:/msys64/mingw64\\x86_64-w64-mingw32\\include\\c++\\v1" -internal-isystem "C:/msys64/mingw64\\include\\c++\\v1" -internal-isystem "C:\\msys64\\mingw64\\lib\\clang\\9.0.0\\include" -internal-isystem "C:/msys64/mingw64\\x86_64-w64-mingw32/sys-root/mingw/include" -internal-isystem "C:/msys64/mingw64\\x86_64-w64-mingw32\\include" -internal-isystem "C:/msys64/mingw64\\include" -fdeprecated-macro -fdebug-compilation-dir "C:\\Users\\xiaoc\\source\\repos\\shiinamiyuki\\miyuki-renderer\\external\\embree3\\src\\Embree3-build\\CMakeFiles\\3.15.3\\CompilerIdCXX" -ferror-limit 19 -fmessage-length 0 -pthread -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fseh-exceptions -fdiagnostics-show-option -faddrsig -o "C:\\Users\\xiaoc\\AppData\\Local\\Temp\\CMakeCXXCompilerId-d050cd.o" -x c++ CMakeCXXCompilerId.cpp
clang -cc1 version 9.0.0 based upon LLVM 9.0.0 default target x86_64-w64-windows-gnu
ignoring nonexistent directory "C:/msys64/mingw64\x86_64-w64-mingw32\include\c++\v1"
ignoring nonexistent directory "C:/msys64/mingw64\include\c++\v1"
ignoring nonexistent directory "C:/msys64/mingw64\x86_64-w64-mingw32/sys-root/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
C:\msys64\mingw64\lib\clang\9.0.0\include
C:/msys64/mingw64\x86_64-w64-mingw32\include
C:/msys64/mingw64\include
End of search list.
"C:/msys64/mingw64/bin\\ld" -m i386pep -Bdynamic -o a.exe "C:/msys64/mingw64\\x86_64-w64-mingw32\\lib\\crt2.o" "C:/msys64/mingw64\\lib\\gcc\\x86_64-w64-mingw32\\9.2.0\\crtbegin.o" "-LC:/msys64/mingw64\\lib\\gcc\\x86_64-w64-mingw32\\9.2.0" "-LC:/msys64/mingw64\\x86_64-w64-mingw32\\lib" "-LC:/msys64/mingw64\\lib" "-LC:/msys64/mingw64\\x86_64-w64-mingw32/sys-root/mingw/lib" "C:\\Users\\xiaoc\\AppData\\Local\\Temp\\CMakeCXXCompilerId-d050cd.o" -lc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt "C:/msys64/mingw64\\lib\\gcc\\x86_64-w64-mingw32\\9.2.0\\crtend.o"
C:/msys64/mingw64/bin\ld: cannot find -lc++
clang++: error: linker command failed with exit code 1 (use -v to see invocation)


Determining if the CXX compiler works failed with the following output:
Change Dir: C:/Users/xiaoc/source/repos/shiinamiyuki/miyuki-renderer/external/embree3/src/Embree3-build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/msys64/mingw64/bin/mingw32-make.exe cmTC_ac1bb/fast && mingw32-make.exe[4]: Entering directory 'C:/Users/xiaoc/source/repos/shiinamiyuki/miyuki-renderer/external/embree3/src/Embree3-build/CMakeFiles/CMakeTmp'
C:/msys64/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_ac1bb.dir\build.make CMakeFiles/cmTC_ac1bb.dir/build
mingw32-make.exe[5]: Entering directory 'C:/Users/xiaoc/source/repos/shiinamiyuki/miyuki-renderer/external/embree3/src/Embree3-build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_ac1bb.dir/testCXXCompiler.cxx.obj
C:\msys64\mingw64\bin\clang++.exe --verbose -target x86_64-pc-windows-gnu -stdlib=libc++ -pthread -o CMakeFiles\cmTC_ac1bb.dir\testCXXCompiler.cxx.obj -c C:\Users\xiaoc\source\repos\shiinamiyuki\miyuki-renderer\external\embree3\src\Embree3-build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
clang version 9.0.0 (https://github.com/msys2/MINGW-packages.git fdafa4d8c4022588676c8ec0985dafaf834258ae)
Target: x86_64-pc-windows-gnu
Thread model: posix
InstalledDir: C:\msys64\mingw64\bin
"C:\\msys64\\mingw64\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name testCXXCompiler.cxx -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -v -coverage-notes-file "C:\\Users\\xiaoc\\source\\repos\\shiinamiyuki\\miyuki-renderer\\external\\embree3\\src\\Embree3-build\\CMakeFiles\\CMakeTmp\\CMakeFiles\\cmTC_ac1bb.dir\\testCXXCompiler.cxx.gcno" -resource-dir "C:\\msys64\\mingw64\\lib\\clang\\9.0.0" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include\\c++\\v1" -internal-isystem "C:\\msys64\\mingw64\\include\\c++\\v1" -internal-isystem "C:\\msys64\\mingw64\\lib\\clang\\9.0.0\\include" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32/sys-root/mingw/include" -internal-isystem "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include" -internal-isystem "C:\\msys64\\mingw64\\include" -fdeprecated-macro -fdebug-compilation-dir "C:\\Users\\xiaoc\\source\\repos\\shiinamiyuki\\miyuki-renderer\\external\\embree3\\src\\Embree3-build\\CMakeFiles\\CMakeTmp" -ferror-limit 19 -fmessage-length 0 -pthread -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fseh-exceptions -fdiagnostics-show-option -faddrsig -o "CMakeFiles\\cmTC_ac1bb.dir\\testCXXCompiler.cxx.obj" -x c++ "C:\\Users\\xiaoc\\source\\repos\\shiinamiyuki\\miyuki-renderer\\external\\embree3\\src\\Embree3-build\\CMakeFiles\\CMakeTmp\\testCXXCompiler.cxx"
clang -cc1 version 9.0.0 based upon LLVM 9.0.0 default target x86_64-w64-windows-gnu
ignoring nonexistent directory "C:\msys64\mingw64\x86_64-w64-mingw32\include\c++\v1"
ignoring nonexistent directory "C:\msys64\mingw64\include\c++\v1"
ignoring nonexistent directory "C:\msys64\mingw64\x86_64-w64-mingw32/sys-root/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
C:\msys64\mingw64\lib\clang\9.0.0\include
C:\msys64\mingw64\x86_64-w64-mingw32\include
C:\msys64\mingw64\include
End of search list.
Linking CXX executable cmTC_ac1bb.exe
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_ac1bb.dir\link.txt --verbose=1
"C:\Program Files\JetBrains\CLion 2019.2.4\bin\cmake\win\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_ac1bb.dir/objects.a
C:\msys64\mingw64\bin\ar.exe cr CMakeFiles\cmTC_ac1bb.dir/objects.a @CMakeFiles\cmTC_ac1bb.dir\objects1.rsp
C:\msys64\mingw64\bin\clang++.exe --verbose -target x86_64-pc-windows-gnu -stdlib=libc++ -pthread -Wl,--whole-archive CMakeFiles\cmTC_ac1bb.dir/objects.a -Wl,--no-whole-archive -o cmTC_ac1bb.exe -Wl,--out-implib,libcmTC_ac1bb.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\cmTC_ac1bb.dir\linklibs.rsp
clang version 9.0.0 (https://github.com/msys2/MINGW-packages.git fdafa4d8c4022588676c8ec0985dafaf834258ae)
Target: x86_64-pc-windows-gnu
Thread model: posix
InstalledDir: C:\msys64\mingw64\bin
clang++: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
"C:\\msys64\\mingw64\\bin\\ld" -m i386pep -Bdynamic -o cmTC_ac1bb.exe "C:\\msys64\\mingw64\\x86_64-w64-mingw32\\lib\\crt2.o" "C:\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\9.2.0\\crtbegin.o" "-LC:\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\9.2.0" "-LC:\\msys64\\mingw64\\x86_64-w64-mingw32\\lib" "-LC:\\msys64\\mingw64\\lib" "-LC:\\msys64\\mingw64\\x86_64-w64-mingw32/sys-root/mingw/lib" --whole-archive "CMakeFiles\\cmTC_ac1bb.dir/objects.a" --no-whole-archive --out-implib libcmTC_ac1bb.dll.a --major-image-version 0 --minor-image-version 0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -lc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt "C:\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\9.2.0\\crtend.o"
C:\msys64\mingw64\bin\ld: cannot find -lc++
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
mingw32-make.exe[5]: *** [CMakeFiles\cmTC_ac1bb.dir\build.make:88: cmTC_ac1bb.exe] Error 1
mingw32-make.exe[5]: Leaving directory 'C:/Users/xiaoc/source/repos/shiinamiyuki/miyuki-renderer/external/embree3/src/Embree3-build/CMakeFiles/CMakeTmp'
mingw32-make.exe[4]: *** [Makefile:120: cmTC_ac1bb/fast] Error 2
mingw32-make.exe[4]: Leaving directory 'C:/Users/xiaoc/source/repos/shiinamiyuki/miyuki-renderer/external/embree3/src/Embree3-build/CMakeFiles/CMakeTmp'



Expand Down
1 change: 1 addition & 0 deletions external/embree3/src/Embree3-build/CMakeFiles/Progress/1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
empty
1 change: 1 addition & 0 deletions external/embree3/src/Embree3-build/CMakeFiles/Progress/2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
empty
Empty file.
Empty file.
Empty file.
Empty file.
Binary file added external/embree3/src/v3.6.1.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/api/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace miyuki{

#define MIYUKI_ASSERT(expr) _assert(expr, fmt::format("{} failed at {}:{}",#expr, __FILE__,__LINE__))

#ifdef _MSV_VER
#ifdef _MSC_VER

#define MYK_PUBLIC_API __declspec(dllexport)
#elif defined(__GNUC__) || defined(__MINGW32__)
Expand Down
11 changes: 6 additions & 5 deletions src/api/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ namespace miyuki::core {
if (t < isct.distance) {
isct.distance = t;
isct.Ng = Ng;
isct.Ns = lerp3(vertex(0), vertex(1), vertex(2), u, v).normalized();
isct.uv = Point2f(u, v);
isct.Ns = normalAt(isct.uv);
isct.shape = this;
return true;
}
Expand Down Expand Up @@ -133,7 +134,7 @@ namespace miyuki::core {
}

[[nodiscard]] Normal3f normalAt(const Point2f &uv) const {
return lerp3(normal(0), normal(1), normal(2), uv[0], uv[1]);
return lerp3(normal(0), normal(1), normal(2), uv[0], uv[1]).normalized();
}

[[nodiscard]] Point2f texCoordAt(const Point2f &uv) const {
Expand All @@ -160,11 +161,11 @@ namespace miyuki::core {

MYK_AUTO_INIT(filename, materials)

bool intersect(const Ray &ray, Intersection &isct) const {
bool intersect(const Ray &ray, Intersection &isct) const override {
return accelerator->intersect(ray, isct);
}

[[nodiscard]] Bounds3f getBoundingBox() const {
[[nodiscard]] Bounds3f getBoundingBox() const override {
return accelerator->getBoundingBox();
}

Expand Down Expand Up @@ -197,7 +198,7 @@ namespace miyuki::core {

MYK_AUTO_SER(transform, mesh)

bool intersect(const Ray &ray, Intersection &isct) const {
bool intersect(const Ray &ray, Intersection &isct) const override {
auto o = invTransform(ray.o);
auto p = invTransform(ray.o + ray.d);
Float k = (p - o).length();
Expand Down
45 changes: 45 additions & 0 deletions src/api/profiler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// MIT License
//
// Copyright (c) 2019 椎名深雪
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#ifndef MIYUKIRENDERER_PROFILER_H
#define MIYUKIRENDERER_PROFILER_H

#include <chrono>


namespace miyuki {
class Profiler {
std::chrono::high_resolution_clock::time_point start;
public:
Profiler() {
start = std::chrono::high_resolution_clock::now();
}

template<class T>
std::chrono::duration<T> elapsed() const {
return std::chrono::high_resolution_clock::now() - start;
}
};
}


#endif //MIYUKIRENDERER_PROFILER_H
2 changes: 1 addition & 1 deletion src/api/ray.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace miyuki::core {
}

void computeLocalFrame() {
localFrame = CoordinateSystem(Ng);
localFrame = CoordinateSystem(Ns);
}

[[nodiscard]] Vec3f worldToLocal(const Vec3f &v) const {
Expand Down
15 changes: 14 additions & 1 deletion src/api/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,30 @@
#include <api/light.h>
#include <api/ray.h>
#include <api/accelerator.h>
#include <atomic>

#include <core/accelerators/sahbvh.h>

namespace miyuki::core {

class Scene {
std::shared_ptr<TopLevelBVHAccelerator> accelerator;
std::atomic<size_t> rayCounter = 0;
public:
std::vector<std::shared_ptr<Light>> lights;
std::vector<std::shared_ptr<Shape>> shapes;
bool intersect(const Ray&ray, Intersection& isct);

bool intersect(const Ray &ray, Intersection &isct);

void preprocess();

size_t getRayCounter() const {
return rayCounter;
}

void resetRayCounter() {
rayCounter = 0;
}
};
}
#endif //MIYUKIRENDERER_SCENE_H
2 changes: 1 addition & 1 deletion src/api/serialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ namespace cereal {
try {
ar(CEREAL_NVP_(name, val));
} catch (cereal::Exception &e) {
//
(void)e;//
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/api/shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <api/spectrum.h>
#include <api/entity.hpp>
#include <api/ray.h>
#include <functional>

namespace miyuki::core {

Expand Down
5 changes: 3 additions & 2 deletions src/core/export.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
#ifndef MIYUKIRENDERER_EXPORT_H
#define MIYUKIRENDERER_EXPORT_H

#include <api/defs.h>
namespace miyuki::core{
void Initialize();
void Finalize();
MYK_PUBLIC_API void Initialize();
MYK_PUBLIC_API void Finalize();
}
#endif //MIYUKIRENDERER_EXPORT_H
Loading

0 comments on commit 24d0929

Please sign in to comment.