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

Failure to compile effect #23

Closed
jeffphilp opened this issue May 5, 2016 · 12 comments
Closed

Failure to compile effect #23

jeffphilp opened this issue May 5, 2016 · 12 comments

Comments

@jeffphilp
Copy link

Hi,

I have upgraded to the latest 16.5.5 version and I am getting the following errors occurring when attempting to load an effect file:

GREMEDY_string_marker not supported!
OpenGL Device: Intel(R) HD Graphics 4600    
OpenGL Driver: 4.3.0 - Build 10.18.14.4170
OpenGL Vendor: Intel
MojoShader Profile: glsl120
Using EXT_swap_control_tear VSync!
Using EXT_swap_control_tear VSync!
Error has been generated. GL error GL_INVALID_ENUM
        Source: GL_DEBUG_SOURCE_API_ARB
        Type: GL_DEBUG_TYPE_ERROR_ARB
        Severity: GL_DEBUG_SEVERITY_HIGH_ARB

Unhandled Exception: System.InvalidOperationException: ARB_debug_output found an error.
   at Microsoft.Xna.Framework.Graphics.OpenGLDevice.DebugCallback(GLenum source, GLenum type, UInt32 id, GLenum severity, Int32 length, IntPtr message, IntPtr userParam) 

I presume something is going wrong in the native mojoshader code. Has anyone seen anything like this before? or else I will be stepping through mojoshader :)

@flibitijibibo
Copy link
Member

Put a breakpoint in the DebugCallback and it'll tell you which call it was.

@flibitijibibo
Copy link
Member

@jeffphilp
Copy link
Author

Good shout, it produces the error during the call to MOJOSHADER_glCompileEffect. I agree the drivers may be out of date on this laptop, but I got the same issue on my work machine running up to date nvidea drivers.

@flibitijibibo
Copy link
Member

If you've also got the latest fnalibs and you're still getting this then you'll have to step through this:

https://github.com/flibitijibibo/MojoShader/blob/master/mojoshader_opengl.c#L416

The likelihood of an actual INVALID_ENUM is extremely unlikely, as it would have to be glCreateShader getting sent GL_NONE, which is only true if you're attempting to send a shader other than vertex/pixel, which wouldn't make it past the parsing process.

@jeffphilp
Copy link
Author

I am using the latest fnalibs, Ill step through that code first thing and post what I find. Thanks for your help.

@jeffphilp
Copy link
Author

After stepping through the failure occurs in mojoshader.c 2723:
fail(ctx, "unsupported color index");

it was caused by an effect file which passed a color between the Vertex shader, and Pixel shader using COLOR2.

I'm not sure if by using that channel if I am violating the usage of the COLOR2 semantic, but the problem is fixed by passing a float4 using a TEXCOORD semantic.

@flibitijibibo
Copy link
Member

I believe I fixed this with the latest MojoShader commit, can you try it out?

@jeffphilp
Copy link
Author

I just tried your latest commit, and that fixes the unknown variable issue. Thank you! What do you think about trying to get access to the fail reasons which are written too during processing and trying to expose them to the FNA logger? even if it is only during debug sessions. May make diagnostics easier in future, which in my case testing on windows involved a lot of printf statements.

@flibitijibibo
Copy link
Member

Error checking for the effects has been a very overdue fix, so I'd be up for that. Just add it to this method using FNAPlatform.Log and I'll pull it in (check your tabs carefully! ;P ).

https://github.com/FNA-XNA/FNA/blob/master/src/Graphics/OpenGLDevice.cs#L1750

@jeffphilp
Copy link
Author

So I have written at least logging errors for parsing of effects, however it also uses Utf8 to managed string marshaling like that which exists in SDL2# LPUtf8StrMarshaler, and which is also used in SDL2_FnaPlatform. Do you have a place for sticking a convenience method such as:

private static unsafe string MarshalNativeUtf8ToManagedString(IntPtr pNativeData)
{
    if (pNativeData == IntPtr.Zero)
        return null;
    var ptr = (byte*)pNativeData;
    while (*ptr != 0)
    {
        ptr++;
    }
    var bytes = new byte[ptr - (byte*)pNativeData];
    Marshal.Copy(pNativeData, bytes, 0, bytes.Length);
    return Encoding.UTF8.GetString(bytes);
}

which could be used at least initially in OpenGLDevice#CreateEffect ?

@flibitijibibo
Copy link
Member

At the moment no, but I wouldn't mind if you just copied this into that function:

https://github.com/FNA-XNA/FNA/blob/master/src/SDL2/SDL2_FNAPlatform.cs#L395

@flibitijibibo
Copy link
Member

This will be fixed with the next fnalibs update, pending #24's fixes.

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