diff options
author | Valtteri Koskivuori <vkoskiv@gmail.com> | 2020-02-25 22:03:47 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-27 09:53:36 +0100 |
commit | 22259bf85dca5aebc2010fd037e439f76b5ba0c8 (patch) | |
tree | 7f987920a2359e4caa701c3390009468e1cca402 | |
parent | 712e7102b068e9010af82d31c7d7af3d1c4ebf8e (diff) | |
download | serenity-22259bf85dca5aebc2010fd037e439f76b5ba0c8.zip |
Ports: Update the C-ray renderer port
-rwxr-xr-x | Ports/c-ray/package.sh | 3 | ||||
-rw-r--r-- | Ports/c-ray/patches/add-dummy-configure.patch | 6 | ||||
-rw-r--r-- | Ports/c-ray/patches/fix-linkage.patch | 2 | ||||
-rw-r--r-- | Ports/c-ray/patches/fix-usleep.patch | 27 | ||||
-rw-r--r-- | Ports/c-ray/patches/lower-hdr-json-settings.patch | 26 | ||||
-rw-r--r-- | Ports/c-ray/patches/patch-renderthread-and-main-loop.patch | 58 | ||||
-rw-r--r-- | Ports/c-ray/patches/reduce-hdr-scene-settings.patch | 24 | ||||
-rw-r--r-- | Ports/c-ray/patches/replace-micro-symbol.patch | 13 | ||||
-rw-r--r-- | Ports/c-ray/patches/set-sdl-software-renderer.patch | 13 |
9 files changed, 85 insertions, 87 deletions
diff --git a/Ports/c-ray/package.sh b/Ports/c-ray/package.sh index b66a668464..05aa71f6ce 100755 --- a/Ports/c-ray/package.sh +++ b/Ports/c-ray/package.sh @@ -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 diff --git a/Ports/c-ray/patches/add-dummy-configure.patch b/Ports/c-ray/patches/add-dummy-configure.patch index 80f1456b76..37c1b591a8 100644 --- a/Ports/c-ray/patches/add-dummy-configure.patch +++ b/Ports/c-ray/patches/add-dummy-configure.patch @@ -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 diff --git a/Ports/c-ray/patches/fix-linkage.patch b/Ports/c-ray/patches/fix-linkage.patch index 986cdd3868..a957421f22 100644 --- a/Ports/c-ray/patches/fix-linkage.patch +++ b/Ports/c-ray/patches/fix-linkage.patch @@ -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() diff --git a/Ports/c-ray/patches/fix-usleep.patch b/Ports/c-ray/patches/fix-usleep.patch new file mode 100644 index 0000000000..b1c7290b05 --- /dev/null +++ b/Ports/c-ray/patches/fix-usleep.patch @@ -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 + } diff --git a/Ports/c-ray/patches/lower-hdr-json-settings.patch b/Ports/c-ray/patches/lower-hdr-json-settings.patch deleted file mode 100644 index d0db6253f3..0000000000 --- a/Ports/c-ray/patches/lower-hdr-json-settings.patch +++ /dev/null @@ -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, diff --git a/Ports/c-ray/patches/patch-renderthread-and-main-loop.patch b/Ports/c-ray/patches/patch-renderthread-and-main-loop.patch deleted file mode 100644 index e55aad3e78..0000000000 --- a/Ports/c-ray/patches/patch-renderthread-and-main-loop.patch +++ /dev/null @@ -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() { diff --git a/Ports/c-ray/patches/reduce-hdr-scene-settings.patch b/Ports/c-ray/patches/reduce-hdr-scene-settings.patch new file mode 100644 index 0000000000..9ac27dd04e --- /dev/null +++ b/Ports/c-ray/patches/reduce-hdr-scene-settings.patch @@ -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, diff --git a/Ports/c-ray/patches/replace-micro-symbol.patch b/Ports/c-ray/patches/replace-micro-symbol.patch new file mode 100644 index 0000000000..74ce575b81 --- /dev/null +++ b/Ports/c-ray/patches/replace-micro-symbol.patch @@ -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, diff --git a/Ports/c-ray/patches/set-sdl-software-renderer.patch b/Ports/c-ray/patches/set-sdl-software-renderer.patch new file mode 100644 index 0000000000..7b7899c0fe --- /dev/null +++ b/Ports/c-ray/patches/set-sdl-software-renderer.patch @@ -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; |