mojoshader icon indicating copy to clipboard operation
mojoshader copied to clipboard

[FXC] Shader Model 3 allows TEXKILL with input register

Open flibitijibibo opened this issue 7 years ago • 0 comments

This is a follow-up issue for https://github.com/FNA-XNA/FNA/issues/124.

From that issue...

The problem gets introduced when clip() is done directly on an input value, such as the TEXCOORD5 value in the very first pixel shader, which produces something like this:

        pixelshader = 
            asm {
            //
            // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
                ps_3_0
                dcl_color v0
                dcl_texcoord5 v1
                texkill v1
                mov oC0, v0
            
            // approximately 2 instruction slots used
            };

The problem is that texkill against an input register is forbidden according to Microsoft's own documentation on the texkill instruction. In fact, if I change the shader model to 2.0 instead of 3.0, I get this...

        pixelshader = 
            asm {
            //
            // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
                ps_2_0
                dcl v0
                dcl t5
                texkill t5
                mov oC0, v0
            
            // approximately 2 instruction slots used
            };

This is what we're actually expecting! So either the documentation we're looking at is outdated and only references SM2 or the SM3 compiler has a problem with this shader.

CC @mklingen

flibitijibibo avatar Jun 19 '18 18:06 flibitijibibo