; vec4_projPos.z = ROUND(vec4_projPos.z);
mov TMP_0.xy, ZERO_ONE ; TMP_0.x = 0.0
; TMP_0.y = 1.0
mov TMP_1.xy, vec4_projPos.zz ; TMP_1.x = vec4_projPos.z
; TMP_1.y = vec4_projPos.z
add TMP_0.xy, TMP_1.xy, TMP_0.xy ; TMP_0.x = vec4_projPos.z
; TMP_0.y = vec4_projPos.z + 1.0
flr TMP_0.xy, TMP_0.xy ; TMP_0.x = floor(vec4_projPos.z)
; TMP_0.y = ceil(vec4_projPos.z)
mov TMP_2.xy, TMP_0.xy
mul TMP_1.y, NEGONES ; TMP_1.x = vec4_projPos.z
; TMP_1.y = -vec4_projPos.z
mul TMP_0.x, NEGONES ; TMP_0.x = -floor(vec4_projPos.z)
; TMP_0.y = ceil(vec4_projPos.z)
add TMP_0.xy, TMP_0.xy, TMP_1.xy ; TMP_0.x = vec4_projPos.z - floor(vec4_projPos.z)
; TMP_0.y = ceil(vec4_projPos.z) - vec4_projPos.z
cmp TMP_0.x, lt, lt, TMP_0.y
ifc cmp.x ; decimal is closer to floor than to ceil
mov vec4_projPos.z, TMP_2.x
.else ; decimal is closer to ceil than to floor, or is 0.5
mov vec4_projPos.z, TMP_2.y
.end
Is there any way I can simplify this? Here's details on the instruction set:
https://github.com/devkitPro/picasso/blob/master/Manual.md#supported-instructions
https://3dbrew.org/wiki/GPU/Shader_Instruction_Set