Skip to content

Commit

Permalink
Added more VT codes; Split extremely long lines for efficiency; Clean…
Browse files Browse the repository at this point in the history
…ed up zero slot handling; Added flags to splat2; Made VirtualAlloc2 fallback try multiple addresses; Other various cleanup
  • Loading branch information
cmuratori committed Jul 10, 2021
1 parent ab165e6 commit 60e3eaf
Show file tree
Hide file tree
Showing 14 changed files with 787 additions and 500 deletions.
17 changes: 13 additions & 4 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
setlocal

where /q cl || (
echo ERROR: please run this from MSVC command prompt
echo ERROR: "cl" not found - please run this from the MSVC x64 native tools command prompt.
exit /b 1
)

if "%Platform%" neq "x64" (
echo ERROR: Platform is not "x64" - please run this from the MSVC x64 native tools command prompt.
exit /b 1
)

call fxc /nologo /T cs_5_0 /E ComputeMain /O3 /WX /Fh refterm_cs.h /Vn ReftermCSShaderBytes /Qstrip_reflect /Qstrip_debug /Qstrip_priv refterm.hlsl
call fxc /nologo /T ps_5_0 /E PixelMain /O3 /WX /Fh refterm_ps.h /Vn ReftermPSShaderBytes /Qstrip_reflect /Qstrip_debug /Qstrip_priv refterm.hlsl
call fxc /nologo /T vs_5_0 /E VertexMain /O3 /WX /Fh refterm_vs.h /Vn ReftermVSShaderBytes /Qstrip_reflect /Qstrip_debug /Qstrip_priv refterm.hlsl
Expand All @@ -21,9 +26,13 @@ set BASE_FILES=refterm.c refterm_example_dwrite.cpp
call cl -D_DEBUG -Od -Ferefterm_debug_msvc.exe %CFLAGS% %BASE_FILES% /link %LDFLAGS% /subsystem:windows
call cl -O2 -Ferefterm_release_msvc.exe %CFLAGS% %BASE_FILES% /link %LDFLAGS% /subsystem:windows

call clang %CLANGCompileFlags% %CLANGLinkFlags% %BASE_FILES% -o refterm_debug_clang.exe
call clang -O3 %CLANGCompileFlags% %CLANGLinkFlags% %BASE_FILES% -o refterm_release_clang.exe

call cl -O2 -Fesplat.exe %CFLAGS% splat.cpp /link %LDFLAGS% /subsystem:console
call cl -O2 -Fesplat2.exe %CFLAGS% splat2.cpp /link %LDFLAGS% /subsystem:console

where /q clang || (
echo WARNING: "clang" not found - to run the fastest version of refterm, please install CLANG.
exit /b 1
)

call clang %CLANGCompileFlags% %CLANGLinkFlags% %BASE_FILES% -o refterm_debug_clang.exe
call clang -O3 %CLANGCompileFlags% %CLANGLinkFlags% %BASE_FILES% -o refterm_release_clang.exe
4 changes: 4 additions & 0 deletions refterm.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#if !_M_X64
#error refterm requires a 64-bit platform
#endif

#define COBJMACROS
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
Expand Down
18 changes: 15 additions & 3 deletions refterm.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ cbuffer ConstBuffer : register(b0)
uint2 TopLeftMargin;
uint BlinkModulate;
uint MarginColor;

uint StrikeMin;
uint StrikeMax;
uint UnderlineMin;
uint UnderlineMax;
};

StructuredBuffer<TerminalCell> Cells : register(t0);
Expand Down Expand Up @@ -54,12 +59,19 @@ float4 ComputeOutputColor(uint2 ScreenPos)
float3 Foreground = UnpackColor(Cell.Foreground);
float3 Blink = UnpackColor(BlinkModulate);

float tBlink = float(Cell.Background >> 31);
float3 Modulate = lerp(float3(1, 1, 1), Blink, tBlink);
Foreground *= Modulate;

if((Cell.Foreground >> 28) & 1) Foreground *= Blink;
if((Cell.Foreground >> 25) & 1) Foreground *= 0.5;

// TODO: proper ClearType blending
Result = (1-GlyphTexel.a)*Background + GlyphTexel.rgb*Foreground;

if( ((Cell.Foreground >> 27) & 1) &&
(CellPos.y >= UnderlineMin) &&
(CellPos.y < UnderlineMax)) Result.rgb = Foreground.rgb;
if( (Cell.Foreground >> 31) &&
(CellPos.y >= StrikeMin) &&
(CellPos.y < StrikeMax)) Result.rgb = Foreground.rgb;
}
else
{
Expand Down
Loading

0 comments on commit 60e3eaf

Please sign in to comment.