Etwas gaaaanz merkwürdiges:
Wenn ich die Retail Runtime oder die Debug Runtime mit einem Output level von mittel oder weniger benutze, bekomme ich eine eine AccessViolationException wenn ich SlimDX.Direct3D9.Device.DrawIndexedUserPrimitives() aufrufe. (Die Werte die übergeben werden sind alle wie sie sein sollten). Ich hab mir auch zwischenzeitlichdie SlimDx sourcen runtergeladen und auch das, was SlimDx an IDirect3DDevice9:: DrawIndexedPrimitiveUP() weiter gibt ist ok.
Die Exception die ich bekomme sieht so aus:
First-chance exception at 0x757fa04c in 01.HelloWorld.exe: 0xC0000005: Access violation reading location 0x029e2000.
A first chance exception of type 'System.AccessViolationException' occurred in SlimDX.dll
An unhandled exception of type 'System.AccessViolationException' occurred in SlimDX.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Der Code der die Exception auslöst ist folgender:
|
Quellcode
|
1
2
3
4
5
6
|
pID3DDevice.VertexFormat = VertexFormat.Position | VertexFormat.Normal | VertexFormat.Diffuse | VertexFormat.Texture1;
pID3DDevice.DrawIndexedUserPrimitives( PrimitiveType.TriangleList, 0, 0, vtx.Count, indices.Count / 3, indices.ToArray(), Format.Index16, vtx.ToArray(), S3DVertex.VertexStride );
// indicies = List<ushort> mit 216 Werten
// vtx = List<Meine_Vertex_Struct> mit 144 Werten
// S3DVertex.VertexStride = 36
|
Die Ausgabe der Dx-Debug Runtime sieht wie folgt aus:
Direct3D9: (INFO)
DI threading stopped
Direct3D9: (INFO) :Using FF to VS converter
Direct3D9: (INFO) :Using FF to PS converter
Direct3D9: (INFO)
DI threading started
D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 5.03137e-316f. This is ok.
Was mich jetzt mehr wundert als meine Unfähigkeit ist die Tatsache, dass diese Exception nicht auftritt, wenn ich die Debug Runtime mit einem der beiden höchsten Output level benutze.
Was ist an diesen beiden Leveln so besonders, dass diese Exception nicht einmal auftritt? Zumindest laut VS Debugger wird sie nichtmal geschmissen...
Ich bin für jeden Rat und/oder schupser in die richtige Richtung dankbar
P.S.:
Falls es jemandem hilf: Hier mal der callstack:
msvcrt.dll!_memcpy() + 0x250 bytes
d3d9d.dll!CUMBuffer::AddVertices() + 0x1d bytes
d3d9d.dll!CBatchFilterI:
rawIndexedPrimitive() + 0x1e9 bytes
d3d9d.dll!CBatchFilterI::LHBatchDrawIndexedPrimitive() + 0x11 bytes
d3d9d.dll!CD3DDDIDX10:
rawIndexedPrimitiveUP() + 0x354 bytes
d3d9d.dll!CD3DHal:
rawIndexedPrimitiveUPI() + 0x31 bytes
d3d9d.dll!CD3DBase:
rawIndexedPrimitiveUP() + 0x5e5 bytes
d3d9d.dll!CDirect3DDevice9W:
rawIndexedPrimitiveUP() + 0x131 bytes
[Managed to Native Transition]
SlimDX.dll!SlimDX.Direct3D9.Device.DrawIndexedUserPrimitives<ushort,IrrSharp.video.S3DVertex>(SlimDX.Direct3D9.PrimitiveType primitiveType, int startIndex, int startVertex, int minimumVertexIndex, int vertexCount, int primitiveCount, ushort[] indexData, SlimDX.Direct3D9.Format indexDataFormat, IrrSharp.video.S3DVertex[] vertexData, int vertexStride) + 0x67 bytes
SlimDX.dll!SlimDX.Direct3D9.Device.DrawIndexedUserPrimitives<ushort,IrrSharp.video.S3DVertex>(SlimDX.Direct3D9.PrimitiveType primitiveType, int startIndex, int minimumVertexIndex, int vertexCount, int primitiveCount, ushort[] indexData, SlimDX.Direct3D9.Format indexDataFormat, IrrSharp.video.S3DVertex[] vertexData, int vertexStride) + 0x26 bytes
Jetzt weiß ich wohl immerhin, dass etwas mit den Vertices nicht zu stimmen scheint... gut da ich aber schon den halben Tag da dran gesessen hab, werd ich jetzt schlafen gehen und mir das morgen mal genauer angucken, oder vielleicht hat ja bis dahin jemand von euch eine zündene Idee
Okay für alle die es interessiert:
Sowas passiert, wenn man in dem value-Type, den man als Vertex an SlimDX übergbit reference-types drin hat, also sowas wie
|
Quellcode
|
1
2
3
4
5
6
7
8
9
|
class Vector
{
float x,y,z;
}
struct Vertex
{
Vector pos;
}
|
Sondern man darf nur value-types inerhalb der Vertices haben, also
|
Quellcode
|
1
2
3
4
|
struct Vertex
{
float x,y,z;
}
|
Wenn man seine class nicht in eine strukt umbauen will / kann, kann man ja immernoch Properties benutzen.