Skip to content

Add spvfc CLI tool and GLSLCompiler public C++ API header#2

Draft
Copilot wants to merge 7 commits intomasterfrom
copilot/make-library-cross-platform
Draft

Add spvfc CLI tool and GLSLCompiler public C++ API header#2
Copilot wants to merge 7 commits intomasterfrom
copilot/make-library-cross-platform

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 25, 2026

Adds a command-line compiler (spvfc) that compiles GLSL/HLSL shaders directly to .spvf files and prints a human-readable reflection summary. Also extracts a proper public C++ API header from the previously header-less library.

GLSLCompiler.h (new)

  • Moves ShaderLanguageType and CompileInfo out of glsl2spv.cpp into a public header
  • SPVData / SPVParseData exposed as opaque handles; layouts remain private
  • Includes SPVParseFlat.h — one include gives both the compiler API and the zero-dep flat-file loader
  • vulkan_version / spv_version in CompileInfo changed from const members to plain uint32_t (assignable)

glsl2spv.cpp changes

  • Three new extern "C" field accessors for the opaque SPVData handle: SPVDataGetResult, SPVDataGetLog, SPVDataGetDebugLog — also wired into GLSLCompilerInterface for dynamic-load callers
  • Duplicate type definitions removed; #include "GLSLCompiler.h" replaces the old #include "SPVParseFlat.h"

spvfc.cpp (new)

Links against GLSLCompilerStatic. Per-file pipeline: extension → stage detection → CompileFromPathParseSPVCreateShaderFlatShaderFlatLoad (for reflection printing) → write .spvf.

spvfc [options] <shader_file> [<shader_file2> ...]

  -o <file>       Output .spvf path  (single input only)
  -e <name>       Entry-point name   [default: main]
  -I <dir>        Add include search path  (repeatable; -I<dir> also OK)
  -D <macro>      Add preprocessor define  (-DMACRO=value also OK)
  --hlsl          Treat all inputs as HLSL
  --vulkan <ver>  Target Vulkan version: 1.0 (default)  1.1  1.2  1.3
  --spv    <ver>  Target SPIR-V version: 1.0 (default)  1.1 .. 1.6
  --no-output     Compile + reflect, skip writing .spvf
  --no-reflect    Suppress reflection text
  --quiet         Suppress informational messages

Sample reflection output:

=== Reflection: mesh.vert ===
Stage      : vertex (0x00000001)
Entry      : main
SPIR-V     : 4096 bytes (1024 words)

Stage Inputs (2):
  loc=0    vec3            inPosition
  loc=1    vec2            inTexCoord

uniform_buffer (1):
  set=0   binding=0    UboData

Push Constants (1):
  offset=0     size=64    Transform

CMakeLists.txt

  • GLSLCompiler.h added to both library source lists
  • New target: add_executable(spvfc spvfc.cpp) linked against GLSLCompilerStatic ${VULKAN_SPIRV_LIBS}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: hyzboy <1788285+hyzboy@users.noreply.github.com>
Copilot AI changed the title [WIP] Update library for cross-platform support including Linux and macOS Add Linux/macOS cross-platform support Feb 25, 2026
Copilot AI requested a review from hyzboy February 25, 2026 05:48
…ption

Co-authored-by: hyzboy <1788285+hyzboy@users.noreply.github.com>
Copilot AI changed the title Add Linux/macOS cross-platform support Cross-platform build: add Linux/macOS support and flexible dependency discovery Feb 25, 2026
Co-authored-by: hyzboy <1788285+hyzboy@users.noreply.github.com>
Copilot AI changed the title Cross-platform build: add Linux/macOS support and flexible dependency discovery Add flat binary serialization for SPVParseData with zero-dependency loader Feb 25, 2026
…l reflection

Co-authored-by: hyzboy <1788285+hyzboy@users.noreply.github.com>
Copilot AI changed the title Add flat binary serialization for SPVParseData with zero-dependency loader Cross-platform build + unified shader flat-file format (SPIRV + reflection, zero-dep loader) Feb 25, 2026
Co-authored-by: hyzboy <1788285+hyzboy@users.noreply.github.com>
Copilot AI changed the title Cross-platform build + unified shader flat-file format (SPIRV + reflection, zero-dep loader) Cross-platform build, flexible dependency discovery, unified shader flat-file format, and technical documentation Feb 25, 2026
Co-authored-by: hyzboy <1788285+hyzboy@users.noreply.github.com>
Copilot AI changed the title Cross-platform build, flexible dependency discovery, unified shader flat-file format, and technical documentation Add spvfc CLI tool and GLSLCompiler public C++ API header Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants