Skip to main content
GameDev.net gamedev.net
🔒 Locked

HLSL instruction count

Started by Black Knight Aug 31, 2009 at 7:13 PM 5 replies 4.5k views
Original Post
Black Knight
Black Knight
I have piece of HLSL code and it works when compiled against shader model 2.0.When it I try compiling it for 1.1-1.4 it doesnt compile.Is there anyway to check the reason of this? How can I know if it is exceeding a limit of the shader model like instruction count etc.
DieterVW
DieterVW
The compile function(s) of the API have an out parameter that holds the text error message. You'll need to look at that.

Otherwise, use fxc.exe on the command line to compile your shader. The error will be printed to the screen.
Black Knight
Black Knight
Thanks that helped out.The error returned says that ps1_x is no longer supported and that I need to enable some flags to compile it etc.

Thanks anyway.
Black Knight
Black Knight
I looked up the limits for ps_1_1 and it states that its 4 texture and 8 arithmetic instructions for the max limit.

Source :
http://msdn.microsoft.com/en-us/library/bb219846(VS.85).aspx

Now when I analyze the shader in FX Composer I see 21 cycles and the ASM output is like this :

  ps_2_0    def c3, 1, 0, 0, 0    dcl t1.xy    dcl t2.xy    dcl_2d s0    dcl_2d s1    texld r0, t2, s1    texld r1, t1, s0    mul r2.xyz, r0.z, c2    mad r2.xyz, r0.y, c1, r2    mad r2.xyz, r0.x, c0, r2    dp3_sat r2.w, c3.x, r0    add r2.w, -r2.w, c3.x    mul r0.xyz, r1, r2.w    mad r1.xyz, r1, r2, r0    mov oC0, r1// approximately 10 instruction slots used (2 texture, 8 arithmetic)



So whats the cycles about?Is it the instruction count ?When I look at the asm code the line "approximately 10 instruction slots used (2 texture, 8 arithmetic)" looks like it can work in ps_1_1.Though it doesn't on a xp machine with no dx10.

MJP
MJP
That number of cycles is the number of shader clock cycles it would take for it to run on a certain class of Nvidia GPU. It doesn't necessarily directly correspond to the number of ASM instructions, since an ASM instruction might take multiple cycles or instructions might be executed simultaneously depending on hardware.

Also the number of instructions in ps_2_0 likely won't be the same as the number of instructions in ps_1_1, since the instruction set isn't the same.

BTW...why do you want to use ps_1_1 anyway?
ET3D
ET3D
Quote:
Original post by MJPBTW...why do you want to use ps_1_1 anyway?

I'll second that question. ps_1_1 was only used in the GeForce3, which I doubt people are using today. ps_1_3 was in the GeForce4, which probably isn't much in use, either. (Both were high end cards.) ps_1_4 is in the Radeon 8500 and 9000-9200, and that sold in higher numbers, but though still in use today (according to the Steam hardware survey), they represent a very small percentage of currently used cards.
Black Knight
Black Knight
I was trying to use ps_1_1 so that the shader runs on more computers but I guess it's too limited to do anything serious.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.