<p>How does a CPU know which piece of code should be executed on GPU (i.e how to recognize whether a code is shader or not) and how is it been sent to GPU VRAM?Is it via DMA?</p>

CC BY-SA 4.0
2020-02-15T19:17:19.037Z
Same way a computer knows how to do anything. There is a API that has calls that the graphics card driver handles.
joojaa
CC BY-SA 4.0
2020-02-16T07:02:35.310Z
Thanks for clear explanation.I know that something like a driver lives in kernel space and some library like CUDA needs to use driver API to communicate with GPU.How can a userspace code use the driver API at runtime ?Is it like a system call?
Parsa Mousavi
CC BY-SA 4.0
2020-02-16T11:38:35.720Z
Is command buffer like an event queue?And which kind of syscalls do it need?
Parsa Mousavi
CC BY-SA 4.0
2020-02-16T12:19:16.363Z
Thanks @Daniel.I've been looked for an answer for a long time.Please post these as an answer since comments may get deleted.
Parsa Mousavi
<shader><gpu>
Sending programs from CPU to GPU
Parsa Mousavi
# Sending programs from CPU to GPU

(Asked by: username_0 on 2020-02-15)

How does a CPU know which piece of code should be executed on GPU (i.e how to recognize whether a code is shader or not) and how is it been sent to GPU VRAM?Is it via DMA?

**Tags:** shader, gpu

> **Comments:**
> **username_1**: Same way a computer knows how to do anything. There is a API that has calls that the graphics card driver handles.  
> **username_0**: Thanks for clear explanation.I know that something like a driver lives in kernel space and some library like CUDA needs to use driver API to communicate with GPU.How can a userspace code use the driver API at runtime ?Is it like a system call?  
> **username_0**: Is command buffer like an event queue?And which kind of syscalls do it need?  
> **username_0**: Thanks @Daniel.I've been looked for an answer for a long time.Please post these as an answer since comments may get deleted.  

---

## 0 answers

