Skip to content

Commit 0db833e

Browse files
committed
add AI tools and Vulkan development guide to documentation
1 parent 2b62314 commit 0db833e

File tree

3 files changed

+211
-0
lines changed

3 files changed

+211
-0
lines changed

README.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ The Vulkan Guide content is also viewable from https://docs.vulkan.org/guide/lat
7070

7171
== xref:{chapters}ide.adoc[Development Environments & IDEs]
7272

73+
== xref:{chapters}ai_tools_and_agents.adoc[AI-assisted Vulkan Development: MCP, Local LLMs, and Agentic IDE Tools]
74+
7375
== xref:{chapters}vulkan_profiles.adoc[Vulkan Profiles]
7476

7577
== xref:{chapters}loader.adoc[Loader]

antora/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
** xref:{chapters}vulkan_cts.adoc[]
1919
** xref:{chapters}development_tools.adoc[]
2020
** xref:{chapters}ide.adoc[]
21+
** xref:{chapters}ai_tools_and_agents.adoc[]
2122
** xref:{chapters}validation_overview.adoc[]
2223
** xref:{chapters}decoder_ring.adoc[]
2324
* Using Vulkan

chapters/ai_tools_and_agents.adoc

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
// Copyright 2025 Holochip Inc.
2+
// SPDX-License-Identifier: CC-BY-4.0
3+
4+
= AI-assisted Vulkan Development: MCP, Local LLMs, and Agentic IDE Tools
5+
6+
This chapter explains how to leverage modern AI tooling with Vulkan development. It covers:
7+
8+
- Using the Vulkan MCP with a LLM (Large Language Model) so the Vulkan context of the LLM can be updated to the latest version.
9+
- Running a local LLM with llama.cpp by downloading a model from Hugging Face
10+
- Practical agentic tool use cases in popular IDEs (CLion, Android Studio, Visual Studio, Xcode) for Vulkan projects
11+
12+
== 1) Using the Vulkan MCP with an LLM
13+
14+
The "Model Context Protocol" (MCP) enables tools to expose capabilities the LLM can call. The Vulkan MCP provides Vulkan-specific context and actions that help an LLM reason about your Vulkan project.
15+
16+
Project: https://github.com/gpx1000/mcp-Vulkan[mcp-Vulkan]
17+
18+
=== Goal: Use the latest Vulkan version in the LLM's Vulkan context
19+
20+
Many issues stem from the LLM assuming the wrong Vulkan version (for example, defaulting to Vulkan 1.0). This is caused by the LLM being trained on the version of Vulkan that was latest at the time of the LLM model getting training. To combat this, we need to update the context the LLM uses to understand Vulkan. The Vulkan MCP is designed so the LLM can query and set the Vulkan context version to latest. By providing all the Vulkan Documentation resources including the Spec, Man pages, Tutorial, Guide and Samples we ensure guidance and code suggested by the LLM target the up-to-date Vulkan specification.
21+
22+
High-level steps:
23+
24+
. Install an MCP-capable LLM client (for example, clients that support MCP bridges).
25+
+
26+
+ Major LLM services you can use with MCP-capable clients/bridges include:
27+
+ - Anthropic Claude (Claude Desktop supports MCP natively)
28+
+ - OpenAI models (via MCP bridges/clients)
29+
+ - Google Gemini (via MCP bridges/clients)
30+
+ - Mistral (via MCP bridges/clients)
31+
+ - Cohere (via MCP bridges/clients)
32+
+ - Groq API–served models (via MCP bridges/clients)
33+
+ - Local engines: llama.cpp and Ollama (via MCP-capable clients/bridges)
34+
. Install and configure the Vulkan MCP from mcp-Vulkan.
35+
36+
=== Example setup (generic MCP client)
37+
38+
1. Install the MCP client of your choice that supports external MCP servers.
39+
2. Clone the Vulkan MCP (this is the MCP server we will connect the clients to):
40+
+
41+
----
42+
git clone https://github.com/gpx1000/mcp-Vulkan.git
43+
cd mcp-Vulkan
44+
----
45+
3. Most MCP clients require a small JSON/YAML config to register the MCP server URL and advertised tools. (See below for an example JSON config)
46+
4. In your MCP client configuration, add a "Vulkan" tool/provider, pointing to the running mcp-Vulkan server (or node running in the command line).
47+
5. Test by asking your LLM: "Use the Vulkan MCP to set your Vulkan context, then list the extensions that are core in that version." The LLM should call the MCP, update its working context, and answer consistently with the latest Vulkan version.
48+
+ - The functions directly provided by the Vulkan MCP server are:
49+
search-vulkan-docs:
50+
Search Vulkan documentation for specific topics
51+
52+
get-vulkan-topic:
53+
Get information about a specific Vulkan topic
54+
55+
56+
Tips:
57+
58+
- When discussing features, ask the LLM to explicitly cite the Vulkan version it believes is active to avoid drift.
59+
60+
==== Minimal MCP client config example
61+
62+
The following JSON shows a minimal configuration entry that works with the Vulkan MCP. It registers the MCP server under the key "vulkan".
63+
64+
----
65+
{
66+
"mcpServers": {
67+
"vulkan": {
68+
"command": "node",
69+
"args": [
70+
"build/index.js"
71+
]
72+
}
73+
}
74+
}
75+
----
76+
77+
Note: Some clients accept additional fields (environment variables, transport, URL). Keep the above structure as a starting point and consult your client's docs to add any required fields.
78+
79+
== 2) Running a local LLM with llama.cpp
80+
81+
You can run a local LLM on your machine using https://github.com/ggerganov/llama.cpp[llama.cpp]. This allows private, offline experimentation and integration with MCP-enabled clients that support local model backends.
82+
83+
=== Build or install llama.cpp
84+
85+
- Prebuilt binaries are available for common platforms in the repository Releases page, or you can build from source:
86+
+
87+
----
88+
# Linux/macOS (requires CMake and a recent compiler)
89+
git clone https://github.com/ggerganov/llama.cpp.git
90+
cd llama.cpp
91+
cmake -S . -B build -DGGML_NATIVE=ON
92+
cmake --build build -j
93+
# Binaries will be in ./build/bin
94+
----
95+
96+
Optional GPU acceleration:
97+
98+
- Vulkan: build with -DGGML_VULKAN=ON if supported on your platform/driver
99+
- CUDA: build with -DGGML_CUDA=ON
100+
- Metal (macOS): build with -DGGML_METAL=ON
101+
102+
Refer to the llama.cpp README for the latest flags supported by your platform.
103+
104+
=== Download a GGUF model from Hugging Face
105+
106+
llama.cpp consumes models in the GGUF format. Choose an instruct-tuned model appropriate for on-device use (7–8B parameters is a common starting point).
107+
108+
Examples on Hugging Face:
109+
110+
- https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.2-GGUF[Mistral-7B-Instruct GGUF]
111+
- https://huggingface.co/QuantFactory/Meta-Llama-3-8B-Instruct-GGUF[Llama 3 8B Instruct GGUF]
112+
113+
Download a quantized file (e.g., Q4_K_M) for faster inference on CPUs/GPUs with modest memory.
114+
115+
=== Run the model with llama.cpp
116+
117+
----
118+
# Example invocation (adjust paths and model file name)
119+
./build/bin/llama-cli \
120+
-m /path/to/model/YourModelName.Q4_K_M.gguf \
121+
-p "You are a Vulkan development assistant."
122+
----
123+
124+
Once you confirm local inference works, integrate with your MCP-capable client if it supports a local llama.cpp backend. Some clients can connect to a local server (e.g., llama.cpp’s simple server mode) or a bridge. Consult your client’s documentation for enabling a local model as the LLM engine while still attaching the Vulkan MCP.
125+
126+
== 3) Agentic tools in IDEs for Vulkan projects
127+
128+
Modern IDEs offer AI assistants and agentic workflows that can call tools, analyze projects, and perform guided changes. Below are common tools and Vulkan-oriented use cases.
129+
130+
=== CLion (JetBrains)
131+
132+
Options:
133+
134+
- JetBrains AI Assistant (plugin)
135+
- JetBrains Junie (plugin)
136+
- GitHub Copilot / Copilot Chat (plugin)
137+
- Codeium (plugin)
138+
139+
Vulkan-specific use cases:
140+
141+
- Generate boilerplate for instance/device creation, queues, and swapchain setup using your project’s coding style
142+
- Draft synchronization scopes and barriers; then validate with the Vulkan Validation Layers
143+
- Summarize validation errors and map them to the relevant Vulkan Guide sections
144+
- Write small tests for feature/extension queries and profile toggles
145+
- Automatically understand and suggest fixes for VUID reported warnings and errors from Validation Layers directly within your project.
146+
147+
Tips:
148+
149+
- Keep your vk.xml or Vulkan-Headers dependency in sync; assistants can reference it for enums and structure definitions
150+
- Use CLion/IDE inspections and run-time sanitizers alongside AI suggestions
151+
152+
=== Android Studio
153+
154+
Options:
155+
156+
- Gemini in Android Studio
157+
- GitHub Copilot / Copilot Chat (plugin)
158+
159+
Vulkan-specific use cases:
160+
161+
- Create or adjust Vulkan initialization for Android (ANativeWindow, VK_KHR_surface, VK_KHR_android_surface)
162+
- Generate Gradle/CMake integration snippets for NDK-based Vulkan samples
163+
- Explain and fix mobile-specific validation messages (tiling, Y′CBCR sampling, protected memory, etc.)
164+
165+
Tips:
166+
167+
- Attach a device or emulator and ask the assistant to tailor swapchain and color space selection to the active device
168+
- Use Android GPU profiling tools alongside AI-generated changes
169+
170+
=== Visual Studio
171+
172+
Options:
173+
174+
- GitHub Copilot / Copilot Chat
175+
- Azure AI extension options
176+
177+
Vulkan-specific use cases:
178+
179+
- Port small D3D samples to Vulkan with step-by-step assistance referencing the Vulkan Decoder Ring
180+
- Generate DXGI-to-WSI migration scaffolding and synchronize resource transitions
181+
- Summarize renderdoc/capture findings and propose minimal code diffs
182+
183+
Tips:
184+
185+
- Ask the assistant to keep generated code consistent with the Vulkan version defined by your MCP context
186+
187+
=== Xcode
188+
189+
Options:
190+
191+
- Third-party plugins or external assistants via MCP-capable clients
192+
193+
Vulkan-specific use cases:
194+
195+
- Improve portability layers usage (e.g., MoltenVK) and suggest configuration alignment with your target Apple GPU
196+
- Create command-line tools and unit tests for Vulkan modules in cross-platform CMake projects
197+
198+
Tips:
199+
200+
- Consider a local model for proprietary code bases; combine with the Vulkan MCP to keep context precise and private
201+
202+
== Good practices for AI + Vulkan
203+
204+
- Treat AI output as a draft; compile, run, and profile just as you would hand-written code
205+
- Keep the Vulkan MCP active and set the version to "latest" so the LLM’s answers align with the right features and limits
206+
- Use the Validation Layers early; ask the assistant to explain errors and point to Documentation resources to better understand the problems. Most LLMs can even suggest reasonable fixes for your project directly.
207+
- Prefer incremental refactors; have the assistant propose diffs, then review and test
208+
- AI can understand how text based assets work with your project and thus can help with text based asset creation or augmentation. (i.e. you can request checking features in the gltf asset or slang shader).

0 commit comments

Comments
 (0)