On 08/22/2013 02:59 AM, Liu Xin wrote:
Dear list,

i wonder if all vendors in mesa3d use intel's glsl compiler now? by
browsing glsl source code, i still don't understand how it generates
ir_texture.  in my idea, it treats it as normal function call.

Yes, all drivers use the same shader compiler, in src/glsl.

for example, this is tiny fragment shader:
uniform sampler2D sampler2d;
varying mediump vec2  myTexCoord;
void main (void)
{
   gl_FragColor = texture2D(sampler2d,myTexCoord);
}

glsl_compiler will emit LIR/HIR like this. please note (call texture2D
...). it's a normal ir_call instead of ir_texture.  i confirm that
ast2hir doesn't new ir_texture in any case.

That's correct. At shader compile time, all built-in functions (texturing, mix, abs, sin, etc.) are treated as normal functions.

We create several other shaders - stored in the builtins_to_link list - and at link time, we link those with the user's shaders. Then, the function inliner runs and replaces the (call ...) nodes.

If you run ./src/glsl/builtins/tools/texture_builtins.py, you can see the IR for all of the texturing functions. The body of these functions contain the (tex ...) nodes. ir_reader creates these, as part of _mesa_glsl_initialize_functions().

The built-in code is kind of a mess...sorry for that.

(function main
   (signature void
     (parameters
     )
     (
       (declare (temporary ) vec4 texture2D_retval@0x94fc11c)
       (assign (constant bool (1)) (xyzw) (var_ref
texture2D_retval@0x94fc11c)  (call texture2D ((var_ref
sampler2d@0x955b114) (var_ref myTexCoord@0x955b03c) ))
)
       (assign (constant bool (1)) (xyzw) (var_ref
gl_FragColor@0x92c2eb4)  (var_ref texture2D_retval@0x94fc11c) )
     ))

)

do mesa glsl compiler can make use of ir_texture? i think it must be yes
because all GPUs have texture unit and should handle tex commands. how
does mesa do it?

thanks,
--lx



_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to