fixed losing textures

This commit is contained in:
David Rose 2008-09-26 01:58:09 +00:00
parent c740062d29
commit 131f768d8d
2 changed files with 18 additions and 3 deletions

View File

@ -353,6 +353,8 @@ upload_texture(DXTextureContext9 *dtc, bool force) {
}
dtc->delete_texture();
dtc->update_data_size_bytes(0);
dtc->mark_unloaded();
if (_incomplete_render && !force) {
bool has_image = _supports_compressed_texture ? tex->has_ram_image() : tex->has_uncompressed_ram_image();
@ -5136,6 +5138,8 @@ check_dx_allocation (HRESULT result, int allocation_size, int attempts)
size_t current_size = _prepared_objects->_graphics_memory_lru.get_total_size();
size_t target_size = max(current_size - allocation_size * attempts, 0);
_prepared_objects->_graphics_memory_lru.evict_to(target_size);
dxgsg9_cat.info()
<< "Evicted " << current_size - _prepared_objects->_graphics_memory_lru.get_total_size() << " bytes of texture memory to make room for more.\n";
if (_prepared_objects->_graphics_memory_lru.get_total_size() < current_size) {
retry = true;
}

View File

@ -22,7 +22,7 @@
#include <time.h>
#define DEBUG_SURFACES false
#define DEBUG_TEXTURES false
#define DEBUG_TEXTURES true
TypeHandle DXTextureContext9::_type_handle;
@ -83,6 +83,10 @@ evict_lru() {
mark_used_lru();
return;
}
if (dxgsg9_cat.is_debug()) {
dxgsg9_cat.debug()
<< "Evicting " << *get_texture() << "\n";
}
dequeue_lru();
delete_texture();
@ -820,6 +824,13 @@ create_texture(DXScreenData &scrn) {
int attempts;
if (dxgsg9_cat.is_debug()) {
dxgsg9_cat.debug()
<< "Creating " << *tex << ", " << data_size << " bytes, "
<< scrn._d3d_device->GetAvailableTextureMem()
<< " reported available.\n";
}
attempts = 0;
do
{
@ -850,8 +861,8 @@ create_texture(DXScreenData &scrn) {
}
attempts++;
}
while (scrn._dxgsg9 -> check_dx_allocation (hr, data_size, attempts));
} while (scrn._dxgsg9 -> check_dx_allocation (hr, data_size, attempts));
if (FAILED(hr)) {
dxgsg9_cat.error()
<< "D3D create_texture failed!" << D3DERRORSTRING(hr);