Accurate understanding and quantitative characterization of the three-dimensional (3D) immiscible water–oil two-phase displacement process and of the factors that affect this process in porous reservoir rocks are prerequisites for the enhancement of petroleum recovery efficiency. To meet these prerequisites, it is crucial to directly visualize and quantify the pore scale physics and dynamic evolution of the water–oil two-phase displacement behavior. However, engineering activities, such as borehole drilling, reservoir fracturing, and oil recovery, can cause geostress redistribution in petroleum reservoirs and drastically change the 3D pore structures of reservoir rocks. This makes it difficult to apply conventional experimental techniques and analytical models to directly reveal and evaluate the 3D immiscible fluid displacement in reservoir rocks during pore structure deformation. In this study, we used X-ray computed tomography, integrated with triaxial loading techniques, to capture in situ the immiscible water–oil displacement and oil trapping inside 3D pore spaces during the deformation induced by various geostresses. An additive manufacturing or 3D printing (3DP) technology was applied to replicate the transparent models of actual porous rocks, facilitating the representation and quantification of pore space deformation and the dynamic process of water–oil displacement and oil trapping. Pore scale displacement behaviors (including water sweeping, fingering effects, preferential flow paths, and oil trapping) and their evolution and pore structure deformation with varying geostress were directly visualized and quantified. The relationships between the characteristics of the deformed structures, water–oil displacement efficiency, and effective geostress changes were formulated. The results indicate that stress-induced pore structure deformation has an evident impact on the 3D water–oil displacement behavior and efficiency. A comparison of the 2D and 3D water-oil displacement behaviors indicates that the 3D model predicts a more realistic displacement performance, whereas the residual oil saturation is overestimated in a 2D pore system owing to the truncation of pore connectivity in the third dimension. This study provides a method for directly visualizing and quantifying the effects of geostress-induced pore deformation on the 3D water–oil displacement in porous reservoirs; this method can help draft a strategy to enhance petroleum recovery.