Both Fujifilm X-H2 and Pentax 645D have 40.0 MP resolution sensors but Fujifilm X-H2's sensor is APS-C (23.5 x 15.6 mm ) and Pentax 645D's sensor is Medium format (44 x 33 mm ).
Since Pentax 645D's has a larger sensor area with the same resolution, this means that it also has a larger pixel area hence better light collecting capacity for a given aperture compared to Fujifilm X-H2.
Another similarity between these two cameras is that both Pentax 645D and Fujifilm X-H2 sensors lack anti-alias (Low-Pass) filters. Removing anti-alias filter increases the sharpness and level of detail but at the same time, it increases the chance of moiré occurring in certain scenes.
Below you can see the X-H2 and 645D sensor size comparison.
As seen above, Pentax 645D has a 4.0x Larger sensor area than Fujifilm X-H2. Larger sensors give photographer more control on the depth of field and blurry background compared to smaller sensor when shot in same focal length and aperture.