mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
Revert "macos: enable Metal shader logging"
This reverts commit aad101565abff3368af76e8c2e93cbe7c278a89f.
This commit is contained in:
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@ -196,9 +196,6 @@ jobs:
|
|||||||
name: ghostty
|
name: ghostty
|
||||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||||
|
|
||||||
- name: XCode Select
|
|
||||||
run: sudo xcode-select -s /Applications/Xcode_16.0.app
|
|
||||||
|
|
||||||
- name: Test All
|
- name: Test All
|
||||||
run: |
|
run: |
|
||||||
# OpenGL
|
# OpenGL
|
||||||
@ -355,9 +352,6 @@ jobs:
|
|||||||
name: ghostty
|
name: ghostty
|
||||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||||
|
|
||||||
- name: XCode Select
|
|
||||||
run: sudo xcode-select -s /Applications/Xcode_16.0.app
|
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
run: nix develop -c zig build test
|
run: nix develop -c zig build test
|
||||||
|
|
||||||
|
11
build.zig
11
build.zig
@ -1385,21 +1385,10 @@ fn addMetallib(
|
|||||||
b: *std.Build,
|
b: *std.Build,
|
||||||
step: *std.Build.Step.Compile,
|
step: *std.Build.Step.Compile,
|
||||||
) !void {
|
) !void {
|
||||||
const optimize = step.root_module.optimize.?;
|
|
||||||
|
|
||||||
const metal_step = MetallibStep.create(b, .{
|
const metal_step = MetallibStep.create(b, .{
|
||||||
.name = "Ghostty",
|
.name = "Ghostty",
|
||||||
.target = step.root_module.resolved_target.?,
|
.target = step.root_module.resolved_target.?,
|
||||||
.sources = &.{b.path("src/renderer/shaders/cell.metal")},
|
.sources = &.{b.path("src/renderer/shaders/cell.metal")},
|
||||||
.logging = switch (optimize) {
|
|
||||||
.Debug,
|
|
||||||
=> true,
|
|
||||||
|
|
||||||
.ReleaseFast,
|
|
||||||
.ReleaseSmall,
|
|
||||||
.ReleaseSafe,
|
|
||||||
=> false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
metal_step.output.addStepDependencies(&step.step);
|
metal_step.output.addStepDependencies(&step.step);
|
||||||
|
@ -55,23 +55,6 @@
|
|||||||
isEnabled = "YES">
|
isEnabled = "YES">
|
||||||
</CommandLineArgument>
|
</CommandLineArgument>
|
||||||
</CommandLineArguments>
|
</CommandLineArguments>
|
||||||
<EnvironmentVariables>
|
|
||||||
<EnvironmentVariable
|
|
||||||
key = "MTL_LOG_BUFFER_SIZE"
|
|
||||||
value = "4096"
|
|
||||||
isEnabled = "YES">
|
|
||||||
</EnvironmentVariable>
|
|
||||||
<EnvironmentVariable
|
|
||||||
key = "MTL_LOG_LEVEL"
|
|
||||||
value = "MTLLogLevelDebug"
|
|
||||||
isEnabled = "YES">
|
|
||||||
</EnvironmentVariable>
|
|
||||||
<EnvironmentVariable
|
|
||||||
key = "MTL_LOG_TO_STDERR"
|
|
||||||
value = "1"
|
|
||||||
isEnabled = "YES">
|
|
||||||
</EnvironmentVariable>
|
|
||||||
</EnvironmentVariables>
|
|
||||||
<AdditionalOptions>
|
<AdditionalOptions>
|
||||||
<AdditionalOption
|
<AdditionalOption
|
||||||
key = "NSZombieEnabled"
|
key = "NSZombieEnabled"
|
||||||
|
@ -16,9 +16,6 @@ pub const Options = struct {
|
|||||||
|
|
||||||
/// The Metal source files.
|
/// The Metal source files.
|
||||||
sources: []const LazyPath,
|
sources: []const LazyPath,
|
||||||
|
|
||||||
/// Whether to enable Metal shader logging.
|
|
||||||
logging: bool = false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
step: *Step,
|
step: *Step,
|
||||||
@ -45,20 +42,7 @@ pub fn create(b: *std.Build, opts: Options) *MetallibStep {
|
|||||||
b,
|
b,
|
||||||
b.fmt("metal {s}", .{opts.name}),
|
b.fmt("metal {s}", .{opts.name}),
|
||||||
);
|
);
|
||||||
run_ir.addArgs(&.{
|
run_ir.addArgs(&.{ "xcrun", "-sdk", sdk, "metal", "-o" });
|
||||||
"xcrun",
|
|
||||||
"-sdk",
|
|
||||||
sdk,
|
|
||||||
"metal",
|
|
||||||
"-std=metal3.2",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (opts.logging) run_ir.addArgs(&.{
|
|
||||||
// https://developer.apple.com/documentation/metal/logging_shader_debug_messages
|
|
||||||
"-fmetal-enable-logging",
|
|
||||||
});
|
|
||||||
|
|
||||||
run_ir.addArgs(&.{"-o"});
|
|
||||||
const output_ir = run_ir.addOutputFileArg(b.fmt("{s}.ir", .{opts.name}));
|
const output_ir = run_ir.addOutputFileArg(b.fmt("{s}.ir", .{opts.name}));
|
||||||
run_ir.addArgs(&.{"-c"});
|
run_ir.addArgs(&.{"-c"});
|
||||||
for (opts.sources) |source| run_ir.addFileArg(source);
|
for (opts.sources) |source| run_ir.addFileArg(source);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
|
|
||||||
constant os_log logger("com.mitchellh.ghostty", "cell");
|
|
||||||
|
|
||||||
enum Padding : uint8_t {
|
enum Padding : uint8_t {
|
||||||
EXTEND_LEFT = 1u,
|
EXTEND_LEFT = 1u,
|
||||||
EXTEND_RIGHT = 2u,
|
EXTEND_RIGHT = 2u,
|
||||||
@ -81,7 +79,9 @@ struct FullScreenVertexOut {
|
|||||||
float4 position [[position]];
|
float4 position [[position]];
|
||||||
};
|
};
|
||||||
|
|
||||||
vertex FullScreenVertexOut full_screen_vertex(uint vid [[vertex_id]]) {
|
vertex FullScreenVertexOut full_screen_vertex(
|
||||||
|
uint vid [[vertex_id]]
|
||||||
|
) {
|
||||||
FullScreenVertexOut out;
|
FullScreenVertexOut out;
|
||||||
|
|
||||||
float4 position;
|
float4 position;
|
||||||
@ -112,11 +112,12 @@ vertex FullScreenVertexOut full_screen_vertex(uint vid [[vertex_id]]) {
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
#pragma mark - Cell BG Shader
|
#pragma mark - Cell BG Shader
|
||||||
|
|
||||||
fragment float4 cell_bg_fragment(FullScreenVertexOut in [[stage_in]],
|
fragment float4 cell_bg_fragment(
|
||||||
constant uchar4* cells [[buffer(0)]],
|
FullScreenVertexOut in [[stage_in]],
|
||||||
constant Uniforms& uniforms [[buffer(1)]]) {
|
constant uchar4 *cells [[buffer(0)]],
|
||||||
int2 grid_pos = int2(
|
constant Uniforms& uniforms [[buffer(1)]]
|
||||||
floor((in.position.xy - uniforms.grid_padding.wx) / uniforms.cell_size));
|
) {
|
||||||
|
int2 grid_pos = int2(floor((in.position.xy - uniforms.grid_padding.wx) / uniforms.cell_size));
|
||||||
|
|
||||||
// Clamp x position, extends edge bg colors in to padding on sides.
|
// Clamp x position, extends edge bg colors in to padding on sides.
|
||||||
if (grid_pos.x < 0) {
|
if (grid_pos.x < 0) {
|
||||||
@ -196,12 +197,12 @@ struct CellTextVertexOut {
|
|||||||
float2 tex_coord;
|
float2 tex_coord;
|
||||||
};
|
};
|
||||||
|
|
||||||
vertex CellTextVertexOut cell_text_vertex(uint vid [[vertex_id]],
|
vertex CellTextVertexOut cell_text_vertex(
|
||||||
CellTextVertexIn in [[stage_in]],
|
uint vid [[vertex_id]],
|
||||||
constant Uniforms& uniforms
|
CellTextVertexIn in [[stage_in]],
|
||||||
[[buffer(1)]],
|
constant Uniforms& uniforms [[buffer(1)]],
|
||||||
constant uchar4* bg_colors
|
constant uchar4 *bg_colors [[buffer(2)]]
|
||||||
[[buffer(2)]]) {
|
) {
|
||||||
// Convert the grid x, y into world space x, y by accounting for cell size
|
// Convert the grid x, y into world space x, y by accounting for cell size
|
||||||
float2 cell_pos = uniforms.cell_size * float2(in.grid_pos);
|
float2 cell_pos = uniforms.cell_size * float2(in.grid_pos);
|
||||||
|
|
||||||
@ -286,31 +287,36 @@ vertex CellTextVertexOut cell_text_vertex(uint vid [[vertex_id]],
|
|||||||
// and Powerline glyphs to be unaffected (else parts of the line would
|
// and Powerline glyphs to be unaffected (else parts of the line would
|
||||||
// have different colors as some parts are displayed via background colors).
|
// have different colors as some parts are displayed via background colors).
|
||||||
if (uniforms.min_contrast > 1.0f && in.mode == MODE_TEXT) {
|
if (uniforms.min_contrast > 1.0f && in.mode == MODE_TEXT) {
|
||||||
float4 bg_color =
|
float4 bg_color = float4(bg_colors[in.grid_pos.y * uniforms.grid_size.x + in.grid_pos.x]) / 255.0f;
|
||||||
float4(
|
|
||||||
bg_colors[in.grid_pos.y * uniforms.grid_size.x + in.grid_pos.x]) /
|
|
||||||
255.0f;
|
|
||||||
out.color = contrasted_color(uniforms.min_contrast, out.color, bg_color);
|
out.color = contrasted_color(uniforms.min_contrast, out.color, bg_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this cell is the cursor cell, then we need to change the color.
|
// If this cell is the cursor cell, then we need to change the color.
|
||||||
if (in.mode != MODE_TEXT_CURSOR &&
|
if (
|
||||||
(in.grid_pos.x == uniforms.cursor_pos.x ||
|
in.mode != MODE_TEXT_CURSOR &&
|
||||||
uniforms.cursor_wide && in.grid_pos.x == uniforms.cursor_pos.x + 1) &&
|
(
|
||||||
in.grid_pos.y == uniforms.cursor_pos.y) {
|
in.grid_pos.x == uniforms.cursor_pos.x ||
|
||||||
|
uniforms.cursor_wide &&
|
||||||
|
in.grid_pos.x == uniforms.cursor_pos.x + 1
|
||||||
|
) &&
|
||||||
|
in.grid_pos.y == uniforms.cursor_pos.y
|
||||||
|
) {
|
||||||
out.color = float4(uniforms.cursor_color) / 255.0f;
|
out.color = float4(uniforms.cursor_color) / 255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment float4 cell_text_fragment(CellTextVertexOut in [[stage_in]],
|
fragment float4 cell_text_fragment(
|
||||||
texture2d<float> textureGrayscale
|
CellTextVertexOut in [[stage_in]],
|
||||||
[[texture(0)]],
|
texture2d<float> textureGrayscale [[texture(0)]],
|
||||||
texture2d<float> textureColor
|
texture2d<float> textureColor [[texture(1)]]
|
||||||
[[texture(1)]]) {
|
) {
|
||||||
constexpr sampler textureSampler(coord::pixel, address::clamp_to_edge,
|
constexpr sampler textureSampler(
|
||||||
filter::nearest);
|
coord::pixel,
|
||||||
|
address::clamp_to_edge,
|
||||||
|
filter::nearest
|
||||||
|
);
|
||||||
|
|
||||||
switch (in.mode) {
|
switch (in.mode) {
|
||||||
default:
|
default:
|
||||||
@ -361,10 +367,12 @@ struct ImageVertexOut {
|
|||||||
float2 tex_coord;
|
float2 tex_coord;
|
||||||
};
|
};
|
||||||
|
|
||||||
vertex ImageVertexOut image_vertex(uint vid [[vertex_id]],
|
vertex ImageVertexOut image_vertex(
|
||||||
ImageVertexIn in [[stage_in]],
|
uint vid [[vertex_id]],
|
||||||
texture2d<uint> image [[texture(0)]],
|
ImageVertexIn in [[stage_in]],
|
||||||
constant Uniforms& uniforms [[buffer(1)]]) {
|
texture2d<uint> image [[texture(0)]],
|
||||||
|
constant Uniforms& uniforms [[buffer(1)]]
|
||||||
|
) {
|
||||||
// The size of the image in pixels
|
// The size of the image in pixels
|
||||||
float2 image_size = float2(image.get_width(), image.get_height());
|
float2 image_size = float2(image.get_width(), image.get_height());
|
||||||
|
|
||||||
@ -401,8 +409,10 @@ vertex ImageVertexOut image_vertex(uint vid [[vertex_id]],
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment float4 image_fragment(ImageVertexOut in [[stage_in]],
|
fragment float4 image_fragment(
|
||||||
texture2d<uint> image [[texture(0)]]) {
|
ImageVertexOut in [[stage_in]],
|
||||||
|
texture2d<uint> image [[texture(0)]]
|
||||||
|
) {
|
||||||
constexpr sampler textureSampler(address::clamp_to_edge, filter::linear);
|
constexpr sampler textureSampler(address::clamp_to_edge, filter::linear);
|
||||||
|
|
||||||
// Ehhhhh our texture is in RGBA8Uint but our color attachment is
|
// Ehhhhh our texture is in RGBA8Uint but our color attachment is
|
||||||
@ -416,3 +426,4 @@ fragment float4 image_fragment(ImageVertexOut in [[stage_in]],
|
|||||||
result.rgb *= result.a;
|
result.rgb *= result.a;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user