Maximum texture inputs?
Ok, this might be a little crazy (or is it?) but I made some custom filters with 2 - 8 texture inputs, depending on how many "layers" a user has added to their image. It all works really well except when the user has 7 or 8 texture inputs. When they add 7+, the GPUImageView turns black (or whatever the background color of the filter is).
So my question is there are maximum number of textures you can add to a single filter? Is there an OpenGL limit? Is it 6?
Each of the texture images are 640 x 640, but I set the force processing size to 320x320. I've been testing it on iOS 7 with an iPhone 5s... there isn't any lag all the way up to 6 textures, and then it just blanks out... I've done a bunch of research but I can't seem to find the answer.
Thanx for your time. Thoughts?
Some of the iOS devices are limited to a maximum of 8 texture units (remember that there has to be one texture output for the filter, so that means only 7 texture inputs), but the 5S should support 16 texture units:
https://gfxbench.com/device.jsp?benchmark=gfx30&os=iOS&api=gl&D=Apple+iPhone+5S&testgroup=gl
I haven't pushed it that far, but there might be a hard limit in the driver itself.
Thanks so much for the reply! And thanks so much for your work.
So after doing more research, I dug up that you can have a max of 8 texture units per fragment shader... and it looks like thats across the board for all devices (I'm not certain though). But the phones each still have a MAX textures units allowed...
So that brings me to this question, if I can only have 8 textures per frag shader... can I have multiple shaders, each with less than 8 textures, until I reach the max texture units...??
Just a thought.
If you're going to have multiple shaders, each shader will require its own rendering pass, so you might as well reassign textures at that point. You can have a max of 8 texture units active at any time, but you could easily swap all those out for each shader pass.
Yeah, I've worked on something like that before, but the problem I have comes up when a user wants to change one of the texture units in the middle of the stack...
So lets say there are 50 textures (this would never happen, but I'm just curious in theory).
Then user wants to manipulate the texture at index #25 in the stack, like drag it from point A to point B (in real time).
My solution was to have a cached image of layers 0 - 24, and that would become texture unit #0. Then the next one would be #25... but then thats where my solution breaks down... because I could only add 5 more units before I hit the max but I have 26-50 still to add, which means I have to run multiple passes . So in this example that would be roughly 4 more passes?
Thats all great and dandy, but the UI would probably lag like crazy....
Another idea was merge all layers except for the one that is currently "in focus" or being "dragged", and add the "dragging" texture to the top of the stack. So I'd only need 2 units... and once the "drag" was complete, I could re-render it into it's original #24 index.
I'm curious if you have any better ideas or thoughts that might point me in a better direction?
um...I try to input 8 texutres, but i cant add the 7th texture, only 6 textures works,when i add the 7th texture,view is black.do you know how to use 8 or more textures?
I couldn't get anything past 6 to work if I wanted the layers to stay "live"... so I just made my app add 6 filters at a time, then save that as an image, and pass that along to the next set of filters... I'm not totally happy with the solution, but it works.