Xbox: virtual memory fixes
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "archutils/Win32/GraphicsWindow.h"
|
#include "archutils/Win32/GraphicsWindow.h"
|
||||||
#else
|
#else
|
||||||
#include "archutils/Xbox/GraphicsWindow.h"
|
#include "archutils/Xbox/GraphicsWindow.h"
|
||||||
|
#include "archutils/Xbox/VirtualMemory.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ScreenDimensions.h"
|
#include "ScreenDimensions.h"
|
||||||
@@ -1204,6 +1205,16 @@ unsigned RageDisplay_D3D::CreateTexture(
|
|||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IDirect3DTexture8* pTex;
|
IDirect3DTexture8* pTex;
|
||||||
hr = g_pd3dDevice->CreateTexture( img->w, img->h, 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex );
|
hr = g_pd3dDevice->CreateTexture( img->w, img->h, 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex );
|
||||||
|
|
||||||
|
#if defined(XBOX)
|
||||||
|
while(hr == E_OUTOFMEMORY)
|
||||||
|
{
|
||||||
|
if(!vmem_Manager.DecommitLRU())
|
||||||
|
break;
|
||||||
|
hr = g_pd3dDevice->CreateTexture( img->w, img->h, 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if( FAILED(hr) )
|
if( FAILED(hr) )
|
||||||
RageException::Throw( "CreateTexture(%i,%i,pixfmt=%i) failed: %s",
|
RageException::Throw( "CreateTexture(%i,%i,pixfmt=%i) failed: %s",
|
||||||
img->w, img->h, pixfmt, GetErrorString(hr).c_str() );
|
img->w, img->h, pixfmt, GetErrorString(hr).c_str() );
|
||||||
|
|||||||
@@ -34,6 +34,10 @@
|
|||||||
#include "RageSoundReader_Resample.h"
|
#include "RageSoundReader_Resample.h"
|
||||||
#include "RageSoundReader_FileReader.h"
|
#include "RageSoundReader_FileReader.h"
|
||||||
|
|
||||||
|
#if defined(XBOX)
|
||||||
|
#include "archutils/Xbox/VirtualMemory.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
const int channels = 2;
|
const int channels = 2;
|
||||||
const int framesize = 2 * channels; /* 16-bit */
|
const int framesize = 2 * channels; /* 16-bit */
|
||||||
#define samplerate() Sample->GetSampleRate()
|
#define samplerate() Sample->GetSampleRate()
|
||||||
@@ -350,6 +354,11 @@ int RageSound::FillBuf( int frames )
|
|||||||
* that would be read. */
|
* that would be read. */
|
||||||
int RageSound::GetData( char *buffer, int frames )
|
int RageSound::GetData( char *buffer, int frames )
|
||||||
{
|
{
|
||||||
|
#if defined(XBOX)
|
||||||
|
// should prevent a page fault crash
|
||||||
|
vmem_Manager.Lock(buffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
if( m_Param.m_LengthSeconds != -1 )
|
if( m_Param.m_LengthSeconds != -1 )
|
||||||
{
|
{
|
||||||
/* We have a length; only read up to the end. */
|
/* We have a length; only read up to the end. */
|
||||||
@@ -378,6 +387,10 @@ int RageSound::GetData( char *buffer, int frames )
|
|||||||
databuf.read( buffer, got*framesize );
|
databuf.read( buffer, got*framesize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(XBOX)
|
||||||
|
vmem_Manager.Unlock(buffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,10 @@
|
|||||||
#include "arch/arch.h"
|
#include "arch/arch.h"
|
||||||
#include "arch/Sound/RageSoundDriver.h"
|
#include "arch/Sound/RageSoundDriver.h"
|
||||||
|
|
||||||
|
#if defined(XBOX)
|
||||||
|
#include "archutils/Xbox/VirtualMemory.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This mutex is locked before Update() deletes old sounds from owned_sounds. Lock
|
* This mutex is locked before Update() deletes old sounds from owned_sounds. Lock
|
||||||
* this mutex if you want to ensure that sounds remain valid. (Other threads may
|
* this mutex if you want to ensure that sounds remain valid. (Other threads may
|
||||||
@@ -217,6 +221,10 @@ RageSound *RageSoundManager::PlaySound( RageSound &snd, const RageSoundParams *p
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sound_to_play = new RageSound(snd);
|
sound_to_play = new RageSound(snd);
|
||||||
|
#if defined(XBOX)
|
||||||
|
// keep the sound data committed to memory
|
||||||
|
vmem_Manager.Lock(sound_to_play);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We're responsible for freeing it. */
|
/* We're responsible for freeing it. */
|
||||||
g_SoundManMutex.Lock(); /* lock for access to owned_sounds */
|
g_SoundManMutex.Lock(); /* lock for access to owned_sounds */
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#if defined(_XBOX)
|
#if defined(_XBOX)
|
||||||
# include <malloc.h> // for alloca
|
# include <malloc.h> // for alloca
|
||||||
|
# include "archutils/Xbox/VirtualMemory.h"
|
||||||
|
# define PNG_USER_MEM_SUPPORTED
|
||||||
#elif !defined(WIN32)
|
#elif !defined(WIN32)
|
||||||
# include <alloca.h>
|
# include <alloca.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -89,6 +91,17 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
|||||||
error.fn = fn;
|
error.fn = fn;
|
||||||
|
|
||||||
png_struct *png = png_create_read_struct( PNG_LIBPNG_VER_STRING, &error, PNG_Error, PNG_Warning );
|
png_struct *png = png_create_read_struct( PNG_LIBPNG_VER_STRING, &error, PNG_Error, PNG_Warning );
|
||||||
|
|
||||||
|
#if defined(XBOX)
|
||||||
|
while(png == NULL)
|
||||||
|
{
|
||||||
|
if(!vmem_Manager.DecommitLRU())
|
||||||
|
break;
|
||||||
|
|
||||||
|
png = png_create_read_struct( PNG_LIBPNG_VER_STRING, &error, PNG_Error, PNG_Warning );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if( png == NULL )
|
if( png == NULL )
|
||||||
{
|
{
|
||||||
sprintf( errorbuf, "creating png_create_read_struct failed");
|
sprintf( errorbuf, "creating png_create_read_struct failed");
|
||||||
|
|||||||
Reference in New Issue
Block a user