Skip to content

Commit

Permalink
Renderer tweaks and misc fixes
Browse files Browse the repository at this point in the history
* Imagine: Add Gfx::Quads template type as higher level wrapper around VertexBuffer
* Imagine: Integrate most functions of Sprite class into generic quad class
* Imagine: Use index buffers objects instead of client-side indices
* Imagine: Define a common quad index buffer for use with the GUI system in ViewManager
* Imagine: Use Gfx::Buffer::map() in RendererTask::write() if the data exceeds the delegate function size
* Imagine: Add Audio::systemApis array
* Imagine: Add Config::windowFocus
* Imagine: Use generic gamepad mapping for Nvidia Shield controller
* EmuFramework: Fix recent content list not clearing
* EmuFramework: Convert more option variables to use state-less functions
* Misc header file clean up
  • Loading branch information
Robert Broglia committed Oct 24, 2023
1 parent 5e093a8 commit a2d96d1
Show file tree
Hide file tree
Showing 109 changed files with 543 additions and 498 deletions.
6 changes: 6 additions & 0 deletions 2600.emu/src/main/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ EmuSystem::NameFilterFunc EmuSystem::defaultFsFilter =
return IG::endsWithAnyCaseless(name, ".a26", ".bin");
};

A2600App::A2600App(ApplicationInitParams initParams, ApplicationContext &ctx):
EmuApp{initParams, ctx}, a2600System{ctx, *this}
{
audio().setStereo(false); // TODO: stereo mode
}

const char *EmuSystem::shortSystemName() const
{
return "2600";
Expand Down
7 changes: 1 addition & 6 deletions 2600.emu/src/main/MainApp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ class A2600App final: public EmuApp
public:
A2600System a2600System;

A2600App(ApplicationInitParams initParams, ApplicationContext &ctx):
EmuApp{initParams, ctx}, a2600System{ctx, *this}
{
audio().setStereo(false); // TODO: stereo mode
}

A2600App(ApplicationInitParams, ApplicationContext &);
auto &system() { return a2600System; }
const auto &system() const { return a2600System; }
AssetDesc vControllerAssetDesc(KeyInfo) const;
Expand Down
1 change: 1 addition & 0 deletions 2600.emu/src/main/input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// TODO: Some Stella types collide with MacTypes.h
#define Debugger DebuggerMac
#include <emuframework/EmuApp.hh>
#include <emuframework/EmuViewController.hh>
#include <emuframework/keyRemappingUtils.hh>
#undef Debugger
#include "MainSystem.hh"
Expand Down
6 changes: 6 additions & 0 deletions C64.emu/src/main/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ bool EmuSystem::handlesGenericIO = false;
bool EmuSystem::hasRectangularPixels = true;
bool EmuApp::needsGlobalInstance = true;

C64App::C64App(ApplicationInitParams initParams, ApplicationContext &ctx):
EmuApp{initParams, ctx}, c64System{ctx}
{
audio().setStereo(false);
}

const char *EmuSystem::shortSystemName() const
{
return "C64";
Expand Down
7 changes: 1 addition & 6 deletions C64.emu/src/main/MainApp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ class C64App final: public EmuApp
public:
C64System c64System;

C64App(ApplicationInitParams initParams, ApplicationContext &ctx):
EmuApp{initParams, ctx}, c64System{ctx}
{
audio().setStereo(false);
}

C64App(ApplicationInitParams, ApplicationContext &);
auto &system() { return c64System; }
const auto &system() const { return c64System; }
bool willCreateSystem(ViewAttachParams, const Input::Event &);
Expand Down
4 changes: 1 addition & 3 deletions EmuFramework/include/emuframework/AudioOptionView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public:
void loadStockItems();

protected:
static constexpr int MAX_APIS = 2;

BoolMenuItem snd;
BoolMenuItem soundDuringFastSlowMode;
TextMenuItem soundVolumeItem[4];
Expand All @@ -46,7 +44,7 @@ protected:
StaticArrayList<TextMenuItem, 5> audioRateItem;
MultiChoiceMenuItem audioRate;
IG_UseMemberIf(IG::Audio::Manager::HAS_SOLO_MIX, BoolMenuItem, audioSoloMix);
using ApiItemContainer = StaticArrayList<TextMenuItem, MAX_APIS + 1>;
using ApiItemContainer = StaticArrayList<TextMenuItem, Audio::systemApis.size() + 1>;
IG_UseMemberIf(IG::Audio::Config::MULTIPLE_SYSTEM_APIS, ApiItemContainer, apiItem);
IG_UseMemberIf(IG::Audio::Config::MULTIPLE_SYSTEM_APIS, MultiChoiceMenuItem, api);
StaticArrayList<MenuItem*, 22> item;
Expand Down
3 changes: 2 additions & 1 deletion EmuFramework/include/emuframework/ButtonConfigView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <emuframework/EmuAppHelper.hh>
#include <emuframework/EmuInput.hh>
#include <imagine/gfx/GfxText.hh>
#include <imagine/gfx/Quads.hh>
#include <imagine/gui/TableView.hh>
#include <imagine/gui/MenuItem.hh>
#include <imagine/input/config.hh>
Expand Down Expand Up @@ -48,7 +49,7 @@ private:
IG::WindowRect unbindB, cancelB;
Gfx::Text text;
Gfx::Text unbind, cancel;
Gfx::VertexBuffer<Gfx::IQuad::Vertex> rectVerts;
Gfx::IQuads quads;
SetDelegate onSetD;
const Input::Device &dev;
const Input::Device *savedDev{};
Expand Down
21 changes: 9 additions & 12 deletions EmuFramework/include/emuframework/EmuApp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@
#include <emuframework/EmuAudio.hh>
#include <emuframework/EmuVideo.hh>
#include <emuframework/EmuVideoLayer.hh>
#include <emuframework/EmuViewController.hh>
#include <emuframework/EmuInput.hh>
#include <emuframework/VController.hh>
#include <emuframework/Option.hh>
#include <emuframework/AutosaveManager.hh>
#include <emuframework/OutputTimingManager.hh>
#include <emuframework/RecentContent.hh>
#include <imagine/input/inputDefs.hh>
#include <imagine/input/android/MogaManager.hh>
#include <imagine/gui/ViewManager.hh>
#include <imagine/gui/TextEntry.hh>
#include <imagine/gui/MenuItem.hh>
#include <imagine/gui/ToastView.hh>
#include <imagine/fs/FSDefs.hh>
#include <imagine/base/ApplicationContext.hh>
#include <imagine/base/Application.hh>
Expand Down Expand Up @@ -62,6 +60,7 @@ namespace EmuEx

struct MainWindowData;
class EmuMainMenuView;
class EmuViewController;

enum class Tristate : uint8_t
{
Expand Down Expand Up @@ -226,6 +225,7 @@ public:
EmuVideoLayer &videoLayer() { return emuVideoLayer; }
EmuViewController &viewController();
const EmuViewController &viewController() const;
IG::ToastView &toastView();
const Screen &emuScreen() const;
Window &emuWindow();
AutosaveManager &autosaveManager() { return autosaveManager_; }
Expand Down Expand Up @@ -304,7 +304,6 @@ public:
void setVideoBrightness(float brightness, ImageChannel);

// System Options
auto &confirmOverwriteStateOption() { return optionConfirmOverwriteState; }
bool setAltSpeed(AltSpeedMode mode, int16_t speed);
int16_t altSpeed(AltSpeedMode mode) const { return altSpeedRef(mode); }
double altSpeedAsDouble(AltSpeedMode mode) const { return altSpeed(mode) / 100.; }
Expand All @@ -313,10 +312,8 @@ public:
void applyCPUAffinity(bool active);

// GUI Options
auto &pauseUnfocusedOption() { return optionPauseUnfocused; }
auto &systemActionsIsDefaultMenuOption() { return optionSystemActionsIsDefaultMenu; }
void setIdleDisplayPowerSave(bool on);
bool idleDisplayPowerSave() const { return optionIdleDisplayPowerSave; }
bool idleDisplayPowerSave() const { return idleDisplayPowerSave_; }
bool setFontSize(int size); // size in micro-meters
int fontSize() const;
void applyFontSize(Window &win);
Expand Down Expand Up @@ -353,7 +350,7 @@ public:

void postMessage(int secs, bool error, UTF16Convertible auto &&msg)
{
viewController().popup.post(IG_forward(msg), secs, error);
toastView().post(IG_forward(msg), secs, error);
}

void postErrorMessage(UTF16Convertible auto &&msg)
Expand Down Expand Up @@ -523,12 +520,8 @@ protected:
int16_t fastModeSpeed{defaultFastModeSpeed};
int16_t slowModeSpeed{defaultSlowModeSpeed};
Byte2Option optionFontSize;
Byte1Option optionPauseUnfocused;
Byte1Option optionConfirmOverwriteState;
Byte1Option optionNotificationIcon;
Byte1Option optionTitleBar;
Byte1Option optionSystemActionsIsDefaultMenu;
Byte1Option optionIdleDisplayPowerSave;
IG_UseMemberIf(Config::NAVIGATION_BAR, Byte1Option, optionLowProfileOSNav);
IG_UseMemberIf(Config::NAVIGATION_BAR, Byte1Option, optionHideOSNav);
IG_UseMemberIf(Config::STATUS_BAR, Byte1Option, optionHideStatusBar);
Expand All @@ -551,8 +544,12 @@ protected:
IG::PixelFormat renderPixelFmt;
IG::Rotation contentRotation_{IG::Rotation::ANY};
IG_UseMemberIf(Config::TRANSLUCENT_SYSTEM_UI, bool, layoutBehindSystemUI){};
bool idleDisplayPowerSave_{};
public:
bool showHiddenFilesInPicker{};
bool confirmOverwriteState{true};
bool systemActionsIsDefaultMenu{true};
IG_UseMemberIf(Config::windowFocus, bool, pauseUnfocused){true};
IG_UseMemberIf(Config::envIsAndroid, bool, useSustainedPerformanceMode){};
IG_UseMemberIf(Config::Input::BLUETOOTH && Config::BASE_CAN_BACKGROUND_APP, bool, keepBluetoothActive){};
IG_UseMemberIf(Config::Input::DEVICE_HOTSWAP, bool, notifyOnInputDeviceChange){true};
Expand Down
2 changes: 2 additions & 0 deletions EmuFramework/include/emuframework/EmuAppInlines.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <meta.h>
#include <imagine/config/version.h>
#include <main/MainApp.hh>
#include <imagine/gui/NavView.hh>
#include <imagine/input/android/MogaManager.hh>

const char *const IG::ApplicationContext::applicationName{CONFIG_APP_NAME};
const char *const IG::ApplicationContext::applicationId{CONFIG_APP_ID};
Expand Down
7 changes: 3 additions & 4 deletions EmuFramework/include/emuframework/EmuVideoLayer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

#include <emuframework/VideoImageOverlay.hh>
#include <emuframework/VideoImageEffect.hh>
#include <imagine/gfx/GfxSprite.hh>
#include <imagine/gfx/Buffer.hh>
#include <imagine/gfx/Quads.hh>
#include <imagine/gfx/Vec3.hh>
#include <imagine/pixmap/PixelFormat.hh>
#include <imagine/util/container/ArrayList.hh>
Expand Down Expand Up @@ -64,8 +63,8 @@ private:
IG::StaticArrayList<VideoImageEffect*, 1> effects;
EmuVideo &video;
VideoImageEffect userEffect;
Gfx::VertexBuffer<Gfx::Sprite::Vertex> spriteVerts;
Gfx::TextureSpan videoTex;
Gfx::ITexQuads quad;
Gfx::TextureSpan texture;
IG::WindowRect contentRect_;
Gfx::Vec3 brightness{1.f, 1.f, 1.f};
Gfx::Vec3 brightnessSrgb{1.f, 1.f, 1.f};
Expand Down
4 changes: 2 additions & 2 deletions EmuFramework/include/emuframework/EmuView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <imagine/gui/View.hh>
#include <imagine/time/Time.hh>
#include <imagine/gfx/GfxText.hh>
#include <imagine/gfx/GeomQuad.hh>
#include <imagine/gfx/Quads.hh>

namespace EmuEx
{
Expand Down Expand Up @@ -55,7 +55,7 @@ private:
struct FrameTimeStatsUI
{
Gfx::Text text;
Gfx::VertexBuffer<Gfx::IQuad::Vertex> bgVerts;
Gfx::IQuads bgQuads;
WRect rect{};
};
IG_UseMemberIf(enableFrameTimeStats, FrameTimeStatsUI, frameTimeStats);
Expand Down
2 changes: 1 addition & 1 deletion EmuFramework/include/emuframework/GUIOptionView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public:
void loadStockItems();

protected:
BoolMenuItem pauseUnfocused;
IG_UseMemberIf(Config::windowFocus, BoolMenuItem, pauseUnfocused);
TextMenuItem fontSizeItem[10];
MultiChoiceMenuItem fontSize;
BoolMenuItem notificationIcon;
Expand Down
3 changes: 2 additions & 1 deletion EmuFramework/include/emuframework/InputManagerView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <imagine/gui/TableView.hh>
#include <imagine/gui/MenuItem.hh>
#include <imagine/gfx/GfxText.hh>
#include <imagine/gfx/Quads.hh>
#include <imagine/input/config.hh>
#include <imagine/util/container/ArrayList.hh>
#include <vector>
Expand Down Expand Up @@ -47,7 +48,7 @@ public:

private:
Gfx::Text text;
Gfx::VertexBuffer<Gfx::IQuad::Vertex> rectVerts;
Gfx::IQuads quads;
};

class InputManagerView final: public TableView, public EmuAppHelper<InputManagerView>
Expand Down
3 changes: 2 additions & 1 deletion EmuFramework/include/emuframework/LoadProgressView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <emuframework/EmuApp.hh>
#include <emuframework/EmuAppHelper.hh>
#include <imagine/base/MessagePort.hh>
#include <imagine/gfx/Quads.hh>

namespace EmuEx
{
Expand All @@ -42,7 +43,7 @@ private:
MessagePortType msgPort{"LoadProgressView"};
EmuApp::CreateSystemCompleteDelegate onComplete;
Gfx::Text text;
Gfx::VertexBuffer<Gfx::IQuad::Vertex> progessBarVerts;
Gfx::IQuads progessBarQuads;
Input::Event originalEvent;
int pos{}, max{1};

Expand Down
17 changes: 8 additions & 9 deletions EmuFramework/include/emuframework/VController.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
#include <emuframework/inputDefs.hh>
#include <imagine/input/inputDefs.hh>
#include <imagine/input/DragTracker.hh>
#include <imagine/gfx/GfxSprite.hh>
#include <imagine/gfx/Texture.hh>
#include <imagine/gfx/Buffer.hh>
#include <imagine/gfx/Quads.hh>
#include <imagine/util/variant.hh>
#include <vector>
#include <span>
Expand Down Expand Up @@ -115,7 +114,7 @@ public:
}

protected:
Gfx::VertexBuffer<Gfx::LitSprite::Vertex> spriteVerts;
Gfx::ILitTexQuads spriteQuads;
Gfx::TextureSpan tex;
Gfx::Texture mapImg;
WRect padBaseArea, padArea;
Expand Down Expand Up @@ -170,9 +169,9 @@ public:
bool shiftIsActive() const;

protected:
Gfx::VertexBuffer<Gfx::Sprite::Vertex> spriteVerts;
Gfx::VertexBuffer<Gfx::IQuad::Vertex> rectVerts;
Gfx::TextureSpan kbTex;
Gfx::ITexQuads kbQuad;
Gfx::IQuads selectQuads;
Gfx::TextureSpan texture;
WRect bound;
int keyXSize{}, keyYSize{};
WRect selected{{-1, -1}, {-1, -1}};
Expand Down Expand Up @@ -204,9 +203,9 @@ public:
}

protected:
Gfx::VertexBuffer<Gfx::LitSprite::Vertex> spriteVerts;
Gfx::VertexBuffer<Gfx::IQuad::Vertex> rectVerts;
Gfx::TextureSpan tex;
Gfx::ILitTexQuads quad;
Gfx::IQuads boundQuads;
Gfx::TextureSpan texture;
Gfx::Color spriteColor;
WRect bounds_{};
WRect extendedBounds_{};
Expand Down
5 changes: 2 additions & 3 deletions EmuFramework/include/emuframework/VideoImageEffect.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

#include <imagine/gfx/Texture.hh>
#include <imagine/gfx/Program.hh>
#include <imagine/gfx/Buffer.hh>
#include <imagine/gfx/GfxSprite.hh>
#include <imagine/gfx/Quads.hh>
#include <imagine/util/enum.hh>
#include <optional>

Expand Down Expand Up @@ -59,7 +58,7 @@ public:
operator bool() const { return (bool)prog; }

private:
Gfx::VertexBuffer<Gfx::Sprite::Vertex> spriteVerts;
Gfx::ITexQuads quad;
Gfx::Texture renderTarget_;
Gfx::Program prog;
int srcTexelDeltaU{};
Expand Down
9 changes: 4 additions & 5 deletions EmuFramework/include/emuframework/VideoImageOverlay.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
You should have received a copy of the GNU General Public License
along with EmuFramework. If not, see <http://www.gnu.org/licenses/> */

#include <imagine/gfx/GfxSprite.hh>
#include <imagine/gfx/Texture.hh>
#include <imagine/gfx/Buffer.hh>
#include <imagine/gfx/Quads.hh>
#include <imagine/util/enum.hh>
#include <array>

Expand Down Expand Up @@ -50,10 +49,10 @@ private:
glm::i16vec2 pos;
glm::vec2 texCoord;
};
using Sprite = Gfx::SpriteBase<Vertex>;
using Quads = Gfx::BaseQuads<Vertex>;

Gfx::Texture img;
Gfx::VertexBuffer<Sprite::Vertex> spriteVerts;
Quads quad;
Gfx::Texture texture;
float intensity = 0.75f;
ImageOverlayId overlayId{};
bool multiplyBlend{};
Expand Down

0 comments on commit a2d96d1

Please sign in to comment.