feat: Add HLSL / Shader language support#370
Open
colinchen1984 wants to merge 1 commit into
Open
Conversation
- Add tree-sitter-hlsl WASM grammar (builds from tree-sitter-grammars/tree-sitter-hlsl) - Add languages/hlsl.ts extractor (based on C++ extractor) - Register .hlsl, .usf, .ush, .glsl extensions in EXTENSION_MAP - Maps all shader extensions to HLSL grammar (USF/USH are Unreal Engine HLSL variants) Enables CodeGraph to index shader files in Unreal Engine, Unity, and other HLSL/GLSL-based projects. Parses function definitions, structs, enums, includes, and function calls. Fixes colbymchenry#283 (partially — documents new language support)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds HLSL (High-Level Shader Language) support to CodeGraph, enabling indexing of shader files used in game engines and GPU programming.
Changes
New files
src/extraction/languages/hlsl.ts— Language extractor (based on C++ extractor template)src/extraction/wasm/tree-sitter-hlsl.wasm— Pre-built WASM grammar from tree-sitter-grammars/tree-sitter-hlslModified files
src/types.ts— Addedhlslto LANGUAGES arraysrc/extraction/grammars.ts— WASM grammar registration, extension mappings, display name, custom WASM pathsrc/extraction/languages/index.ts— Import and register hlslExtractorSupported file extensions
.hlsl.usf.ush.glslWhy bundled WASM
tree-sitter-hlsl is not included in the
tree-sitter-wasmspackage. The WASM is pre-built usingtree-sitter build --wasmand follows the same bundling pattern aspascal,scala,lua, andluau.Tested
.usffiles from Unreal Engine 5 (VirtualShadowMapProjection, ShadowDepthPixelShader, etc.)MainPS,VirtualShadowMapGetPageFlag, etc.#include "Common.ush"Related: #283 (language documentation)