0% found this document useful (0 votes)
10 views2 pages

Gpu

Download as txt, pdf, or txt
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 2

Learn citro3d #1 GPU Shader Instruction

This is a complete memorandum. It is called #1, but not in order. The contents are
in different order. I don't even know if I will write #2 in the first place.
This time, I will write about the Shader instruction. I assume that you know how to
specify operands to some extent.

Table of Contents: Shader

DP4
DP3
MOV
RCP
RSQ
MUL
ADD
MAX
MIN
MAD
extra
DP4
dp4 r0, r1, r2
Comes out the most; stands for Dot Product 4-component. It calculates the inner
product of 4-dimensional vectors. By the way, Dot Product means inner product.
Example: r0 = r1 ・r2

DP3
dp3 r0, r1, r2
Three-dimensional version of dp4. Calculates the inner product of 3-dimensional
vectors.
Example: r0 = r1 ・r2

MOV
mov r0, r1
The mov instruction familiar to everyone's favorite ARM! Value copy.
Example: r0 = r1

RCP
rcp r0, r1
Calculate the reciprocal of the first element and store it in each element.
Example: r0[0 ~ n] = 1/r1.x

RSQ
rsq r0, r1
Calculates the reciprocal of the square root of the first element and stores it in
each element.
Example: r0[0 ~ n] =1/√r1.x

MUL
mul r0, r1, r2
Perform multiplication on each element of the vector.
Example: r1(1, 2, 3, 4) * r2(0.1, 0.2, 0.3, 0.4) = r0(0.1, 0.4, 0.9, 1.6)

ADD
add r0, r1, r2
Adds each element of a vector.
Example: r1(1, 2, 3, 4) + r2(0.1, 0.2, 0.3, 0.4) = r0(1.1, 2.2, 3.3, 4.4)
MAX
max r0, r1, r2
Takes the maximum value for each element of the vector.
Example: r1(1.2, 4.9, 3.0, 2.5), r2(1.8, 3.4, 0.3, 2.5) -> r0(1.8, 4.9, 3.0, 2.5)

MIN(1.8, 4.9, 3.0, 2.5)


min r0, r1, r2
Take the minimum value for each element of the vector.
Example: r1(1.2, 0.9, 0, 0.5), r2(1.8, 3.4, 0.3, 0.5) -> r0(1.2, 0.3, 0, 0.5)

MAD
mad r0, r1, r2, r3
Multiply two vectors and add a fourth vector.
Example: r0 = r1 * r2 + r3

addition
If you are using VSCode, we recommend installing the extension pica200, which makes
it easier to view Shader files.

I have only introduced the most frequently used ones, so this is not all of them,
but if you understand just this one, you can read much more.
It requires a little knowledge of mathematics. See you soon.

Translated with DeepL.com (free version)

You might also like