nihstro icon indicating copy to clipboard operation
nihstro copied to clipboard

EX2 and LG2 only operate on scalar values

Open neobrain opened this issue 10 years ago • 1 comments

Supposedly something like EX2 r0.y, r0.xyzw will not actually store the result in r0.y. This was reported in an IRC discussion in #3dsdev on efnet on August 14, 2015. The reason remains to be investigated, but chances are nihstro should provide a diagnostic of some sorts in this case.

; Example PICA200 vertex shader

; Uniforms
.fvec projection[4]

; Constants
.constf myconst(0.0, 1.0, -1.0, -0.5)
.alias  zeros myconst.xxxx ; Vector full of zeros
.alias  ones  myconst.yyyy ; Vector full of ones

; Outputs
.out outpos position
.out outclr color

; Inputs (defined as aliases for convenience)
.alias inpos v0

.proc main
    ; Force the w component of inpos to be 1.0
    mov r0.xyz, inpos.xyz
    ex2 r0.y, r0
    mov r0.w,   ones

    ; outpos = projectionMatrix * inpos
    dp4 outpos.x, projection[0], r0
    dp4 outpos.y, projection[1], r0
    dp4 outpos.z, projection[2], r0
    dp4 outpos.w, projection[3], r0

    ; outclr = solid white color
    mov outclr, ones

    ; We're finished
    end
.end

neobrain avatar Aug 14 '15 16:08 neobrain

After some further investigation by the person who reported this behavior initially, it seems that EX2 only computes the base-2-expontential of the first component of the source operand, and writes the result to all enabled output components.

~~It has been suggested , albeit not verified, that~~ LG2 has a similar quirk.

neobrain avatar Aug 15 '15 09:08 neobrain