A shader that works on a phone doesn't in emulator? Or new Lumia 930?

I wrote this piece of shader code a while ago and until few days back, everybody was happy using my app (link). Suddenly by releasing Lumia 930, some users were complaining they don’t see anything drawn and the screen dims a little when they try drawing in the lower-right corner. I tested in emulator (weird, never tested before) and sure enough, it doesn’t work! So if anyone can tell me if they see a problem please let me know. The purpose of the shader is to take color of every drawn pixel and dim it according to another “heightmap” texture. I’m running it on windows phone 8 and 8.1.

sampler InputSampler : register(s0);
sampler TextureSampler : register(s1);

float4 write(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
    // Look up the texture color.
    float4 inp = tex2D(InputSampler, texCoord);
	float4 tex = tex2D(TextureSampler, texCoord);
	float a = (inp.a - tex.r);

	if(a > 0)
	return float4(inp.r*a, inp.g*a, inp.b*a, inp.a*a);
	else 
	return float4(0, 0, 0, 0);
}

technique Technique1
{
    pass Write
    {
        PixelShader = compile ps_4_0_level_9_3 write();
    }
}

One thing I’ve noticed with Lumia 930 is that it uses padding for storing texture data, something that never happened with WP so far. I think there were some under the hood changes that might break your shader.

What about emulator? The behavior is exactly as reported. So I think if I manage to fix it for emulator and other phones, it will work for everybody. Padding? How would you go about fixing this? I’m sure there is texture coordinates problem which needs transformations of some kind.

That seems like a compatibility nightmare if it is actually affecting games. I’ve heard of these things being internal to DX or limits like requiring PoT. Not ever anything that would make a texture sampler fail to get the right pixel.

Are you saying the bug occurs in the emulator? If so than it isn’t a hardware incompatibility with the 930… it is just a bug of some sort.

Are you using this pixel shader with SpriteBatch? You need to add the position to the function signature:

float4 write(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0

Oh thank you! You are a life saver!
Yes, now it works. Why did it work before then on most mobiles?

Not exactly sure. Most likely just a difference in the hardware/driver.

This change should work everywhere consistently.