Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"BaseInstance not supported in ES profile" when compiling shader for Android #3

Open
k4G17eYWI opened this issue Apr 27, 2024 · 2 comments

Comments

@k4G17eYWI
Copy link

I try to compile this shader. It compiles ok when targeting Desktop but fails with an error "BaseInstance not supported in ES profile" on a content pipeline build phase when targeting Android. I've squeezed my shader to only reproduce this issue and here is a squeezed code:

#define VS_SHADERMODEL vs_5_0
#define PS_SHADERMODEL ps_5_0

StructuredBuffer<float4> particles;

Texture2D MainTex; // primary texture.
SamplerState MySampler  { };

struct VsInputQuad
{
    uint instance_id: SV_InstanceID;
};

struct VsOutputQuad
{
    float4 Position : SV_Position;
    float4 Color : COLOR0;
    float2 TexureCoordinateA : TEXCOORD0;
};

struct PsOutputQuad
{
    float4 Color : SV_TARGET;
};


VsOutputQuad vert(VsInputQuad input)
{
    uint ii = input.instance_id;    
    VsOutputQuad ret;
    ret.Position = float4(particles[ii].x,0,0,0);
    ret.TexureCoordinateA = float2(0,0);
    ret.Color = float4(1,1,1,1);
    return ret; 
}

PsOutputQuad frag(VsOutputQuad input)
{
    PsOutputQuad output;
    output.Color = MainTex.Sample(MySampler, input.TexureCoordinateA) * input.Color;
    clip(output.Color.a - 0.01);
    return output;
}

technique Draw
{
    pass
    {
        VertexShader = compile VS_SHADERMODEL vert();
        PixelShader = compile PS_SHADERMODEL frag();
    }
}

@cpt-max
Copy link
Owner

cpt-max commented Apr 27, 2024

This seems to be coming from DirectXShaderCompiler when using SV_InstanceID: microsoft/DirectXShaderCompiler#3106
I guess an update to the newest version would fix it. Unfortunately there have been some breaking changes, making the update more difficult.

@cpt-max
Copy link
Owner

cpt-max commented Apr 27, 2024

Just noticed that this bug has already been reported in the Android shader samples repo: cpt-max/MonoGame-Shader-Samples-Mobile#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants