接收java层的纹理
This commit is contained in:
@@ -107,4 +107,37 @@ JNIEXPORT void JNICALL
|
||||
Java_com_khronos_vulkan_1samples_MainActivity_nativeButtonClicked(JNIEnv *env, jobject thiz) {
|
||||
// TODO: implement nativeButtonClicked()
|
||||
LOGI("call MainActivity_nativeButtonClicked.");
|
||||
}
|
||||
|
||||
void processWithVulkan(uint8_t* data, int width, int height, int format,
|
||||
int rowStride, size_t dataSize) {
|
||||
// Vulkan 处理逻辑
|
||||
// 1. 创建 Vulkan 图像(如果尚未创建)
|
||||
// 2. 将数据复制到 Vulkan 图像内存
|
||||
// 3. 执行 Vulkan 渲染或计算操作
|
||||
|
||||
LOGI("ProcessingImage: %dx%d, stride: %d, size: %zu",
|
||||
width, height, rowStride, dataSize);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_khronos_vulkan_1samples_MainActivity_processImageNative(JNIEnv *env, jobject thiz,
|
||||
jobject buffer, jint width,
|
||||
jint height, jint format,
|
||||
jint row_stride, jint pixel_stride,
|
||||
jint rotation) {
|
||||
// TODO: implement processImageNative()
|
||||
// 获取直接字节缓冲区指针
|
||||
uint8_t* imageData = static_cast<uint8_t*>(env->GetDirectBufferAddress(buffer));
|
||||
jlong capacity = env->GetDirectBufferCapacity(buffer);
|
||||
|
||||
if (imageData == nullptr) {
|
||||
LOGI("Failed to get direct buffer address");
|
||||
return;
|
||||
}
|
||||
|
||||
// 在这里将图像数据传递给 Vulkan
|
||||
// 创建 Vulkan 图像或更新现有图像
|
||||
processWithVulkan(imageData, width, height, format, row_stride, capacity);
|
||||
}
|
||||
Reference in New Issue
Block a user