Ports: C-ray rendering engine

This commit is contained in:
Valtteri Koskivuori 2019-12-10 16:38:20 +02:00 committed by Andreas Kling
parent fe1df9e9fb
commit 2a21675b01
7 changed files with 176 additions and 0 deletions

17
Ports/c-ray/package.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash ../.port_include.sh
port=c-ray
version=git
workdir=c-ray-master
useconfigure=true
curlopts="-L"
files="https://github.com/vkoskiv/c-ray/archive/master.tar.gz c-ray-git.tar.gz"
configopts="-DCMAKE_TOOLCHAIN_FILE=$SERENITY_ROOT/Toolchain/CMakeToolchain.txt -DNO_SDL2=True"
configure() {
run cmake $configopts
}
install() {
mkdir -p $SERENITY_ROOT/Root/home/anon/c-ray
cp -r c-ray-master/* $SERENITY_ROOT/Root/home/anon/c-ray
}

View file

@ -0,0 +1,3 @@
diff --git a/configure b/configure
new file mode 100644
index 0000000..e69de29

View file

@ -0,0 +1,23 @@
diff --git a/src/utils/filehandler.c b/src/utils/filehandler.c
index 99638f3..feded8f 100644
--- a/src/utils/filehandler.c
+++ b/src/utils/filehandler.c
@@ -162,7 +162,7 @@ char *loadFile(char *inputFileName, size_t *bytes) {
//Wait for 2 secs and abort if nothing is coming in from stdin
void checkBuf() {
#ifndef WINDOWS
- fd_set set;
+ /*fd_set set;
struct timeval timeout;
int rv;
FD_ZERO(&set);
@@ -176,7 +176,8 @@ void checkBuf() {
logr(error, "No input found after %i seconds. Hint: Try `./bin/c-ray input/scene.json`.\n", timeout.tv_sec);
} else {
return;
- }
+ }*/
+ return;
#endif
}

View file

@ -0,0 +1,19 @@
diff --git a/src/libraries/asprintf.h b/src/libraries/asprintf.h
index 70a95ac..0e46c3c 100644
--- a/src/libraries/asprintf.h
+++ b/src/libraries/asprintf.h
@@ -33,7 +33,6 @@ int vscprintf(const char *format, va_list ap) {
* GNU-C-compatible compilers implement these with the same names, thus we
* don't have to do anything
*/
-#ifdef _MSC_VER
int cray_vasprintf(char **strp, const char *format, va_list ap) {
int len = vscprintf(format, ap);
if (len == -1)
@@ -57,6 +56,5 @@ int asprintf(char **strp, const char *format, ...) {
va_end(ap);
return retval;
}
-#endif
#endif // ASPRINTF_H

View file

@ -0,0 +1,30 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ccce96..1db6074 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,7 +58,7 @@ if (NOT NO_SDL2)
if (MSVC)
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARY})
else()
- target_link_libraries(${PROJECT_NAME} -lpthread -lm ${SDL2_LIBRARY})
+ target_link_libraries(${PROJECT_NAME} -lSDL2 -lgui -ldraw -lipc -lcore -lpthread -lm -lstdc++)
endif()
add_definitions(-DUI_ENABLED)
else()
@@ -66,7 +66,7 @@ if (NOT NO_SDL2)
if (MSVC)
target_link_libraries(${PROJECT_NAME})
else()
- target_link_libraries(${PROJECT_NAME} -lpthread -lm)
+ target_link_libraries(${PROJECT_NAME} -lgui -ldraw -lipc -lcore -lpthread -lm -lstdc++)
endif()
endif()
else()
@@ -75,6 +75,6 @@ else()
if (MSVC)
target_link_libraries(${PROJECT_NAME})
else()
- target_link_libraries(${PROJECT_NAME} -lpthread -lm)
+ target_link_libraries(${PROJECT_NAME} -lgui -ldraw -lipc -lcore -lpthread -lm -lstdc++)
endif()
endif()

View file

@ -0,0 +1,26 @@
diff --git a/input/hdr.json b/input/hdr.json
index c3fd066..ebd69da 100644
--- a/input/hdr.json
+++ b/input/hdr.json
@@ -2,8 +2,8 @@
"version": 1.0,
"renderer": {
"threadCount": 0,
- "sampleCount": 250,
- "bounces": 30,
+ "sampleCount": 1,
+ "bounces": 2,
"antialiasing": true,
"tileWidth": 64,
"tileHeight": 64,
@@ -39,8 +39,8 @@
"outputFileName": "rendered",
"fileType": "png",
"count": 0,
- "width": 1280,
- "height": 800,
+ "width": 300,
+ "height": 200,
"ambientColor": {
"hdr": "input/HDRs/rooitou_park_1k.hdr",
"offset": 0,

View file

@ -0,0 +1,58 @@
diff --git a/src/renderer/renderer.c b/src/renderer/renderer.c
index 835d99b..aa06055 100644
--- a/src/renderer/renderer.c
+++ b/src/renderer/renderer.c
@@ -20,8 +20,8 @@
#include "../utils/loaders/textureloader.h"
//Main thread loop speeds
-#define paused_msec 100
-#define active_msec 16
+#define paused_msec 800
+#define active_msec 400
/// @todo Use defaultSettings state struct for this.
/// @todo Clean this up, it's ugly.
@@ -47,7 +47,6 @@ void render(struct renderer *r) {
//Main loop (input)
bool threadsHaveStarted = false;
float avgRayTime = 0.0f;
- int pauser = 0;
float finalAvg = 0.0f;
int ctr = 1;
while (r->state.isRendering) {
@@ -66,25 +65,6 @@ void render(struct renderer *r) {
sleepMSec(paused_msec);
}
- //Run the sample printing about 4x/s
- if (pauser == 280 / active_msec) {
- long remainingSampleCount = ((r->state.tileCount - r->state.finishedTileCount) * r->prefs.tileWidth * r->prefs.tileHeight * r->prefs.sampleCount);
- double sps = (1000000.0f/finalAvg) * r->prefs.threadCount;
- long usecTillFinished = remainingSampleCount * finalAvg;
- char rem[32];
- smartTime((0.001 * usecTillFinished) / r->prefs.threadCount, rem);
- float completion = ((float)r->state.finishedTileCount / r->state.tileCount) * 100;
- logr(info, "[%s%.0f%%%s] μs/ray: %.02f, etf: %s, %.02lfMs/s %s \r",
- KBLU,
- KNRM,
- completion,
- finalAvg,
- rem,
- 0.000001*sps,
- r->state.threadStates[0].paused ? "[PAUSED]" : "");
- pauser = 0;
- }
- pauser++;
if (!threadsHaveStarted) {
threadsHaveStarted = true;
@@ -286,7 +266,7 @@ void *renderThread(void *arg) {
//No more tiles to render, exit thread. (render done)
tinfo->threadComplete = true;
tinfo->currentTileNum = -1;
- return 0;
+ pthread_exit((void*) arg); //for Serenity, return 0 didn't work
}
struct renderer *newRenderer() {