What is the most direct way of addressing a graphics chip?

Viewed 305

My oldish PC has an Intel HD 420 in it.

I was wondering - we can use Assembly code to address the CPU directly, with commands like mul, add etc.

How can I pass on Assembly calculation commands to a graphics chip such as the Intel HD, or say the "gpu part" of AMD's Ryzen? Is it the same mechanics as for an ARM graphics chip?

(No tags for apu, onboard-graphics, intel-hd, ryzen)

Edit: I understand that OpenCL is the correct approach, and that an on-board chip is as good as any other peripheral hardware (eg printer) as far as communication. However, out of theoretical curiosity, looking for the simplest Assembly snippet, that does any sort of mundane calculation on an onboard graphics chip like an Intel HD XXX.

2 Answers

The GPU is a separate core you can only interact with via MMIO; it's not a coprocessor like x87 originally was (where fmul ran on a separate chip). You can access it the same way the graphics drivers do.

There is no CPU instruction that does stuff on the GPU directly because it's not tightly-coupled at all, hence the high latency being a problem for GPGPU. Sending work to the GPU looks like storing to memory and then passing a pointer to that physical memory to the GPU, e.g. via mov [mem], rax or something to the address of one of the GPU's MMIO registers.

For Intel, those are open source if you really want to dive in to Linux DRM (direct rendering manager) and X11 drivers that talk to the GPU after asking the kernel for access.

If you need the ISA for Intel HD graphics, here it is. Intel provides the programmer's reference manuals for all their graphics chips here. These information can be used to create a graphics driver for Intel HD graphics, which is the most "direct" way of accessing the GPU.

Please note this is for Intel HD graphics as they are the only one who provides ISA documentation for open source driver development as I know.

Best of luck!

Related