gl_fragcord shader variable

Hi Forum,

When I profile a simple shader as below with gl_FragCord built-in using streamline, I see about 4k FMA instructions and 12k CVT instructions, even though there is no math operation.

Appreciate any inputs on why these FMA, and and 3x more CVT instructions are getting generated and suggestions to reduce it.

#version 450

precision highp float;

precision highp int;

layout(location = 0) out vec2 out_color;

layout(location = 0) in vec4 texcoord;

void main(){  out_color = vec2(gl_FragCoord.x, texcoord.x);}

Parents
  • Hi peter,

    Thanks for the inputs. I tried a more realistic test as below which is accessing gl_FragCord.xy typically seen in real shaders of few games. 

    And still see quite few CVT (8k) and FMA (8k) for a fragment warp count of 16k. So that is apx 2 FMA (8*4/16) and 2 (8*4/16) CVT instructions per shader invocation. Is this expected?

    #version 450 precision

    highp float; precision

    highp int; layout(location = 0) out vec4 out_color;

    layout(location = 0) in vec4 texcoord;

    void main() { out_color = vec4(gl_FragCoord.xy, texcoord.xy); }

Reply
  • Hi peter,

    Thanks for the inputs. I tried a more realistic test as below which is accessing gl_FragCord.xy typically seen in real shaders of few games. 

    And still see quite few CVT (8k) and FMA (8k) for a fragment warp count of 16k. So that is apx 2 FMA (8*4/16) and 2 (8*4/16) CVT instructions per shader invocation. Is this expected?

    #version 450 precision

    highp float; precision

    highp int; layout(location = 0) out vec4 out_color;

    layout(location = 0) in vec4 texcoord;

    void main() { out_color = vec4(gl_FragCoord.xy, texcoord.xy); }

Children
No data