How does the delegate system work for primaries?
Lots of details here, click on links to individual statesThe Democrats have more detailed requirements. Typically, some delegates are elected on the basis of the popular vote in each congressional district, and others on the basis of the statewide vote. Then there are additional delegate spots for elected officials.
There is a threshold of 15% to be allocated delegates, so with a lot of candidates, only 2 or 3 might get delegates. In addition, most CDs only have a few delegates (3 to 5), so that there might be a higher effective threshold. Texas allocates its statewide delegates on the basis of convention support. On the night of the primary, precinct caucuses are held, which then feed into county and other conventions, and eventually into the state convention. So this could end up being a different result than the primary-based allocation.
The GOP varies a lot between states. In some states, the Democrat rules have been enacted into state law. In others, such as Texas, allocation of delegates is based on the primary vote, but is less proportional, favoring the leading candidates.