System.InvalidOperationException: 'Shader Compilation Failed' Porting to Android

I am having trouble using .fx shaders when porting content to Android (everything works on Windows). When I use the shaders to draw vertexes I get the error “System.InvalidOperationException: ‘Shader Compilation Failed’”. Does anyone know what I am doing wrong?

— More Details–

I use the content pipeline tool to to build my .fx shaders into xnb files. However, they still fail to load using the Content.load() method (textures work). Only when I add a built *.xnb file to the Content Folder in visual studio do they properly load and my program “works”, as long as I don’t use the shader. However when I apply the shader and try to draw vertexes, I get the above error.

I suppose I should be building my shaders differently, but I don’t know how.

Thanks for your help!
–edit–
If anyone can help me get any vertex shader effect to load in Android, that will probably do,
Here is the very simple effect I am trying to get working:

#if OPENGL
	#define SV_POSITION POSITION
	#define VS_SHADERMODEL vs_3_0
	#define PS_SHADERMODEL ps_3_0
#else
	#define VS_SHADERMODEL vs_4_0_level_9_1
	#define PS_SHADERMODEL ps_4_0_level_9_1
#endif

texture Texture;
sampler TextureSampler = sampler_state
{
	Texture = <Texture>;
};


struct VertexShaderInput
{
	float4 Position : SV_POSITION0;
    float3 Normal : NORMAL0;
    float2 UV : TEXCOORD0;
};

struct VertexShaderOutput
{
	float4 Position : SV_POSITION;
	float2 UV : TEXCOORD0;
	float4 Color : COLOR0;
	float Depth : FOG;
};

struct PixelShaderOutput
{
	float4 Color : COLOR0;
	float Depth : SV_Depth;
};

VertexShaderOutput MainVS(in VertexShaderInput input)
{
	VertexShaderOutput output = (VertexShaderOutput)0;
     output.UV =  input.UV;
	 output.Position = input.Position;
	 output.Color = float4(1, 0, 1, 1); 
	 output.Depth = 0.5f; 
	return output;
}

PixelShaderOutput MainPS(VertexShaderOutput input)   
{
	PixelShaderOutput output = (PixelShaderOutput)0;
	output.Color = input.Color; 
    output.Depth = input.Depth;
	return output;
}

technique BasicColorDrawing
{
	pass P0
	{
		VertexShader = compile VS_SHADERMODEL MainVS();
		PixelShader = compile PS_SHADERMODEL MainPS();
	}
};

Multiple Render Targets (MRT) does not work properly in the current MonoGame for Android. I also had the same problem when implementing deferred rendering.

In addition to this, as far as I understand, the following writing seems to be useless.

  • Use “MRT”
  • Use “for()”
  • Change RenderTarget and call DrawInstancedPrimitives

Implementation of deferred rendering is difficult because MRT cannot be used.
Since for() cannot be used, it is difficult to replace it with forward rendering.

I’m doing multiple draw calls with the pixel shader return value being just “one float4 variable”.
However, it works, but it’s hopelessly bad performance.

I’m sorry, my English is not good.

float4 MainPSColor(VertexShaderOutput input) : SV_TARGET
{
	return input.Color; 
}
float4 MainPSDepth(VertexShaderOutput input) : SV_TARGET
{
	return float4(input.Depth,0,0,0); 
}

technique BasicColorDrawing
{
	pass Color
	{
		VertexShader = compile vs_3_0 MainVS();
		PixelShader  = compile ps_3_0 MainPSColor();
	}
    pass Depth 
    {
		VertexShader = compile vs_3_0 MainVS();
		PixelShader  = compile ps_3_0 MainPSDepth();
    }
};

remark:
By the way, in my case I’m using MonoGame on the PC version, but on Android porting I’m using Veldrid instead of MonoGame.

The cause of the problem is not the MonoGame runtime, but the SharpDX and MojoShader that MonoGame uses as a backend.
I output SPIR-V with DirectX Shader Compiler and use it in Veldrid.