0
0

Is there a performance comparison between using FMODEx’s internal heap algorithm:

[code:34e2s4e0]
Void game::audio::Audio::InitFmodExMemory() throw (XInitializationFailed)
{
FMOD_RESULT r;

// initialize memory
STATIC_ASSERT (!(system::Memory::AudioSystemSize % 512));

m_pMemoryBlock = NiPhysicalAlloc (
    system::Memory::AudioSystemSize, 
    system::Memory::AudioSystemBase, 
    512, PAGE_READWRITE | MEM_LARGE_PAGES
);

r = FMOD::Memory_Initialize (
    m_pMemoryBlock, system::Memory::AudioSystemSize,
    0, 0, 0
    );

FMOD_THROW_ON_ERROR (XInitializationFailed, r);

}

Void game::audio::Audio::DeinitFmodExMemory() throw ()
{
if (m_pMemoryBlock)
NiPhysicalFree (m_pMemoryBlock);
}
[/code:34e2s4e0]

and the XBox 360/Games4Windows Heap API:

[code:34e2s4e0]
static Void* g_pAudioHeap = 0;

if (BUILD_TYPE == DEBUG)

static DWORD g_AudioHeapThreadId (0);

endif

static void* F_CALLBACK FmodExMalloc(unsigned int stSizeInBytes)
{
ASSERT (GetCurrentThreadId() == g_AudioHeapThreadId);

return HeapAlloc (
    g_pAudioHeap,
    HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE,
    stSizeInBytes
    );

}

static void* F_CALLBACK FmodExRealloc(void* p, unsigned int stSizeInBytes)
{
ASSERT (GetCurrentThreadId() == g_AudioHeapThreadId);

return HeapReAlloc (
    g_pAudioHeap,
    HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE,
    p,
    stSizeInBytes
    );

}

static void F_CALLBACK FmodExFree(void* p)
{
ASSERT (GetCurrentThreadId() == g_AudioHeapThreadId);

HeapFree (
    g_pAudioHeap,
    HEAP_NO_SERIALIZE,
    p
    );

}

Void game::audio::Audio::InitFmodExMemory() throw (XInitializationFailed)
{
FMOD_RESULT r;

// initialize memory
STATIC_ASSERT (!(system::Memory::AudioSystemSize % 512));
ASSERT (!g_pAudioHeap);
ASSERT (!g_AudioHeapThreadId);

g_pAudioHeap = HeapCreate (
    HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE, 
    system::Memory::AudioSystemSize, 
    0 /* FMODEx might need more than 524280 bytes at once */
);

#if (BUILD_TYPE == DEBUG)
    g_AudioHeapThreadId = GetCurrentThreadId();
#endif

r = FMOD::Memory_Initialize (
    0, 0,
    FmodExMalloc, FmodExRealloc, FmodExFree
    );

FMOD_THROW_ON_ERROR (XInitializationFailed, r);

}

Void game::audio::Audio::DeinitFmodExMemory() throw ()
{
if (g_pAudioHeap)
{
HeapDestroy (g_pAudioHeap);
g_pAudioHeap = 0;

    #if (BUILD_TYPE == DEBUG)
        g_AudioHeapThreadId = 0;
    #endif
}

}
[/code:34e2s4e0]

?

Regards
Felix Kollmann

  • You must to post comments
0
0

I have done speed tests and fmod’s allocator beats everything. It doesn’t even search for free blocks now (if the block is big enough for the new memory to go into), it knows immediately where it should put the new memory and simply returns straight away with the pointer. Anyway, you can’t use default allocators on 360 you have to use fmod’s system, its not an option (unless you override it with your own).

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.