Skip to main content
gamedev.net
🔒 Locked

performance method

Started by lomateron Sep 26, 2012 at 7:26 PM 5 replies 1.3k views
Original Post
lomateron
lomateron
I want to know how is the fastest way
to get whats the lowest alpha value in a texture
21st Century Moose
21st Century Moose
If the texture data never changes just do it at load time and store it out somewhere. Best case is that you'll be passing over the texels anyway so you can combine the computation with the pass; worst case is that you may need to copy it off to a staging resource, map that, and calculate from there. I don't know of any easy way to get the lowest alpha at runtime for dynamic textures; average alpha is easy as pie (just sample from the smallest mip level) but lowest? Nope.
Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
lomateron
lomateron
It is a dynamic texture, I'm still looking for the fastest way to do it, not the easiest, i dont care about complexity. I have tought about rendering to another texture that is half the number of pixels of the original texture and to each pixel of this new texture will be rendered the lowest alpha bettwen 2 pixels of the original, and do this again and again until there is small number of pixels were its faster to read all of them and compare them in one pass(i mean in one shader method pass).
phil_t
phil_t
Downsampling to one pixel will work. That will be the fastest, assuming you only need the value on the GPU (e.g. for a shader to sample from).

Do you need this information on the CPU? If so, do you need to maintain interactive framerates? If not, just copy the texture data to CPU memory and run through it.
lomateron
lomateron
I dont need the info in the CPU.
Can you help me on how to do that down sampling?
Is the that downsampling what i just write in my second comment or is another way.
InvalidPointer
InvalidPointer
FWIW you may be able to speed that up a bit by downsampling by a factor of 4 or more each pass-- usually write bandwidth doesn't scale quite as well as read does (and you do a lot more writing with a 2x2 than with a 4x4 or greater, let alone need more passes/CPU time)
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
lomateron
lomateron
If the texture is 1D and instead of RGBA, it has R, will it be faster if I increase the factor from 4 to 7? just to ask, i really dont think it will be.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.