Compare commits

...
Author SHA1 Message Date
t3hn3rd aac376fa22 progress: ImGui Port - Desktop UI + ImGui rendering performance overhaul
Full ImGui desktop environment (desktop.pas):
- Gradient wallpaper, taskbar with clock, start menu
- Desktop icons with click-to-open
- Windowed apps: System Info, Terminal, File Browser, Task Manager
- Terminal dispatches to registered kernel commands with output capture

Performance: Software rasterizer rewrite (imgui.pas, imgbridge.c)
- Quad detection: merge consecutive triangle pairs into fast rect fills
- 3 new fast-path rect fillers (solid/gradient/textured) using REP STOSD
  and 16.16 fixed-point integer inner loops
- Triangle rasterizer rewritten with fixed-point edge functions
- Back-buffer clear: DrawPixel loop -> REP STOSD (~200x faster)
- Render stat debug counters added

ISR-safe input buffering (imgbridge.c)
- Keyboard/mouse events buffered in lock-free ring buffers from ISR context
- Drained once per frame from main loop to prevent data races

Other changes:
- imguitypes.pas: InputTextFlags renumbered for cimgui 1.91+
- video.pas: backBufferLocation getter added
- kernel.pas: VFS init moved earlier, main loop uses desktop_frame,
  mouse hook uses ISR-safe buffering
- lmemorymanager.pas: kalloc/kfree exported with public aliases for C linkage
- scheduler.pas: Root_Task moved to interface for desktop task manager
- terminal.pas: freeParams exposed in interface
2026-02-25 23:28:12 +00:00
t3hn3rd 51a29244ed Imgui initial changes & shim (Claude Opus 4.6)
Can now draw ImGui demo.
2026-02-22 21:06:59 +00:00
25 changed files with 5373 additions and 117 deletions
+4 -1
View File
@@ -5,9 +5,12 @@ VOLUME ["/code"]
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN dpkg --add-architecture i386 RUN dpkg --add-architecture i386
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
curl dos2unix wget git make nasm binutils:i386 xorriso grub-pc-bin && \ curl dos2unix wget git make nasm binutils xorriso grub-pc-bin \
gcc-multilib g++-multilib && \
apt-get clean my room apt-get clean my room
RUN git clone --depth=1 --recurse-submodules https://github.com/cimgui/cimgui.git /cimgui
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
ARG FPC_VERSION=2.6.4 ARG FPC_VERSION=2.6.4
RUN curl -sL https://sourceforge.net/projects/freepascal/files/Linux/$FPC_VERSION/fpc-$FPC_VERSION.i386-linux.tar/download | tar -xf - && \ RUN curl -sL https://sourceforge.net/projects/freepascal/files/Linux/$FPC_VERSION/fpc-$FPC_VERSION.i386-linux.tar/download | tar -xf - && \
+1
View File
@@ -23,6 +23,7 @@ runOrFail() {
declare -a run_steps=( declare -a run_steps=(
"compile_stub.sh" "Failed to compile stub!" "compile_stub.sh" "Failed to compile stub!"
"compile_vergen.sh" "Versions failed to compile" "compile_vergen.sh" "Versions failed to compile"
"compile_imgui.sh" "Failed to compile ImGui!"
"compile_sources.sh" "Failed to compile FPC Sources!" "compile_sources.sh" "Failed to compile FPC Sources!"
"compile_link.sh" "Failed linking!" "compile_link.sh" "Failed linking!"
"compile_isogen.sh" "Failed to create ISO!" "compile_isogen.sh" "Failed to create ISO!"
+90
View File
@@ -0,0 +1,90 @@
#!/usr/bin/env bash
echo " "
echo "======================="
echo " "
echo "Compiling ImGui (cimgui)..."
echo " "
IMGUI_DIR=/cimgui
IMGUI_SRC=$IMGUI_DIR/imgui
BRIDGE_SRC=src/driver/video/imgui
# Flags shared by all C/C++ compilation units:
# -m32 -> i386 target
# -ffreestanding -> no implicit stdlib inclusion
# -fno-builtin -> don't inline memcpy/memset/etc. so our stubs are used
# -O2 -> optimise for speed
# -ffunction-sections -fdata-sections -> allow --gc-sections in linker
C_FLAGS="-m32 -ffreestanding -fno-builtin -O2 -ffunction-sections -fdata-sections"
# Extra flags for C++ translation units (cimgui/imgui sources):
# -fno-exceptions -> no stack-unwinding machinery
# -fno-rtti -> no typeinfo / dynamic_cast
# -fno-use-cxa-atexit -> don't emit __cxa_atexit calls for static dtors
# -fno-threadsafe-statics -> no guard-variable emission for local statics
# NOTE: *not* -ffreestanding / -fno-builtin here — imgui includes <cmath> and
# other hosted headers that refuse to compile in freestanding mode.
# The object files are archived into a static lib and linked freestanding;
# any hosted-stdlib calls (malloc/free/sin/cos/…) resolve to crtshim.c.
CPP_FLAGS="-m32 -O2 -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics -fno-stack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -DNDEBUG -DIMGUI_ENABLE_STB_TRUETYPE"
INCLUDE="-I$IMGUI_DIR -I$IMGUI_SRC"
echo "Compiling C runtime shim..."
gcc $C_FLAGS $INCLUDE \
-c $BRIDGE_SRC/crtshim.c \
-o lib/imgui_crtshim.o || { echo "Failed: crtshim.c"; exit 1; }
echo "Compiling render bridge..."
# imgbridge is compiled as C++ so it sees cimgui.h function declarations
# (C++ mode is required; the .c extension is overridden with -x c++)
g++ $CPP_FLAGS $INCLUDE \
-x c++ \
-DCIMGUI_DEFINE_ENUMS_AND_STRUCTS \
-c $BRIDGE_SRC/imgbridge.c \
-o lib/imgui_bridge.o || { echo "Failed: imgbridge.c"; exit 1; }
echo "Compiling cimgui wrapper..."
g++ $CPP_FLAGS $INCLUDE \
-c $IMGUI_DIR/cimgui.cpp \
-o lib/imgui_cimgui.o || { echo "Failed: cimgui.cpp"; exit 1; }
echo "Compiling imgui core..."
g++ $CPP_FLAGS $INCLUDE \
-c $IMGUI_SRC/imgui.cpp \
-o lib/imgui_core.o || { echo "Failed: imgui.cpp"; exit 1; }
echo "Compiling imgui draw..."
g++ $CPP_FLAGS $INCLUDE \
-c $IMGUI_SRC/imgui_draw.cpp \
-o lib/imgui_draw.o || { echo "Failed: imgui_draw.cpp"; exit 1; }
echo "Compiling imgui tables..."
g++ $CPP_FLAGS $INCLUDE \
-c $IMGUI_SRC/imgui_tables.cpp \
-o lib/imgui_tables.o || { echo "Failed: imgui_tables.cpp"; exit 1; }
echo "Compiling imgui widgets..."
g++ $CPP_FLAGS $INCLUDE \
-c $IMGUI_SRC/imgui_widgets.cpp \
-o lib/imgui_widgets.o || { echo "Failed: imgui_widgets.cpp"; exit 1; }
echo "Compiling imgui demo..."
g++ $CPP_FLAGS $INCLUDE \
-c $IMGUI_SRC/imgui_demo.cpp \
-o lib/imgui_demo.o || { echo "Failed: imgui_demo.cpp"; exit 1; }
echo "Archiving cimgui.a..."
# NOTE: imgui_bridge.o and imgui_crtshim.o are NOT in the archive because
# compile_link.sh already picks them up individually via find lib/ -name "*.o".
# Including them here would cause duplicate symbol errors.
ar rcs lib/cimgui.a \
lib/imgui_cimgui.o \
lib/imgui_core.o \
lib/imgui_draw.o \
lib/imgui_tables.o \
lib/imgui_widgets.o \
lib/imgui_demo.o || { echo "Failed: ar"; exit 1; }
echo "ImGui compiled successfully."
exit 0
+3 -1
View File
@@ -14,4 +14,6 @@ done;
objstring=lib/stub.o" "$objstring objstring=lib/stub.o" "$objstring
echo "Object Files: "$objstring echo "Object Files: "$objstring
echo " " echo " "
ld -m elf_i386 -s --gc-sections -Tlinker.script -o bin/kernel.bin $objstring LIBGCC=$(gcc -m32 -print-libgcc-file-name)
ld -m elf_i386 -s --gc-sections -Tlinker.script -o bin/kernel.bin $objstring \
--start-group lib/cimgui.a $LIBGCC --end-group
+1 -1
View File
@@ -4,4 +4,4 @@ echo "======================="
echo " " echo " "
echo "Compiling FPC Sources..." echo "Compiling FPC Sources..."
echo " " echo " "
fpc -Aelf -gw -g -gl -n -vlewn -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* -Fusrc/driver/net/* src/kernel.pas fpc -Aelf -gw -g -gl -n -vlewn -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* -Fusrc/driver/net/* -Fusrc/driver/video/* -Fusrc/driver/video/imgui/* src/kernel.pas
+20
View File
@@ -0,0 +1,20 @@
4023:CIMGUI_API float igGetWindowDpiScale(void);
4081:CIMGUI_API const ImVec4_c* igGetStyleColorVec4(ImGuiCol idx);
4082:CIMGUI_API ImVec2_c igGetCursorScreenPos(void);
4084:CIMGUI_API ImVec2_c igGetContentRegionAvail(void);
4085:CIMGUI_API ImVec2_c igGetCursorPos(void);
4086:CIMGUI_API float igGetCursorPosX(void);
4087:CIMGUI_API float igGetCursorPosY(void);
4091:CIMGUI_API ImVec2_c igGetCursorStartPos(void);
4350:CIMGUI_API void igBeginDisabled(bool disabled);
4372:CIMGUI_API ImVec2_c igGetItemRectMin(void);
4373:CIMGUI_API ImVec2_c igGetItemRectMax(void);
4374:CIMGUI_API ImVec2_c igGetItemRectSize(void);
4377:CIMGUI_API ImDrawList* igGetBackgroundDrawList(ImGuiViewport* viewport);
4378:CIMGUI_API ImDrawList* igGetForegroundDrawList_ViewportPtr(ImGuiViewport* viewport);
4387:CIMGUI_API ImVec2_c igCalcTextSize(const char* text,const char* text_end,bool hide_text_after_double_hash,float wrap_width);
4388:CIMGUI_API ImVec4_c igColorConvertU32ToFloat4(ImU32 in);
4405:CIMGUI_API bool igIsMouseDoubleClicked_Nil(ImGuiMouseButton button);
5092:CIMGUI_API ImDrawList* igGetForegroundDrawList_WindowPtr(ImGuiWindow* window);
5161:CIMGUI_API void igBeginDisabledOverrideReenable(void);
5244:CIMGUI_API bool igIsMouseDoubleClicked_ID(ImGuiMouseButton button,ImGuiID owner_id);
+10
View File
@@ -34,4 +34,14 @@ SECTIONS
} }
end = .; _end = .; __end = .; end = .; _end = .; __end = .;
kernel_end = .; kernel_end = .;
/DISCARD/ : {
*(.init_array*)
*(.fini_array*)
*(.ctors)
*(.dtors)
*(.eh_frame*)
*(.gcc_except_table*)
*(.note.GNU-stack)
}
} }
+45
View File
@@ -838,6 +838,18 @@ const
MAX_WINDOWS = 255; //< Maximum number of Windows open. MAX_WINDOWS = 255; //< Maximum number of Windows open.
DefaultWND = 0; //< The Window assigned for output when no Window is specified. (Default). DefaultWND = 0; //< The Window assigned for output when no Window is specified. (Default).
type
TWNDCaptureCallback = procedure(s: pchar);
var
WND_CaptureActive : boolean = false;
WND_CaptureHWND : uint32 = 0;
WND_CaptureBuf : array[0..511] of char;
WND_CaptureBufIdx : uint32 = 0;
WND_CaptureCallback : TWNDCaptureCallback = nil;
procedure flushCapture;
implementation implementation
uses uses
@@ -2259,6 +2271,7 @@ var
x,y: Byte; x,y: Byte;
begin begin
if WND_CaptureActive and (WND = WND_CaptureHWND) then exit;
if WindowManager.Windows[WND] <> nil then begin if WindowManager.Windows[WND] <> nil then begin
for y:=0 to Console_Properties.MAX_CELL_Y do begin for y:=0 to Console_Properties.MAX_CELL_Y do begin
for x:=0 to Console_Properties.MAX_CELL_X do begin for x:=0 to Console_Properties.MAX_CELL_X do begin
@@ -2419,8 +2432,26 @@ begin
console.writeintlnexWND(i, Console_Properties.Default_Attribute, WND); console.writeintlnexWND(i, Console_Properties.Default_Attribute, WND);
end; end;
procedure flushCapture;
begin
if WND_CaptureActive and (WND_CaptureCallback <> nil) and (WND_CaptureBufIdx > 0) then begin
WND_CaptureBuf[WND_CaptureBufIdx] := #0;
WND_CaptureCallback(@WND_CaptureBuf[0]);
WND_CaptureBufIdx := 0;
WND_CaptureBuf[0] := #0;
end;
end;
procedure writecharexWND(character: char; attributes: uint32; WND : uint32); procedure writecharexWND(character: char; attributes: uint32; WND : uint32);
begin begin
if WND_CaptureActive and (WND = WND_CaptureHWND) and (WND_CaptureCallback <> nil) then begin
if WND_CaptureBufIdx < 511 then begin
WND_CaptureBuf[WND_CaptureBufIdx] := character;
inc(WND_CaptureBufIdx);
WND_CaptureBuf[WND_CaptureBufIdx] := #0;
end;
exit;
end;
if WindowManager.Windows[WND] <> nil then begin if WindowManager.Windows[WND] <> nil then begin
WindowManager.Windows[WND]^.Buffer[WindowManager.Windows[WND]^.Cursor.Y][WindowManager.Windows[WND]^.Cursor.X].Character:= character; WindowManager.Windows[WND]^.Buffer[WindowManager.Windows[WND]^.Cursor.Y][WindowManager.Windows[WND]^.Cursor.X].Character:= character;
WindowManager.Windows[WND]^.Buffer[WindowManager.Windows[WND]^.Cursor.Y][WindowManager.Windows[WND]^.Cursor.X].Attributes:= attributes; WindowManager.Windows[WND]^.Buffer[WindowManager.Windows[WND]^.Cursor.Y][WindowManager.Windows[WND]^.Cursor.X].Attributes:= attributes;
@@ -2603,6 +2634,13 @@ end;
procedure backspaceWND(WND : uint32); procedure backspaceWND(WND : uint32);
begin begin
if WND_CaptureActive and (WND = WND_CaptureHWND) then begin
if WND_CaptureBufIdx > 0 then begin
dec(WND_CaptureBufIdx);
WND_CaptureBuf[WND_CaptureBufIdx] := #0;
end;
exit;
end;
if WindowManager.Windows[WND] <> nil then begin if WindowManager.Windows[WND] <> nil then begin
Dec(WindowManager.Windows[WND]^.Cursor.X); Dec(WindowManager.Windows[WND]^.Cursor.X);
writecharWND(' ', WND); writecharWND(' ', WND);
@@ -2659,6 +2697,13 @@ end;
procedure _safeincrement_y_WND(WND : uint32); procedure _safeincrement_y_WND(WND : uint32);
begin begin
if WND_CaptureActive and (WND = WND_CaptureHWND) and (WND_CaptureCallback <> nil) then begin
WND_CaptureBuf[WND_CaptureBufIdx] := #0;
WND_CaptureCallback(@WND_CaptureBuf[0]);
WND_CaptureBufIdx := 0;
WND_CaptureBuf[0] := #0;
exit;
end;
if WindowManager.Windows[WND] <> nil then begin if WindowManager.Windows[WND] <> nil then begin
WindowManager.Windows[WND]^.Cursor.Y:= WindowManager.Windows[WND]^.Cursor.Y+1; WindowManager.Windows[WND]^.Cursor.Y:= WindowManager.Windows[WND]^.Cursor.Y+1;
if WindowManager.Windows[WND]^.Cursor.Y > WindowManager.Windows[WND]^.WND_H-1 then begin if WindowManager.Windows[WND]^.Cursor.Y > WindowManager.Windows[WND]^.WND_H-1 then begin
+38 -33
View File
@@ -49,8 +49,12 @@ type
y : sint32; y : sint32;
end; end;
{ Mouse hook callback: receives absolute position and button states }
TMouseHook = procedure(x, y: sint32; lmb, rmb, mmb: boolean);
procedure init(); procedure init();
procedure DrawCursor; procedure DrawCursor;
procedure setHook(h: TMouseHook);
implementation implementation
@@ -67,6 +71,7 @@ var
LMouseDownPos : TMousePos; LMouseDownPos : TMousePos;
LMouseDown : Boolean; LMouseDown : Boolean;
RMouseDown : Boolean; RMouseDown : Boolean;
MouseHookCB : TMouseHook = nil;
procedure DrawCursor; procedure DrawCursor;
var var
@@ -174,43 +179,38 @@ begin
if Current.y > (Console.getConsoleProperties^.Height-8) then Current.y:= (Console.getConsoleProperties^.Height-8); if Current.y > (Console.getConsoleProperties^.Height-8) then Current.y:= (Console.getConsoleProperties^.Height-8);
end; end;
Cycle:= 0; Cycle:= 0;
if Packet.LMB_Down then begin { Track button transitions }
if not LMouseDown then begin if Packet.LMB_Down and (not LMouseDown) then begin
LMouseDown:= true; LMouseDown:= true;
LMouseDownPos.x:= Current.x; LMouseDownPos.x:= Current.x;
LMouseDownPos.y:= Current.y; LMouseDownPos.y:= Current.y;
//MouseDownEvent
console._mouseDown();
end;
end; end;
if not Packet.LMB_Down then begin if (not Packet.LMB_Down) and LMouseDown then
if LMouseDown then begin LMouseDown:= false;
If (Current.x = LMouseDownPos.x) and (Current.y = LMouseDownPos.y) then begin if Packet.RMB_Down and (not RMouseDown) then begin
Console._MouseClick(true); RMouseDown:= true;
end; RMouseDownPos.x:= Current.x;
//MouseUpEvent RMouseDownPos.y:= Current.y;
Console._MouseUp();
LMouseDown:= false;
end;
end; end;
if Packet.RMB_Down then begin if (not Packet.RMB_Down) and RMouseDown then
if not RMouseDown then begin
RMouseDown:= true;
RMouseDownPos.x:= Current.x;
RMouseDownPos.y:= Current.y;
end;
end;
if not Packet.RMB_Down then begin
if RMouseDown then begin
if (Current.x = RMouseDownPos.x) and (Current.y = RMouseDownPos.y) then begin
Console._MouseClick(false);
end;
end;
RMouseDown:= false; RMouseDown:= false;
{ Dispatch to hook or console }
if MouseHookCB <> nil then
MouseHookCB(Current.x, Current.y, Packet.LMB_Down, Packet.RMB_Down, Packet.MMB_Down)
else begin
if Packet.LMB_Down and (not LMouseDown) then console._mouseDown();
if (not Packet.LMB_Down) and LMouseDown then begin
if (Current.x = LMouseDownPos.x) and (Current.y = LMouseDownPos.y) then
Console._MouseClick(true);
Console._MouseUp();
end;
if (not Packet.RMB_Down) and RMouseDown then begin
if (Current.x = RMouseDownPos.x) and (Current.y = RMouseDownPos.y) then
Console._MouseClick(false);
end;
console.setMousePosition(Current.x, Current.y);
end; end;
console.setMousePosition(Current.x, Current.y);
end; end;
end; end;
end; end;
@@ -242,6 +242,11 @@ begin
pop_trace; pop_trace;
end; end;
procedure setHook(h: TMouseHook);
begin
MouseHookCB := h;
end;
procedure init(); procedure init();
var var
devid : TDeviceIdentifier; devid : TDeviceIdentifier;
+16 -2
View File
@@ -92,6 +92,7 @@ var
Root : PVFSObject; Root : PVFSObject;
CurrentDirectory : pchar = nil; CurrentDirectory : pchar = nil;
PushPopDirectory : PLinkedListBase; PushPopDirectory : PLinkedListBase;
MountDepth : uint32 = 0;
procedure init(); procedure init();
Function OpenFile(Filename : pchar; OpenMode : TOpenMode; WriteMode : TWriteMode; Lock : Boolean; Error : PError) : TFileHandle; Function OpenFile(Filename : pchar; OpenMode : TOpenMode; WriteMode : TWriteMode; Lock : Boolean; Error : PError) : TFileHandle;
@@ -104,6 +105,7 @@ function GetDirectories(Handle : uint32; Path : pchar) : PHashMap;
function PathValid(Path : pchar) : TIsPathValid; function PathValid(Path : pchar) : TIsPathValid;
function changeDirectory(Path : pchar) : TIsPathValid; function changeDirectory(Path : pchar) : TIsPathValid;
function getWorkingDirectory : pchar; function getWorkingDirectory : pchar;
function GetDirectoryListing(Path : pchar) : PHashMap;
//VFS Functions //VFS Functions
function newVirtualDirectory(Path : pchar) : TError; function newVirtualDirectory(Path : pchar) : TError;
@@ -288,6 +290,7 @@ begin
NewObj:= PVFSObject(hashmap.get(ht, item)); NewObj:= PVFSObject(hashmap.get(ht, item));
if NewObj = nil then begin if NewObj = nil then begin
GetObjectFromPath:= nil; GetObjectFromPath:= nil;
STRLL_Free(SplitPath);
tracer.push_trace('vfs.GetObjectFromPath.shortexit_1'); tracer.push_trace('vfs.GetObjectFromPath.shortexit_1');
exit; exit;
end; end;
@@ -304,6 +307,7 @@ begin
end; end;
end; end;
GetObjectFromPath:= Obj; GetObjectFromPath:= Obj;
STRLL_Free(SplitPath);
tracer.push_trace('vfs.GetObjectFromPath.exit'); tracer.push_trace('vfs.GetObjectFromPath.exit');
end; end;
@@ -348,7 +352,17 @@ begin
GetDirectoryListing:= nil; GetDirectoryListing:= nil;
end; end;
otMOUNT:begin otMOUNT:begin
GetDirectoryListing:= GetDirectoryListing(PVFSMount(Obj^.Reference)^.Path); { Safety: cap mount-follow depth to prevent infinite recursion
from circular mounts. Use a simple static counter. }
if MountDepth < 16 then begin
Inc(MountDepth);
GetDirectoryListing:= GetDirectoryListing(PVFSMount(Obj^.Reference)^.Path);
Dec(MountDepth);
end else
GetDirectoryListing:= nil;
end;
else begin
GetDirectoryListing:= nil;
end; end;
end; end;
end else begin end else begin
@@ -420,7 +434,7 @@ begin
NewObj^.Reference:= void(NewDev); NewObj^.Reference:= void(NewDev);
hashmap.add(ht, stringCopy(DeviceName), void(NewDev)); hashmap.add(ht, stringCopy(DeviceName), void(NewObj));
end; end;
{ Filesystem Functions } { Filesystem Functions }
+27 -11
View File
@@ -54,13 +54,8 @@ end;
procedure Flush(FrontBuffer : PVideoBuffer; BackBuffer : PVideoBuffer); procedure Flush(FrontBuffer : PVideoBuffer; BackBuffer : PVideoBuffer);
var var
idx : uint32;
Back,Front : uint32; Back,Front : uint32;
BufferSize : uint32; Count64 : uint32;
const
//COPY_WIDTH = 64; //Use this for 64bit copies
COPY_WIDTH = 128; //Use this for SSE copies
begin begin
//tracer.push_trace('doublebuffer.Flush.enter'); //tracer.push_trace('doublebuffer.Flush.enter');
@@ -68,11 +63,32 @@ begin
if ((FrontBuffer^.Width > BackBuffer^.Width) or (FrontBuffer^.Height > BackBuffer^.Height)) then exit; if ((FrontBuffer^.Width > BackBuffer^.Width) or (FrontBuffer^.Height > BackBuffer^.Height)) then exit;
Back:= BackBuffer^.Location; Back:= BackBuffer^.Location;
Front:= FrontBuffer^.Location; Front:= FrontBuffer^.Location;
BufferSize:= ( ( BackBuffer^.Width * BackBuffer^.Height * BackBuffer^.BitsPerPixel) div COPY_WIDTH ) - 1; { Number of 64-byte blocks: total_bytes / 64 = (W * H * BPP/8) / 64 }
for idx:=0 to BufferSize do begin Count64:= ( BackBuffer^.Width * BackBuffer^.Height * BackBuffer^.BitsPerPixel) div 512;
//Front[idx]:= Back[idx]; if Count64 = 0 then exit;
// -- TODO: Get SSE working here for 128bit copies -- { Bulk SSE copy: 4 x MOVAPS (64 bytes) per iteration.
__SSE_128_memcpy(Back + (idx * 16), Front + (idx * 16)); 4x fewer loop iterations than the old per-16-byte function-call loop. }
asm
PUSH ESI
PUSH EDI
MOV ESI, Back
MOV EDI, Front
MOV ECX, Count64
@sseloop:
MOVAPS XMM0, [ESI]
MOVAPS XMM1, [ESI + 16]
MOVAPS XMM2, [ESI + 32]
MOVAPS XMM3, [ESI + 48]
MOVAPS [EDI], XMM0
MOVAPS [EDI + 16], XMM1
MOVAPS [EDI + 32], XMM2
MOVAPS [EDI + 48], XMM3
ADD ESI, 64
ADD EDI, 64
DEC ECX
JNZ @sseloop
POP EDI
POP ESI
end; end;
//tracer.push_trace('doublebuffer.Flush.exit'); //tracer.push_trace('doublebuffer.Flush.exit');
end; end;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+6
View File
@@ -40,6 +40,7 @@ function frontBufferBpp : uint8;
function backBufferWidth : uint32; function backBufferWidth : uint32;
function backBufferHeight : uint32; function backBufferHeight : uint32;
function backBufferBpp : uint8; function backBufferBpp : uint8;
function backBufferLocation : uint32;
Procedure basicFDrawTexture(Buffer : PVideoBuffer; X : uint32; Y : uint32; Texture : PTexture); Procedure basicFDrawTexture(Buffer : PVideoBuffer; X : uint32; Y : uint32; Texture : PTexture);
@@ -315,4 +316,9 @@ begin
backBufferBpp:= VideoInterface.BackBuffer.BitsPerPixel; backBufferBpp:= VideoInterface.BackBuffer.BitsPerPixel;
end; end;
function backBufferLocation : uint32;
begin
backBufferLocation:= VideoInterface.BackBuffer.Location;
end;
end. end.
+16
View File
@@ -35,10 +35,26 @@ implementation
procedure Main(); procedure Main();
var var
i : integer; i : integer;
faulting_addr : uint32;
begin begin
CLI; CLI;
{ Read CR2 — the linear address that caused the page fault }
asm
MOV EAX, CR2
MOV faulting_addr, EAX
end;
correctInterruptRegisters(true); correctInterruptRegisters(true);
console.writestring('[PF] Faulting address: ');
console.writehexln(faulting_addr);
if IntSpec <> nil then begin
console.writestring('[PF] Faulting EIP: ');
console.writehexln(IntSpec^.EIP);
end;
if IntErr <> nil then begin
console.writestring('[PF] Error code: ');
console.writehexln(IntErr^.Error);
end;
BSOD('PF', 'Page Fault.'); BSOD('PF', 'Page Fault.');
console.writestringln('Page Fault.'); console.writestringln('Page Fault.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
+1 -1
View File
@@ -22,7 +22,7 @@ unit multiboot;
interface interface
const const
KERNEL_STACKSIZE = $4000; KERNEL_STACKSIZE = $40000;
MULTIBOOT_BOOTLOADER_MAGIC = $2BADB002; MULTIBOOT_BOOTLOADER_MAGIC = $2BADB002;
type type
+30
View File
@@ -152,8 +152,38 @@ var
procedure init(); procedure init();
{ 64-bit multiply compilerproc required by FPC on i386 when
any int64/uint64 arithmetic occurs (e.g. sint32 * uint32 promotion).
Must live in the system unit so the compiler can resolve it. }
function fpc_mul_int64(f1, f2: int64): int64; compilerproc;
implementation implementation
function fpc_mul_int64(f1, f2: int64): int64; [public, alias: 'FPC_MUL_INT64']; compilerproc;
{ 64×64→64 multiply using three 32-bit MUL instructions.
We only keep the low 64 bits of the 128-bit product. }
var
res: int64;
begin
asm
MOV EAX, DWORD [f1] { f1_lo }
MUL DWORD [f2] { EDX:EAX = f1_lo * f2_lo }
MOV DWORD [res], EAX { result_lo }
MOV ECX, EDX { carry = high(f1_lo * f2_lo) }
MOV EAX, DWORD [f1] { f1_lo }
MUL DWORD [f2+4] { EDX:EAX = f1_lo * f2_hi }
ADD ECX, EAX { carry += low(f1_lo * f2_hi) }
MOV EAX, DWORD [f1+4] { f1_hi }
MUL DWORD [f2] { EDX:EAX = f1_hi * f2_lo }
ADD ECX, EAX { carry += low(f1_hi * f2_lo) }
MOV DWORD [res+4], ECX { result_hi }
end;
fpc_mul_int64 := res;
end;
procedure init(); procedure init();
begin begin
ASURO_KERNEL_START := uint32(@AK_START); ASURO_KERNEL_START := uint32(@AK_START);

Some files were not shown because too many files have changed in this diff Show More