Skip to content

Init vulkan#5132

Open
gnavdev28 wants to merge 7 commits into
ldc-developers:masterfrom
gnavdev28:init_vulkan
Open

Init vulkan#5132
gnavdev28 wants to merge 7 commits into
ldc-developers:masterfrom
gnavdev28:init_vulkan

Conversation

@gnavdev28
Copy link
Copy Markdown
Contributor

@gnavdev28 gnavdev28 commented May 24, 2026

In this PR, I have:

  • Squashed and integrated Nicholas's PR: [Dcompute] Initial support for Vulkan #4958.
  • Added new values for the --mdcompute-targets flag, expanding support from vulkan 1.0 to vulkan 1.6.
  • Fixed a minor typo in llvmhelpers.cpp (changed . to ->) to resolve a compilation failure.
  • Updated LLVM version checks by replacing LLVM_LDC_VER >= 2100 with LLVM_VERSION_MAJOR >= 23 across several files to fix the build with newer LLVM versions.
  • Updated CMakeLists.txt to fix linker/compilation errors.
  • Added and refined validation/error messages related to supported Vulkan versions.

💡 Technical Notes

To make LLVM_VERSION_MAJOR >= 23 work correctly, #include "llvm/Config/llvm-config.h" has been added to the corresponding files where it was missing.

Copilot AI review requested due to automatic review settings May 24, 2026 05:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds initial Vulkan DCompute target support (SPIR-V/Vulkan) and wires it into the driver/build configuration for LLVM versions supporting the required SPIR-V/HLSL infrastructure.

Changes:

  • Add Vulkan as a DCompute/reflect target and introduce a Vulkan-specific SPIR-V ABI.
  • Implement a new Vulkan DCompute backend target (targetVulkan.cpp) and update driver parsing/help text for vulkan-xy0.
  • Update build configuration to include new sources and LLVM component dependencies.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
runtime/druntime/src/ldc/dcompute.d Adds Vulkan to ReflectTarget.
gen/llvmhelpers.cpp Adjusts LLVM 23+ getMCAsmInfo() access.
gen/dcompute/targetVulkan.cpp New Vulkan DCompute target implementation.
gen/dcompute/target.h Adds Vulkan target ID + factory declaration (LLVM 23+).
gen/abi/targets.h Declares Vulkan-specific SPIR-V ABI factory.
gen/abi/spirv.cpp Implements Vulkan SPIR-V ABI (calling convention override).
driver/dcomputecodegenerator.cpp Adds vulkan-* target parsing + updates error text.
driver/cl_options.cpp Updates CLI help to mention Vulkan targets.
CMakeLists.txt Adds LLVM frontendhlsl, expands gen source globs, changes MSVC link flags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 79 to 85
error(Loc(),
"Unrecognised or invalid DCompute targets: the format is ocl-xy0 "
"for OpenCl x.y and cuda-xy0 for CUDA CC x.y."
"for OpenCl x.y and cuda-xy0 for CUDA CC x.y, and vulkan-xy0 for Vulkan."
#if LDC_LLVM_SUPPORTED_TARGET_SPIRV
" Valid version strings for OpenCl are ocl-{" XSTR(OCL_VALID_VER_INIT) "}."
" Valid version strings for Vulkan are vulkan-{" XSTR(VULKAN_VALID_VER_INIT) "}."
#endif
Comment on lines +108 to +109
llvm::Value *buildIntrinsicCall(IRBuilder<>& builder, llvm::StringRef dbg,llvm::StringRef name,
llvm::ArrayRef<llvm::Type *> types, llvm::ArrayRef<llvm::Value *> args) {
Comment on lines +114 to +116
llvm::Function *intrinsic = llvm::Intrinsic::getOrInsertDeclaration(&_ir->module,
llvm::Intrinsic::lookupIntrinsicID(name),
types);
Comment thread gen/dcompute/targetVulkan.cpp
Comment on lines +102 to +105
auto * ArrayType = llvm::ArrayType::get(argType, 0);
return llvm::TargetExtType::get(ctx, "spirv.VulkanBuffer",
{ArrayType},
{12/*StorageClass*/, 0 /*isWritable*/});
Comment thread CMakeLists.txt
Comment on lines 32 to 37
find_package(LLVM 18.0 REQUIRED
all-targets analysis asmparser asmprinter bitreader bitwriter codegen core
debuginfodwarf debuginfomsf debuginfopdb demangle
debuginfodwarf debuginfomsf debuginfopdb demangle frontendhlsl
instcombine ipo instrumentation irreader libdriver linker lto mc
mcdisassembler mcparser objcarcopts object option profiledata scalaropts
selectiondag support tablegen target transformutils vectorize
Comment thread CMakeLists.txt Outdated
if(${D_COMPILER_ID} STREQUAL "DigitalMars" AND (MSVC_VERSION GREATER 1800)) # VS 2015+
append("-Llegacy_stdio_definitions.lib" DFLAGS_BASE)
endif()
append("-L/NODEFAULTLIB:libucrt -L/NODEFAULTLIB:libcmt -L/NODEFAULTLIB:libvcruntime -Lmsvcrt.lib -Lucrt.lib -Lvcruntime.lib -Llegacy_stdio_definitions.lib" DFLAGS_BASE)
Comment thread CMakeLists.txt Outdated

include (CMakeCPack.cmake)
include (CPack)

gnavdev28 added 6 commits May 24, 2026 16:09
commit 4314ddcbee8d65049675fb5d33cf71241d3a8bfd
Merge: 29789c7 79976be
Author: Pham Quang Ha <ha.phamquang.dev@gmail.com>
Date:   Tue May 12 11:50:28 2026 +0700

    Merge remote-tracking branch 'upstream/master' into pr-4958

commit 29789c7
Author: Nicholas Wilson <iamthewilsonator@hotmail.com>
Date:   Mon Oct 20 15:42:49 2025 +0800

    [Dcompute] initial vulkan support
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