epic: refactor SDL2_Renderer usage to IRenderer and queued texture rendering

- Updated the testing guide to clarify the testing framework's organization and execution methods, improving user understanding.
- Refactored CMakeLists to include new platform-specific files, ensuring proper integration of the rendering backend.
- Modified main application files to utilize the new IRenderer interface, enhancing flexibility in rendering operations.
- Implemented deferred texture management in various components, allowing for more efficient graphics handling and improved performance.
- Introduced new methods for texture creation and updates, streamlining the rendering process across the application.
- Enhanced logging and error handling in the rendering pipeline to facilitate better debugging and diagnostics.
This commit is contained in:
scawful
2025-10-07 17:15:11 -04:00
parent 9e6f538520
commit 6c331f1fd0
101 changed files with 1401 additions and 2677 deletions

View File

@@ -14,7 +14,7 @@
#endif
namespace yaze {
namespace app {
namespace gui {
AgentChatWidget::AgentChatWidget()
@@ -334,5 +334,5 @@ void AgentChatWidget::ScrollToBottom() {
}
} // namespace gui
} // namespace app
} // namespace yaze

View File

@@ -10,7 +10,7 @@
#include "app/rom.h"
namespace yaze {
namespace app {
namespace gui {
/**
@@ -77,7 +77,7 @@ class AgentChatWidget {
};
} // namespace gui
} // namespace app
} // namespace yaze
#endif // YAZE_APP_GUI_WIDGETS_AGENT_CHAT_WIDGET_H_

View File

@@ -8,7 +8,7 @@
#include "imgui/imgui.h"
namespace yaze {
namespace app {
namespace gui {
CollaborationPanel::CollaborationPanel()
@@ -660,5 +660,5 @@ void CollaborationPanel::RenderApprovalProposal(
}
} // namespace gui
} // namespace app
} // namespace yaze

View File

@@ -15,7 +15,7 @@
#endif
namespace yaze {
namespace app {
namespace gui {
/**
@@ -180,7 +180,7 @@ class CollaborationPanel {
};
} // namespace gui
} // namespace app
} // namespace yaze
#endif // YAZE_APP_GUI_WIDGETS_COLLABORATION_PANEL_H_

View File

@@ -1,4 +1,5 @@
#include "app/gui/widgets/dungeon_object_emulator_preview.h"
#include "app/gfx/backend/irenderer.h"
#include "app/zelda3/dungeon/room.h"
#include "app/zelda3/dungeon/room_object.h"
@@ -11,23 +12,22 @@ namespace gui {
DungeonObjectEmulatorPreview::DungeonObjectEmulatorPreview() {
snes_instance_ = std::make_unique<emu::Snes>();
object_texture_ = SDL_CreateTexture(core::Renderer::Get().renderer(),
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, 256, 256);
}
DungeonObjectEmulatorPreview::~DungeonObjectEmulatorPreview() {
if (object_texture_) {
SDL_DestroyTexture(object_texture_);
}
// if (object_texture_) {
// renderer_->DestroyTexture(object_texture_);
// }
}
void DungeonObjectEmulatorPreview::Initialize(Rom* rom) {
rom_ = rom;
if (rom_ && rom_->is_loaded()) {
auto rom_data = rom_->vector();
snes_instance_->Init(rom_data);
}
void DungeonObjectEmulatorPreview::Initialize(gfx::IRenderer* renderer, Rom* rom) {
renderer_ = renderer;
rom_ = rom;
snes_instance_ = std::make_unique<emu::Snes>();
std::vector<uint8_t> rom_data = rom->vector();
snes_instance_->Init(rom_data);
// object_texture_ = renderer_->CreateTexture(256, 256);
}
void DungeonObjectEmulatorPreview::Render() {
@@ -286,9 +286,9 @@ void DungeonObjectEmulatorPreview::TriggerEmulatedRender() {
// 15. Get the rendered pixels from PPU
void* pixels = nullptr;
int pitch = 0;
if (SDL_LockTexture(object_texture_, nullptr, &pixels, &pitch) == 0) {
if (renderer_->LockTexture(object_texture_, nullptr, &pixels, &pitch)) {
snes_instance_->SetPixels(static_cast<uint8_t*>(pixels));
SDL_UnlockTexture(object_texture_);
renderer_->UnlockTexture(object_texture_);
}
}

View File

@@ -4,6 +4,12 @@
#include "app/emu/snes.h"
#include "app/rom.h"
namespace yaze {
namespace gfx {
class IRenderer;
} // namespace gfx
}
namespace yaze {
namespace gui {
@@ -12,16 +18,17 @@ class DungeonObjectEmulatorPreview {
DungeonObjectEmulatorPreview();
~DungeonObjectEmulatorPreview();
void Initialize(Rom* rom);
void Initialize(gfx::IRenderer* renderer, Rom* rom);
void Render();
private:
void RenderControls();
void TriggerEmulatedRender();
gfx::IRenderer* renderer_ = nullptr;
Rom* rom_ = nullptr;
std::unique_ptr<emu::Snes> snes_instance_;
SDL_Texture* object_texture_ = nullptr;
void* object_texture_ = nullptr;
int object_id_ = 0;
int room_id_ = 0;

View File

@@ -2,15 +2,13 @@
#include <algorithm>
#include <map>
#include "app/core/window.h"
#include "app/gfx/arena.h"
#include "app/gui/color.h"
#include "util/log.h"
namespace yaze {
namespace gui {
using core::Renderer;
void PaletteWidget::Initialize(Rom* rom) {
rom_ = rom;
rom_palettes_loaded_ = false;
@@ -169,7 +167,9 @@ bool PaletteWidget::ApplyROMPalette(gfx::Bitmap* bitmap, int group_index, int pa
bitmap->SetPalette(selected_palette);
}
Renderer::Get().UpdateBitmap(bitmap);
// Queue texture update via Arena's deferred system
gfx::Arena::Get().QueueTextureCommand(
gfx::Arena::TextureCommandType::UPDATE, bitmap);
current_group_index_ = group_index;
current_palette_index_ = palette_index;