software renderer, part F

This commit is contained in:
tildearrow 2024-04-08 22:24:08 -05:00
parent 823876a5c6
commit c5a811f58e
5 changed files with 45 additions and 11 deletions

View file

@ -147,7 +147,7 @@ inline ImU32 color_convert_float4_to_u32(const ImVec4 &in)
// TODO: make it 32-bit or else
using Int = int32_t;
const Int kFixedBias = 256;
const Int kFixedBias = 1;
struct Point
{

View file

@ -6296,6 +6296,17 @@ bool FurnaceGUI::loop() {
}
#endif
if (settings.displayRenderTime) {
String renderTime=fmt::sprintf("%.0fµs",ImGui::GetIO().DeltaTime*1000000.0);
String renderTime2=fmt::sprintf("%.1f FPS",1.0/ImGui::GetIO().DeltaTime);
ImDrawList* dl=ImGui::GetForegroundDrawList();
ImVec2 markPos=ImVec2(canvasW-ImGui::CalcTextSize(renderTime.c_str()).x-60.0*dpiScale,4.0*dpiScale);
ImVec2 markPos2=ImVec2(canvasW-ImGui::CalcTextSize(renderTime2.c_str()).x-160.0*dpiScale,4.0*dpiScale);
dl->AddText(markPos,0xffffffff,renderTime.c_str());
dl->AddText(markPos2,0xffffffff,renderTime2.c_str());
}
layoutTimeEnd=SDL_GetPerformanceCounter();
// backup trigger

View file

@ -1842,6 +1842,7 @@ class FurnaceGUI {
int cursorWheelStep;
int vsync;
int frameRateLimit;
int displayRenderTime;
unsigned int maxUndoSteps;
String mainFontPath;
String headFontPath;
@ -2073,6 +2074,7 @@ class FurnaceGUI {
cursorWheelStep(0),
vsync(1),
frameRateLimit(60),
displayRenderTime(0),
maxUndoSteps(100),
mainFontPath(""),
headFontPath(""),

View file

@ -216,6 +216,13 @@ void FurnaceGUI::drawOsc() {
ImU32 guideColor=ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_GUIDE]);
ImGui::ItemSize(size,style.FramePadding.y);
if (ImGui::ItemAdd(rect,ImGui::GetID("wsDisplay"))) {
if (safeMode || renderBackend==GUI_BACKEND_SOFTWARE) {
dl->AddRectFilled(
inRect.Min,
inRect.Max,
ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_BG4])
);
} else {
dl->AddRectFilledMultiColor(
inRect.Min,
inRect.Max,
@ -225,6 +232,7 @@ void FurnaceGUI::drawOsc() {
ImGui::GetColorU32(uiColors[GUI_COLOR_OSC_BG3]),
settings.oscRoundedCorners?(8.0f*dpiScale):0.0f
);
}
dl->AddLine(
ImLerp(rect.Min,rect.Max,ImVec2(0.0f,0.5f)),
@ -367,7 +375,7 @@ void FurnaceGUI::drawOsc() {
dl->Flags=prevFlags;
if (settings.oscBorder) {
dl->AddRect(inRect.Min,inRect.Max,borderColor,settings.oscRoundedCorners?(8.0f*dpiScale):0.0f,0,1.5f*dpiScale);
dl->AddRect(inRect.Min,inRect.Max,borderColor,(settings.oscRoundedCorners && !(safeMode || renderBackend==GUI_BACKEND_SOFTWARE))?(8.0f*dpiScale):0.0f,0,1.5f*dpiScale);
}
}
if (oscZoomSlider && ImGui::IsItemHovered()) {

View file

@ -476,6 +476,12 @@ void FurnaceGUI::drawSettings() {
ImGui::SetTooltip("only applies when VSync is disabled.");
}
bool displayRenderTimeB=settings.displayRenderTime;
if (ImGui::Checkbox("Display render time",&displayRenderTimeB)) {
settings.displayRenderTime=displayRenderTimeB;
settingsChanged=true;
}
bool renderClearPosB=settings.renderClearPos;
if (ImGui::Checkbox("Late render clear",&renderClearPosB)) {
settings.renderClearPos=renderClearPosB;
@ -4006,6 +4012,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
settings.vsync=conf.getInt("vsync",1);
settings.frameRateLimit=conf.getInt("frameRateLimit",100);
settings.displayRenderTime=conf.getInt("displayRenderTime",0);
settings.chanOscThreads=conf.getInt("chanOscThreads",0);
settings.renderPoolThreads=conf.getInt("renderPoolThreads",0);
@ -4512,6 +4519,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
clampSetting(settings.cursorWheelStep,0,1);
clampSetting(settings.vsync,0,4);
clampSetting(settings.frameRateLimit,0,1000);
clampSetting(settings.displayRenderTime,0,1);
if (settings.exportLoops<0.0) settings.exportLoops=0.0;
if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0;
@ -4537,6 +4545,7 @@ void FurnaceGUI::writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
conf.set("vsync",settings.vsync);
conf.set("frameRateLimit",settings.frameRateLimit);
conf.set("displayRenderTime",settings.displayRenderTime);
conf.set("chanOscThreads",settings.chanOscThreads);
conf.set("renderPoolThreads",settings.renderPoolThreads);
@ -5531,6 +5540,10 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
sty.FrameRounding=0.0f;
sty.GrabRounding=0.0f;
sty.FrameShading=0.0f;
sty.TabRounding=0.0f;
sty.ScrollbarRounding=0.0f;
sty.ChildRounding=0.0f;
sty.PopupRounding=0.0f;
sty.AntiAliasedLines=false;
sty.AntiAliasedLinesUseTex=false;
sty.AntiAliasedFill=false;