reorg + add stb dependency

This commit is contained in:
unknown 2024-02-29 20:54:47 -05:00
parent 61124b55c1
commit 4bbc4883b6
9 changed files with 38 additions and 19 deletions

3
.gitignore vendored
View File

@ -7,4 +7,5 @@
/.project /.project
/.vscode /.vscode
/shared-folder /shared-folder
/shared-folder/** /shared-folder/**
/src/main/c/lib/**

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "src/main/c/lib/stb"]
path = src/main/c/lib/stb
url = https://github.com/nothings/stb.git

View File

@ -42,17 +42,17 @@ rm -f ./*.dll
#compile object files #compile object files
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -O1" COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -O1"
INPUT_FILES="./densitystep.c" INPUT_FILES="./src/densitystep.c"
OUTPUT_FILE="./densitystep.o" OUTPUT_FILE="./densitystep.o"
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -O1" COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -O1"
INPUT_FILES="./velocitystep.c" INPUT_FILES="./src/velocitystep.c"
OUTPUT_FILE="./velocitystep.o" OUTPUT_FILE="./velocitystep.o"
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -O1" COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -O1"
INPUT_FILES="./chunkmask.c" INPUT_FILES="./src/chunkmask.c"
OUTPUT_FILE="./chunkmask.o" OUTPUT_FILE="./chunkmask.o"
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE

View File

@ -0,0 +1,10 @@
//include guard
#ifndef LIB_FLUID_SIM
#define LIB_FLUID_SIM
//include stb ds
#define STB_IMAGE_IMPLEMENTATION
#include "../lib/stb/stb_ds.h"
//close include guard
#endif

1
src/main/c/lib/stb Submodule

@ -0,0 +1 @@
Subproject commit ae721c50eaf761660b4f90cc590453cdb0c2acd0

View File

@ -1,7 +1,8 @@
#include <jni.h> #include <jni.h>
#include <stdint.h> #include <stdint.h>
#include "includes/utilities.h" #include "../includes/libfluidsim.h"
#include "includes/chunkmask.h" #include "../includes/utilities.h"
#include "../includes/chunkmask.h"
uint32_t matrix_transform(JNIEnv * env, jobjectArray jrx); uint32_t matrix_transform(JNIEnv * env, jobjectArray jrx);

View File

@ -2,9 +2,11 @@
#include <stdio.h> #include <stdio.h>
#include <immintrin.h> #include <immintrin.h>
#include <stdint.h> #include <stdint.h>
#include <pthread.h>
#include "includes/utilities.h" #include "../includes/libfluidsim.h"
#include "includes/chunkmask.h" #include "../includes/utilities.h"
#include "../includes/chunkmask.h"
void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, jobjectArray jrd, jobjectArray d0, float * u, float * v, float * w, float dt); void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, jobjectArray jrd, jobjectArray d0, float * u, float * v, float * w, float dt);
@ -127,12 +129,12 @@ void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, jobjectArray
m = n = o = 1; m = n = o = 1;
if(x < 1){ m -= 1; } // if(x < 1){ m -= 1; }
if(x >= N-1){ m += 1; } // if(x >= N-1){ m += 1; }
if(y < 1){ n -= 1; } // if(y < 1){ n -= 1; }
if(y >= N-1){ n += 1; } // if(y >= N-1){ n += 1; }
if(z < 1){ o -= 1; } // if(z < 1){ o -= 1; }
if(z >= N-1){ o += 1; } // if(z >= N-1){ o += 1; }
//If the out of bounds coordinate is in bounds for a neighbor chunk, use that chunk as source instead //If the out of bounds coordinate is in bounds for a neighbor chunk, use that chunk as source instead
// if(CK(m,n,o) != CENTER_LOC){ // if(CK(m,n,o) != CENTER_LOC){

View File

@ -3,8 +3,9 @@
#include <immintrin.h> #include <immintrin.h>
#include <stdint.h> #include <stdint.h>
#include "includes/utilities.h" #include "../includes/libfluidsim.h"
#include "includes/chunkmask.h" #include "../includes/utilities.h"
#include "../includes/chunkmask.h"
#define BOUND_NO_DIR 0 #define BOUND_NO_DIR 0

View File

@ -22,7 +22,7 @@ public class Main {
public static void main(String args[]){ public static void main(String args[]){
int dim = 5; int dim = 10;
int i = 0; int i = 0;
long time = 0; long time = 0;
long lastTime = 0; long lastTime = 0;
@ -36,9 +36,9 @@ public class Main {
Mesh.initShaderProgram(); Mesh.initShaderProgram();
FluidSim[][][] simArray = initFluidSim(dim,1,dim); FluidSim[][][] simArray = initFluidSim(dim,1,1);
Mesh[][][] meshArray = initMeshes(dim,1,dim,simArray); Mesh[][][] meshArray = initMeshes(dim,1,1,simArray);