Problem with GL_ATI_fragment_shader

I’m trying to convert some DX PS1.4 code to OpenGL for ATI 8500/9200

I’m using this nice tool : PS14toATIfs

But I have some problem: a PS1.4 shader i’m trying to do is not working properly. The tool reports that compilation is OK, but it failed around the glAlphaFragmentOp2ATI:

Is anyone used this extension before and encounters such problem ? (code was generated by glIntercept)

ATI Radeon 9800/Cat 5.4


From the spec :

The error INVALID_OPERATION is generated by AlphaFragmentOp[2…3]ATI if <op> is DOT3_ATI, DOT4_ATI, or DOT2_ADD_ATI and there was no matching ColorFragmentOp[2…3]ATI immediately preceding, or if <op> is not DOT4_ATI and the immediately preceding ColorFragmentOp2ATI specifies an <op> of DOT4_ATI.
So, you need to setup a corresponding color operation just before your alpha’s DOT3 operation.

Whoa! Someone is using my library? :eek: :smiley:

Ah, you made this lib ? (yes, according your email, i’ve sent one already).

So there is a problem in the lib …

Can you fix it ? Else i’ve tried some other shader and each time, it bumps into the the glAlphaFragmentOp2ATI. Else, it seems to works fine apparently.

Anyway, here the input shader and some debug output.

I could try to debug the app, but the code is quite … obfuscated
(python thing, and VC doesn’t want to trace into the functions).

def c3, 0, 0, 0, 0
texld r0, t1
texld r1, t3
texld r2, t2
dp3_sat r1.x, r1_bx2, r0_bx2
mov r1.y, c3.y
texld r0, t0
texld r3, r1
dp3_sat r0.w, r2_bx2, r0_bx2
mad r0, r0.w, c1, c0
mad r0, r3.x, c2, r0

Debug (using PS14_DEBUG)

CONSTDEF: def       c3, 0, 0, 0, 0
TEXADDR:  texld     r0, t1
TEXADDR:  texld     r1, t3
TEXADDR:  texld     r2, t2
RGB:      dp3       r1, r1_bx2, r0_bx2
RGB:      mov       r1, c3.g
TEXADDR:  texld     r0, t0
TEXADDR:  texld     r3, r1
ALPHA:    dp3       r0, r2_bx2, r0_bx2
GLI | GL ERROR - Function glAlphaFragmentOp2ATI generated error GL_INVALID_OPERATION
RGB:      mad       r0, r0.a, c1, c0
RGB:      mad       r0, r3.r, c2, r0


OK, it think I can fix it finally (not that difficult in fact.)

I need to change the code in ps14_program.c to this:
</font><blockquote><font size=“1” face=“Verdana, Arial”>code:</font><hr /><pre style=“font-size:x-small; font-family: monospace;”>if(!alpha_op

Originally posted by execom_rt:
[b]OK, it think I can fix it finally (not that difficult in fact.)

I need to change the code in ps14_program.c to this:
</font><blockquote><font size=“1” face=“Verdana, Arial”>code:</font><hr /><pre style=“font-size:x-small; font-family: monospace;”>if(!alpha_op[/b]
ARG the awful cut-the-code-at-double-pipe-bug stroke again … the common OR code in C cuts comments: |

Yes it’s horrible …

Any I think it is fixed now (needs to check that it works everywhere). GL_ATI_fragment_shader works nicely with GL_ARB_vertex_program as well

If you want to know, just send me a message.

I think nVidia made also a PS1.1->TexEnvCombiners (nvparse) but it doesn’t very well on VC7 (due to a bad STL usage).

nvparse…the memory of it makes me shudder.

Originally posted by knackered:
nvparse…the memory of it makes me shudder.
Ba ha ha ha ha, that is funny :smiley:
I dunno man, to this day I’m still impressed by the fact that Nvidia had stuff working individually on the pixel level dating all the way back to TNT and GeForce 256.

Yes, just tried ps1.1 and nvparse, but I think I will drop it. It’s seems to be the hell to use.
I’ve tried to load some ps1.1 code, it didn’t work properly and it produced a huge log in glIntercept (so the PS1.1->RC is not optimised at all).

I will stick to ATI_FS (there is still lot of ATI 9200 out there), ARB_fragment_program and GLSL.

always when this topic comes up (ps1.x on gl) the xengine might help

the guy put in ATIFS and nvRC support for directx pixelshaders, also Cg -> dxpsa -> atifs. the license is very liberal (basically free for all) so it’s worth a grab.