The red shape is the irregular triangular pyramid, the blue shape is the triangular prism.

All vertices of the pyramid have different z-values (except the ones shared with the prism).

I could of course calculate the volume of the pyramid and the prism independently and add them together, but I'm looking for a simpler solution that involves a "single" operation (this is for thousands of iterations of data with poorly distinguished vertices between batches; two independent volume calculations is out of the question).

Could I calculate the volume of two prisms -- one with a height at the bottom of the pyramid, one with the height at its top -- take the difference, and then operate on this "slice" of prism using the slope of a face of the pyramid to calculate the volume of that pyramid? If so, what would my formula look like (using the x, y, and z values of the pyramid's vertices)? Or could there be some other way?

Thanks!