[Lima] NIR constant problem for GPU which doesn't have native integer support

Qiang Yu yuq825 at gmail.com
Wed Jan 2 11:28:40 UTC 2019


Hi guys,

I found the problem with this test fragment shader when lima development:
uniform int color;
void main() {
    if (color > 1)
        gl_FragColor = vec4(1.0, 0.0, 0.0, 1);
    else
        gl_FragColor = vec4(0.0, 1.0, 0.0, 1);
}

nir_print_shader output:
impl main {
        block block_0:
        /* preds: */
        vec1 32 ssa_0 = load_const (0x00000001 /* 0.000000 */)
        vec4 32 ssa_1 = load_const (0x3f800000 /* 1.000000 */,
0x00000000 /* 0.000000 */, 0x00000000 /* 0.000000 */, 0x3f800000 /*
1.000000 */)
        vec4 32 ssa_2 = load_const (0x00000000 /* 0.000000 */,
0x3f800000 /* 1.000000 */, 0x00000000 /* 0.000000 */, 0x3f800000 /*
1.000000 */)
        vec1 32 ssa_3 = load_const (0x00000000 /* 0.000000 */)
        vec1 32 ssa_4 = intrinsic load_uniform (ssa_3) (0, 1, 0) /*
base=0 */ /* range=1 */ /* component=0 */   /* color */
        vec1 32 ssa_5 = slt ssa_0, ssa_4
        vec1 32 ssa_6 = fnot ssa_5
        vec4 32 ssa_7 = bcsel ssa_6.xxxx, ssa_2, ssa_1
        intrinsic store_output (ssa_7, ssa_3) (0, 15, 0) /* base=0 */
/* wrmask=xyzw */ /* component=0 */       /* gl_FragColor */
        /* succs: block_1 */
        block block_1:
}

ssa0 is not converted to float when glsl to nir. I see glsl_to_nir.cpp
will create flt/ilt/ult
based on source type for gpu support native integer, but for gpu not
support native
integer, just create slt for all source type. And in
nir_lower_constant_initializers,
there's also no type conversion for integer constant.

Do you know how to fix this problem?

Thanks,
Qiang


More information about the lima mailing list