Enhance graphics editor performance with batch processing and profiling
- Integrated performance profiling using ScopedTimer in GraphicsEditor and ScreenEditor for better timing insights. - Implemented batch texture updates in GraphicsEditor and ScreenEditor to reduce individual texture update calls, improving rendering efficiency. - Enhanced tile rendering in ScreenEditor with pre-allocated vectors for batch operations, optimizing drawing performance. - Added safety checks and validation in various components to prevent crashes and ensure data integrity during rendering operations. - Updated Bitmap and Arena classes to support improved texture management and synchronization, enhancing overall graphics performance.
This commit is contained in:
@@ -35,7 +35,7 @@ RoomSize CalculateRoomSize(Rom *rom, int room_id) {
|
||||
room_size.room_size = 0;
|
||||
|
||||
auto room_size_address = 0xF8000 + (room_id * 3);
|
||||
util::logf("Room #%#03X Addresss: %#06X", room_id, room_size_address);
|
||||
// util::logf("Room #%#03X Addresss: %#06X", room_id, room_size_address);
|
||||
|
||||
// Reading bytes for long address construction
|
||||
uint8_t low = rom->data()[room_size_address];
|
||||
@@ -44,12 +44,12 @@ RoomSize CalculateRoomSize(Rom *rom, int room_id) {
|
||||
|
||||
// Constructing the long address
|
||||
int long_address = (bank << 16) | (high << 8) | low;
|
||||
util::logf("%#06X", long_address);
|
||||
// util::logf("%#06X", long_address);
|
||||
room_size.room_size_pointer = long_address;
|
||||
|
||||
if (long_address == 0x0A8000) {
|
||||
// Blank room disregard in size calculation
|
||||
util::logf("Size of Room #%#03X: 0 bytes", room_id);
|
||||
// util::logf("Size of Room #%#03X: 0 bytes", room_id);
|
||||
room_size.room_size = 0;
|
||||
} else {
|
||||
// use the long address to calculate the size of the room
|
||||
@@ -57,7 +57,7 @@ RoomSize CalculateRoomSize(Rom *rom, int room_id) {
|
||||
// and subtract the two to get the size of the room
|
||||
|
||||
int next_room_address = 0xF8000 + ((room_id + 1) * 3);
|
||||
util::logf("Next Room Address: %#06X", next_room_address);
|
||||
// util::logf("Next Room Address: %#06X", next_room_address);
|
||||
|
||||
// Reading bytes for long address construction
|
||||
uint8_t next_low = rom->data()[next_room_address];
|
||||
@@ -66,12 +66,12 @@ RoomSize CalculateRoomSize(Rom *rom, int room_id) {
|
||||
|
||||
// Constructing the long address
|
||||
int next_long_address = (next_bank << 16) | (next_high << 8) | next_low;
|
||||
util::logf("%#06X", next_long_address);
|
||||
// util::logf("%#06X", next_long_address);
|
||||
|
||||
// Calculate the size of the room
|
||||
int actual_room_size = next_long_address - long_address;
|
||||
room_size.room_size = actual_room_size;
|
||||
util::logf("Size of Room #%#03X: %d bytes", room_id, actual_room_size);
|
||||
// util::logf("Size of Room #%#03X: %d bytes", room_id, actual_room_size);
|
||||
}
|
||||
|
||||
return room_size;
|
||||
@@ -383,7 +383,7 @@ void Room::LoadObjects() {
|
||||
|
||||
// Enhanced bounds checking for object pointer
|
||||
if (object_pointer < 0 || object_pointer >= (int)rom_->size()) {
|
||||
util::logf("Object pointer out of range for room %d: %#06x", room_id_, object_pointer);
|
||||
// util::logf("Object pointer out of range for room %d: %#06x", room_id_, object_pointer);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ void Room::LoadObjects() {
|
||||
|
||||
// Enhanced bounds checking for room address
|
||||
if (room_address < 0 || room_address + 2 >= (int)rom_->size()) {
|
||||
util::logf("Room address out of range for room %d: %#06x", room_id_, room_address);
|
||||
// util::logf("Room address out of range for room %d: %#06x", room_id_, room_address);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ void Room::LoadObjects() {
|
||||
|
||||
// Enhanced bounds checking for objects location
|
||||
if (objects_location < 0 || objects_location >= (int)rom_->size()) {
|
||||
util::logf("Objects location out of range for room %d: %#06x", room_id_, objects_location);
|
||||
// util::logf("Objects location out of range for room %d: %#06x", room_id_, objects_location);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -634,16 +634,16 @@ void Room::LoadRoomLayout() {
|
||||
auto status = layout_.LoadLayout(room_id_);
|
||||
if (!status.ok()) {
|
||||
// Log error but don't fail - some rooms might not have layout data
|
||||
util::logf("Failed to load room layout for room %d: %s",
|
||||
room_id_, status.message().data());
|
||||
// util::logf("Failed to load room layout for room %d: %s",
|
||||
// room_id_, status.message().data());
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the layout ID for compatibility with existing code
|
||||
layout = static_cast<uint8_t>(room_id_ & 0xFF);
|
||||
|
||||
util::logf("Loaded room layout for room %d with %zu objects",
|
||||
room_id_, layout_.GetObjects().size());
|
||||
// util::logf("Loaded room layout for room %d with %zu objects",
|
||||
// room_id_, layout_.GetObjects().size());
|
||||
}
|
||||
|
||||
void Room::LoadDoors() {
|
||||
|
||||
@@ -633,13 +633,13 @@ absl::Status Overworld::LoadExits() {
|
||||
uint16_t px = (uint16_t)((rom_data[OWExitXPlayer + (i * 2) + 1] << 8) +
|
||||
rom_data[OWExitXPlayer + (i * 2)]);
|
||||
|
||||
util::logf(
|
||||
"Exit: %d RoomID: %d MapID: %d VRAM: %d YScroll: %d XScroll: "
|
||||
"%d YPlayer: %d XPlayer: %d YCamera: %d XCamera: %d "
|
||||
"ScrollModY: %d ScrollModX: %d DoorType1: %d DoorType2: %d",
|
||||
i, exit_room_id, exit_map_id, exit_vram, exit_y_scroll, exit_x_scroll,
|
||||
py, px, exit_y_camera, exit_x_camera, exit_scroll_mod_y,
|
||||
exit_scroll_mod_x, exit_door_type_1, exit_door_type_2);
|
||||
// util::logf(
|
||||
// "Exit: %d RoomID: %d MapID: %d VRAM: %d YScroll: %d XScroll: "
|
||||
// "%d YPlayer: %d XPlayer: %d YCamera: %d XCamera: %d "
|
||||
// "ScrollModY: %d ScrollModX: %d DoorType1: %d DoorType2: %d",
|
||||
// i, exit_room_id, exit_map_id, exit_vram, exit_y_scroll, exit_x_scroll,
|
||||
// py, px, exit_y_camera, exit_x_camera, exit_scroll_mod_y,
|
||||
// exit_scroll_mod_x, exit_door_type_1, exit_door_type_2);
|
||||
|
||||
exits.emplace_back(exit_room_id, exit_map_id, exit_vram, exit_y_scroll,
|
||||
exit_x_scroll, py, px, exit_y_camera, exit_x_camera,
|
||||
|
||||
Reference in New Issue
Block a user