Ports: Update c-ray patches
This commit is contained in:
parent
caa8f3d3bf
commit
161b36bb09
Notes:
sideshowbarker
2024-07-18 21:23:37 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/161b36bb09a Pull-request: https://github.com/SerenityOS/serenity/pull/5765 Reviewed-by: https://github.com/BenWiederhake Reviewed-by: https://github.com/awesomekling
6 changed files with 58 additions and 99 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue