Merge pull request #421 from erwincoumans/master

fix shadowmap crash on some Intel GPUs, see https://github.com/bullet…
This commit is contained in:
erwincoumans
2015-07-12 14:17:56 -07:00
34 changed files with 339 additions and 119 deletions

View File

@@ -174,6 +174,7 @@ protected:
btAlignedObjectArray<short> mTlens;
btHashMap<btHashInt, int> mStructReverse;
btHashMap<btHashString,int> mTypeLookup;
btHashMap<btHashPtr,void*> m_chunkP;
@@ -185,6 +186,7 @@ protected:
int m_totalSize;
unsigned char* m_buffer;
bool m_ownsBuffer;
int m_currentSize;
void* m_dna;
int m_dnaLength;
@@ -196,6 +198,7 @@ protected:
protected:
virtual void* findPointer(void* oldPtr)
{
void** ptr = m_chunkP.find(oldPtr);
@@ -384,17 +387,25 @@ protected:
public:
btHashMap<btHashPtr,void*> m_skipPointers;
btDefaultSerializer(int totalSize=0)
btDefaultSerializer(int totalSize=0, unsigned char* buffer=0)
:m_totalSize(totalSize),
m_currentSize(0),
m_dna(0),
m_dnaLength(0),
m_serializationFlags(0)
{
m_buffer = m_totalSize?(unsigned char*)btAlignedAlloc(totalSize,16):0;
if (buffer==0)
{
m_buffer = m_totalSize?(unsigned char*)btAlignedAlloc(totalSize,16):0;
m_ownsBuffer = true;
} else
{
m_buffer = buffer;
m_ownsBuffer = false;
}
const bool VOID_IS_8 = ((sizeof(void*)==8));
@@ -429,12 +440,18 @@ public:
virtual ~btDefaultSerializer()
{
if (m_buffer)
if (m_buffer && m_ownsBuffer)
btAlignedFree(m_buffer);
if (m_dna)
btAlignedFree(m_dna);
}
void insertHeader()
{
writeHeader(m_buffer);
m_currentSize += BT_HEADER_LENGTH;
}
void writeHeader(unsigned char* buffer) const
{
@@ -515,6 +532,7 @@ public:
mTlens.clear();
mStructReverse.clear();
mTypeLookup.clear();
m_skipPointers.clear();
m_chunkP.clear();
m_nameMap.clear();
m_uniquePointers.clear();
@@ -531,6 +549,13 @@ public:
{
return uptr->m_ptr;
}
void** ptr2 = m_skipPointers[oldPtr];
if (ptr2)
{
return 0;
}
m_uniqueIdGenerator++;
btPointerUid uid;
@@ -684,10 +709,15 @@ struct btInMemorySerializer : public btDefaultSerializer
btHashMap<btHashPtr,btChunk*> m_uid2ChunkPtr;
btHashMap<btHashPtr,void*> m_orgPtr2UniqueDataPtr;
btHashMap<btHashString,const void*> m_names2Ptr;
btHashMap<btHashPtr,void*> m_skipPointers;
btBulletSerializedArrays m_arrays;
btInMemorySerializer(int totalSize=0, unsigned char* buffer=0)
:btDefaultSerializer(totalSize,buffer)
{
}
virtual void startSerialization()
{
@@ -696,6 +726,8 @@ struct btInMemorySerializer : public btDefaultSerializer
btDefaultSerializer::startSerialization();
}
btChunk* findChunkFromUniquePointer(void* uniquePointer)
{
btChunk** chkPtr = m_uid2ChunkPtr[uniquePointer];