summaryrefslogtreecommitdiff
path: root/src/renderer/OpenGL.zig
AgeCommit message (Collapse)Author
2025-09-18renderer: create explicit sampler state for custom shadersMitchell Hashimoto
The GLSL to MSL conversion process uses a passed-in sampler state for the `iChannel0` parameter and we weren't providing it. This magically worked on Apple Silicon for unknown reasons but failed on Intel GPUs. In normal, hand-written MSL, we'd explicitly create the sampler state as a normal variable (we do this in `shaders.metal` already!), but the Shadertoy conversion stuff doesn't do this, probably because the exact sampler parameters can't be safely known. This fixes a Metal validation error when using custom shaders: ``` -[MTLDebugRenderCommandEncoder validateCommonDrawErrors:]:5970: failed assertion `Draw Errors Validation Fragment Function(main0): missing Sampler binding at index 0 for iChannel0Smplr[0]. ```
2025-09-05gtk: the Future is NowLeah Amelia Chen
2025-09-05gtk: nuke the legacy apprt from orbitLeah Amelia Chen
We don't really have any large outstanding regressions on -ng to warrant keeping this alive anymore. ¡Adiós!
2025-07-18apprt/gtk-ng: hook up surface initializationMitchell Hashimoto
2025-07-05renderer/opengl: explicit texture optionsQwerasd
This sets up for a couple improvments (see TODO comments) and also sets the glyph atlas textures to nearest neighbor sampling since we can do that now that we never scale glyphs.
2025-07-04Nuke GLFW from OrbitMitchell Hashimoto
This deletes the GLFW apprt from the Ghostty codebase. The GLFW apprt was the original apprt used by Ghostty (well, before Ghostty even had the concept of an "apprt" -- it was all just a single application then). It let me iterate on the core terminal features, rendering, etc. without bothering about the UI. It was a good way to get started. But it has long since outlived its usefulness. We've had a stable GTK apprt for Linux (and Windows via WSL) and a native macOS app via libghostty for awhile now. The GLFW apprt only remained within the tree for a few reasons: 1. Primarily, it provided a faster feedback loop on macOS because building the macOS app historically required us to hop out of the zig build system and into Xcode, which is slow and cumbersome. 2. It was a convenient way to narrow whether a bug was in the core Ghostty codebase or in the apprt itself. If a bug was in both the glfw and macOS app then it was likely in the core. 3. It provided us a way on macOS to test OpenGL. All of these reasons are no longer valid. Respectively: 1. Our Zig build scripts now execute the `xcodebuild` CLI directly and can open the resulting app, stream logs, etc. This is the same experience we have on Linux. (Xcode has always been a dependency of building on macOS in general, so this is not cumbersome.) 2. We have a healthy group of maintainers, many of which have access to both macOS and Linux, so we can quickly narrow down bugs regardless of the apprt. 3. Our OpenGL renderer hasn't been compatible with macOS for some time now, so this is no longer a useful feature. At this point, the GLFW apprt is just a burden. It adds complexity across the board, and some people try to run Ghostty with it in the real world and get confused when it doesn't work (it's always been lacking in features and buggy compared to the other apprts). So, it's time to say goodbye. Its bittersweet because it is a big part of Ghostty's history, but we've grown up now and it's time to move on. Thank you, goodbye. (NOTE: If you are a user of the GLFW apprt, then please fork the project prior to this commit or start a new project based on it. We've warned against using it for a very, very long time now.)
2025-06-26renderer/OpenGL: switch image texture from Rect to 2DQwerasd
We were using the Rectangle target for simpler addressing, since that allows for pixel coordinates instead of normalized coordinates, but there are downsides to rectangle textures, including not supporting compressed texture formats, and we do probably want to use compressed formats in the future, so I'm making this change now.
2025-06-26renderer/OpenGL: revert change to compressed texture formatQwerasd
This was applied to the wrong thing by accident, making the custom shader ping-pong textures compressed, which breaks custom shaders because compressed texture formats are not color renderable. Additionally, I've not switched the compressed format to the correct texture options, because I tried that and it turns out that the default compression applied by drivers can't be trusted to be good quality and generally speaking looks terrible. In the future we can explore doing the compression ourselves CPU-side with something like b7enc_rdo.
2025-06-25renderer/OpenGL: use compressed texture formats for imagesQwerasd
BPTC is required to be available OpenGL >= 4.2 and our minimum is 4.3 so this is safe in terms of support. I tested briefly in a VM and didn't encounter any problems so this should just be a complete win. (Note: texture data is already automatically compressed on Metal)
2025-06-25renderer: add support for background imagesQwerasd
Adds support for background images via the `background-image` config. Resolves #3645, supersedes PRs #4226 and #5233. See docs of added config keys for usage details.
2025-06-23renderer: fix color glyph rendering under OpenGLQwerasd
Also changes color atlas to always use an sRGB internal format so that the texture reads automatically linearize the colors. Renames the misleading `rgba` atlas format to `bgra`, since both FreeType and CoreText are set up to draw color glyphs in bgra.
2025-06-23renderer: unify `image.zig`Qwerasd
The code in metal/image.zig and opengl/image.zig was virtually identical save for the texture options, so I've moved that to the GraphicsAPI and unified them in to renderer/image.zig
2025-06-23renderer: unify `cell.zig`Qwerasd
The code in metal/cell.zig and opengl/cell.zig was virtually identical aside from the types for the cell data, moved it to renderer/cell.zig
2025-06-22renderer: add custom shader cursor uniformsQwerasd
Based on / supersedes PR #6912, implements discussion #6901 Co-authored-by: Krone Corylus <ahustinkrone@gmail.com>
2025-06-20renderer: move drawFrame AutoreleasePool handling to GraphicsAPIQwerasd
Introduces `drawFrameStart`/`drawFrameEnd` for this purpose.
2025-06-20naming(GraphicsAPI): repeat -> presentLastTargetQwerasd
2025-06-20style(renderer): explicit empty error set for OpenGL initQwerasd
2025-06-20style(renderer): explicit error setsQwerasd
2025-06-20fix window cross-compilationQwerasd
2025-06-20renderer: disable multi-buffering for OpenGLQwerasd
Frames are sequential for OpenGL since the completion handler always calls `glFinish`, so the extra buffers do nothing but waste memory.
2025-06-20renderer: big rework, graphics API abstraction layers, unified logicQwerasd
This commit is very large, representing about a month of work with many interdependent changes that don't separate cleanly in to atomic commits. The main change here is unifying the renderer logic to a single generic renderer, implemented on top of an abstraction layer over OpenGL/Metal. I'll write a more complete summary of the changes in the description of the PR.
2025-05-15fix(renderer): Don't force images to grid/cell sizesQwerasd
This problem was introduced by f091a69 (PR #6675). I've gone ahead and overhauled the placement positioning logic as well; it was doing a lot of expensive calls before, I've significantly reduced that. Clipping partially off-screen images is now handled entirely by the renderer, rather than while preparing the placement, and as such the grid position passed to the image shader is now signed.
2025-04-21renderer/opengl: reduce flickering/stretching on resizeMitchell Hashimoto
Fixes #2446 Two separate issues: 1. Ensure that our screen size matches the viewport size when drawFrame is called. By the time drawFrame is called, GTK will have updated the OpenGL context, but our deferred screen size may still be incorrect since we wait for the pty to update the screen size. 2. Do not clear our cells buffer when the screen size changes, instead changing to a mechanism that only clears the buffers when we have over 50% wasted space. Co-authored-by: Andrew de los Reyes <adlr@rivosinc.com>
2025-03-13Fix aspect ratio when rendering images with kitty protocol (#6675)Mitchell Hashimoto
Fixes https://github.com/ghostty-org/ghostty/issues/6673 <img width="914" alt="image" src="https://github.com/user-attachments/assets/010a1304-0d46-46ec-9a82-87a8d8fbea1b" />
2025-03-12fix tests building on LinuxMitchell Hashimoto
2025-03-12Lots of 0.14 changesMitchell Hashimoto
2025-03-12Fix aspect ratio when rendering images with kitty protocolBryan Lee
2025-03-06renderer(OpenGL): pass cell_width to glyph rendererTim Culverhouse
When adding a glyph, we didn't pass the expected width to the glyph renderer. This can be helpful when scaling emoji, as will happen in the next commit.
2025-03-06chore: zig fmtTim Culverhouse
2025-01-23use main buffer and copy data to fbo texture (opengl) (#5294)Julia
NEEDS REVIEW continuation of #5037 resolves #4729 renders all shaders to the default buffer and then copies it to the designated custom shader texture. this is a draft pr because: - it introduces a new shader "pipeline" which doesnt fit in with how the system was designed to work (which is only rendering to the fbo) - im not sure if this is the best way to achieve shaders being able to sample their output while also drawing to the screen. the cusom fbo (previous implementation) was useful in that it modularized the custom shader stage in rendering --------- Co-authored-by: Mitchell Hashimoto <m@mitchellh.com>
2025-01-20fix(renderer): clip terminal contents to expected grid size (#4523)Qwerasd
This significantly improves the robustness of the renderers since it prevents synchronization issues from causing memory corruption due to out of bounds read/writes while building the cells. TODO: when viewport is narrower than renderer grid size, fill blank margin with bg color- currently appears as black, this only affects DECCOLM right now, and possibly could create single-frame artefacts during poorly managed resizes, but it's not ideal regardless.
2025-01-20render consecutive shaders to the fbojulia
not that big. see comments
2025-01-07refactor(font): move `Metrics` from `Face` to `Collection` (#4739)Mitchell Hashimoto
This refactor enables two very significant improvements to our font handling, which I will be implementing next: 1. Automatically adjust size of fallback faces to better align with the primary face, a la CSS [`font-size-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size-adjust). [^1] 2. Move glyph resizing/positioning out of GPU-land and in to `renderGlyph` and apply alignment/resizing rules from the nerd fonts patcher[^2] to the glyphs at rasterization time, so that we can ensure exact cell fits and swap out our embedded JB Mono with an unpatched version with a separate dedicated symbols-only nerd font. In addition to being necessary prep work for those two changes, this PR is also a minor but real stand-alone improvement. By only computing the cell metrics for our primary font, we avoid a *lot* of wasted work when loading fallback fonts, and also avoid that being a source of load errors, which we don't yet handle gracefully[^3]. To validate this PR I've run the full set of font backend tests locally on my Mac with no failures, and did a sanity check of running Ghostty with both renderers and with CoreText and FreeType font backends and then `cat`ing a file that requires fallback fonts to render, and everything looks correct. [^1]: #3029 [^2]: The alignment and resizing rules for the nerd font symbols are defined in the patcher [here](https://github.com/ryanoasis/nerd-fonts/blob/6d0b8ba05af0d1380905aee1a136c1dedf71c1db/font-patcher#L866-L1151) [^3]: #2991
2025-01-07renderer: respect reverse with cursor-invert-fg-bgGregory Anders
2025-01-06refactor(font): move `Metrics` out of `face`Qwerasd
in preparation to move ownership of metrics from faces to collections
2025-01-05font(coretext): add config to adjust strength of `font-thicken`. (#4531)Mitchell Hashimoto
This is achieved by rendering to an alpha-only context rather than a normal single-channel context, and adjusting the brightness at which CoreText thinks it's drawing the glyph, which affects how it applies font smoothing (which is what `font-thicken` enables).
2025-01-03font(coretext): add config to adjust strength of `font-thicken`.Qwerasd
This is achieved by rendering to an alpha-only context rather than a normal single-channel context, and adjusting the brightness at which coretext thinks it's drawing the glyph, which affects how it applies font smoothing (which is what `font-thicken` enables).
2025-01-03Fixing a few typos in the source code comments (#4529)Peter Cock
2025-01-03Correct typos and update typos.tomlBryan Lee
2024-12-29renderer: track if fg/bg/cursor color is explicitly set by an OSC (#3228)Mitchell Hashimoto
The renderer must track if the foreground, background, and cursor colors are explicitly set by an OSC so that changes are not overridden when the config file is reloaded. Fixes: https://github.com/ghostty-org/ghostty/issues/2795
2024-12-28Fix the typing error when building on LinuxXiaoYan Li
Co-authored-by: Gareth Widlansky <101901964+gerblesh@users.noreply.github.com>
2024-12-28Use premultiplied alpha for renderer clearColorXiaoyan Li
Fixes #3324
2024-12-26renderer: track if fg/bg/cursor color is explicitly set by an OSCGregory Anders
The renderer must track if the foreground, background, and cursor colors are explicitly set by an OSC so that changes are not overridden when the config file is reloaded.
2024-12-23kittygfx: placement with rows (r) param scrolls properly out of viewportMitchell Hashimoto
Fixes #2332 Two bugs fixed to fix this behavior: 1. Our destination height didn't account for the top-left being offscreen. 2. We were using the wrong height for the source rectangle. When a rows param (r=) is specified, the image height and destination height are at different scales. We were using the viewport scale for the offset but it should be the image scale.
2024-12-23kittygfx: z-index handling fixesMitchell Hashimoto
Fixes #2921 Our z-index handling was pretty much completely broken, hence I can't think of a better initial commit message. We were splitting the placements at the wrong points and just generally putting images in the wrong z-index. I'm shocked this didn't come up earlier.
2024-11-20renderer/opengl: fix memory leak when copying font featuresMitchell Hashimoto
2024-11-14apprt/gtk: use new size structsMitchell Hashimoto
2024-11-14renderer/opengl: update to new size structMitchell Hashimoto
2024-11-07terminal: PageList rename "page" to "node" everywhereMitchell Hashimoto
This is more correct: a pagelist is a linked list of nodes, not pages. The nodes themselves contain pages but we were previously calling the nodes "pages" which was confusing, especially as I plan some future changes to the way pages are stored.
2024-10-21implement overline decoration (SGR 53/55)Marijn Besseling