Skip to content

Commit

Permalink
v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
187J3X1-114514 committed Oct 3, 2024
1 parent 5aa088a commit 806dc49
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ JNIEXPORT jint JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper
/*
* Class: io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper
* Method: ffxFsr2CreateGL
* Signature: (IFIII)I
* Signature: (IFIII)[I
*/
JNIEXPORT jint JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_ffxFsr2CreateGL
JNIEXPORT jintArray JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_ffxFsr2CreateGL
(JNIEnv *, jobject, jint, jfloat, jint, jint, jint);

/*
Expand All @@ -36,18 +36,10 @@ JNIEXPORT jint JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper

/*
* Class: io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper
* Method: getGPUInfoNV
* Method: getVersionInfo
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_getGPUInfoNV
(JNIEnv *, jobject);

/*
* Class: io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper
* Method: getGPUInfoAMD
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_getGPUInfoAMD
JNIEXPORT jstring JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_getVersionInfo
(JNIEnv *, jobject);

/*
Expand Down
1 change: 1 addition & 0 deletions src/ffx-fsr2-api/ffx_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static const FfxErrorCode FFX_ERROR_OUT_OF_RANGE = 0x8000000b; ///<
static const FfxErrorCode FFX_ERROR_NULL_DEVICE = 0x8000000c; ///< The operation failed because a device was null.
static const FfxErrorCode FFX_ERROR_BACKEND_API_ERROR = 0x8000000d; ///< The operation failed because the backend API returned an error code.
static const FfxErrorCode FFX_ERROR_INSUFFICIENT_MEMORY = 0x8000000e; ///< The operation failed because there was not enough memory.
static const FfxErrorCode FFX_ERROR_GL_KHR_shader_subgroup = 0x7000000e;

/// Helper macro to return error code y from a function when a specific condition, x, is not met.
#define FFX_RETURN_ON_ERROR(x, y) \
Expand Down
1 change: 0 additions & 1 deletion src/ffx-fsr2-api/ffx_fsr2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ static FfxErrorCode fsr2Create(FfxFsr2Context_Private *context, const FfxFsr2Con
// Create the device.
FfxErrorCode errorCode = context->contextDescription.callbacks.fpCreateBackendContext(&context->contextDescription.callbacks, context->device);
FFX_RETURN_ON_ERROR(errorCode == FFX_OK, errorCode);

// call out for device caps.
errorCode = context->contextDescription.callbacks.fpGetDeviceCapabilities(&context->contextDescription.callbacks, &context->deviceCapabilities, context->device);
FFX_RETURN_ON_ERROR(errorCode == FFX_OK, errorCode);
Expand Down
3 changes: 2 additions & 1 deletion src/ffx-fsr2-api/gl/ffx_fsr2_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <cstdlib>
#include <codecvt>
#include <locale>
#include "../../../include/utils.h"

#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
Expand Down Expand Up @@ -674,7 +675,7 @@ FfxErrorCode GetDeviceCapabilitiesGL(FfxFsr2Interface *backendInterface, FfxDevi

if (!subgroupSupported)
{
return FFX_ERROR_BACKEND_API_ERROR; // GL_KHR_shader_subgroup is required
return FFX_ERROR_GL_KHR_shader_subgroup; // GL_KHR_shader_subgroup is required
}

GLint subgroupSize = FSR2_DEFAULT_SUBGROUP_SIZE;
Expand Down
25 changes: 17 additions & 8 deletions src/ffxFsr2.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "io_homo_superresolution_fsr2_nativelib_ffx_fsr2_api.h"
#define VES "0.0.2"

#include "io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper.h"
#include "ffx-fsr2-api/ffx_fsr2.h"
#include "ffx-fsr2-api/gl/ffx_fsr2_gl.h"
#include "ffx-fsr2-api/ffx_error.h"
#include <stdlib.h>
#include <memory>
#include "glfw3.h"
#include "utils.h"

bool fsr2FirstInit = true;
FfxFsr2Context fsr2Context;
std::unique_ptr<char[]> fsr2ScratchMemory;
Expand All @@ -20,7 +21,7 @@ static void check_env(JNIEnv *env)
set_env(env);
}

JNIEXPORT jint JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_ffxFsr2CreateGL(JNIEnv *env, jobject, jint scratchMemorySize, jfloat fsr2Ratio, jint width, jint height, jint flags)
JNIEXPORT jintArray JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_ffxFsr2CreateGL(JNIEnv *env, jobject, jint scratchMemorySize, jfloat fsr2Ratio, jint width, jint height, jint flags)
{
if (!fsr2FirstInit)
{
Expand Down Expand Up @@ -48,10 +49,13 @@ JNIEXPORT jint JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper
java_log(cstr, 0);
};
fsr2ScratchMemory = std::make_unique<char[]>(ffxFsr2GetScratchMemorySizeGL());
ffxFsr2GetInterfaceGL(&contextDesc.callbacks, fsr2ScratchMemory.get(), ffxFsr2GetScratchMemorySizeGL(), java_glfwGetProcAddress);
FfxErrorCode code = ffxFsr2ContextCreate(&fsr2Context, &contextDesc);
java_log("FSR_CPP ffxFsr2CreateGL", 0);
return static_cast<int>(code);
FfxErrorCode code1 = ffxFsr2GetInterfaceGL(&contextDesc.callbacks, fsr2ScratchMemory.get(), ffxFsr2GetScratchMemorySizeGL(), java_glfwGetProcAddress);
FfxErrorCode code2 = ffxFsr2ContextCreate(&fsr2Context, &contextDesc);
java_log("FSR2_CPP ffxFsr2CreateGL",0);
jint code_c[] = {code1,code2};
jintArray outJNIArray = (env)->NewIntArray(2);
(env)->SetIntArrayRegion(outJNIArray, 0 , 2, code_c);
return outJNIArray;
}
JNIEXPORT jint JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_ffxFsr2GetScratchMemorySizeGL(JNIEnv *env, jobject)
{
Expand Down Expand Up @@ -147,4 +151,9 @@ JNIEXPORT jint JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper
jobject j = Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_ffxGetTextureResourceGL(env, o, 0, 1, 1, 0);
ffxResourceJavaToCpp(env, j);
return 0;
};
};

JNIEXPORT jstring JNICALL Java_io_homo_superresolution_fsr2_nativelib_FSR2ApiHelper_getVersionInfo
(JNIEnv *env, jobject){
return (env)->NewStringUTF(VES);
}
3 changes: 2 additions & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GLFWglproc java_glfwGetProcAddress(const char *name)
return 0;
}

/*
using namespace std;
char *get_gpu_info_nv()
Expand Down Expand Up @@ -100,7 +101,7 @@ char *get_gpu_info_nv()
nvmlShutdown();
return (char *)jsonString.c_str();
}

*/
bool ToCppBool(jboolean value)
{
return value == JNI_TRUE;
Expand Down

0 comments on commit 806dc49

Please sign in to comment.