Using OpenCL with Android JNI produces slow code due to some overheadHow to obtain computation time in NDKWhere can I find Android source code online?Why is the Android emulator so slow? How can we speed up the Android emulator?What makes JNI calls slow?Asynchronous execution of commands from two command queues in OpenCLWhat is the quantitative overhead of making a JNI call?RenderScript GPU performance not on par with device GFLOPS?Multiplying thousands of 4x4 matrices with OpenCL on GPU slower than single threaded CPUGaussianBlur and optimization for gpu using openMP and CVOptimizing kernel code in opencl for a GPUWhy does my program run significantly faster on my CPU device than on my GPU device?
“T” in subscript in formulas
Circular Reasoning for Epsilon-Delta Proof?
Why are non-collision-resistant hash functions considered insecure for signing self-generated information
Notepad++ cannot print
"There were either twelve sexes or none."
Two questions about typesetting a Roman missal
Does an atom recoil when photon radiate?
Papers on arXiv solving the same problem at the same time
Another solution to create a set with two conditions
Was it ever possible to target a zone?
Prove your innocence
Uri tokenizer as a simple state machine
Can I get temporary health insurance while moving to the US?
Architectural feasibility of a tiered circular stone keep
Was there ever a treaty between 2 entities with significantly different translations to the detriment of one party?
'Us students' - Does this apposition need a comma?
Who was president of the USA?
Is gzip atomic?
Why in most German places is the church the tallest building?
Why doesn't the Bitcoin-qt client ask for the Wallet passphrase upon startup?
Transposing from C to Cm?
Are the A380 engines interchangeable (given they are not all equipped with reverse)?
Handling Disruptive Student on the Autistic Spectrum
How to respectfully refuse to assist co-workers with IT issues?
Using OpenCL with Android JNI produces slow code due to some overhead
How to obtain computation time in NDKWhere can I find Android source code online?Why is the Android emulator so slow? How can we speed up the Android emulator?What makes JNI calls slow?Asynchronous execution of commands from two command queues in OpenCLWhat is the quantitative overhead of making a JNI call?RenderScript GPU performance not on par with device GFLOPS?Multiplying thousands of 4x4 matrices with OpenCL on GPU slower than single threaded CPUGaussianBlur and optimization for gpu using openMP and CVOptimizing kernel code in opencl for a GPUWhy does my program run significantly faster on my CPU device than on my GPU device?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I implemented an algorithm on android using OpenCL and OpenMP. The OpenMP implementation runs about 10 times slower than the OpenCL one.
- OpenMP: ~250 ms
- OpenCL: ~25 ms
But overall, if I measure the time from the java android side, I get roughly the same time to call and get my values.
For example:
Java code:
// calls C implementation using JNI (Java Native Interface)
bool useOpenCL = true;
myFunction(bitmap, useOpenCL); // ~300 ms, timed with System.nanoTime() here, but omitted code for clarity
myFunction(bitmap, !useOpenCL); // ~300 ms, timed with System.nanoTime() here, but omitted code for clarityC code:
JNIEXPORT void JNICALL Java_com_xxxxx_myFunctionNative(JNIEnv * env, jobject obj, jobject pBitmap, jboolean useOpenCL)
// same before, setting some variables
clock_t startTimer, stopTimer;
startTimer = clock();
if ((bool) useOpenCL)
calculateUsingOpenCL(); // runs in ~25 ms, timed here, using clock()
else
calculateUsingOpenMP(); // runs in ~250 ms
stopTimer = clock();
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Time in ms: %fn", 1000.0f* (float)(stopTimer - startTimer) / (float)CLOCKS_PER_SEC);
// same from here on, e.g.: copying values to java side
The Java code, in both cases executes roughly in the same time, around 300 ms. To be more precise, elapsedTime
is a bit more for OpenCL, that is OpenCL is slower on average.
Looking at the individual run-times of the OpenMP, and OpenCL implementations, OpenCL version should be much faster overall. But for some reason, there is an overhead that I cannot find.
I also compared OpenCL vs Normal native code (no OpenMP), I still got the same results, with roughly same runtime overall, even though the calculateUsingOpenCL
ran at least 10 times faster.
Ideas:
Maybe the GPU (in OpenCL case) is less efficient in general, because it has less memory available. There are few variables that we need to preallocate, which are used every frame. So, we checked the time it takes for android to draw a bitmap in both cases (OpenMP, OpenCL). In the OpenCL case, sometimes drawing a bitmap took longer (3 times longer), but not by the amount that would equalize the overall run time of the program.
Does JNI use GPU to accelerate some calls, which could cause the OpenCL version to be slower?
EDIT:
- Is it possible that Java Garbage collection is triggered by OpenCL, causing the big overhead?
android performance java-native-interface opencl
add a comment |
I implemented an algorithm on android using OpenCL and OpenMP. The OpenMP implementation runs about 10 times slower than the OpenCL one.
- OpenMP: ~250 ms
- OpenCL: ~25 ms
But overall, if I measure the time from the java android side, I get roughly the same time to call and get my values.
For example:
Java code:
// calls C implementation using JNI (Java Native Interface)
bool useOpenCL = true;
myFunction(bitmap, useOpenCL); // ~300 ms, timed with System.nanoTime() here, but omitted code for clarity
myFunction(bitmap, !useOpenCL); // ~300 ms, timed with System.nanoTime() here, but omitted code for clarityC code:
JNIEXPORT void JNICALL Java_com_xxxxx_myFunctionNative(JNIEnv * env, jobject obj, jobject pBitmap, jboolean useOpenCL)
// same before, setting some variables
clock_t startTimer, stopTimer;
startTimer = clock();
if ((bool) useOpenCL)
calculateUsingOpenCL(); // runs in ~25 ms, timed here, using clock()
else
calculateUsingOpenMP(); // runs in ~250 ms
stopTimer = clock();
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Time in ms: %fn", 1000.0f* (float)(stopTimer - startTimer) / (float)CLOCKS_PER_SEC);
// same from here on, e.g.: copying values to java side
The Java code, in both cases executes roughly in the same time, around 300 ms. To be more precise, elapsedTime
is a bit more for OpenCL, that is OpenCL is slower on average.
Looking at the individual run-times of the OpenMP, and OpenCL implementations, OpenCL version should be much faster overall. But for some reason, there is an overhead that I cannot find.
I also compared OpenCL vs Normal native code (no OpenMP), I still got the same results, with roughly same runtime overall, even though the calculateUsingOpenCL
ran at least 10 times faster.
Ideas:
Maybe the GPU (in OpenCL case) is less efficient in general, because it has less memory available. There are few variables that we need to preallocate, which are used every frame. So, we checked the time it takes for android to draw a bitmap in both cases (OpenMP, OpenCL). In the OpenCL case, sometimes drawing a bitmap took longer (3 times longer), but not by the amount that would equalize the overall run time of the program.
Does JNI use GPU to accelerate some calls, which could cause the OpenCL version to be slower?
EDIT:
- Is it possible that Java Garbage collection is triggered by OpenCL, causing the big overhead?
android performance java-native-interface opencl
Which device/OS did you test on. Also which version of OpenMP library did you use (32 bit/64 bit)?
– Morrison Chang
Mar 27 at 18:44
I tested on Open-Q 820 μSOM. OpenMP does not really matter here, because the question is about OpenCL being slow.
– Snowman
Mar 27 at 18:55
"with OpenCL we need to allocate a few variables on it, which are used in every frame" - i'm not sure what you mean by "variables" but if you're allocating and releasing new buffers on every frame, you're almost certainly doing it wrong. My approach would be to have the buffers as static variables ("cl_mem" type), and add two methods "init" and "teardown" (self-explanatory). Then just use those buffers via static variables in every frame rendering. Same applies to OpenCL Command Queues - don't create & destroy them every frame; it can be slow. You want to reuse CL objects as much as possible.
– mogu
Mar 28 at 7:58
No, we don't create variables every frame obviously.
– Snowman
Mar 28 at 19:13
add a comment |
I implemented an algorithm on android using OpenCL and OpenMP. The OpenMP implementation runs about 10 times slower than the OpenCL one.
- OpenMP: ~250 ms
- OpenCL: ~25 ms
But overall, if I measure the time from the java android side, I get roughly the same time to call and get my values.
For example:
Java code:
// calls C implementation using JNI (Java Native Interface)
bool useOpenCL = true;
myFunction(bitmap, useOpenCL); // ~300 ms, timed with System.nanoTime() here, but omitted code for clarity
myFunction(bitmap, !useOpenCL); // ~300 ms, timed with System.nanoTime() here, but omitted code for clarityC code:
JNIEXPORT void JNICALL Java_com_xxxxx_myFunctionNative(JNIEnv * env, jobject obj, jobject pBitmap, jboolean useOpenCL)
// same before, setting some variables
clock_t startTimer, stopTimer;
startTimer = clock();
if ((bool) useOpenCL)
calculateUsingOpenCL(); // runs in ~25 ms, timed here, using clock()
else
calculateUsingOpenMP(); // runs in ~250 ms
stopTimer = clock();
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Time in ms: %fn", 1000.0f* (float)(stopTimer - startTimer) / (float)CLOCKS_PER_SEC);
// same from here on, e.g.: copying values to java side
The Java code, in both cases executes roughly in the same time, around 300 ms. To be more precise, elapsedTime
is a bit more for OpenCL, that is OpenCL is slower on average.
Looking at the individual run-times of the OpenMP, and OpenCL implementations, OpenCL version should be much faster overall. But for some reason, there is an overhead that I cannot find.
I also compared OpenCL vs Normal native code (no OpenMP), I still got the same results, with roughly same runtime overall, even though the calculateUsingOpenCL
ran at least 10 times faster.
Ideas:
Maybe the GPU (in OpenCL case) is less efficient in general, because it has less memory available. There are few variables that we need to preallocate, which are used every frame. So, we checked the time it takes for android to draw a bitmap in both cases (OpenMP, OpenCL). In the OpenCL case, sometimes drawing a bitmap took longer (3 times longer), but not by the amount that would equalize the overall run time of the program.
Does JNI use GPU to accelerate some calls, which could cause the OpenCL version to be slower?
EDIT:
- Is it possible that Java Garbage collection is triggered by OpenCL, causing the big overhead?
android performance java-native-interface opencl
I implemented an algorithm on android using OpenCL and OpenMP. The OpenMP implementation runs about 10 times slower than the OpenCL one.
- OpenMP: ~250 ms
- OpenCL: ~25 ms
But overall, if I measure the time from the java android side, I get roughly the same time to call and get my values.
For example:
Java code:
// calls C implementation using JNI (Java Native Interface)
bool useOpenCL = true;
myFunction(bitmap, useOpenCL); // ~300 ms, timed with System.nanoTime() here, but omitted code for clarity
myFunction(bitmap, !useOpenCL); // ~300 ms, timed with System.nanoTime() here, but omitted code for clarityC code:
JNIEXPORT void JNICALL Java_com_xxxxx_myFunctionNative(JNIEnv * env, jobject obj, jobject pBitmap, jboolean useOpenCL)
// same before, setting some variables
clock_t startTimer, stopTimer;
startTimer = clock();
if ((bool) useOpenCL)
calculateUsingOpenCL(); // runs in ~25 ms, timed here, using clock()
else
calculateUsingOpenMP(); // runs in ~250 ms
stopTimer = clock();
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Time in ms: %fn", 1000.0f* (float)(stopTimer - startTimer) / (float)CLOCKS_PER_SEC);
// same from here on, e.g.: copying values to java side
The Java code, in both cases executes roughly in the same time, around 300 ms. To be more precise, elapsedTime
is a bit more for OpenCL, that is OpenCL is slower on average.
Looking at the individual run-times of the OpenMP, and OpenCL implementations, OpenCL version should be much faster overall. But for some reason, there is an overhead that I cannot find.
I also compared OpenCL vs Normal native code (no OpenMP), I still got the same results, with roughly same runtime overall, even though the calculateUsingOpenCL
ran at least 10 times faster.
Ideas:
Maybe the GPU (in OpenCL case) is less efficient in general, because it has less memory available. There are few variables that we need to preallocate, which are used every frame. So, we checked the time it takes for android to draw a bitmap in both cases (OpenMP, OpenCL). In the OpenCL case, sometimes drawing a bitmap took longer (3 times longer), but not by the amount that would equalize the overall run time of the program.
Does JNI use GPU to accelerate some calls, which could cause the OpenCL version to be slower?
EDIT:
- Is it possible that Java Garbage collection is triggered by OpenCL, causing the big overhead?
android performance java-native-interface opencl
android performance java-native-interface opencl
edited Apr 2 at 13:23
Snowman
asked Mar 27 at 18:28
SnowmanSnowman
1,0971 gold badge9 silver badges29 bronze badges
1,0971 gold badge9 silver badges29 bronze badges
Which device/OS did you test on. Also which version of OpenMP library did you use (32 bit/64 bit)?
– Morrison Chang
Mar 27 at 18:44
I tested on Open-Q 820 μSOM. OpenMP does not really matter here, because the question is about OpenCL being slow.
– Snowman
Mar 27 at 18:55
"with OpenCL we need to allocate a few variables on it, which are used in every frame" - i'm not sure what you mean by "variables" but if you're allocating and releasing new buffers on every frame, you're almost certainly doing it wrong. My approach would be to have the buffers as static variables ("cl_mem" type), and add two methods "init" and "teardown" (self-explanatory). Then just use those buffers via static variables in every frame rendering. Same applies to OpenCL Command Queues - don't create & destroy them every frame; it can be slow. You want to reuse CL objects as much as possible.
– mogu
Mar 28 at 7:58
No, we don't create variables every frame obviously.
– Snowman
Mar 28 at 19:13
add a comment |
Which device/OS did you test on. Also which version of OpenMP library did you use (32 bit/64 bit)?
– Morrison Chang
Mar 27 at 18:44
I tested on Open-Q 820 μSOM. OpenMP does not really matter here, because the question is about OpenCL being slow.
– Snowman
Mar 27 at 18:55
"with OpenCL we need to allocate a few variables on it, which are used in every frame" - i'm not sure what you mean by "variables" but if you're allocating and releasing new buffers on every frame, you're almost certainly doing it wrong. My approach would be to have the buffers as static variables ("cl_mem" type), and add two methods "init" and "teardown" (self-explanatory). Then just use those buffers via static variables in every frame rendering. Same applies to OpenCL Command Queues - don't create & destroy them every frame; it can be slow. You want to reuse CL objects as much as possible.
– mogu
Mar 28 at 7:58
No, we don't create variables every frame obviously.
– Snowman
Mar 28 at 19:13
Which device/OS did you test on. Also which version of OpenMP library did you use (32 bit/64 bit)?
– Morrison Chang
Mar 27 at 18:44
Which device/OS did you test on. Also which version of OpenMP library did you use (32 bit/64 bit)?
– Morrison Chang
Mar 27 at 18:44
I tested on Open-Q 820 μSOM. OpenMP does not really matter here, because the question is about OpenCL being slow.
– Snowman
Mar 27 at 18:55
I tested on Open-Q 820 μSOM. OpenMP does not really matter here, because the question is about OpenCL being slow.
– Snowman
Mar 27 at 18:55
"with OpenCL we need to allocate a few variables on it, which are used in every frame" - i'm not sure what you mean by "variables" but if you're allocating and releasing new buffers on every frame, you're almost certainly doing it wrong. My approach would be to have the buffers as static variables ("cl_mem" type), and add two methods "init" and "teardown" (self-explanatory). Then just use those buffers via static variables in every frame rendering. Same applies to OpenCL Command Queues - don't create & destroy them every frame; it can be slow. You want to reuse CL objects as much as possible.
– mogu
Mar 28 at 7:58
"with OpenCL we need to allocate a few variables on it, which are used in every frame" - i'm not sure what you mean by "variables" but if you're allocating and releasing new buffers on every frame, you're almost certainly doing it wrong. My approach would be to have the buffers as static variables ("cl_mem" type), and add two methods "init" and "teardown" (self-explanatory). Then just use those buffers via static variables in every frame rendering. Same applies to OpenCL Command Queues - don't create & destroy them every frame; it can be slow. You want to reuse CL objects as much as possible.
– mogu
Mar 28 at 7:58
No, we don't create variables every frame obviously.
– Snowman
Mar 28 at 19:13
No, we don't create variables every frame obviously.
– Snowman
Mar 28 at 19:13
add a comment |
1 Answer
1
active
oldest
votes
It turns out, clock() is unreliable (on Android), so instead we used the following method to measure time. With this method, everything is ok.
int64_t getTimeNsec()
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return (int64_t) now.tv_sec*1000000000LL + now.tv_nsec;
clock_t startTimer, stopTimer;
startTimer = getTimeNsec();
function_to_measure();
stopTimer = getTimeNsec();
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Runtime in milliseconds (ms): %f", (float)(stopTimer - startTimer) / 1000000.0f);
This was suggested here:
How to obtain computation time in NDK
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55384225%2fusing-opencl-with-android-jni-produces-slow-code-due-to-some-overhead%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It turns out, clock() is unreliable (on Android), so instead we used the following method to measure time. With this method, everything is ok.
int64_t getTimeNsec()
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return (int64_t) now.tv_sec*1000000000LL + now.tv_nsec;
clock_t startTimer, stopTimer;
startTimer = getTimeNsec();
function_to_measure();
stopTimer = getTimeNsec();
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Runtime in milliseconds (ms): %f", (float)(stopTimer - startTimer) / 1000000.0f);
This was suggested here:
How to obtain computation time in NDK
add a comment |
It turns out, clock() is unreliable (on Android), so instead we used the following method to measure time. With this method, everything is ok.
int64_t getTimeNsec()
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return (int64_t) now.tv_sec*1000000000LL + now.tv_nsec;
clock_t startTimer, stopTimer;
startTimer = getTimeNsec();
function_to_measure();
stopTimer = getTimeNsec();
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Runtime in milliseconds (ms): %f", (float)(stopTimer - startTimer) / 1000000.0f);
This was suggested here:
How to obtain computation time in NDK
add a comment |
It turns out, clock() is unreliable (on Android), so instead we used the following method to measure time. With this method, everything is ok.
int64_t getTimeNsec()
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return (int64_t) now.tv_sec*1000000000LL + now.tv_nsec;
clock_t startTimer, stopTimer;
startTimer = getTimeNsec();
function_to_measure();
stopTimer = getTimeNsec();
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Runtime in milliseconds (ms): %f", (float)(stopTimer - startTimer) / 1000000.0f);
This was suggested here:
How to obtain computation time in NDK
It turns out, clock() is unreliable (on Android), so instead we used the following method to measure time. With this method, everything is ok.
int64_t getTimeNsec()
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return (int64_t) now.tv_sec*1000000000LL + now.tv_nsec;
clock_t startTimer, stopTimer;
startTimer = getTimeNsec();
function_to_measure();
stopTimer = getTimeNsec();
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Runtime in milliseconds (ms): %f", (float)(stopTimer - startTimer) / 1000000.0f);
This was suggested here:
How to obtain computation time in NDK
answered Apr 3 at 13:11
SnowmanSnowman
1,0971 gold badge9 silver badges29 bronze badges
1,0971 gold badge9 silver badges29 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55384225%2fusing-opencl-with-android-jni-produces-slow-code-due-to-some-overhead%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Which device/OS did you test on. Also which version of OpenMP library did you use (32 bit/64 bit)?
– Morrison Chang
Mar 27 at 18:44
I tested on Open-Q 820 μSOM. OpenMP does not really matter here, because the question is about OpenCL being slow.
– Snowman
Mar 27 at 18:55
"with OpenCL we need to allocate a few variables on it, which are used in every frame" - i'm not sure what you mean by "variables" but if you're allocating and releasing new buffers on every frame, you're almost certainly doing it wrong. My approach would be to have the buffers as static variables ("cl_mem" type), and add two methods "init" and "teardown" (self-explanatory). Then just use those buffers via static variables in every frame rendering. Same applies to OpenCL Command Queues - don't create & destroy them every frame; it can be slow. You want to reuse CL objects as much as possible.
– mogu
Mar 28 at 7:58
No, we don't create variables every frame obviously.
– Snowman
Mar 28 at 19:13