ARB vfp crash on ATI

Hi all,
I made this little Vertex & Fragment program, and it run absolutly fine on my NVIDIA.
I know there is issues on ATIs, but here, it make the game (DoomIII) crash without any error message.

Here comes the code:


# "Screen Post Effect(s) Shader" by 6th Venom

##############
# VERTEX SHADER #
#############

!!ARBvp1.0 
OPTION ARB_position_invariant ;

# parameter 0 is target interpolation
# parameter 1 is target color
# parameter 2 is textures strengh
# parameter 3 is time translation

# texture 0 is _currentRender
# texture 1 is shadow texture
# texture 2 is light texture

# nothing to do but pass the parameters along
MOV		result.texcoord[0], program.local[0];
MOV		result.texcoord[1], program.local[1];
MOV		result.texcoord[2], program.local[2];
MOV		result.texcoord[3], program.local[3];

TEMP R1;

# pixels distance for bloomlight checks = texcoord 5
MOV	        R1, 0.001;
MUL	        R1.y, R1.y,  1.333;
MOV	        result.texcoord[5], R1;

END

#############
# PIXEL SHADER #
############

!!ARBfp1.0
OPTION ARB_precision_hint_fastest;

TEMP	        R0, SRC, temp, screenColor, shadowColor, shadowCoord, shadowTex, lightColor, lightCoord, lightTex;

# calculate the screen texcoord in the 0.0 to 1.0 range
MUL		R0, fragment.position, program.env[1];

# scale by the screen non-power-of-two-adjust
MUL		R0, R0, program.env[0];

# scale by vertexParm 2 & 3 for shadow & light respectivly
MUL             shadowCoord, R0, 6.0;
ADD	        shadowCoord, fragment.texcoord[3], shadowCoord;
MUL             lightCoord, R0, 6.0;

# load the screen render
TEX_SAT		screenColor, R0, texture[0], 2D;
TEX_SAT		shadowTex, shadowCoord, texture[1], 2D;
TEX_SAT		lightTex, lightCoord, texture[2], 2D;

# calculate greyscaled version of color
ADD		R0.x, screenColor.x, screenColor.y;
ADD		R0.x, R0.x, screenColor.z;
MUL		R0, R0.x, 0.33;

# scale by the target color
MUL		R0, R0, fragment.texcoord[1];

# Dark areas detection
# set temp.x = R+G+B pixel color (sum RGB)
ADD             temp.x, screenColor.x, screenColor.y;
ADD             temp.x, temp.x, screenColor.z;

# set temp.y = 1/(sum RGB)
MUL             temp.x, temp.x, 0.3333;

# define dark areas and store in channel w
SLT             temp, temp.x, 0.25;

# interpolation between temp and Shadow texture
SUB             shadowColor, 1.0, shadowTex;
SUB             shadowColor, temp, shadowColor.y;

# multiply by Parm 2
MUL_SAT         shadowColor, shadowColor, fragment.texcoord[2];

# compute color+shadow
SUB             screenColor, screenColor, shadowColor;

# interpolation between the previous result and the light texture, with Parm 2
SUB             lightColor, 1.0, lightTex;
MUL		lightColor, lightColor, fragment.texcoord[2];

SUB		screenColor, screenColor, lightColor;


# prepare for lightbloom
TEMP	        R1,R2,R3,R4,R5,R6,R7,R8,R9,RA,RB,RC, PIX, SUM, light;

PARAM           off01 = { -2.0, -2.0, 0.0, 0.0 };
PARAM           off02 = { -2.0,  0.0, 0.0, 0.0 };
PARAM           off03 = { -2.0,  2.0, 0.0, 0.0 };
PARAM           off04 = {  0.0, -2.0, 0.0, 0.0 };
PARAM           off05 = {  0.0,  2.0, 0.0, 0.0 };
PARAM           off06 = {  2.0, -2.0, 0.0, 0.0 };
PARAM           off07 = {  2.0,  0.0, 0.0, 0.0 };
PARAM           off08 = {  2.0,  2.0, 0.0, 0.0 };
PARAM           off09 = { -2.0, -4.0, 0.0, 0.0 };
PARAM           off10 = {  0.0, -4.0, 0.0, 0.0 };
PARAM           off11 = {  2.0, -4.0, 0.0, 0.0 };
PARAM           off12 = { -4.0, -2.0, 0.0, 0.0 };
PARAM           off13 = {  4.0, -2.0, 0.0, 0.0 };
PARAM           off14 = { -4.0,  0.0, 0.0, 0.0 };
PARAM           off15 = {  4.0,  0.0, 0.0, 0.0 };
PARAM           off16 = { -4.0,  2.0, 0.0, 0.0 };
PARAM           off17 = {  4.0,  2.0, 0.0, 0.0 };
PARAM           off18 = { -2.0,  4.0, 0.0, 0.0 };
PARAM           off19 = {  0.0,  4.0, 0.0, 0.0 };
PARAM           off20 = {  2.0,  4.0, 0.0, 0.0 };

PARAM           white = {  1.0,  1.0, 1.0, 0.0 };

# range MAX for black
PARAM           MAX = 0.1;

# calculate the screen texcoord in the 0.0 to 1.0 range
MUL		PIX, fragment.position, program.env[1];

# scale by the screen non-power-of-two-adjust to give us normal screen coords in PIX
MUL		PIX, PIX, program.env[0];

# load the screen render
TEX		SUM, PIX, texture[0], 2D;

# calculate bloomlight offsets: first circle
MAD		R1, fragment.texcoord[5], off01, PIX;
MAD		R2, fragment.texcoord[5], off02, PIX;
MAD		R3, fragment.texcoord[5], off03, PIX;
MAD		R4, fragment.texcoord[5], off04, PIX;
MAD		R5, fragment.texcoord[5], off05, PIX;
MAD		R6, fragment.texcoord[5], off06, PIX;
MAD		R7, fragment.texcoord[5], off07, PIX;
MAD		R8, fragment.texcoord[5], off08, PIX;

TEX		R1, R1, texture[0], 2D;
TEX		R2, R2, texture[0], 2D;
TEX		R3, R3, texture[0], 2D;
TEX		R4, R4, texture[0], 2D;
TEX		R5, R5, texture[0], 2D;
TEX		R6, R6, texture[0], 2D;
TEX		R7, R7, texture[0], 2D;
TEX		R8, R8, texture[0], 2D;

MOV             light, SUM;
ADD             light, light, R1;
ADD             light, light, R2;
ADD             light, light, R3;
ADD             light, light, R4;
ADD             light, light, R5;
ADD             light, light, R6;
ADD             light, light, R7;
ADD             light, light, R8;

MAD		R1, fragment.texcoord[5], off09, PIX;
MAD		R2, fragment.texcoord[5], off10, PIX;
MAD		R3, fragment.texcoord[5], off11, PIX;
MAD		R4, fragment.texcoord[5], off12, PIX;
MAD		R5, fragment.texcoord[5], off13, PIX;
MAD		R6, fragment.texcoord[5], off14, PIX;
MAD		R7, fragment.texcoord[5], off15, PIX;
MAD		R8, fragment.texcoord[5], off16, PIX;
MAD		R9, fragment.texcoord[5], off17, PIX;
MAD		RA, fragment.texcoord[5], off18, PIX;
MAD		RB, fragment.texcoord[5], off19, PIX;
MAD		RC, fragment.texcoord[5], off20, PIX;

TEX		R1, R1, texture[0], 2D;
TEX		R2, R2, texture[0], 2D;
TEX		R3, R3, texture[0], 2D;
TEX		R4, R4, texture[0], 2D;
TEX		R5, R5, texture[0], 2D;
TEX		R6, R6, texture[0], 2D;
TEX		R7, R7, texture[0], 2D;
TEX		R8, R8, texture[0], 2D;
TEX		R9, R9, texture[0], 2D;
TEX		RA, RA, texture[0], 2D;
TEX		RB, RB, texture[0], 2D;
TEX		RC, RC, texture[0], 2D;

ADD             light, light, R1;
ADD             light, light, R2;
ADD             light, light, R3;
ADD             light, light, R4;
ADD             light, light, R5;
ADD             light, light, R6;
ADD             light, light, R7;
ADD             light, light, R8;
ADD             light, light, R9;
ADD             light, light, RA;
ADD             light, light, RB;
ADD             light, light, RC;

# store in light
MUL             light, light, 0.05;

# calculate final smooth value
MUL		light, light, 1.5;
ADD             light, light, -0.45;
MUL_SAT		light, light, 0.5;

# add the bloomlight to screen
ADD             screenColor, screenColor, light;

# calculate greyscaled version of color
ADD		R0, screenColor.x, screenColor.y;
ADD		R0, R0, screenColor.z;
MUL_SAT		R0, R0, 0.333;

# scale by the target color
MUL		R0, R0, fragment.texcoord[1];

# linear interpolation, between source color and target color, with Parm 0
LRP             screenColor, fragment.texcoord[0], R0, screenColor;

# send to screen
MOV		result.color.xyz, screenColor;

END

Does anyone see anything really wrong, except my noob way of coding shaders? :wink:

Thanks for any help!

Your code deviates slightly in its format from what I’ve seen that drivers accept. (your formatting may be correct, though)

  • “!!ARBxxxxx” maybe should be right on the first line
  • nothing after “END”, just in case you didn’t merge the code to show it here.
  • “TEMP xxxx;” should be before any instruction
  • “PARAM” should be before TEMP
  • maybe you should define output

Examples:


!!ARBvp1.0
PARAM c[4] = { program.local[0..3] };
TEMP R0;
MUL R0, vertex.position.y, c[1];
MAD R0, vertex.position.x, c[0], R0;
MAD R0, vertex.position.z, c[2], R0;
MOV result.texcoord[0], vertex.position;
MAD result.position, vertex.position.w, c[3], R0;
END


!!ARBfp1.0
OPTION ARB_precision_hint_fastest;
PARAM c[122] = { program.local[0..120],
		{ 1 } };
TEMP R0;
TEMP R1;
ADD R0.xyz, -fragment.texcoord[0], c[2];
DP3 R0.w, R0, R0;
ADD R0.xyz, -fragment.texcoord[0], c[1];
DP3 R0.x, R0, R0;
RSQ R0.w, R0.w;
RCP R0.y, R0.w;
....
MUL result.color, R0.x, c[0];
END

Mmmh, ok, i’ll look into that, thank you! :wink:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.