Immune-mediated inflammation directly impairs pulmonary function, contributing to the pathogenesis of Pneumocystis carinii pneumonia.