opengl - Why is depth buffers faster than depth textures? -


this tutorial on shadow-mapping in opengl briefly mentions difference between using depth buffer , depth texture (edit: store per pixel depth information depth testing or other purposes, such shadow-mapping) stating:

depth texture. slower depth buffer, can sample later in shader

however, got me wondering why so. after all, both seem nothing more two-dimensional array containing data, , definition on microsofts notes on graphics define them in similar terms such (these notes pointed out in comment, not on opengl graphical engine, purpose of depth-buffers/-textures seem quite similar -- have have not found equal description of 2 opengl depth-buffers/-textures -- reason have decided keep these articles. if has link article describing depth buffers , depth textures in opengl welcome post in comments)

a depth buffer contains per-pixel floating-point data z depth of each pixel rendered.

and

a depth texture, known shadow map, texture contains data depth buffer particular scene

of course, there few differences between 2 methods -- notably, depth texture can sampled later, unlike depth buffer.
despite these differences, can not see why depth buffer should faster use depth texture, , question is, therefore: why can't these 2 methods of storing same data equally fast (edit: when used storing depth data depth testing).

by "depth buffer", assume mean "renderbuffer depth format".

possible reasons why depth renderbuffer might faster render depth texture include:

  1. a depth renderbuffer can live within specialized memory not shader-accessible, since implementation knows can't access shader.
  2. a depth renderbuffer might able have special format or layout depth texture cannot have, since texture has shader-accessible. include things hi-z/hierarchical-z , forth.

#1 tends crop on tile-based architectures. if things right, can keep depth renderbuffer entirely within tile memory. means that, after rendering operation, there no need copy out main memory. contrast, depth texture, implementation can't sure don't need copy out, has safe.

note list purely speculative. unless you've profiled it, or have specific knowledge of hardware (as in tbr case), there's no reason assume there substantial difference in performance.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -