PDA

View Full Version : Problem with GL_ATI_fragment_shader



execom_rt
04-13-2005, 10:57 AM
I'm trying to convert some DX PS1.4 code to OpenGL for ATI 8500/9200

I'm using this nice tool : PS14toATIfs (http://nifelheim.dyndns.org/~cocidius/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



glBeginFragmentShaderATI()
glSetFragmentShaderConstantATI(GL_CON_3_ATI,0xc72f aac)
glSampleMapATI(GL_REG_0_ATI,GL_TEXTURE1,GL_SWIZZLE _STR_ATI)
glSampleMapATI(GL_REG_1_ATI,GL_TEXTURE3,GL_SWIZZLE _STR_ATI)
glSampleMapATI(GL_REG_2_ATI,GL_TEXTURE2,GL_SWIZZLE _STR_ATI)
glColorFragmentOp2ATI(GL_DOT3_ATI,GL_REG_1_ATI,GL_ RED_BIT_ATI,GL_SATURATE_BIT_ATI,GL_REG_1_ATI,GL_NO NE,GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,GL_REG_0_ATI,GL_NONE,GL_2X_BIT_ATI | GL_BIAS_BIT_ATI)
glColorFragmentOp1ATI(GL_MOV_ATI,GL_REG_1_ATI,GL_G REEN_BIT_ATI,GL_NONE,GL_CON_3_ATI,GL_GREEN,GL_NONE )
glSampleMapATI(GL_REG_0_ATI,GL_TEXTURE0,GL_SWIZZLE _STR_ATI)
glSampleMapATI(GL_REG_3_ATI,GL_REG_1_ATI,GL_SWIZZL E_STR_ATI)
glPassTexCoordATI(GL_REG_1_ATI,GL_REG_1_ATI,GL_SWI ZZLE_STR_ATI)
glPassTexCoordATI(GL_REG_2_ATI,GL_REG_2_ATI,GL_SWI ZZLE_STR_ATI)
glAlphaFragmentOp2ATI(GL_DOT3_ATI,GL_REG_0_ATI,GL_ SATURATE_BIT_ATI,GL_REG_2_ATI,GL_NONE,GL_2X_BIT_AT I | GL_BIAS_BIT_ATI,GL_REG_0_ATI,GL_NONE,GL_2X_BIT_ATI | GL_BIAS_BIT_ATI) glGetError() =GL_INVALID_OPERATION
glColorFragmentOp3ATI(GL_MAD_ATI,GL_REG_0_ATI,GL_N ONE,GL_NONE,GL_REG_0_ATI,GL_ALPHA,GL_NONE,GL_CON_1 _ATI,GL_NONE,GL_NONE,GL_CON_0_ATI,GL_NONE,GL_NONE)
glColorFragmentOp3ATI(GL_MAD_ATI,GL_REG_0_ATI,GL_N ONE,GL_NONE,GL_REG_3_ATI,GL_RED,GL_NONE,GL_CON_2_A TI,GL_NONE,GL_NONE,GL_REG_0_ATI,GL_NONE,GL_NONE)
glEndFragmentShaderATI()

vincoof
04-13-2005, 12:18 PM
From the spec (http://oss.sgi.com/projects/ogl-sample/registry/ATI/fragment_shader.txt) :
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.

fenris
04-13-2005, 12:47 PM
Whoa! Someone is using my library? :eek: :D

execom_rt
04-13-2005, 01:42 PM
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).


ps_1_4
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
phase
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
phase
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

execom_rt
04-14-2005, 12:11 AM
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

ZbuffeR
04-14-2005, 12:50 AM
Originally posted by execom_rt:
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_opARG the awful cut-the-code-at-double-pipe-bug stroke again ... the common OR code in C cuts comments: |

execom_rt
04-14-2005, 03:50 AM
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).

knackered
04-14-2005, 04:41 AM
nvparse...the memory of it makes me shudder.

Java Cool Dude
04-14-2005, 04:56 AM
Originally posted by knackered:
nvparse...the memory of it makes me shudder.Ba ha ha ha ha, that is funny :D
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.
<3

execom_rt
04-14-2005, 07:16 AM
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.

CrazyButcher
04-14-2005, 08:05 AM
always when this topic comes up (ps1.x on gl) the xengine might help

http://xengine.sourceforge.net

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.