7
votes

In order to build shaders for Windows Store apps (and Windows Phone 8) Shader model 4_0_level_9_3 you need to use the vs_4_0_level_9_3 and ps_4_0_level_9_3 . While all this sounds fine using the HLSL syntax designed for DirectX 10 and up, I'm unable to use the VPOS semantic from DirectX 9 or use SV_POSITION from DirectX 10 and up in a pixel shader, so what do I do besides making yet another semantic for outputting the vertex position in clip space ?

PS: Some shaders on 4_0_level_9_3 spit out an "internal error: blob content mismatch between level9 and d3d10 shader" which I have no idea what is about. Probably some inconsistency with the driver I suppose ( I use an Nvidia GTX 560 TI) that I see it goes away if you just compile your shaders with release flags (like optimization level 3 and avoid flow control).

1
"Probably some inconsistency with the driver I suppose ( I use an Nvidia GTX 560 TI) that I see it goes away if you just compile your shaders with release flags (like optimization level 3 and avoid flow control)." - I've seen this on multiple build machines, turning off 'disable optimisation' removes the problem. it doesn't prevent debugging, just be aware that flow through the compiled instructions might differ greatly from that in your HLSL. i have no problems using the same semantics in all feature levels, specifically SV_POSITION - although i do always use a vertex layout struct...jheriko

1 Answers

0
votes

Your best bet is, as you say, to pass these values as secondary semantics (i.e. pass both a "POSITION" and a "SV_POSITION" value). Note that if you place SV_POSITION at the end of the output declaration for the vertex shader, you may omit it from the input declaration for the pixel shader.

Regarding the internal error, this is typically due to the declaration of a texture or other shader input that is optimized out in one pass but not in another. Disabling optimization typically works around the issue, but you should also be able to fix it by eliminating unused (including via dead-code elimination) input declarations, and ensuring you avoid complicated code that reduces to no-op.