Multisampled textures

Which operations can be effective in fragment shader for multisampled depth textures? I mean, for RGBA textures, we could just take average of color values came from texelFetch().

What should be ideal shader code for multisampled depth texture?

I don’t understand your question. Do you mean, what’s the point of having them?

Think about the edge AA benefits of rasterizing to an MSAA window. Same benefits go to rasterizing to an MSAA texture or renderbuffer attached to an FBO.

No, I mean for RGBA textures, we can average the color values for all the samples. But is it the good way in case of depth textures?

With standard MSAA rasterization, the MSAA depth buffer is only used to capture subsample MSAA color information properly. What you really want is the downsampled color, not the downsampled depth.

So why are you concerned about how to downsample the depth buffer?

Averaging depths doesn’t really have any useful meaning. What makes more sense (considering shadow maps, which is just a depth buffer afterall) is something like what PCF does, where multiple depth compares are done per-texel/sample and then the boolean comparison results are averaged.