locked
My vertex shader works on ARM only when optimizations are disabled.

    Question

  • I have a simple vertex shader shown below. It works successfully for Win32 and x64 platforms but seems to have a problem with ARM. The ARM device I'm testing on is a Surface RT (not surface 2 RT). When I disable optimizations however, the problem goes away. I believe it has something to do with the constant buffer. Can someone please comment on what the problem might be or how to go about finding it?

    cbuffer data
    {
    	float4x4 viewTransform;
    	float4x4 scaleMatrix;
    	float4 ripples[20];
    	int numRipples;
    };
    
    struct PixelShaderInput
    {
    	float4 pos : SV_POSITION;
    	float2 tex : TEXCOORD;
    	float4 ssPos : SCREENSPACE; // screen space coordinates
    };
    
    PixelShaderInput main(float4 pos : POSITION, float2 tex : TEXCOORD)
    {
    	PixelShaderInput ret;
    
    	for (int i = 0; i < numRipples; i++)
    	{
    		float d = abs(distance(pos.xy, ripples[i].xy) - ripples[i].z);
    		float z = exp(-d / 50) * 10;
    		pos.z += z;
    	}
    
    	ret.pos = mul(viewTransform, pos);
    	ret.ssPos = pos;
    	ret.tex = tex;
    	return ret;
    }

    Thanks!

    David


     



    • Edited by davidb353 Saturday, April 05, 2014 3:55 AM
    Saturday, April 05, 2014 3:53 AM

Answers

  • The big DirectX difference between Windows RT and most Windows 8 and 8.1 systems is feature level support. Windows RT supports only feature level 9_1, so you'll need to make sure your shader works at that feature level. Desktop Windows systems often have higher level support. See Direct3D feature levels

    You can use DXCPL to limit your app to feature level 9_1 on desktop systems to make sure it works there.

    --Rob

    • Marked as answer by davidb353 Saturday, April 05, 2014 4:21 PM
    Saturday, April 05, 2014 5:30 AM
    Owner

All replies

  • The big DirectX difference between Windows RT and most Windows 8 and 8.1 systems is feature level support. Windows RT supports only feature level 9_1, so you'll need to make sure your shader works at that feature level. Desktop Windows systems often have higher level support. See Direct3D feature levels

    You can use DXCPL to limit your app to feature level 9_1 on desktop systems to make sure it works there.

    --Rob

    • Marked as answer by davidb353 Saturday, April 05, 2014 4:21 PM
    Saturday, April 05, 2014 5:30 AM
    Owner
  • Okay, thanks. I think I found the problem. I was compiling my shaders with shader model 4_0_level_9_3 when I should have been using 4_0_level_9_1.

    Saturday, April 05, 2014 4:21 PM
  • That wasn't it. The shader still doesn't work when I turn on optimizations. And I'm still confused why using shader model 4_0_level_9_3 has been working up until now when my device only supports feature level 9_1.

    Saturday, April 05, 2014 4:28 PM
  • I read the blogs but it still doesn't make sense that turning on optimizations makes the shader fail. Also, why can the surface RT run shaders compiled using model 4_0_level_9_3 when it only supports feature level 9_1?
    Sunday, April 06, 2014 3:17 AM
  • In general, 4_0_level_9_3 shaders should not work for feature level 9.1. That said, there may be some quirk of your particular usage that managed to work because the internals of the shader blob happen to fit in the constraints of the 9.1 feature level (technically, a 4_0_level_9_3 profile contains both a shader model 4.0 and a shader model 2.0 version of the original HLSL code).

    Optimizations enabled was probably causing it to use instructions that were really not supported on 9.1 (ps_2_0), but are on 9.3 (ps_2_x) that it didn't generate without optimizations.

    In other words, you either got luck or unlucky depending on your perspective...

    Monday, April 07, 2014 5:53 AM
  • That makes sense about 4_0_level_9_3, but I am having the same problem with 4_0_level_9_1. So there must be something else gong on.
    Monday, April 07, 2014 4:52 PM
  • Are you using the FXC in the Windows 8.1 SDK / VS 2013 or the Winodws 8.0 SDK / VS 2012?

    Have you enabled the debug device to look for any errors/messages when you bind this particular shader?

    Monday, April 07, 2014 6:02 PM
  • Turns out I was getting shader linkage errors and not catching them. Its clear now. Thanks
    Monday, April 07, 2014 6:47 PM