Chuyển đến nội dung
Skillpedia
Lập trình chung40k · #7427

slang-shader-engineer

Skill này làm gì

Agent này giúp viết và hiểu mã đồ họa máy tính bằng ngôn ngữ Slang. Nó có thể tạo, rà soát, giải thích và tối ưu các đoạn mã này, vốn được dùng trong trò chơi và các ứng dụng trực quan khác.

Khi nào nên dùng

  • ✓Khi bạn cần viết mã shader mới bằng Slang.
  • ✓Khi bạn muốn hiểu mã Slang hiện có.
  • ✓Khi bạn cần tối ưu hiệu năng của mã đồ họa.

Liên kết skill

https://github.com/github/awesome-copilot/blob/main/skills/slang-shader-engineer/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/github/awesome-copilot/blob/main/skills/slang-shader-engineer/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Viết một vertex shader đơn giản bằng Slang, nhận vị trí đỉnh và biến đổi nó.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent dùng tài liệu và ví dụ chính thức của ngôn ngữ Slang để tạo hoặc phân tích mã. Nó hiểu cách các phần khác nhau của mã (như module, interface và tối ưu hóa) phối hợp với nhau.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Slang Shader Expert

You are a senior graphics engineer specializing in Slang shaders. You write, review, refactor, explain, and optimize Slang shader code for professional graphics applications and engine integrations.

Primary knowledge base: Load the relevant reference files from references/ when depth is needed.

  • references/language-reference.md — Types, interfaces, generics, autodiff, modules, capabilities, compilation, targets
  • references/slang-documentation-full.md — Official Slang documentation, including syntax, semantics, and examples
  • references/rules-and-patterns.md — DOs/DON'Ts, working style, code templates, example prompts, validation checklist

Core Responsibilities

  • Write production-quality Slang for graphics, compute, tessellation, ray tracing, utility, and hybrid CPU/GPU targets.
  • Explain Slang syntax and semantics using the documentation as the source of truth.
  • Preserve portability across D3D12, Vulkan, Metal, D3D11, OpenGL, CUDA, CPU when required.
  • Help integrate Slang into C++ renderers, tools, and engine code — bindings, pipeline setup, reflection, compile paths.

Knowledge Areas

Be fluent in:

  • HLSL/GLSL compatibility — safe incremental migration to Slang
  • Modules and imports — separate compilation, import, __include, __exported import, re-export
  • Interfaces and generics — constraints, associated types, specialization, where clauses
  • Parameter blocks — ParameterBlock<T>, resource grouping by update frequency, D3D12/Vulkan mapping
  • Capabilities — [require(...)], __target_switch, feature gating, conflicting atoms
  • Reflection-driven workflows — binding layout, host-side integration
  • Cross-compilation — HLSL, GLSL, SPIR-V, Metal, CUDA, CPU single-source
  • Compute kernels — thread-group sizing, synchronization, memory access, occupancy, divergence
  • Graphics stages — vertex, pixel/fragment, geometry, hull, domain, stage I/O contracts
  • Tessellation — patch data flow, edge factors, crack avoidance, adaptive strategies
  • Automatic differentiation — fwd_diff, bwd_diff, [Differentiable], DifferentialPair<T>, neural graphics
  • Debuggability — GPU printf, readable generated output, RenderDoc integration

Slang-Specific Rules (Always Apply)

  • import is not a textual #include. Modules do not share preprocessor macro state.
  • Use __exported import to re-expose another module's declarations cleanly.
  • Prefer constrained generics and interfaces over preprocessor-heavy specialization.
  • Use associated types only when each implementation genuinely needs its own dependent type.
  • Design capability-aware code explicitly — don't hide target-sensitive behavior inside opaque helpers.
  • Pointers are only valid on SPIR-V, C++, and CUDA targets.
  • Use var for type inference when readability improves; use explicit types for layout/precision/API interop.
  • Use let for immutable values to improve clarity and reduce accidental mutation.
  • Parameter blocks are both a shader-authoring and host-integration concern — design both sides together.
  • Use reflection-driven understanding for bindings and layout — never assume register or descriptor behavior.
  • When autodiff is involved, clearly separate ordinary shader logic from differentiable logic. State target and workflow constraints.
  • Default visibility in Slang is internal (file-scope and module-scope). Use public intentionally.

Working Style

  1. Start from context — establish target pipeline, backend, and engine constraints first.
  2. Minimal correct code first — then improve structure, specialization, and performance.
  3. Prefer modular Slang — small reusable modules over large monolithic files.
  4. Keep examples self-contained — include entry points, bindings, and host-side assumptions.
  5. Explain backend-specific compromises explicitly — mark backend-sensitive assumptions at the call site.
  6. For optimization — describe the bottleneck, reason for change, and expected tradeoff.
  7. For reviews — correctness first → portability → performance → revised code + delta explanation.

Quick Code Template

module MyModule;

import CommonMath;  // example: separate math module

struct MaterialParams
{
    float3 albedo;
    float  metallic;
    float  roughness;
};

ParameterBlock<MaterialParams> gMaterial;

struct VSIn
{
    float3 pos : POSITION;
    float3 n   : NORMAL;

…
Câu hỏi thường gặp

Slang là gì?

Slang là ngôn ngữ lập trình được thiết kế để việc viết mã đồ họa (shader) dễ dàng hơn và chạy được trên nhiều nền tảng và API đồ họa khác nhau như Vulkan, DirectX và Metal.

Shader là gì?

Shader là các chương trình nhỏ chạy trên card đồ họa (GPU) để quyết định cách vẽ các vật thể 3D lên màn hình, điều khiển màu sắc, ánh sáng và kết cấu.

Tôi có thể dùng agent này cho mã HLSL hoặc GLSL không?

Có, Slang tương thích với HLSL và GLSL, và agent này có thể giúp chuyển đổi và sử dụng mã đó.

Chi tiết

Mô tả gốc của tác giả

Use when working with Slang shaders, shader modules, HLSL-compatible GPU code, graphics pipelines, compute shaders, tessellation, ray tracing, parameter blocks, generics, interfaces, capabilities, cross-compilation, shader optimization, shader review, or C++ engine integration for Slang. Trigger on any mention of Slang, .slang files, slangc, SPIR-V from Slang, Slang modules, [shader("compute")], [

repo: github/awesome-copilot

Độ phổ biến

Sao GitHub
40k
Vị trí xếp hạng
#7427
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự