summaryrefslogtreecommitdiff
path: root/Ports/c-ray/patches
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-03-13 22:11:07 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-13 22:44:16 +0100
commit161b36bb09a4cb3dcf163f0b6f4a01459c01b97f (patch)
tree21cc83d49db08e9a795936dbba0a4ca273e1242f /Ports/c-ray/patches
parentcaa8f3d3bfefb57c787d4f70039b019be801c3cd (diff)
downloadserenity-161b36bb09a4cb3dcf163f0b6f4a01459c01b97f.zip
Ports: Update c-ray patches
Diffstat (limited to 'Ports/c-ray/patches')
-rw-r--r--Ports/c-ray/patches/disable-checkbuf.patch26
-rw-r--r--Ports/c-ray/patches/enable-own-asprintf.patch16
-rw-r--r--Ports/c-ray/patches/fix-linkage.patch48
-rw-r--r--Ports/c-ray/patches/fix-usleep.patch35
-rw-r--r--Ports/c-ray/patches/replace-micro-symbol.patch14
-rw-r--r--Ports/c-ray/patches/set-sdl-software-renderer.patch18
6 files changed, 58 insertions, 99 deletions
diff --git a/Ports/c-ray/patches/disable-checkbuf.patch b/Ports/c-ray/patches/disable-checkbuf.patch
index eea4156855..f625e2b059 100644
--- a/Ports/c-ray/patches/disable-checkbuf.patch
+++ b/Ports/c-ray/patches/disable-checkbuf.patch
@@ -1,23 +1,11 @@
-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) {
+--- c-ray-master/src/utils/fileio.c 2021-03-13 00:13:46.067407670 +0100
++++ c-ray-master/src/utils/fileio.c 2021-01-11 01:01:57.000000000 +0100
+@@ -83,7 +83,7 @@
+
//Wait for 2 secs and abort if nothing is coming in from stdin
void checkBuf() {
- #ifndef WINDOWS
-- fd_set set;
-+ /*fd_set set;
+-#ifndef WINDOWS
++#if !defined(WINDOWS) && !defined(__serenity__)
+ 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
- }
-
diff --git a/Ports/c-ray/patches/enable-own-asprintf.patch b/Ports/c-ray/patches/enable-own-asprintf.patch
index 9263dd815d..57083d29dd 100644
--- a/Ports/c-ray/patches/enable-own-asprintf.patch
+++ b/Ports/c-ray/patches/enable-own-asprintf.patch
@@ -1,19 +1,11 @@
-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) {
+--- c-ray-master/src/libraries/asprintf.h 2021-03-13 00:16:23.782000000 +0100
++++ c-ray-master/src/libraries/asprintf.h 2021-03-13 00:16:41.350553067 +0100
+@@ -33,7 +33,7 @@
* GNU-C-compatible compilers implement these with the same names, thus we
* don't have to do anything
*/
-#ifdef _MSC_VER
++#if defined(_MSC_VER) || defined(__serenity__)
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
diff --git a/Ports/c-ray/patches/fix-linkage.patch b/Ports/c-ray/patches/fix-linkage.patch
index f8a44bcf16..93622abb28 100644
--- a/Ports/c-ray/patches/fix-linkage.patch
+++ b/Ports/c-ray/patches/fix-linkage.patch
@@ -1,30 +1,20 @@
-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 -lgfx -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 -lipc -lcore -lpthread -lm -lstdc++)
- endif()
- endif()
+--- c-ray-master/CMakeLists.txt 2021-03-13 00:40:48.474000000 +0100
++++ c-ray-master/CMakeLists.txt 2021-03-13 00:41:04.770789629 +0100
+@@ -38,7 +38,7 @@
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE)
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 -lipc -lcore -lpthread -lm -lstdc++)
- endif()
- endif()
+ # set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wconversion -std=gnu99")
+- set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-missing-field-initializers -std=gnu99 -march=native -mtune=native -D_GNU_SOURCE")
++ set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-missing-field-initializers -std=gnu99 -mtune=native -D_GNU_SOURCE")
+ set(CMAKE_C_FLAGS_RELEASE "-O3 -ftree-vectorize")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g")
+ if (ASAN)
+@@ -71,7 +71,7 @@
+ target_include_directories(c-ray PRIVATE ${c-ray_SOURCE_DIR}/src)
+ target_include_directories(c-ray PRIVATE ${c-ray_SOURCE_DIR}/tests)
+ if (NOT MSVC)
+- target_link_libraries(c-ray PRIVATE -lpthread -lm)
++ target_link_libraries(c-ray PRIVATE -lSDL2 -lgui -lgfx -lipc -lcore -lpthread -lstdc++ -lm)
+ endif ()
+
+ include(CheckIPOSupported)
diff --git a/Ports/c-ray/patches/fix-usleep.patch b/Ports/c-ray/patches/fix-usleep.patch
index b1c7290b05..a32b108a9a 100644
--- a/Ports/c-ray/patches/fix-usleep.patch
+++ b/Ports/c-ray/patches/fix-usleep.patch
@@ -1,27 +1,20 @@
-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) {
+--- c-ray-master/src/utils/timer.c 2021-03-13 00:26:36.846000000 +0100
++++ c-ray-master/src/utils/timer.c 2021-03-13 00:27:29.453478737 +0100
+@@ -48,7 +48,7 @@
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);
+-#ifdef __linux__
++#if defined(__linux__) || defined(__serenity__)
+ #define _BSD_SOURCE
+ #include <unistd.h>
+ #endif
+@@ -66,7 +66,7 @@
+ ts.tv_sec = ms / 1000;
+ ts.tv_nsec = (ms % 1000) * 1000000;
+ nanosleep(&ts, NULL);
-#elif __linux__
++#elif defined(__linux__) || defined(__serenity__)
usleep(ms * 1000);
--#endif
+ #endif
}
diff --git a/Ports/c-ray/patches/replace-micro-symbol.patch b/Ports/c-ray/patches/replace-micro-symbol.patch
index 74ce575b81..8aba698723 100644
--- a/Ports/c-ray/patches/replace-micro-symbol.patch
+++ b/Ports/c-ray/patches/replace-micro-symbol.patch
@@ -1,13 +1,11 @@
-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) {
+--- c-ray-master/src/renderer/renderer.c 2021-03-13 22:08:24.699323180 +0100
++++ c-ray-master/src/renderer/renderer.c 2021-03-13 22:08:53.513237904 +0100
+@@ -108,7 +108,7 @@
+ float sps = (1000000.0f/usPerRay) * r->prefs.threadCount;
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,
+ interactive ? ((float)r->state.finishedPasses / (float)r->prefs.sampleCount) * 100.0f :
+ ((float)r->state.finishedTileCount / (float)r->state.tileCount) * 100.0f,
diff --git a/Ports/c-ray/patches/set-sdl-software-renderer.patch b/Ports/c-ray/patches/set-sdl-software-renderer.patch
index 7b7899c0fe..40dd120008 100644
--- a/Ports/c-ray/patches/set-sdl-software-renderer.patch
+++ b/Ports/c-ray/patches/set-sdl-software-renderer.patch
@@ -1,13 +1,11 @@
-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;
+--- c-ray-master/src/utils/ui.c 2021-03-13 00:30:25.488000000 +0100
++++ c-ray-master/src/utils/ui.c 2021-03-13 00:30:41.056572879 +0100
+@@ -120,7 +120,7 @@
+ return;
}
//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) {
+- gdisplay->renderer = SDL_CreateRenderer(gdisplay->window, -1, SDL_RENDERER_ACCELERATED);
++ gdisplay->renderer = SDL_CreateRenderer(gdisplay->window, -1, SDL_RENDERER_SOFTWARE);
+ if (gdisplay->renderer == NULL) {
logr(warning, "Renderer couldn't be created, error: \"%s\"\n", SDL_GetError());
- return -1;
+ destroyDisplay();