Graphics chip makers Advanced Micro Devices (NASDAQ:AMD) and NVIDIA (NASDAQ:NVDA) have delivered huge gains for shareholders in recent years as both companies benefit from major tailwinds in the gaming and data center markets. We'll review where each has been and where they are going from here to determine which stock is the better buy for long-term investors today.

A computer chip with the letters "CPU" hovering a motherboard.

IMAGE SOURCE: GETTY IMAGES.

AMD winning on all fronts

Investors are clearly pumped about AMD's future, as noted by the stock's incredible 1,110% climb over the last three years, which has brought its market cap to $24.4 billion. AMD's share of the discrete GPU market has climbed 740 basis points over the last year to 34.9% as of Q1 2018, with the balance going to NVIDIA. AMD has also been gaining share against Intel (NASDAQ:INTC) in the CPU market with its Ryzen chips. 

In the second quarter, revenue grew 53% year over year, driven by strong performance across all segments. The standout was the computing and graphics segment (65% of revenue), which grew 64% year over year in the last quarter, driven by strong demand for Radeon Vega graphics cards and Ryzen processors. 

The PC gaming market has exploded in popularity lately, and megapopular games like Fortnite and Playerunkown's Battlegrounds have been credited with bringing in new gamers to the market. In 2017 and Q1 2018, both AMD and NVIDIA also saw a surge in demand from cryptocurrency miners. Both trends contributed to a strong upgrade cycle for high-end GPUs. 

AMD has also seen strong demand in the data center market, driven by shipments of the Vega-based Radeon Instinct MI25 GPU. To build on its momentum, the chip maker just announced a new GPU for the data center market -- the Radeon Pro V340. Data centers are also turning to AMD for its Epyc processors, which drove revenue growth of 37% year over year in the Enterprise segment. 

Segment TTM As of Q2 2018 2017 2016 2015
Computing and graphics $3.996 $3.029 $1.967 $1.805
Enterprise, Embedded, and Sem-Custom $2.407 $2.300 $2.305 $2.186
Total revenue $6.403 $5.329 $4.272 $3.991
Net income $0.315 $0.043 ($0.497) ($0.660)

Data source: The company. Amounts in billions. TTM = Trailing 12-month.

As an added bonus for investors, the growing demand for high-end chips have driven up average selling prices, which has pushed up margins and allowed AMD to report its first second-quarter profit in seven years.

Looking forward, AMD is facing some near-term headwinds. Crypto demand contributed about 10% of first-quarter revenue, but has been tapering off recently. In addition, NVIDIA's announcement of its new Turing RTX GPUs featuring ray-tracing technology could shift some market share back toward NVIDIA.

However, it won't be long before AMD announces its highly anticipated 7-nanometer chips, which will feature embedded artificial intelligence capabilities for rendering graphics, similar to the technology in NVIDIA's Turing-based chips. This should position AMD well for further CPU market share gains against Intel over the next year.

NVIDIA's RTX 2080 Ti graphics card

IMAGE SOURCE: NVIDIA.

NVIDIA: The king of graphics

NVIDIA's story lately has been just as impressive as AMD's. A strong upgrade cycle for NVIDIA's Pascal-based gaming GPUs, in addition to equally strong demand for chips in the data center space, has sent shares soaring 1,140% over the past three years, bringing the company's market cap to $167 billion. 

In the most recent quarter, NVIDIA posted revenue growth of 40% year over year, led by strong demand in its two largest segments, gaming and data center. As with AMD, robust demand for high-priced graphics cards contributed to a 490-basis point expansion in gross margin, which translated to a 91% year over year jump in earnings per share.

Segment TTM As of Q2 2019 2018 2017 2016
Gaming $6.828 $5.513 $4.060 $2.818
Data center $2.568 $1.932 $0.830 $0.339
Automotive $0.582 $0.558 $0.487 $0.320
Other $1.899 $1.711 $1.533 $1.533
Total revenue $11.877 $9.714 $6.910 $5.010
Net income $4.301 $3.047 $1.666 $0.614

Data source: NVIDIA. Amounts in billions. TTM = Trailing 12-month.

The momentum in the gaming segment should continue when the company unveils the new Turing RTX graphics cards, which implements what's known as "the holy grail" of computer graphics -- real-time ray-tracing. This is a graphical engineering technique that allows for realistic lighting and shadow effects in a computer-simulated environment. It's not just a big deal for the gaming industry -- it could also boost NVIDIA's professional visualization segment, which has already seen revenue accelerate over 20% year over year in recent quarters. 

As the new Turing chips fill out the high end of the price range for NVIDIA's GPU lineup, it should push down prices, and thereby increase demand for NVIDIA's current high-end cards like the GeForce GTX 1080 and 1080 Ti, which are powerful enough to run any game on the market. This could potentially cost AMD some market share in the coming months, as NVIDIA is going to have a very competitive GPU lineup at every price point heading into a busy fall video game release schedule.

Which is the better buy?

On valuation, AMD and NVIDIA both trade at about the same forward P/E of roughly 34x, so there's no advantage for either on that front. 

Both chip makers estimate their market opportunity in the data center space to be several times their current revenue, so they should be able to grow in that space without butting heads for a long time. 

But while AMD's Ryzen CPUs and upcoming 7-nanometer chips have the upper hand on Intel, NVIDIA has the edge on AMD with the introduction of its Turing-based GPUs. There's really nothing slowing NVIDIA's growth in its two largest segments (gaming and data center). Plus, Turing could cause a boom in NVIDIA's professional visualization segment, where NVIDIA is already experiencing accelerating revenue growth -- which may accelerate further if graphics artists rapidly adopt NVIDIA's ray-tracing-enabled RTX graphics cards.

For these reasons, I think NVIDIA is the better buy for investors today.

John Ballard owns shares of Nvidia. The Motley Fool owns shares of and recommends Nvidia. The Motley Fool has a disclosure policy.