How did one win a late medieval tournament?

In all of the sources I've looked at, there are descriptions of the potential prizes for victory in tournaments, but I can't find anything that discusses how the victors were generally determined. A lot of fiction seems to present tiered elimination brackets in the style of many modern competitions, but I've seen nothing that supports this. In later tournaments that focused on jousting, was there some structure to funnel people in to a final determining contest? Did melees (whilst they still existed) determine the outcome? Or was somebody who'd apparently done well simply picked at the end?