i'm thinking a problem that is it possible to do some arrays calcution using OpenGL ES in mobile devices. For example, i used glTexImage2D to pass shader a float array (which contains some 0.0 and 1.0, such as {0.0, 1.0, 1.0, 0.0, 0.0...}), and i wish to figure out how many "1" are there in this array through Shader Language. Finally return the result to CPU. Is this possible? And how can i do this?
How to do calculation using OpenGL ES 2.0/3.0?
676 Views Asked by KiBa1215 At
1
There are 1 best solutions below
Related Questions in OPENGL-ES
- Setting up OpenGL ES 1.1, and my android environment
- Opengl Augmented Reality in Android from solvepnp
- error 1281 for the call to glUseProgram
- Page Curl with best quality
- Qtwebengine on Embedded linux, with qtwayland and OpenGL not working, black rectangles seen on browser
- Maintaining glSurfaceView through different activities
- LibGDX - load and process texture asynchronously
- OpenGL ES 2.0 Framebuffer with render to texture iOS: nothing shown
- Generating a sphere in OpenGL without high level libraries - what's wrong with my code?
- matrix.multiply returning Nan
- Android OpenGL ES Fatal signal crash
- OpenGL / weight order independent transparency
- GLSL: How to calculate fragments output RGB value based on Photoshops curve value?
- Find a longitude given a pair of (lat,long) and an offset latitude
- How to implement dynamic page curl in android?
Related Questions in GPGPU
- How to detect NVIDIA CUDA Architecture
- Different Kernels sharing SMx
- How to do calculation using OpenGL ES 2.0/3.0?
- How to run PageRank in Blazegraph on a dataset?
- When do we need two dimension threads in CUDA?
- CUDA cuBlasGetmatrix / cublasSetMatrix fails | Explanation of arguments
- Confusion over compute units and expected cores on nvidia GPU
- Declaring a cl_uint variable in OpenCL C leads to Segmentation fault (core dumped)
- Unkown Issue with input sequence size of FFT in OpenCL
- Passing Host Function as a function pointer in __global__ OR __device__ function in CUDA
- Nvidia OpenCL hangs on blocking buffer access
- CUDA: Cuda memory accessing different than OpenCL? What is causing this illegal memory access?
- Computing on variable length arrays in OpenCL
- AMD HCC Swizzle Intrinsic
- Sparse matrix multiplication OpenCL vs Intel MKL performance
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Well, you could try renderscript (assuming you are on android).
If it's not feasible, you could try something like this:
What you want to do could be accomplished by writing these data into a texture, where every texel is 1 or 0 depending on the data. Then you should perform something like mip-mapping on this texture until you have only 1 pixel. Then that 1 pixel will have the average value of all pixels combined, so you can calculate back exactly how many of them were 1, by multipying it with the size of your initial float array. E.g. if that 1 pixel's value is 0.25, and you had 400 data, then 100 of them had the value of 1.
Note: If the data does not fit into a texture entirely, (for example you have an odd number of data), fill the unused texels with 0.
Note2: Float precision may ruin precision if you have too much data... Make sure you are using a single channel texture format with the highest precision. Single channel 32bit textures (which you should aim for) are only available in opengl es 3.0 afaik, but check the specs.
tldr; you should make a texture, generate mipmaps for it, read the last mip level, and multiply it's value by the number of data items