aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/pkg/glslang
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/pkg/glslang
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/pkg/glslang')
-rw-r--r--vendor/libghostty-vt/pkg/glslang/build.zig169
-rw-r--r--vendor/libghostty-vt/pkg/glslang/build.zig.zon16
-rw-r--r--vendor/libghostty-vt/pkg/glslang/c.zig4
-rw-r--r--vendor/libghostty-vt/pkg/glslang/init.zig9
-rw-r--r--vendor/libghostty-vt/pkg/glslang/main.zig15
-rw-r--r--vendor/libghostty-vt/pkg/glslang/override/glslang/build_info.h62
-rw-r--r--vendor/libghostty-vt/pkg/glslang/program.zig60
-rw-r--r--vendor/libghostty-vt/pkg/glslang/shader.zig58
-rw-r--r--vendor/libghostty-vt/pkg/glslang/test.zig10
-rw-r--r--vendor/libghostty-vt/pkg/glslang/test/simple.frag56
10 files changed, 459 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/pkg/glslang/build.zig b/vendor/libghostty-vt/pkg/glslang/build.zig
new file mode 100644
index 00000000..1dc82a6e
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/build.zig
@@ -0,0 +1,169 @@
+const std = @import("std");
+
+pub fn build(b: *std.Build) !void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+
+ const module = b.addModule("glslang", .{
+ .root_source_file = b.path("main.zig"),
+ .target = target,
+ .optimize = optimize,
+ });
+
+ const upstream = b.lazyDependency("glslang", .{});
+ const lib = try buildGlslang(b, upstream, target, optimize);
+ b.installArtifact(lib);
+
+ if (upstream) |v| module.addIncludePath(v.path(""));
+ module.addIncludePath(b.path("override"));
+
+ if (target.query.isNative()) {
+ const test_exe = b.addTest(.{
+ .name = "test",
+ .root_module = b.createModule(.{
+ .root_source_file = b.path("main.zig"),
+ .target = target,
+ .optimize = optimize,
+ }),
+ });
+ test_exe.linkLibrary(lib);
+ const tests_run = b.addRunArtifact(test_exe);
+ const test_step = b.step("test", "Run tests");
+ test_step.dependOn(&tests_run.step);
+
+ // Uncomment this if we're debugging tests
+ // b.installArtifact(test_exe);
+ }
+}
+
+fn buildGlslang(
+ b: *std.Build,
+ upstream_: ?*std.Build.Dependency,
+ target: std.Build.ResolvedTarget,
+ optimize: std.builtin.OptimizeMode,
+) !*std.Build.Step.Compile {
+ const lib = b.addLibrary(.{
+ .name = "glslang",
+ .root_module = b.createModule(.{
+ .target = target,
+ .optimize = optimize,
+ }),
+ .linkage = .static,
+ });
+ lib.linkLibC();
+ // On MSVC, we must not use linkLibCpp because Zig unconditionally
+ // passes -nostdinc++ and then adds its bundled libc++/libc++abi
+ // include paths, which conflict with MSVC's own C++ runtime headers.
+ // The MSVC SDK include directories (added via linkLibC) contain
+ // both C and C++ headers, so linkLibCpp is not needed.
+ if (target.result.abi != .msvc) {
+ lib.linkLibCpp();
+ }
+ if (upstream_) |upstream| lib.addIncludePath(upstream.path(""));
+ lib.addIncludePath(b.path("override"));
+ if (target.result.os.tag.isDarwin()) {
+ const apple_sdk = @import("apple_sdk");
+ try apple_sdk.addPaths(b, lib);
+ }
+
+ var flags: std.ArrayList([]const u8) = .empty;
+ defer flags.deinit(b.allocator);
+ try flags.appendSlice(b.allocator, &.{
+ "-fno-sanitize=undefined",
+ "-fno-sanitize-trap=undefined",
+ });
+ // MSVC requires explicit std specification otherwise C++17 features
+ // like std::variant, std::filesystem, and inline variables are
+ // guarded behind _HAS_CXX17.
+ try flags.append(b.allocator, "-std=c++17");
+
+ if (target.result.os.tag == .freebsd or target.result.abi == .musl) {
+ try flags.append(b.allocator, "-fPIC");
+ }
+
+ if (upstream_) |upstream| {
+ lib.addCSourceFiles(.{
+ .root = upstream.path(""),
+ .flags = flags.items,
+ .files = &.{
+ // GenericCodeGen
+ "glslang/GenericCodeGen/CodeGen.cpp",
+ "glslang/GenericCodeGen/Link.cpp",
+
+ // MachineIndependent
+ //"MachineIndependent/glslang.y",
+ "glslang/MachineIndependent/glslang_tab.cpp",
+ "glslang/MachineIndependent/attribute.cpp",
+ "glslang/MachineIndependent/Constant.cpp",
+ "glslang/MachineIndependent/iomapper.cpp",
+ "glslang/MachineIndependent/InfoSink.cpp",
+ "glslang/MachineIndependent/Initialize.cpp",
+ "glslang/MachineIndependent/IntermTraverse.cpp",
+ "glslang/MachineIndependent/Intermediate.cpp",
+ "glslang/MachineIndependent/ParseContextBase.cpp",
+ "glslang/MachineIndependent/ParseHelper.cpp",
+ "glslang/MachineIndependent/PoolAlloc.cpp",
+ "glslang/MachineIndependent/RemoveTree.cpp",
+ "glslang/MachineIndependent/Scan.cpp",
+ "glslang/MachineIndependent/ShaderLang.cpp",
+ "glslang/MachineIndependent/SpirvIntrinsics.cpp",
+ "glslang/MachineIndependent/SymbolTable.cpp",
+ "glslang/MachineIndependent/Versions.cpp",
+ "glslang/MachineIndependent/intermOut.cpp",
+ "glslang/MachineIndependent/limits.cpp",
+ "glslang/MachineIndependent/linkValidate.cpp",
+ "glslang/MachineIndependent/parseConst.cpp",
+ "glslang/MachineIndependent/reflection.cpp",
+ "glslang/MachineIndependent/preprocessor/Pp.cpp",
+ "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
+ "glslang/MachineIndependent/preprocessor/PpContext.cpp",
+ "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
+ "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
+ "glslang/MachineIndependent/propagateNoContraction.cpp",
+
+ // C Interface
+ "glslang/CInterface/glslang_c_interface.cpp",
+
+ // ResourceLimits
+ "glslang/ResourceLimits/ResourceLimits.cpp",
+ "glslang/ResourceLimits/resource_limits_c.cpp",
+
+ // SPIRV
+ "SPIRV/GlslangToSpv.cpp",
+ "SPIRV/InReadableOrder.cpp",
+ "SPIRV/Logger.cpp",
+ "SPIRV/SpvBuilder.cpp",
+ "SPIRV/SpvPostProcess.cpp",
+ "SPIRV/doc.cpp",
+ "SPIRV/disassemble.cpp",
+ "SPIRV/CInterface/spirv_c_interface.cpp",
+ },
+ });
+
+ if (target.result.os.tag != .windows) {
+ lib.addCSourceFiles(.{
+ .root = upstream.path(""),
+ .flags = flags.items,
+ .files = &.{
+ "glslang/OSDependent/Unix/ossource.cpp",
+ },
+ });
+ } else {
+ lib.addCSourceFiles(.{
+ .root = upstream.path(""),
+ .flags = flags.items,
+ .files = &.{
+ "glslang/OSDependent/Windows/ossource.cpp",
+ },
+ });
+ }
+
+ lib.installHeadersDirectory(
+ upstream.path(""),
+ "",
+ .{ .include_extensions = &.{".h"} },
+ );
+ }
+
+ return lib;
+}
diff --git a/vendor/libghostty-vt/pkg/glslang/build.zig.zon b/vendor/libghostty-vt/pkg/glslang/build.zig.zon
new file mode 100644
index 00000000..252237e5
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/build.zig.zon
@@ -0,0 +1,16 @@
+.{
+ .name = .glslang,
+ .version = "14.2.0",
+ .fingerprint = 0x274a35558e2e504,
+ .paths = .{""},
+ .dependencies = .{
+ // KhronosGroup/glslang
+ .glslang = .{
+ .url = "https://deps.files.ghostty.org/glslang-12201278a1a05c0ce0b6eb6026c65cd3e9247aa041b1c260324bf29cee559dd23ba1.tar.gz",
+ .hash = "N-V-__8AABzkUgISeKGgXAzgtutgJsZc0-kkeqBBscJgMkvy",
+ .lazy = true,
+ },
+
+ .apple_sdk = .{ .path = "../apple-sdk" },
+ },
+}
diff --git a/vendor/libghostty-vt/pkg/glslang/c.zig b/vendor/libghostty-vt/pkg/glslang/c.zig
new file mode 100644
index 00000000..c0010846
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/c.zig
@@ -0,0 +1,4 @@
+pub const c = @cImport({
+ @cInclude("glslang/Include/glslang_c_interface.h");
+ @cInclude("glslang/Public/resource_limits_c.h");
+});
diff --git a/vendor/libghostty-vt/pkg/glslang/init.zig b/vendor/libghostty-vt/pkg/glslang/init.zig
new file mode 100644
index 00000000..a865e9e7
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/init.zig
@@ -0,0 +1,9 @@
+const c = @import("c.zig").c;
+
+pub fn init() !void {
+ if (c.glslang_initialize_process() == 0) return error.GlslangInitFailed;
+}
+
+pub fn finalize() void {
+ c.glslang_finalize_process();
+}
diff --git a/vendor/libghostty-vt/pkg/glslang/main.zig b/vendor/libghostty-vt/pkg/glslang/main.zig
new file mode 100644
index 00000000..2743650c
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/main.zig
@@ -0,0 +1,15 @@
+const initpkg = @import("init.zig");
+const program = @import("program.zig");
+const shader = @import("shader.zig");
+
+pub const c = @import("c.zig").c;
+pub const testing = @import("test.zig");
+
+pub const init = initpkg.init;
+pub const finalize = initpkg.finalize;
+pub const Program = program.Program;
+pub const Shader = shader.Shader;
+
+test {
+ @import("std").testing.refAllDecls(@This());
+}
diff --git a/vendor/libghostty-vt/pkg/glslang/override/glslang/build_info.h b/vendor/libghostty-vt/pkg/glslang/override/glslang/build_info.h
new file mode 100644
index 00000000..c25117ee
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/override/glslang/build_info.h
@@ -0,0 +1,62 @@
+// Copyright (C) 2020 The Khronos Group Inc.
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of The Khronos Group Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GLSLANG_BUILD_INFO
+#define GLSLANG_BUILD_INFO
+
+#define GLSLANG_VERSION_MAJOR 13
+#define GLSLANG_VERSION_MINOR 1
+#define GLSLANG_VERSION_PATCH 1
+#define GLSLANG_VERSION_FLAVOR ""
+
+#define GLSLANG_VERSION_GREATER_THAN(major, minor, patch) \
+ ((GLSLANG_VERSION_MAJOR) > (major) || ((major) == GLSLANG_VERSION_MAJOR && \
+ ((GLSLANG_VERSION_MINOR) > (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
+ (GLSLANG_VERSION_PATCH) > (patch)))))
+
+#define GLSLANG_VERSION_GREATER_OR_EQUAL_TO(major, minor, patch) \
+ ((GLSLANG_VERSION_MAJOR) > (major) || ((major) == GLSLANG_VERSION_MAJOR && \
+ ((GLSLANG_VERSION_MINOR) > (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
+ (GLSLANG_VERSION_PATCH >= (patch))))))
+
+#define GLSLANG_VERSION_LESS_THAN(major, minor, patch) \
+ ((GLSLANG_VERSION_MAJOR) < (major) || ((major) == GLSLANG_VERSION_MAJOR && \
+ ((GLSLANG_VERSION_MINOR) < (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
+ (GLSLANG_VERSION_PATCH) < (patch)))))
+
+#define GLSLANG_VERSION_LESS_OR_EQUAL_TO(major, minor, patch) \
+ ((GLSLANG_VERSION_MAJOR) < (major) || ((major) == GLSLANG_VERSION_MAJOR && \
+ ((GLSLANG_VERSION_MINOR) < (minor) || ((minor) == GLSLANG_VERSION_MINOR && \
+ (GLSLANG_VERSION_PATCH <= (patch))))))
+
+#endif // GLSLANG_BUILD_INFO
diff --git a/vendor/libghostty-vt/pkg/glslang/program.zig b/vendor/libghostty-vt/pkg/glslang/program.zig
new file mode 100644
index 00000000..4af687cc
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/program.zig
@@ -0,0 +1,60 @@
+const std = @import("std");
+const c = @import("c.zig").c;
+const testlib = @import("test.zig");
+const Shader = @import("shader.zig").Shader;
+
+pub const Program = opaque {
+ pub fn create() !*Program {
+ if (c.glslang_program_create()) |ptr| return @ptrCast(ptr);
+ return error.OutOfMemory;
+ }
+
+ pub fn delete(self: *Program) void {
+ c.glslang_program_delete(@ptrCast(self));
+ }
+
+ pub fn addShader(self: *Program, shader: *Shader) void {
+ c.glslang_program_add_shader(@ptrCast(self), @ptrCast(shader));
+ }
+
+ pub fn link(self: *Program, messages: c_int) !void {
+ if (c.glslang_program_link(@ptrCast(self), messages) != 0) return;
+ return error.GlslangFailed;
+ }
+
+ pub fn spirvGenerate(self: *Program, stage: c.glslang_stage_t) void {
+ c.glslang_program_SPIRV_generate(@ptrCast(self), stage);
+ }
+
+ pub fn spirvGetSize(self: *Program) usize {
+ return @intCast(c.glslang_program_SPIRV_get_size(@ptrCast(self)));
+ }
+
+ pub fn spirvGet(self: *Program, buf: []u32) void {
+ c.glslang_program_SPIRV_get(@ptrCast(self), buf.ptr);
+ }
+
+ pub fn spirvGetPtr(self: *Program) ![*]u32 {
+ return @ptrCast(c.glslang_program_SPIRV_get_ptr(@ptrCast(self)));
+ }
+
+ pub fn spirvGetMessages(self: *Program) ![:0]const u8 {
+ const ptr = c.glslang_program_SPIRV_get_messages(@ptrCast(self));
+ return std.mem.sliceTo(ptr, 0);
+ }
+
+ pub fn getInfoLog(self: *Program) ![:0]const u8 {
+ const ptr = c.glslang_program_get_info_log(@ptrCast(self));
+ return std.mem.sliceTo(ptr, 0);
+ }
+
+ pub fn getDebugInfoLog(self: *Program) ![:0]const u8 {
+ const ptr = c.glslang_program_get_info_debug_log(@ptrCast(self));
+ return std.mem.sliceTo(ptr, 0);
+ }
+};
+
+test {
+ var program = try Program.create();
+ defer program.delete();
+}
diff --git a/vendor/libghostty-vt/pkg/glslang/shader.zig b/vendor/libghostty-vt/pkg/glslang/shader.zig
new file mode 100644
index 00000000..36a09f34
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/shader.zig
@@ -0,0 +1,58 @@
+const std = @import("std");
+const c = @import("c.zig").c;
+const testlib = @import("test.zig");
+
+pub const Shader = opaque {
+ pub fn create(input: *const c.glslang_input_t) !*Shader {
+ if (c.glslang_shader_create(input)) |ptr| return @ptrCast(ptr);
+ return error.OutOfMemory;
+ }
+
+ pub fn delete(self: *Shader) void {
+ c.glslang_shader_delete(@ptrCast(self));
+ }
+
+ pub fn preprocess(self: *Shader, input: *const c.glslang_input_t) !void {
+ if (c.glslang_shader_preprocess(@ptrCast(self), input) == 0)
+ return error.GlslangFailed;
+ }
+
+ pub fn parse(self: *Shader, input: *const c.glslang_input_t) !void {
+ if (c.glslang_shader_parse(@ptrCast(self), input) == 0)
+ return error.GlslangFailed;
+ }
+
+ pub fn getInfoLog(self: *Shader) ![:0]const u8 {
+ const ptr = c.glslang_shader_get_info_log(@ptrCast(self));
+ return std.mem.sliceTo(ptr, 0);
+ }
+
+ pub fn getDebugInfoLog(self: *Shader) ![:0]const u8 {
+ const ptr = c.glslang_shader_get_info_debug_log(@ptrCast(self));
+ return std.mem.sliceTo(ptr, 0);
+ }
+};
+
+test {
+ const input: c.glslang_input_t = .{
+ .language = c.GLSLANG_SOURCE_GLSL,
+ .stage = c.GLSLANG_STAGE_FRAGMENT,
+ .client = c.GLSLANG_CLIENT_VULKAN,
+ .client_version = c.GLSLANG_TARGET_VULKAN_1_2,
+ .target_language = c.GLSLANG_TARGET_SPV,
+ .target_language_version = c.GLSLANG_TARGET_SPV_1_5,
+ .code = @embedFile("test/simple.frag"),
+ .default_version = 100,
+ .default_profile = c.GLSLANG_NO_PROFILE,
+ .force_default_version_and_profile = 0,
+ .forward_compatible = 0,
+ .messages = c.GLSLANG_MSG_DEFAULT_BIT,
+ .resource = c.glslang_default_resource(),
+ };
+
+ try testlib.ensureInit();
+ const shader = try Shader.create(&input);
+ defer shader.delete();
+ try shader.preprocess(&input);
+ try shader.parse(&input);
+}
diff --git a/vendor/libghostty-vt/pkg/glslang/test.zig b/vendor/libghostty-vt/pkg/glslang/test.zig
new file mode 100644
index 00000000..8cdf98f7
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/test.zig
@@ -0,0 +1,10 @@
+const glslang = @import("main.zig");
+
+var initialized: bool = false;
+
+/// Call this function before any other tests in this package to ensure that
+/// the glslang library is initialized.
+pub fn ensureInit() !void {
+ if (initialized) return;
+ try glslang.init();
+}
diff --git a/vendor/libghostty-vt/pkg/glslang/test/simple.frag b/vendor/libghostty-vt/pkg/glslang/test/simple.frag
new file mode 100644
index 00000000..c1cd903c
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/glslang/test/simple.frag
@@ -0,0 +1,56 @@
+#version 430 core
+
+layout(binding = 0) uniform Globals {
+ uniform vec3 iResolution;
+ uniform float iTime;
+ uniform float iTimeDelta;
+ uniform float iFrameRate;
+ uniform int iFrame;
+ uniform float iChannelTime[4];
+ uniform vec3 iChannelResolution[4];
+ uniform vec4 iMouse;
+ uniform vec4 iDate;
+ uniform float iSampleRate;
+};
+
+layout(binding = 0) uniform sampler2D iChannel0;
+layout(binding = 1) uniform sampler2D iChannel1;
+layout(binding = 2) uniform sampler2D iChannel2;
+layout(binding = 3) uniform sampler2D iChannel3;
+
+layout(location = 0) in vec4 gl_FragCoord;
+layout(location = 0) out vec4 _fragColor;
+
+#define texture2D texture
+
+void mainImage( out vec4 fragColor, in vec2 fragCoord );
+void main() { mainImage (_fragColor, gl_FragCoord.xy); }
+
+#define t iTime
+
+void mainImage( out vec4 fragColor, in vec2 fragCoord )
+{
+ // Normalized pixel coordinates (from 0 to 1)
+ vec2 uv = ( fragCoord - .5*iResolution.xy) / iResolution.y;
+ vec3 col = vec3(0.);
+ float a = atan(uv.y,uv.x);
+ float r = 0.5*length(uv);
+ float counter = 100.;
+ a = 4.*a+20.*r+50.*cos(r)*cos(.1*t)+abs(a*r);
+ float f = 0.02*abs(cos(a))/(r*r);
+
+
+ vec2 v = vec2(0.);
+ for(float i=0.;i<counter;i++){
+ v = mat2(v,-v.y,v.x) * v + vec2(2.*f+cos(0.5*t*(exp(-0.2* r))),-cos(t*r*r)*cos(0.5*t));
+ if(length(v)>2.){
+ counter = i;
+ break;
+ }
+ }
+
+ col=vec3(min(0.9,1.2*exp(-pow(f,0.45)*counter)));
+
+ fragColor = min(0.9,1.2*exp(-pow(f,0.45)*counter) )
+ * ( 0.7 + 0.3* cos(10.*r - 2.*t -vec4(.7,1.4,2.1,0) ) );
+}