-
-
Notifications
You must be signed in to change notification settings - Fork 432
Assimp fatal error on method GetMaterialTexture #663
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
Labels
bug
Something isn't working
Comments
Are you sure that's correct? Below I've dumped the generated code for your reference. Your issue is the usage of the API. Consider: var mat = scene.MMaterials[mesh->MMaterialIndex];
var diffuseCnt = Ai.GetMaterialTextureCount(mat, TextureType.TextureTypeDiffuse);
for (var i = 0u; i < diffuseCnt; i++)
{
AssimpString path;
TextureMapping textureMapping;
uint uvIndex;
float blend;
TextureOp op;
TextureMapMode mapMode;
uint flags;
Ai.GetMaterialTexture(mat, TextureType.TextureTypeDiffuse, i, &path, &textureMapping, &uvIndex, &blend, &op, &mapMode, &flags);
} Assimp is expecting to be able to put the values you want to get into the pointers you give it, but they're all null so you get a fatal error. Code we generateDebug - .NET public unsafe partial global::Silk.NET.Assimp.Return GetMaterialTexture(global::Silk.NET.Assimp.Material* mat, global::Silk.NET.Assimp.TextureType type, uint index, global::Silk.NET.Assimp.AssimpString* path, global::Silk.NET.Assimp.TextureMapping* mapping, uint* uvindex, float* blend, global::Silk.NET.Assimp.TextureOp* op, global::Silk.NET.Assimp.TextureMapMode* mapmode, uint* flags)
{
global::Silk.NET.Assimp.Return n10;
; // BEGIN RESOLVE 10 | READCOUNT: 1 | ALLOW_INLINE: False | FORCE_INLINE: False | CACHED: False
// BEGIN RESOLVE 0 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 0 INLINED
// END RESOLVE 0
// BEGIN RESOLVE 1 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 1 INLINED
// END RESOLVE 1
// BEGIN RESOLVE 2 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 2 INLINED
// END RESOLVE 2
// BEGIN RESOLVE 3 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 3 INLINED
// END RESOLVE 3
// BEGIN RESOLVE 4 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 4 INLINED
// END RESOLVE 4
// BEGIN RESOLVE 5 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 5 INLINED
// END RESOLVE 5
// BEGIN RESOLVE 6 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 6 INLINED
// END RESOLVE 6
// BEGIN RESOLVE 7 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 7 INLINED
// END RESOLVE 7
// BEGIN RESOLVE 8 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 8 INLINED
// END RESOLVE 8
// BEGIN RESOLVE 9 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 9 INLINED
// END RESOLVE 9
// RESOLVED 10 TO VARIABLE n10
n10 = ((delegate* unmanaged<global::Silk.NET.Assimp.Material*, global::Silk.NET.Assimp.TextureType, uint, global::Silk.NET.Assimp.AssimpString*, global::Silk.NET.Assimp.TextureMapping*, uint*, float*, global::Silk.NET.Assimp.TextureOp*, global::Silk.NET.Assimp.TextureMapMode*, uint*, global::Silk.NET.Assimp.Return> )(CurrentVTable as GeneratedVTable).aiGetMaterialTexture)((/* VAR 0 */
mat), (/* VAR 1 */
type), (/* VAR 2 */
index), (/* VAR 3 */
path), (/* VAR 4 */
mapping), (/* VAR 5 */
uvindex), (/* VAR 6 */
blend), (/* VAR 7 */
op), (/* VAR 8 */
mapmode), (/* VAR 9 */
flags)); // END RESOLVE 10
// ALREADY RESOLVED 10
return /* VAR 10 */
n10;
} Release - .NETpublic unsafe partial global::Silk.NET.Assimp.Return GetMaterialTexture(global::Silk.NET.Assimp.Material* mat, global::Silk.NET.Assimp.TextureType type, uint index, global::Silk.NET.Assimp.AssimpString* path, global::Silk.NET.Assimp.TextureMapping* mapping, uint* uvindex, float* blend, global::Silk.NET.Assimp.TextureOp* op, global::Silk.NET.Assimp.TextureMapMode* mapmode, uint* flags)
{
global::Silk.NET.Assimp.Return n10;
n10 = ((delegate* unmanaged<global::Silk.NET.Assimp.Material*, global::Silk.NET.Assimp.TextureType, uint, global::Silk.NET.Assimp.AssimpString*, global::Silk.NET.Assimp.TextureMapping*, uint*, float*, global::Silk.NET.Assimp.TextureOp*, global::Silk.NET.Assimp.TextureMapMode*, uint*, global::Silk.NET.Assimp.Return> )(CurrentVTable as _B)._BB)((mat), (type), (index), (path), (mapping), (uvindex), (blend), (op), (mapmode), (flags));
return n10;
} Debug - .NET Standardpublic unsafe partial global::Silk.NET.Assimp.Return GetMaterialTexture(global::Silk.NET.Assimp.Material* mat, global::Silk.NET.Assimp.TextureType type, uint index, global::Silk.NET.Assimp.AssimpString* path, global::Silk.NET.Assimp.TextureMapping* mapping, uint* uvindex, float* blend, global::Silk.NET.Assimp.TextureOp* op, global::Silk.NET.Assimp.TextureMapMode* mapmode, uint* flags)
{
global::Silk.NET.Assimp.Return n10;
global::Silk.NET.Assimp.Return StCall(global::Silk.NET.Assimp.Material* arg0, global::Silk.NET.Assimp.TextureType arg1, uint arg2, global::Silk.NET.Assimp.AssimpString* arg3, global::Silk.NET.Assimp.TextureMapping* arg4, uint* arg5, float* arg6, global::Silk.NET.Assimp.TextureOp* arg7, global::Silk.NET.Assimp.TextureMapMode* arg8, uint* arg9)
{
if (Silk.NET.Core.Native.SilkMarshal.IsWinapiStdcall)
{
return ((delegate* unmanaged[Stdcall]<global::Silk.NET.Assimp.Material*, global::Silk.NET.Assimp.TextureType, uint, global::Silk.NET.Assimp.AssimpString*, global::Silk.NET.Assimp.TextureMapping*, uint*, float*, global::Silk.NET.Assimp.TextureOp*, global::Silk.NET.Assimp.TextureMapMode*, uint*, global::Silk.NET.Assimp.Return> )(CurrentVTable as GeneratedVTable).aiGetMaterialTexture)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
else
{
return ((delegate* unmanaged[Cdecl]<global::Silk.NET.Assimp.Material*, global::Silk.NET.Assimp.TextureType, uint, global::Silk.NET.Assimp.AssimpString*, global::Silk.NET.Assimp.TextureMapping*, uint*, float*, global::Silk.NET.Assimp.TextureOp*, global::Silk.NET.Assimp.TextureMapMode*, uint*, global::Silk.NET.Assimp.Return> )(CurrentVTable as GeneratedVTable).aiGetMaterialTexture)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
}
; // BEGIN RESOLVE 10 | READCOUNT: 1 | ALLOW_INLINE: False | FORCE_INLINE: False | CACHED: False
// BEGIN RESOLVE 0 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 0 INLINED
// END RESOLVE 0
// BEGIN RESOLVE 1 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 1 INLINED
// END RESOLVE 1
// BEGIN RESOLVE 2 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 2 INLINED
// END RESOLVE 2
// BEGIN RESOLVE 3 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 3 INLINED
// END RESOLVE 3
// BEGIN RESOLVE 4 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 4 INLINED
// END RESOLVE 4
// BEGIN RESOLVE 5 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 5 INLINED
// END RESOLVE 5
// BEGIN RESOLVE 6 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 6 INLINED
// END RESOLVE 6
// BEGIN RESOLVE 7 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 7 INLINED
// END RESOLVE 7
// BEGIN RESOLVE 8 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 8 INLINED
// END RESOLVE 8
// BEGIN RESOLVE 9 | READCOUNT: 1 | ALLOW_INLINE: True | FORCE_INLINE: False | CACHED: False
// RESOLVED 9 INLINED
// END RESOLVE 9
// RESOLVED 10 TO VARIABLE n10
n10 = StCall((/* VAR 0 */
mat), (/* VAR 1 */
type), (/* VAR 2 */
index), (/* VAR 3 */
path), (/* VAR 4 */
mapping), (/* VAR 5 */
uvindex), (/* VAR 6 */
blend), (/* VAR 7 */
op), (/* VAR 8 */
mapmode), (/* VAR 9 */
flags)); // END RESOLVE 10
// ALREADY RESOLVED 10
return /* VAR 10 */
n10;
} Release - .NET Standardpublic unsafe partial global::Silk.NET.Assimp.Return GetMaterialTexture(global::Silk.NET.Assimp.Material* mat, global::Silk.NET.Assimp.TextureType type, uint index, global::Silk.NET.Assimp.AssimpString* path, global::Silk.NET.Assimp.TextureMapping* mapping, uint* uvindex, float* blend, global::Silk.NET.Assimp.TextureOp* op, global::Silk.NET.Assimp.TextureMapMode* mapmode, uint* flags)
{
global::Silk.NET.Assimp.Return n10;
global::Silk.NET.Assimp.Return StCall(global::Silk.NET.Assimp.Material* arg0, global::Silk.NET.Assimp.TextureType arg1, uint arg2, global::Silk.NET.Assimp.AssimpString* arg3, global::Silk.NET.Assimp.TextureMapping* arg4, uint* arg5, float* arg6, global::Silk.NET.Assimp.TextureOp* arg7, global::Silk.NET.Assimp.TextureMapMode* arg8, uint* arg9)
{
if (Silk.NET.Core.Native.SilkMarshal.IsWinapiStdcall)
{
return ((delegate* unmanaged[Stdcall]<global::Silk.NET.Assimp.Material*, global::Silk.NET.Assimp.TextureType, uint, global::Silk.NET.Assimp.AssimpString*, global::Silk.NET.Assimp.TextureMapping*, uint*, float*, global::Silk.NET.Assimp.TextureOp*, global::Silk.NET.Assimp.TextureMapMode*, uint*, global::Silk.NET.Assimp.Return> )(CurrentVTable as _B)._BF)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
else
{
return ((delegate* unmanaged[Cdecl]<global::Silk.NET.Assimp.Material*, global::Silk.NET.Assimp.TextureType, uint, global::Silk.NET.Assimp.AssimpString*, global::Silk.NET.Assimp.TextureMapping*, uint*, float*, global::Silk.NET.Assimp.TextureOp*, global::Silk.NET.Assimp.TextureMapMode*, uint*, global::Silk.NET.Assimp.Return> )(CurrentVTable as _B)._BF)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
}
}
;
n10 = StCall((mat), (type), (index), (path), (mapping), (uvindex), (blend), (op), (mapmode), (flags));
return n10;
} |
Thanks a lot for the reply, Perksey. It is my mistake in the usage of the API. I correct my code and it works. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
I experienced a crash when calling
GetMaterialTexture()
, it says: Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.I checked the generated source code, and found a few mismatches of the parameter's type and it's casting:


Steps to reproduce
The text was updated successfully, but these errors were encountered: