View Full Version : Is this Assembly Language ?

11-27-2011, 04:59 AM
i found these code in an example ,it seems that its fouction just like fragment shader.Do any document can help me learn this kind of assembly Language? or can someone tell me the meaning of the fellowing code?

char _fp_peel[] =
"OPTION ARB_fragment_program_shadow;\n"
"TEMP R0;\n"
"TEX R0.x, fragment.position, texture[0], SHADOWRECT;\n"
"ADD R0.x, R0.x, -0.5;\n"
"KIL R0.x;\n"
"MOV result.color, fragment.color;\n"

11-27-2011, 07:02 AM
Do any document can help me learn this kind of assembly Language?

Here you go:

11-27-2011, 07:41 AM
what should the assembly language code looks like using glsl?

11-27-2011, 08:21 AM
this assembly code found in the Depth Peeling 2 Demo in the OpenGL SDK, i think these assembly code plays a role in depth peeling .
i do not know why using "TEMP R0" because it seems that R0 have no relation with the result and what is the meaning of "TEX R0.x, fragment.position, texture[0], SHADOWRECT;\n"?
can someone explain this to me ?

Alfonse Reinheart
11-27-2011, 12:44 PM
"TEX R0.x, fragment.position, texture[0], SHADOWRECT;\n"

This isn't that hard to work out.

Assembly, regardless of type or language, generally looks like this:


The INSTRUCTION here is `TEX`, which obviously suggests a Texture access.

`R0.x` is the `x` component of the `R0` variable. That's what `TEMP R0` was for: declaring a temporary variable called `R0`. ARB assembly isn't like most assembly languages; you have to declare variables that you use (unless they're built in).

Texture accessing needs 2 things, regardless of language: a texture unit and a texture coordinate.

`fragment.position` is obvious based on the name, though it is built-in which is where it can be confusion (it isn't defined anywhere). That's the position of the fragment in window-space. The first argument of the `TEX` instruction is the texture coordinate.

`texture[0]` is the texture unit to access from. Namely, texture unit 0.

`SHADOWRECT` is a description of what kind of access to do. Basically, it's like the GLSL sampler. SHADOW means depth comparison. RECT means a rectangle texture.


TEX R0.x, fragment.position, texture[0], SHADOWRECT;

does a shadow texture access from a rectangle texture, stored in texture unit 0, from the current fragment position, and the value is stored in the temporary variable `R0`'s `x` component.

11-27-2011, 05:36 PM
First of all,Thank you for your reply .
You mean that the first argument of the "TEX" instruction is the texture coordinate. However R0.x is just a float variable, Can it be the texture coordinate to access the texture? You said in the end" R0 keeps the depth map's value ", i do not understand it very well, what is R0's really role? texcoord or float variable to keep depth?

Alfonse Reinheart
11-27-2011, 07:11 PM
You mean that the first argument of the "TEX" instruction is the texture coordinate.

Where did I say that?


The OUTPUT is almost always the first argument in assembly languages.

11-28-2011, 01:19 AM
Thank you very much ,i have learned this kind of assembly language in Shader Assembly Language (ARB/NV) Quick Reference Guide for OpenGLŪ