Ports: Update the C-ray renderer port

This commit is contained in:
Valtteri Koskivuori 2020-02-25 22:03:47 +02:00 committed by Andreas Kling
parent 712e7102b0
commit 22259bf85d
Notes: sideshowbarker 2024-07-19 09:02:58 +09:00
9 changed files with 85 additions and 87 deletions

View file

@ -4,7 +4,8 @@ version=git
workdir=c-ray-master
useconfigure=true
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"
configopts="-DCMAKE_TOOLCHAIN_FILE=$SERENITY_ROOT/Toolchain/CMakeToolchain.txt"
depends="SDL2"
configure() {
run cmake $configopts

View file

@ -1,3 +1,7 @@
diff --git a/configure b/configure
new file mode 100644
index 0000000..e69de29
index 0000000..04bfb39
--- /dev/null
+++ b/configure
@@ -0,0 +1 @@
+#nop

View file

@ -7,7 +7,7 @@ index 5ccce96..1db6074 100644
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++)
+ target_link_libraries(${PROJECT_NAME} -lSDL2 -lgui -ldraw -lgfx -lipc -lcore -lpthread -lm -lstdc++)
endif()
add_definitions(-DUI_ENABLED)
else()

View file

@ -0,0 +1,27 @@
diff --git a/src/utils/timer.c b/src/utils/timer.c
index 9978a99..c94d33d 100644
--- a/src/utils/timer.c
+++ b/src/utils/timer.c
@@ -48,20 +48,13 @@ long getUs(struct timeval timer) {
return ((tmr2.tv_sec - timer.tv_sec) * 1000000) + (tmr2.tv_usec - timer.tv_usec);
}
+#include <unistd.h>
+
/**
Sleep for a given amount of milliseconds
@param ms Milliseconds to sleep for
*/
void sleepMSec(int ms) {
-#ifdef WINDOWS
- Sleep(ms);
-#elif __APPLE__
- struct timespec ts;
- ts.tv_sec = ms / 1000;
- ts.tv_nsec = (ms % 1000) * 1000000;
- nanosleep(&ts, NULL);
-#elif __linux__
usleep(ms * 1000);
-#endif
}

View file

@ -1,26 +0,0 @@
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

@ -1,58 +0,0 @@
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() {

View file

@ -0,0 +1,24 @@
diff --git a/input/hdr.json b/input/hdr.json
index 5391ff0..138be3a 100644
--- a/input/hdr.json
+++ b/input/hdr.json
@@ -2,7 +2,7 @@
"version": 1.0,
"renderer": {
"threads": 0,
- "samples": 250,
+ "samples": 25,
"bounces": 30,
"antialiasing": true,
"tileWidth": 64,
@@ -12,8 +12,8 @@
"outputFileName": "rendered",
"fileType": "png",
"count": 0,
- "width": 1280,
- "height": 800
+ "width": 320,
+ "height": 200
},
"display": {
"isFullscreen": false,

View file

@ -0,0 +1,13 @@
diff --git a/src/renderer/renderer.c b/src/renderer/renderer.c
index 90cfee9..4e36ed2 100644
--- a/src/renderer/renderer.c
+++ b/src/renderer/renderer.c
@@ -104,7 +104,7 @@ struct texture *renderFrame(struct renderer *r) {
char rem[64];
smartTime((msecTillFinished) / r->prefs.threadCount, rem);
float completion = ((float)completedSamples / totalTileSamples) * 100;
- logr(info, "[%s%.0f%%%s] μs/path: %.02f, etf: %s, %.02lfMs/s %s \r",
+ logr(info, "[%s%.0f%%%s] us/path: %.02f, etf: %s, %.02lfMs/s %s \r",
KBLU,
completion,
KNRM,

View file

@ -0,0 +1,13 @@
diff --git a/src/utils/ui.c b/src/utils/ui.c
index afcb4fc..3713b87 100644
--- a/src/utils/ui.c
+++ b/src/utils/ui.c
@@ -63,7 +63,7 @@ int initSDL(struct display *d) {
return -1;
}
//Init renderer
- d->renderer = SDL_CreateRenderer(d->window, -1, SDL_RENDERER_ACCELERATED);
+ d->renderer = SDL_CreateRenderer(d->window, -1, SDL_RENDERER_SOFTWARE);
if (d->renderer == NULL) {
logr(warning, "Renderer couldn't be created, error: \"%s\"\n", SDL_GetError());
return -1;