release performed different from debug

I bulid a skeleton animation programme, the debug version performed well ,but in the release version, the mesh has no animation, does anyone know why? anyone has the same problem? thanks!

[195 byte] By [ts200702] at [2008-1-8]
# 1

The release version includes more compiler optimizations and hence might expose issues in your code or at sometimes could be compiler issues.

Could you narrow down the problem and post a simple case that would reproduce the issue?

Thanks,

Ayman Shoukry

VC++ Team

AymanShoukry-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 2

In Visual Studio 2005,the release version has no error, the issue only occured in VS2008,so i think the reason is from the compiler perhaps.

I have an old version of my code which performed well ,and i will check the new version with it. But the main section of the two versions are same. So i think the main reason is from the compiler.

Thanks a lot

ts200702 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 3

That could be the case. Unfortunately, I can't confirm without a sample reproducing the issue. Is it possible to post how to reproduce the issue?

Thanks,

Ayman Shoukry

VC++ Team

AymanShoukry-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 4

I use DirectX SDK parsering the X file to get the hiberarchy of the bone, and then load mesh from the file. Another class get animation infomations. The animation class has no error, the problem occured on the frame parser class.But the old version parser X file by the same way and it's main code ware not be changed.So i could not find where the problem is.

some code below:

Code Snippet

BOOL FrameParser::Parse(char *Filename,void **Data)
{

LPD3DXFILE pDXFile = NULL;
LPD3DXFILEENUMOBJECT pDXEnum = NULL;
LPD3DXFILEDATA pDXData = NULL;
HRESULT hr;
SIZE_T cChildren;

if(Filename == NULL)
{
return FALSE;
}

//
if(FAILED(D3DXFileCreate(&pDXFile)))
{
return FALSE;
}

//
if(FAILED(pDXFile->RegisterTemplates((LPVOID)D3DRM_XTEMPLATES,D3DRM_XTEMPLATE_BYTES)))
{
pDXFile->Release();
return FALSE;
}

//
if(FAILED(pDXFile->CreateEnumObject((LPVOID)Filename,
D3DXF_FILELOAD_FROMFILE,&pDXEnum)))
{
pDXFile->Release();
return FALSE;
}

//
//
//
pDXEnum->GetChildren(&cChildren);
for (UINT iChild = 0; iChild < cChildren; iChild++)
{
hr = pDXEnum->GetChild(iChild, &pDXData);
if (FAILED(hr))
{
return FALSE;
}

m_bReference = pDXData->IsReference();
hr = LoadFrame( pDXData,NULL,NULL,m_bReference);

SAFE_RELEASE( pDXData);
if( FAILED(hr) )
{
SAFE_RELEASE( pDXEnum);
SAFE_RELEASE( pDXFile);
return FALSE;
}
}

//
SAFE_RELEASE(pDXEnum);
SAFE_RELEASE(pDXFile);

return TRUE;
}

HRESULT FrameParser::LoadFrame(LPD3DXFILEDATA pFileData,LPD3DXFILEDATA pParentDataObj, void **Data,BOOL Reference)
{
LPD3DXFILEDATA pChildData = NULL;
GUID Guid;
SIZE_T cbSize = 0;
SIZE_T cChildren = 0;
D3DXFRAME_DERIVED* p_CurrentFrame;
// D3DXMESHCONTAINER_DERIVED* p_CurrentMesh;
HRESULT hr;

// Get the type of the object
if( FAILED( hr = pFileData->GetType( &Guid ) ) )
{
return hr;
}


if( Guid == TID_D3DRMFrameTransformMatrix && Reference == FALSE && Data)
{
D3DXFRAME_DERIVED *Frame = (D3DXFRAME_DERIVED*)(*Data);

D3DXMATRIX* pmatMatrix;

if(Frame)
{
hr = pFileData->Lock(&cbSize, (LPCVOID*)&pmatMatrix );
if( FAILED(hr) )
{
return hr;
}

// Update the parent's matrix with the new one
Frame->TransformationMatrix = *pmatMatrix;
pFileData->Unlock();
Frame->matOriginal = Frame->TransformationMatrix;
}

}


if( Guid == TID_D3DRMMesh && Reference == FALSE )
{

// Load the mesh using the data object load method
D3DXMESHCONTAINER_DERIVED *pMesh = NULL;
//mesh
LoadMesh(&pMesh,pFileData,m_texPath);
// Link mesh to head of list of meshes
if(pMesh)
{
pMesh->pNextMeshContainer = m_pRootMesh;
m_pRootMesh = pMesh;
pMesh = NULL;

// Link mesh to frame if needed
if(Data)
{
D3DXFRAME_DERIVED *pFrame = (D3DXFRAME_DERIVED*)*Data;
if(pFrame)
{
pFrame->pMeshContainer = m_pRootMesh;
}
}
}
}

if( Guid == TID_D3DRMMesh && Reference == TRUE )
{
// If referenced, then check if wanting to link to frame
if(Data)
{
D3DXFRAME_DERIVED *pFrame = (D3DXFRAME_DERIVED*)*Data;
if( m_pRootMesh && pFrame)
{
char strAnsiName[512] = "";
SIZE_T dwNameLength = 512;

if( FAILED( hr = pFileData->GetName( strAnsiName, &dwNameLength ) ) )
{
return hr;
}

if(strAnsiName)
{
pFrame->pMeshContainer = m_pRootMesh->FindMesh(strAnsiName);
}

}
}
}


if( Guid == TID_D3DRMFrame && Reference == FALSE)
{
//
char* strAnsiName = new char[100];
SIZE_T dwNameLength = 100;
SIZE_T cChildren;

if( FAILED( hr = pFileData->GetName( strAnsiName, &dwNameLength ) ) )
{
return hr;
}
p_CurrentFrame = new D3DXFRAME_DERIVED();

if(p_CurrentFrame == NULL )
{
return E_OUTOFMEMORY;
}
p_CurrentFrame->Name = strAnsiName;


//
if(Data == NULL)
{
// Link as sibling of root
p_CurrentFrame->pFrameSibling = m_pRootFrame;
m_pRootFrame = p_CurrentFrame;
p_CurrentFrame = NULL;
Data = (void**)&m_pRootFrame;
}
else
{
// Link as child of supplied frame
D3DXFRAME_DERIVED *pFramePtr = (D3DXFRAME_DERIVED*)*Data;
p_CurrentFrame->pFrameSibling = pFramePtr->pFrameFirstChild;
pFramePtr->pFrameFirstChild = p_CurrentFrame;
p_CurrentFrame = NULL;
Data = (void**)&pFramePtr->pFrameFirstChild;
}


cChildren = 0;
pFileData->GetChildren(&cChildren);
for (UINT iChild = 0; iChild < cChildren; iChild++)
{
hr = pFileData->GetChild(iChild, &pChildData);
if (FAILED(hr))
{
return hr;
}

m_bReference = pChildData->IsReference();
hr = LoadFrame( pChildData,pFileData, Data,m_bReference);

SAFE_RELEASE( pChildData);
}
}
return S_OK;
}

HRESULT FrameParser::LoadMesh(D3DXMESHCONTAINER_DERIVED** m_pMesh, LPD3DXFILEDATA pDataObj, char *TexturePath, DWORD NewFVF,DWORD LoadFlags)
{
LPD3DXMESH pLoadMesh = NULL;
LPD3DXSKININFO pSkin = NULL;
HRESULT hr;


if( !pDataObj || !TexturePath)
{
return E_FAIL;
}
DWORD TempLoadFlags = LoadFlags;
if(NewFVF)
{
TempLoadFlags = D3DXMESH_SYSTEMMEM;
}
// Load the mesh using the D3DX skinned mesh interface
LPD3DXBUFFER MaterialBuffer = NULL;
LPD3DXBUFFER AdjacencyBuffer = NULL;
DWORD NumMaterials;

if(FAILED(hr = D3DXLoadSkinMeshFromXof((LPD3DXFILEDATA)pDataObj,
TempLoadFlags,
m_pD3DDevice,
&AdjacencyBuffer,
&MaterialBuffer,
NULL,
&NumMaterials,
&pSkin,
&pLoadMesh)))
{
return hr;
}

// Free skin info if no bones
if(pSkin && !pSkin->GetNumBones())
{
SAFE_RELEASE(pSkin);
}
// Convert to new FVF first as needed (not w/skinned models)
if(NewFVF)
{
LPD3DXMESH pTempMesh = NULL;

// Use CloneMeshFVF to convert mesh
if(FAILED(hr =pLoadMesh->CloneMeshFVF(LoadFlags, NewFVF, m_pD3DDevice, &pTempMesh)))
{
SAFE_RELEASE(pLoadMesh);
SAFE_RELEASE(pSkin);
SAFE_RELEASE(MaterialBuffer);
SAFE_RELEASE(AdjacencyBuffer);
return hr;
}

// Free prior mesh and store new pointer
SAFE_RELEASE(pLoadMesh);
pLoadMesh = pTempMesh;
pTempMesh = NULL;
}

// Allocate a D3DXMESHCONTAINER_EX structure
D3DXMESHCONTAINER_DERIVED *pMesh = new D3DXMESHCONTAINER_DERIVED();
*m_pMesh = pMesh;

// Store mesh template name, type, and mesh pointers
DWORD Size;
pDataObj->GetName(NULL, &Size);
if(Size)
{
pMesh->Name = new char[Size];
pDataObj->GetName(pMesh->Name, &Size);
}
pMesh->MeshData.Type = D3DXMESHTYPE_MESH;
pMesh->MeshData.pMesh = pLoadMesh;
pLoadMesh = NULL;
pMesh->pSkinInfo = pSkin;
pSkin = NULL;

// Store adjacency buffer
DWORD AdjSize = AdjacencyBuffer->GetBufferSize();
if(AdjSize)
{
pMesh->pAdjacency = (DWORD*)new char[AdjSize];
memcpy(pMesh->pAdjacency, AdjacencyBuffer->GetBufferPointer(), AdjSize);
}

SAFE_RELEASE(AdjacencyBuffer);

// Create a duplicate mesh in case skinning is used
if(pMesh->pSkinInfo)
{
pMesh->MeshData.pMesh->CloneMeshFVF(D3DXMESH_SYSTEMMEM/*0*/, //D3DXMESH_MANAGED,
pMesh->MeshData.pMesh->GetFVF(),
m_pD3DDevice,
&pMesh->pSkinMesh);
}

// Build material list
if(!(pMesh->NumMaterials = NumMaterials)) {

// Create a default material
pMesh->NumMaterials = 1;
pMesh->pMaterials = new D3DXMATERIAL[1];
pMesh->pTextures = new IDirect3DTexture9*[1];

ZeroMemory(&pMesh->pMaterials[0], sizeof(D3DXMATERIAL));
pMesh->pMaterials[0].MatD3D.Diffuse.r = 1.0f;
pMesh->pMaterials[0].MatD3D.Diffuse.g = 1.0f;
pMesh->pMaterials[0].MatD3D.Diffuse.b = 1.0f;
pMesh->pMaterials[0].MatD3D.Diffuse.a = 1.0f;
pMesh->pMaterials[0].MatD3D.Ambient = pMesh->pMaterials[0].MatD3D.Diffuse;
pMesh->pMaterials[0].MatD3D.Specular = pMesh->pMaterials[0].MatD3D.Diffuse;
pMesh->pMaterials[0].pTextureFilename = NULL;
pMesh->pTextures[0] = NULL;

}
else
{

// Load the materials
D3DXMATERIAL *Materials = (D3DXMATERIAL*)MaterialBuffer->GetBufferPointer();
pMesh->pMaterials = new D3DXMATERIAL[pMesh->NumMaterials];
pMesh->pTextures = new IDirect3DTexture9*[pMesh->NumMaterials];

for(DWORD i=0;i<pMesh->NumMaterials;i++) {
pMesh->pMaterials[i].MatD3D = Materials[i].MatD3D;
pMesh->pMaterials[i].MatD3D.Ambient = pMesh->pMaterials[i].MatD3D.Diffuse;

// Load the texture if one exists
pMesh->pTextures[i] = NULL;
if(Materials[i].pTextureFilename)
{
char TextureFile[MAX_PATH];
sprintf_s(TextureFile,MAX_PATH, "%s%s", TexturePath, Materials[i].pTextureFilename);
D3DXCreateTextureFromFileA( m_pD3DDevice, TextureFile,
&pMesh->pTextures[i]);
}
}
}
SAFE_RELEASE(MaterialBuffer);

// Optimize the mesh for better attribute access
pMesh->MeshData.pMesh->OptimizeInplace(D3DXMESHOPT_ATTRSORT, NULL, NULL, NULL, NULL);

// Clear pMesh pointer just in case
pMesh = NULL;

return S_OK;
}

ts200702 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 5

I have a new progress. I find that in the DXUT Framework,my code performed well ,but in my own framework,the release has error. i do not know why.

thanks

ts200702 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 6

i found something which may be the reason.

i create a new project in vs2008,and add all the .h and .cpp files to the project's folder,then the release work well !!

So,the issue may be from the converted project parameters.But, i do not know which parameter is wrong.

ts200702 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 7

Can you check the release configuration properties between the two projects (new vs. upgraded) and figure out what changed?

Thanks,

Tarek

TarekMadkourMS at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 8
Tarek Madkour MS wrote:

Can you check the release configuration properties between the two projects (new vs. upgraded) and figure out what changed?

Thanks,

Tarek

Thx a lot

i will check it later

ts200702 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 9

Did Tarek's suggestion fix the issue you were facing?

Thanks,

Ayman Shoukry

Visual C++ Team

AymanShoukry-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 10
Ayman Shoukry - MSFT wrote:

Did Tarek's suggestion fix the issue you were facing?

Thanks,

Ayman Shoukry

Visual C++ Team

I have not found the difference yet , i need more time, thanks

ts200702 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 11

Hello

Any update on the situation?

Thanks

Damien

DamienWatkins-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 12
Damien Watkins - MSFT wrote:

Hello

Any update on the situation?

Thanks

Damien

Sorry, i have some important problem to solve

Please wait

Thanks

ts200702 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 13

Here are the differences i have found between the Update Version of vs2005 and the Original Version of vs2008 beta2:

Note: the 1st value is the Original Version, and the 2nd value is the Update Version

In Project Properties

C/C++>General>Detect 64-bit Portability Issues: No, Yes(/Wp64)

C/C++>Optimization-->Enable Instriusic Fuctions: Yes(/Oi), No

C/C++>Code Generation-->Enable Function-Level Linking Yes(/Gy), No

Linker>Advanced-->Randomized Base Address Enable..., Disable...

Linker>Advanced-->Data Execution Prevention(DEP) Image is compatible..., Default

Thanks a lot

ts200702 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...
# 14

Did you try changing those to your original and see if you still get the same behavior?

Thanks,

Ayman Shoukry

Visual C++ Team

AymanShoukry-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual C++ Orcas...

Visual Studio Orcas

Site Classified