And more importantly: what's a shader? If you already have experience making drawings with computers, you know that in that process you draw a circle, then a rectangle, a line, some triangles until you compose the image you want. That process is very similar to writing a letter or a book by hand - it is a set of instructions that do one task after another.
Shaders are also a set of instructions, but the instructions are executed all at once for every single pixel on the screen. That means the code you write has to behave differently depending on the position of the pixel on the screen.
Like a type press, your program will work as a function that receives a position and returns a color, and when it's compiled it will run extraordinarily fast.
Imagine the CPU of your computer as a big industrial pipe, and every task as something that passes through it - like a factory line. Some tasks are bigger than others, which means they require more time and energy to deal with. We say they require more processing power. Because of the architecture of computers the jobs are forced to run in a series; each job has to be finished one at a time.
Modern computers usually have groups of four processors that work like these pipes, completing tasks one after another to keep things running smoothly. Display updates will be smooth with GPU processing. Display rates of hundreds of frames per second are not always useful, but when lower rates are used, more CPU resources are available for other operations. How Shaders Enhance Performance. Search Results. As such, shader objects are built for a specific shader stage.
So while program objects can contain multiple stages, shader objects only contain code for a single stage. When a drawing command is executed, the currently bound Program Object , or Program Pipeline Object , will be used in the rendering operation. The programmable portions of the Rendering Pipeline will execute the shader code stored in the currently used program s. Each shader stage that has code executes one or more times, based on exactly what is rendering.
Each shader stage defines the frequency at which it executes. Each execution of a shader stage within a Rendering Command is called an "invocation". With a rare few exceptions, shader stage invocations cannot interact with one another. Exactly how many invocations execute for most shader stages depends on the amount of stuff being rendered and the nature of that shader stage. Let us hypothetically divide up a computational unit of a CPU or GPU into a command processor and mathematical unit note that this division isn't really true, but it is useful for this discussion.
The command processor is responsible for reading a command and telling the mathematical unit what to do, then reading the next command. If that command is a branch operation, it is the command processor that figures out where to branch to, to pick which command to execute next.
For conditional branches, the command can be broken down into the math that computes the condition executed on the math unit , followed by the command processor reading the result of the condition and picking the next command to execute based on that.
Let's say that we have a set of command sequences we want to execute. Each sequence has its own set of input data, and will write to its own output values.
But each command sequence is completely independent of each other; none of them can communicate with each other in any way. If you want to execute this set of commands completely in parallel, you need one command processor and one mathematical unit for each command sequence. However, let's alter our scenario. What if all of the above command sequences were actually the same sequence of commands, simply acting on different input values and writing to different output locations?
If we were to design a processor for such an operation, it could have a single command processor which feeds multiple mathematical units. Sort by date Sort by score. Enable comment auto-refresher. LinuxReviews welcomes all comments.
If you do not want to be anonymous, register or log in. It is free.
0コメント