The Upper Ordovician Wufeng and lower Silurian Longmaxi Formations are the most prolific shale gas reservoirs with the annual gas output more than 200 x 10(8) m(3) (706.3 BCF) in 2020 in China. This study aims to quantify porosity type and distribution in the depositional context of this economically important interval, to fundamentally understand key controls on pore development and reservoir quality. Three pore types, mineral-hosted pores, organic matter-hosted pores, and microfractures, were qualitatively and quantitatively characterized for samples in six shale lithofacies by analyzing stitched scanning electron microscopy mosaics of a representative field of view (similar to 100 x 100-250 x 250 mu m(2)). Field-emission scanning electron microscopy and helium ion microscopy observations reveal a remarkable variation in the proportion, porosity, and structure distribution of each pore type among different lithofacies. The argillaceous mudstone facies, silty mudstone facies, and dolomitic mudstone facies have an average total porosity less than 1%, in which the mineral-hosted porosity accounts for approximately 55%-75%. The mixed mudstone facies, silica-rich argillaceous shale facies, and siliceous shale facies contain an average total porosity of 1.9% to 2.8%, in which the organic matter-hosted porosity contributes approximately 60%-95%. Organic matter-hosted porosity and total porosity show a similar positive linear relationship with total organic carbon content, and reinforce the predominance of organic matter-hosted pores in the reservoir strata. Mineral-hosted porosity is low due to strong destruction by mechanical compaction, cementation, and organic matter filling. We propose a comprehensive model to demonstrate the leading role of quality and quantity of organic matter and the importance of mineral preservation on pore development and thus reservoir properties.