├── .gitattributes ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── generate_vs2022.bat ├── generate_xcode.sh ├── premake5.lua ├── src ├── main │ ├── main.cpp │ └── premake5.lua └── shaders │ └── simple.hlsl └── third-party ├── dawn.lua ├── dxc-osx ├── README.md ├── bin │ ├── dxc │ └── dxc-3.7 └── lib │ ├── libdxcompiler.3.7.dylib │ └── libdxcompiler.dylib ├── dxc ├── LICENSE-LLVM.txt ├── LICENSE-MIT.txt ├── LICENSE-MS.txt ├── README.md ├── bin │ ├── arm64 │ │ ├── dxc.exe │ │ ├── dxcompiler.dll │ │ └── dxil.dll │ ├── x64 │ │ ├── dxc.exe │ │ ├── dxcompiler.dll │ │ └── dxil.dll │ └── x86 │ │ ├── dxc.exe │ │ ├── dxcompiler.dll │ │ └── dxil.dll ├── inc │ ├── d3d12shader.h │ ├── dxcapi.h │ ├── dxcerrors.h │ └── dxcisense.h └── lib │ ├── arm64 │ └── dxcompiler.lib │ ├── x64 │ └── dxcompiler.lib │ └── x86 │ └── dxcompiler.lib ├── imgui.lua ├── premake ├── libluasocket.dylib ├── premake5 └── premake5.exe └── sdl.lua /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | local/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third-party/imgui"] 2 | path = third-party/imgui 3 | url = https://github.com/ocornut/imgui 4 | [submodule "third-party/sdl"] 5 | path = third-party/sdl 6 | url = https://github.com/libsdl-org/SDL 7 | branch = SDL2 8 | [submodule "third-party/dawn"] 9 | path = third-party/dawn 10 | url = https://github.com/hexops/dawn 11 | branch = generated-2023-08-10.1691685418 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 bottosson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a quick example of using [Dear ImGui](https://github.com/ocornut/imgui), [SDL](https://www.libsdl.org/) and the [Dawn](hhttps://dawn.googlesource.com/dawn/+/refs/heads/chromium-gpu-experimental/README.md) WebGPU implementation together with a custom [premake](https://premake.github.io/) build script. I created this to be able to experiment with using WebGPU as native graphics API. Despite its name, WebGPU is showing a lot of promise as a simple native graphics API, but there aren't that many examples around for quickly getting started with WebGPU and C++. 2 | 3 | Higlights: 4 | - Builds Dawn, Dear Imgui and SDL from source using premake to generate projects. 5 | - If you have Windows and Visual Studio 2022 or Mac OS X and XCode, all you should need to get started is this repo (but no promises it will work for your particular configuration). Run the generate projects script and build the solution generated in the "local" folder. 6 | - Dawn source includes generated code, normally generated from the build process, from https://github.com/hexops/dawn/tree/main/mach 7 | - Currently only supports Windows and DX12 or Mac OS X and Metal (only verified on Intel Mac). 8 | - Includes an example of using HLSL shaders by using dxc to build spir-v. DXC binaries are included in the repo for Windows and OS X. 9 | - Uses webgpu_cpp.h, a C++ api for webgpu 10 | 11 | Future work I am considering includes: 12 | - Updating to a newer Dawn version. Current version is from 2022-08-16 13 | - Attempting to reduce compile times and executable size 14 | - Generating and storing native shaders per platform rather than generating them at runtime. 15 | -------------------------------------------------------------------------------- /generate_vs2022.bat: -------------------------------------------------------------------------------- 1 | call "third-party/premake/premake5" vs2022 2 | pause 3 | -------------------------------------------------------------------------------- /generate_xcode.sh: -------------------------------------------------------------------------------- 1 | ./third-party/premake/premake5 xcode4 2 | -------------------------------------------------------------------------------- /premake5.lua: -------------------------------------------------------------------------------- 1 | workspace "webgpu-sdl-imgui-cpp-starter-%{_ACTION}" 2 | configurations { "Debug", "Release" } 3 | architecture "x86_64" 4 | startproject "Main" 5 | 6 | location ("local") 7 | 8 | filter "system:macosx" 9 | systemversion "11.0" 10 | 11 | target_dir = "%{wks.location}/bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}-%{_ACTION}" 12 | obj_dir = "%{wks.location}/obj/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}-%{_ACTION}" 13 | build_dir = "%{wks.location}/build/%{_ACTION}" 14 | 15 | sdl_include_dir = "%{wks.location}/../third-party/sdl/include" 16 | dawn_include_dir = "%{wks.location}/../third-party/dawn/include" 17 | dawn_gen_include_dir = "%{wks.location}/../third-party/dawn/out/Debug/gen/include" 18 | imgui_include_dir = "%{wks.location}/../third-party/imgui" 19 | 20 | group "third-party" 21 | include "third-party/sdl.lua" 22 | include "third-party/dawn.lua" 23 | include "third-party/imgui.lua" 24 | 25 | group "" 26 | 27 | include "src/main" -------------------------------------------------------------------------------- /src/main/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "shaderPaths.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #if defined(__MACOSX__) 14 | #include 15 | #endif // defined(__MACOSX__) 16 | 17 | static void OnUnhandledWgpuError(WGPUErrorType errorType, const char* message, void*) 18 | { 19 | const char* errorTypeString = ""; 20 | switch (errorType) 21 | { 22 | case WGPUErrorType_Validation: errorTypeString = "Validation"; break; 23 | case WGPUErrorType_OutOfMemory: errorTypeString = "Out of memory"; break; 24 | case WGPUErrorType_Unknown: errorTypeString = "Unknown"; break; 25 | case WGPUErrorType_DeviceLost: errorTypeString = "Device lost"; break; 26 | default: errorTypeString = "Unknown"; 27 | } 28 | printf("%s error: %s\n", errorTypeString, message); 29 | std::exit(1); 30 | } 31 | 32 | void SetAdapterCallback(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const* message, void* userdata) 33 | { 34 | *reinterpret_cast(userdata) = wgpu::Adapter(adapter); 35 | } 36 | 37 | void SetDeviceCallback(WGPURequestDeviceStatus status, WGPUDevice device, char const* message, void* userdata) 38 | { 39 | *reinterpret_cast(userdata) = wgpu::Device(device); 40 | } 41 | 42 | wgpu::ProgrammableStageDescriptor LoadShader(wgpu::Device& device, const char* name, wgpu::ShaderStage shaderStage) 43 | { 44 | static char spirvPath[512]; 45 | static char hlslPath[512]; 46 | static char cmdPath[512]; 47 | 48 | const char* entry; 49 | const char* targetProfile; 50 | switch (shaderStage) 51 | { 52 | case wgpu::ShaderStage::Compute: 53 | { 54 | targetProfile = "cs_6_7"; 55 | entry = "CSMain"; 56 | break; 57 | } 58 | case wgpu::ShaderStage::Fragment: 59 | { 60 | targetProfile = "ps_6_7"; 61 | entry = "PSMain"; 62 | break; 63 | } 64 | case wgpu::ShaderStage::Vertex: 65 | { 66 | targetProfile = "vs_6_7"; 67 | entry = "VSMain"; 68 | break; 69 | } 70 | } 71 | 72 | snprintf(spirvPath, sizeof(spirvPath), "shaders/%s_%s.spirv", name, entry); 73 | std::filesystem::file_time_type spirvTime; 74 | bool spirvExists = std::filesystem::exists(spirvPath); 75 | if (spirvExists) 76 | spirvTime = std::filesystem::last_write_time(spirvPath); 77 | 78 | snprintf(hlslPath, sizeof(hlslPath), "%s/%s.hlsl", SHADER_SOURCE_PATH, name); 79 | std::filesystem::file_time_type hlslTime; 80 | bool hlslExists = std::filesystem::exists(hlslPath); 81 | if (hlslExists) 82 | hlslTime = std::filesystem::last_write_time(hlslPath); 83 | 84 | if (!hlslExists && !spirvExists) 85 | { 86 | printf("Error loading shader: %s\n", name); 87 | std::exit(1); 88 | } 89 | 90 | 91 | if (!spirvExists || spirvTime < hlslTime) 92 | { 93 | std::filesystem::create_directory("shaders"); 94 | 95 | 96 | snprintf(cmdPath, sizeof(cmdPath), "%s -spirv -T %s -E %s -Fo %s %s", DXC_PATH, targetProfile, entry, spirvPath, hlslPath); 97 | 98 | #if defined(__WINDOWS__) 99 | { 100 | char* ix = cmdPath; 101 | while ((ix = strchr(ix, '/')) != nullptr) 102 | { 103 | *ix++ = '\\'; 104 | } 105 | } 106 | #endif // defined(__WINDOWS__) 107 | 108 | system(cmdPath); 109 | } 110 | 111 | if (!std::filesystem::exists(spirvPath)) 112 | { 113 | printf("Error loading shader: %s, can't find result after compiling.\n", name); 114 | std::exit(1); 115 | } 116 | 117 | std::ifstream f(spirvPath, std::ios::binary); 118 | f.seekg(0, f.end); 119 | size_t size = f.tellg(); 120 | f.seekg(0, f.beg); 121 | 122 | char* data = new char[size]; 123 | f.read(data, size); 124 | f.close(); 125 | 126 | wgpu::ShaderModuleSPIRVDescriptor spirv_desc = {}; 127 | spirv_desc.codeSize = (uint32_t)(size / sizeof(uint32_t)); 128 | spirv_desc.code = (uint32_t*)data; 129 | 130 | wgpu::ShaderModuleDescriptor desc = {}; 131 | desc.nextInChain = &spirv_desc; 132 | 133 | wgpu::ProgrammableStageDescriptor stage_desc = {}; 134 | stage_desc.module = device.CreateShaderModule(&desc); 135 | stage_desc.entryPoint = entry; 136 | 137 | delete[] data; 138 | 139 | return stage_desc; 140 | } 141 | 142 | struct WebGpuData 143 | { 144 | wgpu::Instance instance; 145 | wgpu::Adapter adapter; 146 | wgpu::Device device; 147 | wgpu::Surface surface; 148 | wgpu::SwapChain swapChain; 149 | 150 | #if defined(__MACOSX__) 151 | SDL_MetalView sdlMetalView; 152 | #endif 153 | 154 | static WebGpuData Create(SDL_Window& window, int width, int height); 155 | bool CreateSwapChain(int width, int height); 156 | 157 | 158 | }; 159 | 160 | bool WebGpuData::CreateSwapChain(int width, int height) 161 | { 162 | if (swapChain) 163 | swapChain.Release(); 164 | 165 | wgpu::SwapChainDescriptor swapChainDesc; 166 | swapChainDesc.width = width; 167 | swapChainDesc.height = height; 168 | swapChainDesc.usage = wgpu::TextureUsage::RenderAttachment; 169 | swapChainDesc.format = wgpu::TextureFormat::BGRA8Unorm; 170 | swapChainDesc.presentMode = wgpu::PresentMode::Mailbox; 171 | 172 | swapChain = device.CreateSwapChain(surface, &swapChainDesc); 173 | 174 | return (bool)swapChain; 175 | } 176 | 177 | WebGpuData WebGpuData::Create(SDL_Window& window, int width, int height) 178 | { 179 | WebGpuData data; 180 | 181 | data.instance = wgpu::CreateInstance(); 182 | 183 | if (!data.instance) 184 | return {}; 185 | 186 | data.instance.RequestAdapter(nullptr, SetAdapterCallback, reinterpret_cast(&data.adapter)); 187 | 188 | if (!data.adapter) 189 | return {}; 190 | 191 | data.adapter.RequestDevice(nullptr, SetDeviceCallback, reinterpret_cast(&data.device)); 192 | 193 | if (!data.device) 194 | return {}; 195 | 196 | data.device.SetUncapturedErrorCallback(OnUnhandledWgpuError, nullptr); 197 | 198 | #if defined(__WINDOWS__) 199 | SDL_SysWMinfo wmInfo; 200 | SDL_VERSION(&wmInfo.version); 201 | SDL_GetWindowWMInfo(&window, &wmInfo); 202 | 203 | wgpu::SurfaceDescriptorFromWindowsHWND windowsDesc; 204 | windowsDesc.hwnd = wmInfo.info.win.window; 205 | windowsDesc.hinstance = wmInfo.info.win.hinstance; 206 | 207 | #elif defined(__MACOSX__) 208 | data.sdlMetalView = SDL_Metal_CreateView(&window); 209 | wgpu::SurfaceDescriptorFromMetalLayer windowsDesc; 210 | windowsDesc.layer = SDL_Metal_GetLayer(data.sdlMetalView); 211 | #endif 212 | 213 | wgpu::SurfaceDescriptor surfaceDesc; 214 | surfaceDesc.nextInChain = &windowsDesc; 215 | data.surface = data.instance.CreateSurface(&surfaceDesc); 216 | 217 | if (!data.surface) 218 | return {}; 219 | 220 | if (!data.CreateSwapChain(width, height)) 221 | return {}; 222 | 223 | return data; 224 | } 225 | 226 | int main(int argc, char** argv) 227 | { 228 | if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) 229 | { 230 | printf("Error: %s\n", SDL_GetError()); 231 | return -1; 232 | } 233 | 234 | SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); 235 | SDL_Window* window = SDL_CreateWindow("Dear ImGui + SDL2 + Dawn Example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); 236 | SDL_SysWMinfo wmInfo; 237 | SDL_VERSION(&wmInfo.version); 238 | SDL_GetWindowWMInfo(window, &wmInfo); 239 | 240 | #if defined(__WINDOWS__) 241 | HWND hwnd = (HWND)wmInfo.info.win.window; 242 | #endif // defined(__WINDOWS__) 243 | 244 | int w, h; 245 | SDL_GL_GetDrawableSize(window, &w, &h); 246 | { 247 | WebGpuData webGpuData = WebGpuData::Create(*window, w, h); 248 | if (!webGpuData.swapChain) 249 | { 250 | return 1; 251 | } 252 | 253 | wgpu::RenderPipeline simpleRenderPipeline; 254 | 255 | { 256 | wgpu::ProgrammableStageDescriptor simpleFragment = LoadShader(webGpuData.device, "simple", wgpu::ShaderStage::Fragment); 257 | wgpu::ProgrammableStageDescriptor simpleVertex = LoadShader(webGpuData.device, "simple", wgpu::ShaderStage::Vertex); 258 | 259 | wgpu::RenderPipelineDescriptor renderPipelineDesc = {}; 260 | renderPipelineDesc.primitive.topology = wgpu::PrimitiveTopology::TriangleList; 261 | renderPipelineDesc.layout = nullptr; 262 | 263 | // Create the vertex shader 264 | renderPipelineDesc.vertex.module = simpleVertex.module; 265 | renderPipelineDesc.vertex.entryPoint = simpleVertex.entryPoint; 266 | 267 | wgpu::VertexAttribute vertexDesc[] = 268 | { 269 | { wgpu::VertexFormat::Float32x2, 0, 0 }, 270 | { wgpu::VertexFormat::Float32x3, 2 * sizeof(float), 1 }, 271 | }; 272 | 273 | wgpu::VertexBufferLayout bufferLayouts[1]; 274 | bufferLayouts[0].arrayStride = 5 * sizeof(float); 275 | bufferLayouts[0].stepMode = wgpu::VertexStepMode::Vertex; 276 | bufferLayouts[0].attributeCount = 2; 277 | bufferLayouts[0].attributes = vertexDesc; 278 | 279 | renderPipelineDesc.vertex.bufferCount = 1; 280 | renderPipelineDesc.vertex.buffers = bufferLayouts; 281 | 282 | // Create the blending setup 283 | wgpu::BlendState blendState = {}; 284 | blendState.alpha.operation = wgpu::BlendOperation::Add; 285 | blendState.alpha.srcFactor = wgpu::BlendFactor::One; 286 | blendState.alpha.dstFactor = wgpu::BlendFactor::OneMinusSrcAlpha; 287 | blendState.color.operation = wgpu::BlendOperation::Add; 288 | blendState.color.srcFactor = wgpu::BlendFactor::SrcAlpha; 289 | blendState.color.dstFactor = wgpu::BlendFactor::OneMinusSrcAlpha; 290 | 291 | wgpu::ColorTargetState colorState = {}; 292 | colorState.format = wgpu::TextureFormat::BGRA8Unorm; 293 | colorState.blend = &blendState; 294 | colorState.writeMask = wgpu::ColorWriteMask::All; 295 | 296 | wgpu::FragmentState fragmentState = {}; 297 | fragmentState.module = simpleFragment.module; 298 | fragmentState.entryPoint = simpleFragment.entryPoint; 299 | fragmentState.targetCount = 1; 300 | fragmentState.targets = &colorState; 301 | 302 | renderPipelineDesc.fragment = &fragmentState; 303 | 304 | simpleRenderPipeline = webGpuData.device.CreateRenderPipeline(&renderPipelineDesc); 305 | } 306 | 307 | wgpu::Buffer vertexBuffer; 308 | 309 | { 310 | wgpu::BufferDescriptor desc = {}; 311 | desc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Vertex; 312 | desc.size = 3 * 5 * sizeof(float); 313 | vertexBuffer = webGpuData.device.CreateBuffer(&desc); 314 | } 315 | 316 | IMGUI_CHECKVERSION(); 317 | ImGui::CreateContext(); 318 | ImGui::StyleColorsDark(); 319 | #if defined(__WINDOWS__) 320 | ImGui_ImplSDL2_InitForD3D(window); 321 | #elif defined(__MACOSX__) 322 | ImGui_ImplSDL2_InitForMetal(window); 323 | #endif 324 | ImGui_ImplWGPU_Init(webGpuData.device.Get(), 3, WGPUTextureFormat_BGRA8Unorm, WGPUTextureFormat_Undefined); 325 | 326 | float colorA[] = { 1.f,0.f,0.f }; 327 | float colorB[] = { 0.f,1.f,0.f }; 328 | float colorC[] = { 0.f,0.f,1.f }; 329 | 330 | bool done = false; 331 | while (!done) 332 | { 333 | SDL_Event event; 334 | while (SDL_PollEvent(&event)) 335 | { 336 | ImGui_ImplSDL2_ProcessEvent(&event); 337 | if (event.type == SDL_QUIT) 338 | done = true; 339 | if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) 340 | done = true; 341 | if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED && event.window.windowID == SDL_GetWindowID(window)) 342 | { 343 | int w, h; 344 | SDL_GL_GetDrawableSize(window, &w, &h); 345 | 346 | ImGui_ImplWGPU_InvalidateDeviceObjects(); 347 | webGpuData.CreateSwapChain(w, h); 348 | ImGui_ImplWGPU_CreateDeviceObjects(); 349 | } 350 | } 351 | 352 | { 353 | ImGui_ImplWGPU_NewFrame(); 354 | ImGui_ImplSDL2_NewFrame(); 355 | ImGui::NewFrame(); 356 | 357 | { 358 | ImGui::Begin("Triangle Colors"); 359 | ImGui::ColorPicker3("A", colorA); 360 | ImGui::ColorPicker3("B", colorB); 361 | ImGui::ColorPicker3("C", colorC); 362 | ImGui::End(); 363 | } 364 | 365 | ImGui::Render(); 366 | } 367 | 368 | { 369 | wgpu::RenderPassColorAttachment colorAttachments = {}; 370 | colorAttachments.loadOp = wgpu::LoadOp::Clear; 371 | colorAttachments.storeOp = wgpu::StoreOp::Store; 372 | colorAttachments.clearValue = { 0.1f, 0.1f, 0.1f, 1.f }; 373 | colorAttachments.view = webGpuData.swapChain.GetCurrentTextureView(); 374 | 375 | wgpu::RenderPassDescriptor renderPassDesc = {}; 376 | renderPassDesc.colorAttachmentCount = 1; 377 | renderPassDesc.colorAttachments = &colorAttachments; 378 | renderPassDesc.depthStencilAttachment = NULL; 379 | 380 | wgpu::CommandEncoderDescriptor encoderDesc = {}; 381 | wgpu::CommandEncoder encoder = webGpuData.device.CreateCommandEncoder(&encoderDesc); 382 | 383 | wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDesc); 384 | 385 | pass.SetPipeline(simpleRenderPipeline); 386 | pass.SetVertexBuffer(0, vertexBuffer); 387 | pass.Draw(3, 1, 0, 0); 388 | 389 | ImGui_ImplWGPU_RenderDrawData(ImGui::GetDrawData(), pass.Get()); 390 | pass.End(); 391 | 392 | wgpu::CommandBufferDescriptor commandBufferDesc = {}; 393 | wgpu::CommandBuffer commandBuffer = encoder.Finish(&commandBufferDesc); 394 | wgpu::Queue queue = wgpuDeviceGetQueue(webGpuData.device.Get()); 395 | 396 | float vertexData[] = 397 | { 398 | -0.8f, -0.8f, colorA[0], colorA[1], colorA[2], 399 | 0.8f, -0.8f, colorB[0], colorB[1], colorB[2], 400 | -0.0f, 0.8f, colorC[0], colorC[1], colorC[2], 401 | }; 402 | queue.WriteBuffer(vertexBuffer, 0, vertexData, sizeof(vertexData)); 403 | 404 | queue.Submit(1, &commandBuffer); 405 | 406 | webGpuData.swapChain.Present(); 407 | } 408 | } 409 | 410 | ImGui_ImplWGPU_Shutdown(); 411 | ImGui_ImplSDL2_Shutdown(); 412 | ImGui::DestroyContext(); 413 | 414 | #if defined(__MACOSX__) 415 | SDL_MetalView metalView = webGpuData.sdlMetalView; 416 | #endif 417 | 418 | webGpuData = {}; 419 | 420 | #if defined(__MACOSX__) 421 | SDL_Metal_DestroyView(metalView); 422 | #endif 423 | } 424 | 425 | SDL_DestroyWindow(window); 426 | SDL_Quit(); 427 | 428 | return 0; 429 | } 430 | -------------------------------------------------------------------------------- /src/main/premake5.lua: -------------------------------------------------------------------------------- 1 | project "Main" 2 | kind "ConsoleApp" 3 | language "C++" 4 | cppdialect "C++17" 5 | flags { 6 | "MultiProcessorCompile" 7 | } 8 | 9 | io.writefile("../../local/gen/main/shaderPaths.h",[[ 10 | #pragma once 11 | // This file is generated from Premake. Edits will be overwritten 12 | #include 13 | #if defined(__WINDOWS__) 14 | #define DXC_PATH "../../../../third-party/dxc/bin/x64/dxc.exe" 15 | #elif defined(__MACOSX__) 16 | #define DXC_PATH "../../../../third-party/dxc-osx/bin/dxc" 17 | #endif 18 | #define SHADER_SOURCE_PATH "../../../../src/shaders" 19 | ]]) 20 | 21 | targetdir (target_dir .. "/%{prj.name}") 22 | debugdir (target_dir .. "/%{prj.name}") 23 | objdir (obj_dir .. "/%{prj.name}") 24 | location (build_dir .. "/%{prj.name}") 25 | 26 | includedirs { 27 | "", 28 | "%{wks.location}/gen/main", 29 | } 30 | 31 | externalincludedirs { 32 | "", 33 | "%{wks.location}/gen/main", 34 | dawn_include_dir, 35 | dawn_gen_include_dir, 36 | sdl_include_dir, 37 | imgui_include_dir, 38 | } 39 | 40 | links { 41 | "Dawn", 42 | "SDL", 43 | "SDL_main", 44 | "Imgui", 45 | } 46 | 47 | files { 48 | "%{wks.location}/gen/main/**.h", 49 | "%{wks.location}/gen/main/**.cpp", 50 | "**.h", 51 | "**.cpp" 52 | } 53 | 54 | filter "system:macosx" 55 | systemversion "11.0" 56 | links { 57 | "AudioToolbox.framework", 58 | "Carbon.framework", 59 | "Cocoa.framework", 60 | "CoreAudio.framework", 61 | "CoreFoundation.framework", 62 | "CoreHaptics.framework", 63 | "ForceFeedback.framework", 64 | "GameController.framework", 65 | "IOKit.framework", 66 | "IOSurface.framework", 67 | "Metal.framework", 68 | "QuartzCore.framework", 69 | } 70 | 71 | filter "configurations:Debug" 72 | defines { "DEBUG" } 73 | symbols "On" 74 | 75 | filter "configurations:Release" 76 | defines { "NDEBUG" } 77 | optimize "On" -------------------------------------------------------------------------------- /src/shaders/simple.hlsl: -------------------------------------------------------------------------------- 1 | struct PSInput 2 | { 3 | float4 position : SV_POSITION; 4 | float4 color : COLOR; 5 | }; 6 | 7 | PSInput VSMain(float4 position : POSITION, float4 color : COLOR) 8 | { 9 | PSInput result; 10 | 11 | result.position = position; 12 | result.color = color; 13 | 14 | return result; 15 | } 16 | 17 | float4 PSMain(PSInput input) : SV_TARGET 18 | { 19 | return input.color; 20 | } -------------------------------------------------------------------------------- /third-party/dawn.lua: -------------------------------------------------------------------------------- 1 | project "Dawn" 2 | kind "StaticLib" 3 | language "C++" 4 | cppdialect "C++17" 5 | flags { 6 | "MultiProcessorCompile" 7 | } 8 | 9 | targetdir (target_dir .. "/%{prj.name}") 10 | objdir (obj_dir .. "/%{prj.name}") 11 | location (build_dir .. "/%{prj.name}") 12 | 13 | includedirs { 14 | "dawn/", 15 | "dawn/src/", 16 | "dawn/include", 17 | "dawn/out/Debug/gen/src", 18 | "dawn/out/Debug/gen/include", 19 | } 20 | 21 | externalincludedirs { 22 | "dawn/", 23 | "dawn/src/", 24 | "dawn/include", 25 | "dawn/out/Debug/gen/src", 26 | "dawn/out/Debug/gen/include", 27 | "dawn/third_party/abseil-cpp", 28 | "dawn/out/Debug/gen/third_party/vulkan-deps/spirv-tools/src", 29 | "dawn/third_party/vulkan-deps/spirv-tools/src", 30 | "dawn/third_party/vulkan-deps/spirv-tools/src/include", 31 | "dawn/third_party/vulkan-deps/spirv-headers/src/include", 32 | 33 | } 34 | files { 35 | "dawn/include/**.h", 36 | "dawn/out/Debug/gen/include/**.h", 37 | "dawn/src/**.h", 38 | "dawn/src/**.cpp", 39 | "dawn/src/**.cc", 40 | "dawn/out/Debug/gen/src/**.h", 41 | "dawn/out/Debug/gen/src/**.cpp", 42 | "dawn/third_party/vulkan-deps/spirv-tools/src/source/**.h", 43 | "dawn/third_party/vulkan-deps/spirv-tools/src/source/**.cpp", 44 | "dawn/third_party/abseil-cpp/absl/base/**.h", 45 | "dawn/third_party/abseil-cpp/absl/base/**.cc", 46 | "dawn/third_party/abseil-cpp/absl/strings/**.h", 47 | "dawn/third_party/abseil-cpp/absl/strings/**.cc", 48 | "dawn/third_party/abseil-cpp/absl/numeric/**.h", 49 | "dawn/third_party/abseil-cpp/absl/numeric/**.cc", 50 | } 51 | removefiles { 52 | "dawn/src/dawn/common/WindowsUtils.cpp", 53 | "dawn/src/dawn/common/WindowsUtils.h", 54 | "dawn/src/dawn/common/xlib_with_undefs.h", 55 | "dawn/src/dawn/fuzzers/**", 56 | "dawn/src/dawn/tests/**", 57 | "dawn/src/dawn/native/*/**", 58 | "dawn/src/dawn/native/X11Functions.h", 59 | "dawn/src/dawn/native/X11Functions.cpp", 60 | "dawn/src/dawn/native/SpirvValidation.h", 61 | "dawn/src/dawn/native/SpirvValidation.cpp", 62 | "dawn/src/dawn/glfw/**", 63 | "dawn/src/dawn/node/**", 64 | "dawn/src/dawn/node/**", 65 | "dawn/src/dawn/samples/**", 66 | "dawn/src/dawn/**_mock.h", 67 | "dawn/src/dawn/**_mock.cpp", 68 | "dawn/src/dawn/utils/**.cpp", 69 | "dawn/src/tint/**_test.h", 70 | "dawn/src/tint/**_test.cc", 71 | "dawn/src/tint/**_test_helper.h", 72 | "dawn/src/tint/**_test_helper.cc", 73 | "dawn/src/tint/bench/**", 74 | "dawn/src/tint/cmd/**", 75 | "dawn/src/tint/**_bench.h", 76 | "dawn/src/tint/**_bench.cc", 77 | "dawn/src/tint/fuzzers/**", 78 | "dawn/src/tint/**_posix.cc", 79 | "dawn/src/tint/**_windows.cc", 80 | "dawn/src/tint/**_linux.cc", 81 | "dawn/src/tint/**_other.cc", 82 | "dawn/src/tint/inspector/test_inspector_*", 83 | "dawn/src/tint/resolver/resolver_test_helper.h", 84 | "dawn/src/tint/resolver/resolver_test_helper.cc", 85 | "dawn/src/tint/test_main.cc", 86 | "dawn/src/tint/lang/wgsl/writer/options.cc", 87 | "dawn/out/Debug/gen/src/dawn/native/*/**", 88 | "dawn/out/Debug/gen/src/dawn/mock_webgpu.h", 89 | "dawn/out/Debug/gen/src/dawn/mock_webgpu.cpp", 90 | "dawn/third_party/vulkan-deps/spirv-tools/src/source/wasm/**", 91 | "dawn/third_party/vulkan-deps/spirv-tools/src/source/fuzz/**", 92 | "dawn/third_party/abseil-cpp/absl/**_benchmark.cc", 93 | "dawn/third_party/abseil-cpp/absl/**_testing.cc", 94 | "dawn/third_party/abseil-cpp/absl/**_test.cc", 95 | "dawn/third_party/abseil-cpp/absl/**_test_common.cc", 96 | "dawn/third_party/abseil-cpp/absl/**_test_helpers.h", 97 | } 98 | files { 99 | "dawn/src/dawn/native/null/**.h", 100 | "dawn/src/dawn/native/null/**.cpp", 101 | "dawn/src/dawn/native/stream/**.h", 102 | "dawn/src/dawn/native/stream/**.cpp", 103 | "dawn/src/dawn/native/utils/**.h", 104 | "dawn/src/dawn/native/utils/**.cpp", 105 | "dawn/src/dawn/utils/ComboRenderBundleEncoderDescriptor.cpp", 106 | "dawn/src/dawn/utils/ComboRenderBundleEncoderDescriptor.h", 107 | "dawn/src/dawn/utils/ComboRenderPipelineDescriptor.cpp", 108 | "dawn/src/dawn/utils/ComboRenderPipelineDescriptor.h", 109 | "dawn/src/dawn/utils/PlatformDebugLogger.h", 110 | "dawn/src/dawn/utils/ScopedAutoreleasePool.h", 111 | "dawn/src/dawn/utils/SystemUtils.cpp", 112 | "dawn/src/dawn/utils/SystemUtils.h", 113 | "dawn/src/dawn/utils/TerribleCommandBuffer.cpp", 114 | "dawn/src/dawn/utils/TerribleCommandBuffer.h", 115 | "dawn/src/dawn/utils/TestUtils.cpp", 116 | "dawn/src/dawn/utils/TestUtils.h", 117 | "dawn/src/dawn/utils/TextureUtils.cpp", 118 | "dawn/src/dawn/utils/TextureUtils.h", 119 | "dawn/src/dawn/utils/Timer.h", 120 | "dawn/src/dawn/utils/WGPUHelpers.cpp", 121 | "dawn/src/dawn/utils/WGPUHelpers.h", 122 | "dawn/src/dawn/utils/WireHelper.cpp", 123 | "dawn/src/dawn/utils/WireHelper.h", 124 | } 125 | defines { 126 | "TINT_BUILD_WGSL_WRITER", 127 | "TINT_BUILD_WGSL_READER", 128 | "TINT_BUILD_SPV_WRITER", 129 | "TINT_BUILD_SPV_READER", 130 | } 131 | 132 | filter "configurations:Debug" 133 | defines { "DEBUG" } 134 | symbols "On" 135 | 136 | filter "configurations:Release" 137 | defines { "NDEBUG" } 138 | optimize "On" 139 | 140 | filter "system:macosx" 141 | systemversion "11.0" 142 | files { 143 | "dawn/src/dawn/common/**.mm", 144 | "dawn/src/dawn/native/metal/**.h", 145 | "dawn/src/dawn/native/metal/**.cpp", 146 | "dawn/src/dawn/native/**.mm", 147 | } 148 | defines { 149 | "DAWN_ENABLE_BACKEND_METAL", 150 | "TINT_BUILD_MSL_WRITER", 151 | } 152 | 153 | filter "system:windows" 154 | links { 155 | "d3d12", 156 | "dxgi", 157 | "dxguid", 158 | } 159 | files { 160 | "dawn/src/tint/**_windows.cc", 161 | "dawn/src/dawn/common/WindowsUtils.cpp", 162 | "dawn/src/dawn/common/WindowsUtils.h", 163 | "dawn/src/dawn/native/d3d12/**.h", 164 | "dawn/src/dawn/native/d3d12/**.cpp", 165 | "dawn/src/dawn/native/d3d/**.h", 166 | "dawn/src/dawn/native/d3d/**.cpp", 167 | "dawn/src/dawn/utils/WindowsDebugLogger.cpp", 168 | "dawn/src/dawn/utils/WindowsTimer.cpp", 169 | } 170 | defines { 171 | "NOMINMAX", 172 | "DAWN_ENABLE_BACKEND_D3D12", 173 | "TINT_BUILD_HLSL_WRITER", 174 | } -------------------------------------------------------------------------------- /third-party/dxc-osx/README.md: -------------------------------------------------------------------------------- 1 | # DirectX Shader Compiler OS X build 2 | 3 | This is a OS X build of DirectX Shader Compiler Version 1.7.2212. Built based on the instructions provided here: https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DxcOnUnix.rst 4 | -------------------------------------------------------------------------------- /third-party/dxc-osx/bin/dxc: -------------------------------------------------------------------------------- 1 | dxc-3.7 -------------------------------------------------------------------------------- /third-party/dxc-osx/bin/dxc-3.7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc-osx/bin/dxc-3.7 -------------------------------------------------------------------------------- /third-party/dxc-osx/lib/libdxcompiler.3.7.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc-osx/lib/libdxcompiler.3.7.dylib -------------------------------------------------------------------------------- /third-party/dxc-osx/lib/libdxcompiler.dylib: -------------------------------------------------------------------------------- 1 | libdxcompiler.3.7.dylib -------------------------------------------------------------------------------- /third-party/dxc/LICENSE-LLVM.txt: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | LLVM Release License 3 | ============================================================================== 4 | University of Illinois/NCSA 5 | Open Source License 6 | 7 | Copyright (c) 2003-2015 University of Illinois at Urbana-Champaign. 8 | All rights reserved. 9 | 10 | Developed by: 11 | 12 | LLVM Team 13 | 14 | University of Illinois at Urbana-Champaign 15 | 16 | http://llvm.org 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy of 19 | this software and associated documentation files (the "Software"), to deal with 20 | the Software without restriction, including without limitation the rights to 21 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 22 | of the Software, and to permit persons to whom the Software is furnished to do 23 | so, subject to the following conditions: 24 | 25 | * Redistributions of source code must retain the above copyright notice, 26 | this list of conditions and the following disclaimers. 27 | 28 | * Redistributions in binary form must reproduce the above copyright notice, 29 | this list of conditions and the following disclaimers in the 30 | documentation and/or other materials provided with the distribution. 31 | 32 | * Neither the names of the LLVM Team, University of Illinois at 33 | Urbana-Champaign, nor the names of its contributors may be used to 34 | endorse or promote products derived from this Software without specific 35 | prior written permission. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 38 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 39 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 40 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 41 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 42 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 43 | SOFTWARE. 44 | -------------------------------------------------------------------------------- /third-party/dxc/LICENSE-MIT.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) Microsoft Corporation. 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /third-party/dxc/LICENSE-MS.txt: -------------------------------------------------------------------------------- 1 | MICROSOFT SOFTWARE LICENSE TERMS 2 | 3 | MICROSOFT DIRECTX SHADER COMPILER 4 | 5 | These license terms are an agreement between you and Microsoft 6 | Corporation (or one of its affiliates). They apply to the software named 7 | above and any Microsoft services or software updates (except to the 8 | extent such services or updates are accompanied by new or additional 9 | terms, in which case those different terms apply prospectively and do 10 | not alter your or Microsoft’s rights relating to pre-updated software or 11 | services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS 12 | BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. 13 | 14 | INSTALLATION AND USE RIGHTS. 15 | 16 | a) General. Subject to the terms of this agreement, you may install and use any number of copies of the software, and solely for use on Windows. 17 | 18 | b) Included Microsoft Applications. The software may include other Microsoft applications. These license terms apply to those included applications, if any, unless other license terms are provided with the other Microsoft applications. 19 | 20 | c) Microsoft Platforms. The software may include components from Microsoft Windows. These components are governed by separate agreements and their own product support policies, as described in the license terms found in the installation directory for that component or in the “Licenses” folder accompanying the software. 21 | 22 | d) Third Party Components. The software may include third party components with separate legal notices or governed by other agreements, as may be described in the ThirdPartyNotices file(s) accompanying the software. 23 | 24 | TIME-SENSITIVE SOFTWARE. 25 | 26 | a) Period. This agreement is effective on your acceptance and terminates on the earlier of (i) 30 days following first availability of a commercial release of the software or (ii) upon termination by Microsoft. Microsoft may extend this agreement in its discretion. 27 | 28 | b) Access to data. You may not be able to access data used in the software when it stops running. 29 | 30 | 3. DATA. 31 | 32 | a. Data Collection. The software may collect information about you and your use of the software, and send that to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may opt-out of many of these scenarios, but not all, as described in the product documentation.  There are also some features in the software that may enable you to collect data from users of your applications. If you use these features to enable data collection in your applications, you must comply with applicable law, including providing appropriate notices to users of your applications. You can learn more about data collection and use in the help documentation and the privacy statement at https://aka.ms/privacy. Your use of the software operates as your consent to these practices. 33 | 34 | b. Processing of Personal Data. To the extent Microsoft is a processor or subprocessor of personal data in connection with the software, Microsoft makes the commitments in the European Union General Data Protection Regulation Terms of the Online Services Terms to all customers effective May 25, 2018, at https://docs.microsoft.com/en-us/legal/gdpr. 35 | 36 | 4. SCOPE OF LICENSE. The software is licensed, not sold. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you will not (and have no right to): 37 | 38 | a) work around any technical limitations in the software that only allow you to use it in certain ways; 39 | 40 | b) reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; 41 | 42 | c) remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software; 43 | 44 | d) use the software in any way that is against the law or to create or propagate malware; or 45 | 46 | e) share, publish, distribute, or lease the software, provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party. 47 | 48 | 5. PRE-RELEASE SOFTWARE. The software is a pre-release version. It may not operate correctly. It may be different from the commercially released version. 49 | 50 | 6. FEEDBACK. If you give feedback about the software to Microsoft, you give to Microsoft, without charge, the right to use, share and commercialize your feedback in any way and for any purpose. You will not give feedback that is subject to a license that requires Microsoft to license its software or documentation to third parties because Microsoft includes your feedback in them. These rights survive this agreement. 51 | 52 | 7. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit https://aka.ms/exporting. 53 | 54 | 8. SUPPORT SERVICES. Microsoft is not obligated under this agreement to provide any support services for the software. Any support provided is “as is”, “with all faults”, and without warranty of any kind. 55 | 56 | 9. UPDATES. The software may periodically check for updates, and download and install them for you. You may obtain updates only from Microsoft or authorized sources. Microsoft may need to update your system to provide you with updates. You agree to receive these automatic updates without any additional notice. Updates may not include or support all existing software features, services, or peripheral devices. 57 | 58 | 10. ENTIRE AGREEMENT. This agreement, and any other terms Microsoft may provide for supplements, updates, or third-party applications, is the entire agreement for the software. 59 | 60 | 11. APPLICABLE LAW AND PLACE TO RESOLVE DISPUTES. If you acquired the software in the United States or Canada, the laws of the state or province where you live (or, if a business, where your principal place of business is located) govern the interpretation of this agreement, claims for its breach, and all other claims (including consumer protection, unfair competition, and tort claims), regardless of conflict of laws principles. If you acquired the software in any other country, its laws apply. If U.S. federal jurisdiction exists, you and Microsoft consent to exclusive jurisdiction and venue in the federal court in King County, Washington for all disputes heard in court. If not, you and Microsoft consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington for all disputes heard in court. 61 | 62 | 12. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state, province, or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state, province, or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you: 63 | 64 | a) Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights. 65 | 66 | b) Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software. 67 | 68 | c) Germany and Austria. 69 | 70 | i. Warranty. The properly licensed software will perform substantially 71 | as described in any Microsoft materials that accompany the software. 72 | However, Microsoft gives no contractual guarantee in relation to the 73 | licensed software. 74 | 75 | ii. Limitation of Liability. In case of intentional conduct, gross 76 | negligence, claims based on the Product Liability Act, as well as, in 77 | case of death or personal or physical injury, Microsoft is liable 78 | according to the statutory law. 79 | 80 | Subject to the foregoing clause ii., Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence. 81 | 82 | 13. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. 83 | 84 | 14. LIMITATION ON AND EXCLUSION OF DAMAGES. IF YOU HAVE ANY BASIS FOR RECOVERING DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. 85 | 86 | This limitation applies to (a) anything related to the software, 87 | services, content (including code) on third party Internet sites, or 88 | third party applications; and (b) claims for breach of contract, 89 | warranty, guarantee, or condition; strict liability, negligence, or 90 | other tort; or any other claim; in each case to the extent permitted 91 | by applicable law. 92 | 93 | It also applies even if Microsoft knew or should have known about the 94 | possibility of the damages. The above limitation or exclusion may not 95 | apply to you because your state, province, or country may not allow 96 | the exclusion or limitation of incidental, consequential, or other 97 | damages. 98 | -------------------------------------------------------------------------------- /third-party/dxc/README.md: -------------------------------------------------------------------------------- 1 | # DirectX Shader Compiler Redistributable Package 2 | 3 | This package contains a copy of the DirectX Shader Compiler redistributable and its associated development headers. 4 | 5 | For help getting started, please see: 6 | 7 | https://github.com/microsoft/DirectXShaderCompiler/wiki 8 | 9 | ## Licenses 10 | 11 | The included licenses apply to the following files: 12 | 13 | | License file | Applies to | 14 | |---|---| 15 | |LICENSE-MS.txt |dxil.dll| 16 | |LICENSE-MIT.txt |d3d12shader.h| 17 | |LICENSE-LLVM.txt |all other files| 18 | 19 | ## Changelog 20 | 21 | ### Version 1.7.2212 22 | 23 | DX Compiler release for December 2022. 24 | 25 | - Includes full support of HLSL 2021 for SPIRV generation as well as many HLSL 2021 fixes and enhancements: 26 | - HLSL 2021's `and`, `or` and `select` intrinsics are now exposed in all language modes. This was done to ease porting codebases to HLSL2021, but may cause name conflicts in existing code. 27 | - Improved template utility with user-defined types 28 | - Many additional bug fixes 29 | - Linux binaries are now included. 30 | This includes the compiler executable, the dynamic library, and the dxil signing library. 31 | - New flags for inspecting compile times: 32 | - `-ftime-report` flag prints a high level summary of compile time broken down by major phase or pass in the compiler. The DXC 33 | command line will print the output to stdout. 34 | - `-ftime-trace` flag prints a Chrome trace json file. The output can be routed to a specific file by providing a filename to 35 | the arguent using the format `-ftime-trace=`. Chrome trace files can be opened in Chrome by loading the built-in tracing tool 36 | at chrome://tracing. The trace file captures hierarchial timing data with additional context enabling a much more in-depth profiling 37 | experience. 38 | - Both new options are supported via the DXC API using the `DXC_OUT_TIME_REPORT` and `DXC_OUT_TIME_TRACE` output kinds respectively. 39 | - IDxcPdbUtils2 enables reading new PDB container part 40 | - `-P` flag will now behave as it does with cl using the file specified by `-Fi` or a default 41 | - Unbound multidimensional resource arrays are allowed 42 | - Diagnostic improvements 43 | - Reflection support on non-Windows platforms; minor updates adding RequiredFeatureFlags to library function reflection and thread group size for AS and MS. 44 | 45 | The package includes dxc.exe, dxcompiler.dll, corresponding lib and headers, and dxil.dll for x64 and arm64 platforms on Windows. 46 | For the first time the package also includes Linux version of the compiler with corresponding executable, libdxcompiler.so, corresponding headers, and libdxil.so for x64 platforms. 47 | 48 | The new DirectX 12 Agility SDK (Microsoft.Direct3D.D3D12 nuget package) and a hardware driver with appropriate support 49 | are required to run shader model 6.7 shaders. Please see https://aka.ms/directx12agility for details. 50 | 51 | The SPIR-V backend of the compiler has been enabled in this release. Please note that Microsoft does not perform testing/verification of the SPIR-V backend. 52 | 53 | 54 | ### Version 1.7.2207 55 | 56 | DX Compiler release for July 2022. Contains shader model 6.7 and many bug fixes and improvements, such as: 57 | 58 | - Features: Shader Model 6.7 includes support for Raw Gather, Programmable Offsets, QuadAny/QuadAll, WaveOpsIncludeHelperLanes, and more! 59 | - Platforms: ARM64 support 60 | - HLSL 2021 : Enable “using” keyword 61 | - Optimizations: Loop unrolling and dead code elimination improvements 62 | - Developer tools: Improved disassembly output 63 | 64 | The package includes dxc.exe, dxcompiler.dll, corresponding lib and headers, and dxil.dll for x64 and, for the first time, arm64 platforms! 65 | 66 | The new DirectX 12 Agility SDK (Microsoft.Direct3D.D3D12 nuget package) and a hardware driver with appropriate support 67 | are required to run shader model 6.7 shaders. Please see https://aka.ms/directx12agility for details. 68 | 69 | The SPIR-V backend of the compiler has been enabled in this release. Please note that Microsoft does not perform testing/verification of the SPIR-V backend. 70 | -------------------------------------------------------------------------------- /third-party/dxc/bin/arm64/dxc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/bin/arm64/dxc.exe -------------------------------------------------------------------------------- /third-party/dxc/bin/arm64/dxcompiler.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/bin/arm64/dxcompiler.dll -------------------------------------------------------------------------------- /third-party/dxc/bin/arm64/dxil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/bin/arm64/dxil.dll -------------------------------------------------------------------------------- /third-party/dxc/bin/x64/dxc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/bin/x64/dxc.exe -------------------------------------------------------------------------------- /third-party/dxc/bin/x64/dxcompiler.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/bin/x64/dxcompiler.dll -------------------------------------------------------------------------------- /third-party/dxc/bin/x64/dxil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/bin/x64/dxil.dll -------------------------------------------------------------------------------- /third-party/dxc/bin/x86/dxc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/bin/x86/dxc.exe -------------------------------------------------------------------------------- /third-party/dxc/bin/x86/dxcompiler.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/bin/x86/dxcompiler.dll -------------------------------------------------------------------------------- /third-party/dxc/bin/x86/dxil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/bin/x86/dxil.dll -------------------------------------------------------------------------------- /third-party/dxc/inc/d3d12shader.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) Microsoft Corporation. 4 | // Licensed under the MIT license. 5 | // 6 | // File: D3D12Shader.h 7 | // Content: D3D12 Shader Types and APIs 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef __D3D12SHADER_H__ 12 | #define __D3D12SHADER_H__ 13 | 14 | #include "d3dcommon.h" 15 | 16 | typedef enum D3D12_SHADER_VERSION_TYPE 17 | { 18 | D3D12_SHVER_PIXEL_SHADER = 0, 19 | D3D12_SHVER_VERTEX_SHADER = 1, 20 | D3D12_SHVER_GEOMETRY_SHADER = 2, 21 | 22 | // D3D11 Shaders 23 | D3D12_SHVER_HULL_SHADER = 3, 24 | D3D12_SHVER_DOMAIN_SHADER = 4, 25 | D3D12_SHVER_COMPUTE_SHADER = 5, 26 | 27 | // D3D12 Shaders 28 | D3D12_SHVER_LIBRARY = 6, 29 | 30 | D3D12_SHVER_RAY_GENERATION_SHADER = 7, 31 | D3D12_SHVER_INTERSECTION_SHADER = 8, 32 | D3D12_SHVER_ANY_HIT_SHADER = 9, 33 | D3D12_SHVER_CLOSEST_HIT_SHADER = 10, 34 | D3D12_SHVER_MISS_SHADER = 11, 35 | D3D12_SHVER_CALLABLE_SHADER = 12, 36 | 37 | D3D12_SHVER_MESH_SHADER = 13, 38 | D3D12_SHVER_AMPLIFICATION_SHADER = 14, 39 | 40 | D3D12_SHVER_RESERVED0 = 0xFFF0, 41 | } D3D12_SHADER_VERSION_TYPE; 42 | 43 | #define D3D12_SHVER_GET_TYPE(_Version) \ 44 | (((_Version) >> 16) & 0xffff) 45 | #define D3D12_SHVER_GET_MAJOR(_Version) \ 46 | (((_Version) >> 4) & 0xf) 47 | #define D3D12_SHVER_GET_MINOR(_Version) \ 48 | (((_Version) >> 0) & 0xf) 49 | 50 | // Slot ID for library function return 51 | #define D3D_RETURN_PARAMETER_INDEX (-1) 52 | 53 | typedef D3D_RESOURCE_RETURN_TYPE D3D12_RESOURCE_RETURN_TYPE; 54 | 55 | typedef D3D_CBUFFER_TYPE D3D12_CBUFFER_TYPE; 56 | 57 | 58 | typedef struct _D3D12_SIGNATURE_PARAMETER_DESC 59 | { 60 | LPCSTR SemanticName; // Name of the semantic 61 | UINT SemanticIndex; // Index of the semantic 62 | UINT Register; // Number of member variables 63 | D3D_NAME SystemValueType;// A predefined system value, or D3D_NAME_UNDEFINED if not applicable 64 | D3D_REGISTER_COMPONENT_TYPE ComponentType; // Scalar type (e.g. uint, float, etc.) 65 | BYTE Mask; // Mask to indicate which components of the register 66 | // are used (combination of D3D10_COMPONENT_MASK values) 67 | BYTE ReadWriteMask; // Mask to indicate whether a given component is 68 | // never written (if this is an output signature) or 69 | // always read (if this is an input signature). 70 | // (combination of D3D_MASK_* values) 71 | UINT Stream; // Stream index 72 | D3D_MIN_PRECISION MinPrecision; // Minimum desired interpolation precision 73 | } D3D12_SIGNATURE_PARAMETER_DESC; 74 | 75 | typedef struct _D3D12_SHADER_BUFFER_DESC 76 | { 77 | LPCSTR Name; // Name of the constant buffer 78 | D3D_CBUFFER_TYPE Type; // Indicates type of buffer content 79 | UINT Variables; // Number of member variables 80 | UINT Size; // Size of CB (in bytes) 81 | UINT uFlags; // Buffer description flags 82 | } D3D12_SHADER_BUFFER_DESC; 83 | 84 | typedef struct _D3D12_SHADER_VARIABLE_DESC 85 | { 86 | LPCSTR Name; // Name of the variable 87 | UINT StartOffset; // Offset in constant buffer's backing store 88 | UINT Size; // Size of variable (in bytes) 89 | UINT uFlags; // Variable flags 90 | LPVOID DefaultValue; // Raw pointer to default value 91 | UINT StartTexture; // First texture index (or -1 if no textures used) 92 | UINT TextureSize; // Number of texture slots possibly used. 93 | UINT StartSampler; // First sampler index (or -1 if no textures used) 94 | UINT SamplerSize; // Number of sampler slots possibly used. 95 | } D3D12_SHADER_VARIABLE_DESC; 96 | 97 | typedef struct _D3D12_SHADER_TYPE_DESC 98 | { 99 | D3D_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.) 100 | D3D_SHADER_VARIABLE_TYPE Type; // Variable type (e.g. float, sampler, etc.) 101 | UINT Rows; // Number of rows (for matrices, 1 for other numeric, 0 if not applicable) 102 | UINT Columns; // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable) 103 | UINT Elements; // Number of elements (0 if not an array) 104 | UINT Members; // Number of members (0 if not a structure) 105 | UINT Offset; // Offset from the start of structure (0 if not a structure member) 106 | LPCSTR Name; // Name of type, can be NULL 107 | } D3D12_SHADER_TYPE_DESC; 108 | 109 | typedef D3D_TESSELLATOR_DOMAIN D3D12_TESSELLATOR_DOMAIN; 110 | 111 | typedef D3D_TESSELLATOR_PARTITIONING D3D12_TESSELLATOR_PARTITIONING; 112 | 113 | typedef D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D12_TESSELLATOR_OUTPUT_PRIMITIVE; 114 | 115 | typedef struct _D3D12_SHADER_DESC 116 | { 117 | UINT Version; // Shader version 118 | LPCSTR Creator; // Creator string 119 | UINT Flags; // Shader compilation/parse flags 120 | 121 | UINT ConstantBuffers; // Number of constant buffers 122 | UINT BoundResources; // Number of bound resources 123 | UINT InputParameters; // Number of parameters in the input signature 124 | UINT OutputParameters; // Number of parameters in the output signature 125 | 126 | UINT InstructionCount; // Number of emitted instructions 127 | UINT TempRegisterCount; // Number of temporary registers used 128 | UINT TempArrayCount; // Number of temporary arrays used 129 | UINT DefCount; // Number of constant defines 130 | UINT DclCount; // Number of declarations (input + output) 131 | UINT TextureNormalInstructions; // Number of non-categorized texture instructions 132 | UINT TextureLoadInstructions; // Number of texture load instructions 133 | UINT TextureCompInstructions; // Number of texture comparison instructions 134 | UINT TextureBiasInstructions; // Number of texture bias instructions 135 | UINT TextureGradientInstructions; // Number of texture gradient instructions 136 | UINT FloatInstructionCount; // Number of floating point arithmetic instructions used 137 | UINT IntInstructionCount; // Number of signed integer arithmetic instructions used 138 | UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used 139 | UINT StaticFlowControlCount; // Number of static flow control instructions used 140 | UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used 141 | UINT MacroInstructionCount; // Number of macro instructions used 142 | UINT ArrayInstructionCount; // Number of array instructions used 143 | UINT CutInstructionCount; // Number of cut instructions used 144 | UINT EmitInstructionCount; // Number of emit instructions used 145 | D3D_PRIMITIVE_TOPOLOGY GSOutputTopology; // Geometry shader output topology 146 | UINT GSMaxOutputVertexCount; // Geometry shader maximum output vertex count 147 | D3D_PRIMITIVE InputPrimitive; // GS/HS input primitive 148 | UINT PatchConstantParameters; // Number of parameters in the patch constant signature 149 | UINT cGSInstanceCount; // Number of Geometry shader instances 150 | UINT cControlPoints; // Number of control points in the HS->DS stage 151 | D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive; // Primitive output by the tessellator 152 | D3D_TESSELLATOR_PARTITIONING HSPartitioning; // Partitioning mode of the tessellator 153 | D3D_TESSELLATOR_DOMAIN TessellatorDomain; // Domain of the tessellator (quad, tri, isoline) 154 | // instruction counts 155 | UINT cBarrierInstructions; // Number of barrier instructions in a compute shader 156 | UINT cInterlockedInstructions; // Number of interlocked instructions 157 | UINT cTextureStoreInstructions; // Number of texture writes 158 | } D3D12_SHADER_DESC; 159 | 160 | typedef struct _D3D12_SHADER_INPUT_BIND_DESC 161 | { 162 | LPCSTR Name; // Name of the resource 163 | D3D_SHADER_INPUT_TYPE Type; // Type of resource (e.g. texture, cbuffer, etc.) 164 | UINT BindPoint; // Starting bind point 165 | UINT BindCount; // Number of contiguous bind points (for arrays) 166 | 167 | UINT uFlags; // Input binding flags 168 | D3D_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture) 169 | D3D_SRV_DIMENSION Dimension; // Dimension (if texture) 170 | UINT NumSamples; // Number of samples (0 if not MS texture) 171 | UINT Space; // Register space 172 | UINT uID; // Range ID in the bytecode 173 | } D3D12_SHADER_INPUT_BIND_DESC; 174 | 175 | #define D3D_SHADER_REQUIRES_DOUBLES 0x00000001 176 | #define D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL 0x00000002 177 | #define D3D_SHADER_REQUIRES_UAVS_AT_EVERY_STAGE 0x00000004 178 | #define D3D_SHADER_REQUIRES_64_UAVS 0x00000008 179 | #define D3D_SHADER_REQUIRES_MINIMUM_PRECISION 0x00000010 180 | #define D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS 0x00000020 181 | #define D3D_SHADER_REQUIRES_11_1_SHADER_EXTENSIONS 0x00000040 182 | #define D3D_SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING 0x00000080 183 | #define D3D_SHADER_REQUIRES_TILED_RESOURCES 0x00000100 184 | #define D3D_SHADER_REQUIRES_STENCIL_REF 0x00000200 185 | #define D3D_SHADER_REQUIRES_INNER_COVERAGE 0x00000400 186 | #define D3D_SHADER_REQUIRES_TYPED_UAV_LOAD_ADDITIONAL_FORMATS 0x00000800 187 | #define D3D_SHADER_REQUIRES_ROVS 0x00001000 188 | #define D3D_SHADER_REQUIRES_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER 0x00002000 189 | #define D3D_SHADER_REQUIRES_WAVE_OPS 0x00004000 190 | #define D3D_SHADER_REQUIRES_INT64_OPS 0x00008000 191 | #define D3D_SHADER_REQUIRES_VIEW_ID 0x00010000 192 | #define D3D_SHADER_REQUIRES_BARYCENTRICS 0x00020000 193 | #define D3D_SHADER_REQUIRES_NATIVE_16BIT_OPS 0x00040000 194 | #define D3D_SHADER_REQUIRES_SHADING_RATE 0x00080000 195 | #define D3D_SHADER_REQUIRES_RAYTRACING_TIER_1_1 0x00100000 196 | #define D3D_SHADER_REQUIRES_SAMPLER_FEEDBACK 0x00200000 197 | #define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_TYPED_RESOURCE 0x00400000 198 | #define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_GROUP_SHARED 0x00800000 199 | #define D3D_SHADER_REQUIRES_DERIVATIVES_IN_MESH_AND_AMPLIFICATION_SHADERS 0x01000000 200 | #define D3D_SHADER_REQUIRES_RESOURCE_DESCRIPTOR_HEAP_INDEXING 0x02000000 201 | #define D3D_SHADER_REQUIRES_SAMPLER_DESCRIPTOR_HEAP_INDEXING 0x04000000 202 | #define D3D_SHADER_REQUIRES_WAVE_MMA 0x08000000 203 | #define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE 0x10000000 204 | 205 | typedef struct _D3D12_LIBRARY_DESC 206 | { 207 | LPCSTR Creator; // The name of the originator of the library. 208 | UINT Flags; // Compilation flags. 209 | UINT FunctionCount; // Number of functions exported from the library. 210 | } D3D12_LIBRARY_DESC; 211 | 212 | typedef struct _D3D12_FUNCTION_DESC 213 | { 214 | UINT Version; // Shader version 215 | LPCSTR Creator; // Creator string 216 | UINT Flags; // Shader compilation/parse flags 217 | 218 | UINT ConstantBuffers; // Number of constant buffers 219 | UINT BoundResources; // Number of bound resources 220 | 221 | UINT InstructionCount; // Number of emitted instructions 222 | UINT TempRegisterCount; // Number of temporary registers used 223 | UINT TempArrayCount; // Number of temporary arrays used 224 | UINT DefCount; // Number of constant defines 225 | UINT DclCount; // Number of declarations (input + output) 226 | UINT TextureNormalInstructions; // Number of non-categorized texture instructions 227 | UINT TextureLoadInstructions; // Number of texture load instructions 228 | UINT TextureCompInstructions; // Number of texture comparison instructions 229 | UINT TextureBiasInstructions; // Number of texture bias instructions 230 | UINT TextureGradientInstructions; // Number of texture gradient instructions 231 | UINT FloatInstructionCount; // Number of floating point arithmetic instructions used 232 | UINT IntInstructionCount; // Number of signed integer arithmetic instructions used 233 | UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used 234 | UINT StaticFlowControlCount; // Number of static flow control instructions used 235 | UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used 236 | UINT MacroInstructionCount; // Number of macro instructions used 237 | UINT ArrayInstructionCount; // Number of array instructions used 238 | UINT MovInstructionCount; // Number of mov instructions used 239 | UINT MovcInstructionCount; // Number of movc instructions used 240 | UINT ConversionInstructionCount; // Number of type conversion instructions used 241 | UINT BitwiseInstructionCount; // Number of bitwise arithmetic instructions used 242 | D3D_FEATURE_LEVEL MinFeatureLevel; // Min target of the function byte code 243 | UINT64 RequiredFeatureFlags; // Required feature flags 244 | 245 | LPCSTR Name; // Function name 246 | INT FunctionParameterCount; // Number of logical parameters in the function signature (not including return) 247 | BOOL HasReturn; // TRUE, if function returns a value, false - it is a subroutine 248 | BOOL Has10Level9VertexShader; // TRUE, if there is a 10L9 VS blob 249 | BOOL Has10Level9PixelShader; // TRUE, if there is a 10L9 PS blob 250 | } D3D12_FUNCTION_DESC; 251 | 252 | typedef struct _D3D12_PARAMETER_DESC 253 | { 254 | LPCSTR Name; // Parameter name. 255 | LPCSTR SemanticName; // Parameter semantic name (+index). 256 | D3D_SHADER_VARIABLE_TYPE Type; // Element type. 257 | D3D_SHADER_VARIABLE_CLASS Class; // Scalar/Vector/Matrix. 258 | UINT Rows; // Rows are for matrix parameters. 259 | UINT Columns; // Components or Columns in matrix. 260 | D3D_INTERPOLATION_MODE InterpolationMode; // Interpolation mode. 261 | D3D_PARAMETER_FLAGS Flags; // Parameter modifiers. 262 | 263 | UINT FirstInRegister; // The first input register for this parameter. 264 | UINT FirstInComponent; // The first input register component for this parameter. 265 | UINT FirstOutRegister; // The first output register for this parameter. 266 | UINT FirstOutComponent; // The first output register component for this parameter. 267 | } D3D12_PARAMETER_DESC; 268 | 269 | 270 | ////////////////////////////////////////////////////////////////////////////// 271 | // Interfaces //////////////////////////////////////////////////////////////// 272 | ////////////////////////////////////////////////////////////////////////////// 273 | 274 | typedef interface ID3D12ShaderReflectionType ID3D12ShaderReflectionType; 275 | typedef interface ID3D12ShaderReflectionType *LPD3D12SHADERREFLECTIONTYPE; 276 | 277 | typedef interface ID3D12ShaderReflectionVariable ID3D12ShaderReflectionVariable; 278 | typedef interface ID3D12ShaderReflectionVariable *LPD3D12SHADERREFLECTIONVARIABLE; 279 | 280 | typedef interface ID3D12ShaderReflectionConstantBuffer ID3D12ShaderReflectionConstantBuffer; 281 | typedef interface ID3D12ShaderReflectionConstantBuffer *LPD3D12SHADERREFLECTIONCONSTANTBUFFER; 282 | 283 | typedef interface ID3D12ShaderReflection ID3D12ShaderReflection; 284 | typedef interface ID3D12ShaderReflection *LPD3D12SHADERREFLECTION; 285 | 286 | typedef interface ID3D12LibraryReflection ID3D12LibraryReflection; 287 | typedef interface ID3D12LibraryReflection *LPD3D12LIBRARYREFLECTION; 288 | 289 | typedef interface ID3D12FunctionReflection ID3D12FunctionReflection; 290 | typedef interface ID3D12FunctionReflection *LPD3D12FUNCTIONREFLECTION; 291 | 292 | typedef interface ID3D12FunctionParameterReflection ID3D12FunctionParameterReflection; 293 | typedef interface ID3D12FunctionParameterReflection *LPD3D12FUNCTIONPARAMETERREFLECTION; 294 | 295 | 296 | // {E913C351-783D-48CA-A1D1-4F306284AD56} 297 | interface DECLSPEC_UUID("E913C351-783D-48CA-A1D1-4F306284AD56") ID3D12ShaderReflectionType; 298 | DEFINE_GUID(IID_ID3D12ShaderReflectionType, 299 | 0xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56); 300 | 301 | #undef INTERFACE 302 | #define INTERFACE ID3D12ShaderReflectionType 303 | 304 | DECLARE_INTERFACE(ID3D12ShaderReflectionType) 305 | { 306 | STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_TYPE_DESC *pDesc) PURE; 307 | 308 | STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ _In_ UINT Index) PURE; 309 | STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByName)(THIS_ _In_ LPCSTR Name) PURE; 310 | STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ _In_ UINT Index) PURE; 311 | 312 | STDMETHOD(IsEqual)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE; 313 | STDMETHOD_(ID3D12ShaderReflectionType*, GetSubType)(THIS) PURE; 314 | STDMETHOD_(ID3D12ShaderReflectionType*, GetBaseClass)(THIS) PURE; 315 | STDMETHOD_(UINT, GetNumInterfaces)(THIS) PURE; 316 | STDMETHOD_(ID3D12ShaderReflectionType*, GetInterfaceByIndex)(THIS_ _In_ UINT uIndex) PURE; 317 | STDMETHOD(IsOfType)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE; 318 | STDMETHOD(ImplementsInterface)(THIS_ _In_ ID3D12ShaderReflectionType* pBase) PURE; 319 | }; 320 | 321 | // {8337A8A6-A216-444A-B2F4-314733A73AEA} 322 | interface DECLSPEC_UUID("8337A8A6-A216-444A-B2F4-314733A73AEA") ID3D12ShaderReflectionVariable; 323 | DEFINE_GUID(IID_ID3D12ShaderReflectionVariable, 324 | 0x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea); 325 | 326 | #undef INTERFACE 327 | #define INTERFACE ID3D12ShaderReflectionVariable 328 | 329 | DECLARE_INTERFACE(ID3D12ShaderReflectionVariable) 330 | { 331 | STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_VARIABLE_DESC *pDesc) PURE; 332 | 333 | STDMETHOD_(ID3D12ShaderReflectionType*, GetType)(THIS) PURE; 334 | STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetBuffer)(THIS) PURE; 335 | 336 | STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ _In_ UINT uArrayIndex) PURE; 337 | }; 338 | 339 | // {C59598B4-48B3-4869-B9B1-B1618B14A8B7} 340 | interface DECLSPEC_UUID("C59598B4-48B3-4869-B9B1-B1618B14A8B7") ID3D12ShaderReflectionConstantBuffer; 341 | DEFINE_GUID(IID_ID3D12ShaderReflectionConstantBuffer, 342 | 0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7); 343 | 344 | #undef INTERFACE 345 | #define INTERFACE ID3D12ShaderReflectionConstantBuffer 346 | 347 | DECLARE_INTERFACE(ID3D12ShaderReflectionConstantBuffer) 348 | { 349 | STDMETHOD(GetDesc)(THIS_ D3D12_SHADER_BUFFER_DESC *pDesc) PURE; 350 | 351 | STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByIndex)(THIS_ _In_ UINT Index) PURE; 352 | STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE; 353 | }; 354 | 355 | // The ID3D12ShaderReflection IID may change from SDK version to SDK version 356 | // if the reflection API changes. This prevents new code with the new API 357 | // from working with an old binary. Recompiling with the new header 358 | // will pick up the new IID. 359 | 360 | // {5A58797D-A72C-478D-8BA2-EFC6B0EFE88E} 361 | interface DECLSPEC_UUID("5A58797D-A72C-478D-8BA2-EFC6B0EFE88E") ID3D12ShaderReflection; 362 | DEFINE_GUID(IID_ID3D12ShaderReflection, 363 | 0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e); 364 | 365 | #undef INTERFACE 366 | #define INTERFACE ID3D12ShaderReflection 367 | 368 | DECLARE_INTERFACE_(ID3D12ShaderReflection, IUnknown) 369 | { 370 | STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, 371 | _Out_ LPVOID *ppv) PURE; 372 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; 373 | STDMETHOD_(ULONG, Release)(THIS) PURE; 374 | 375 | STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_DESC *pDesc) PURE; 376 | 377 | STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ _In_ UINT Index) PURE; 378 | STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE; 379 | 380 | STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex, 381 | _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE; 382 | 383 | STDMETHOD(GetInputParameterDesc)(THIS_ _In_ UINT ParameterIndex, 384 | _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE; 385 | STDMETHOD(GetOutputParameterDesc)(THIS_ _In_ UINT ParameterIndex, 386 | _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE; 387 | STDMETHOD(GetPatchConstantParameterDesc)(THIS_ _In_ UINT ParameterIndex, 388 | _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE; 389 | 390 | STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE; 391 | 392 | STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name, 393 | _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE; 394 | 395 | STDMETHOD_(UINT, GetMovInstructionCount)(THIS) PURE; 396 | STDMETHOD_(UINT, GetMovcInstructionCount)(THIS) PURE; 397 | STDMETHOD_(UINT, GetConversionInstructionCount)(THIS) PURE; 398 | STDMETHOD_(UINT, GetBitwiseInstructionCount)(THIS) PURE; 399 | 400 | STDMETHOD_(D3D_PRIMITIVE, GetGSInputPrimitive)(THIS) PURE; 401 | STDMETHOD_(BOOL, IsSampleFrequencyShader)(THIS) PURE; 402 | 403 | STDMETHOD_(UINT, GetNumInterfaceSlots)(THIS) PURE; 404 | STDMETHOD(GetMinFeatureLevel)(THIS_ _Out_ enum D3D_FEATURE_LEVEL* pLevel) PURE; 405 | 406 | STDMETHOD_(UINT, GetThreadGroupSize)(THIS_ 407 | _Out_opt_ UINT* pSizeX, 408 | _Out_opt_ UINT* pSizeY, 409 | _Out_opt_ UINT* pSizeZ) PURE; 410 | 411 | STDMETHOD_(UINT64, GetRequiresFlags)(THIS) PURE; 412 | }; 413 | 414 | // {8E349D19-54DB-4A56-9DC9-119D87BDB804} 415 | interface DECLSPEC_UUID("8E349D19-54DB-4A56-9DC9-119D87BDB804") ID3D12LibraryReflection; 416 | DEFINE_GUID(IID_ID3D12LibraryReflection, 417 | 0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4); 418 | 419 | #undef INTERFACE 420 | #define INTERFACE ID3D12LibraryReflection 421 | 422 | DECLARE_INTERFACE_(ID3D12LibraryReflection, IUnknown) 423 | { 424 | STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE; 425 | STDMETHOD_(ULONG, AddRef)(THIS) PURE; 426 | STDMETHOD_(ULONG, Release)(THIS) PURE; 427 | 428 | STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_LIBRARY_DESC * pDesc) PURE; 429 | 430 | STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex) PURE; 431 | }; 432 | 433 | // {1108795C-2772-4BA9-B2A8-D464DC7E2799} 434 | interface DECLSPEC_UUID("1108795C-2772-4BA9-B2A8-D464DC7E2799") ID3D12FunctionReflection; 435 | DEFINE_GUID(IID_ID3D12FunctionReflection, 436 | 0x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99); 437 | 438 | #undef INTERFACE 439 | #define INTERFACE ID3D12FunctionReflection 440 | 441 | DECLARE_INTERFACE(ID3D12FunctionReflection) 442 | { 443 | STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_FUNCTION_DESC * pDesc) PURE; 444 | 445 | STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex) PURE; 446 | STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE; 447 | 448 | STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex, 449 | _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE; 450 | 451 | STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE; 452 | 453 | STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name, 454 | _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE; 455 | 456 | // Use D3D_RETURN_PARAMETER_INDEX to get description of the return value. 457 | STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter)(THIS_ _In_ INT ParameterIndex) PURE; 458 | }; 459 | 460 | // {EC25F42D-7006-4F2B-B33E-02CC3375733F} 461 | interface DECLSPEC_UUID("EC25F42D-7006-4F2B-B33E-02CC3375733F") ID3D12FunctionParameterReflection; 462 | DEFINE_GUID(IID_ID3D12FunctionParameterReflection, 463 | 0xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x2, 0xcc, 0x33, 0x75, 0x73, 0x3f); 464 | 465 | #undef INTERFACE 466 | #define INTERFACE ID3D12FunctionParameterReflection 467 | 468 | DECLARE_INTERFACE(ID3D12FunctionParameterReflection) 469 | { 470 | STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_PARAMETER_DESC * pDesc) PURE; 471 | }; 472 | 473 | 474 | ////////////////////////////////////////////////////////////////////////////// 475 | // APIs ////////////////////////////////////////////////////////////////////// 476 | ////////////////////////////////////////////////////////////////////////////// 477 | 478 | #ifdef __cplusplus 479 | extern "C" { 480 | #endif //__cplusplus 481 | 482 | #ifdef __cplusplus 483 | } 484 | #endif //__cplusplus 485 | 486 | #endif //__D3D12SHADER_H__ 487 | 488 | -------------------------------------------------------------------------------- /third-party/dxc/inc/dxcapi.h: -------------------------------------------------------------------------------- 1 | 2 | /////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // dxcapi.h // 5 | // Copyright (C) Microsoft Corporation. All rights reserved. // 6 | // This file is distributed under the University of Illinois Open Source // 7 | // License. See LICENSE.TXT for details. // 8 | // // 9 | // Provides declarations for the DirectX Compiler API entry point. // 10 | // // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef __DXC_API__ 14 | #define __DXC_API__ 15 | 16 | #ifdef _WIN32 17 | #ifndef DXC_API_IMPORT 18 | #define DXC_API_IMPORT __declspec(dllimport) 19 | #endif 20 | #else 21 | #ifndef DXC_API_IMPORT 22 | #define DXC_API_IMPORT __attribute__ ((visibility ("default"))) 23 | #endif 24 | #endif 25 | 26 | #ifdef _WIN32 27 | 28 | #ifndef CROSS_PLATFORM_UUIDOF 29 | // Warning: This macro exists in WinAdapter.h as well 30 | #define CROSS_PLATFORM_UUIDOF(interface, spec) \ 31 | struct __declspec(uuid(spec)) interface; 32 | #endif 33 | 34 | #else 35 | 36 | #include 37 | #include "dxc/Support/WinAdapter.h" 38 | #endif 39 | 40 | struct IMalloc; 41 | 42 | struct IDxcIncludeHandler; 43 | 44 | typedef HRESULT (__stdcall *DxcCreateInstanceProc)( 45 | _In_ REFCLSID rclsid, 46 | _In_ REFIID riid, 47 | _Out_ LPVOID* ppv 48 | ); 49 | 50 | typedef HRESULT(__stdcall *DxcCreateInstance2Proc)( 51 | _In_ IMalloc *pMalloc, 52 | _In_ REFCLSID rclsid, 53 | _In_ REFIID riid, 54 | _Out_ LPVOID* ppv 55 | ); 56 | 57 | /// 58 | /// Creates a single uninitialized object of the class associated with a specified CLSID. 59 | /// 60 | /// 61 | /// The CLSID associated with the data and code that will be used to create the object. 62 | /// 63 | /// 64 | /// A reference to the identifier of the interface to be used to communicate 65 | /// with the object. 66 | /// 67 | /// 68 | /// Address of pointer variable that receives the interface pointer requested 69 | /// in riid. Upon successful return, *ppv contains the requested interface 70 | /// pointer. Upon failure, *ppv contains NULL. 71 | /// 72 | /// While this function is similar to CoCreateInstance, there is no COM involvement. 73 | /// 74 | 75 | extern "C" 76 | DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance( 77 | _In_ REFCLSID rclsid, 78 | _In_ REFIID riid, 79 | _Out_ LPVOID* ppv 80 | ); 81 | 82 | extern "C" 83 | DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance2( 84 | _In_ IMalloc *pMalloc, 85 | _In_ REFCLSID rclsid, 86 | _In_ REFIID riid, 87 | _Out_ LPVOID* ppv 88 | ); 89 | 90 | // For convenience, equivalent definitions to CP_UTF8 and CP_UTF16. 91 | #define DXC_CP_UTF8 65001 92 | #define DXC_CP_UTF16 1200 93 | #define DXC_CP_UTF32 12000 94 | // Use DXC_CP_ACP for: Binary; ANSI Text; Autodetect UTF with BOM 95 | #define DXC_CP_ACP 0 96 | 97 | #ifdef _WIN32 98 | #define DXC_CP_WIDE DXC_CP_UTF16 99 | #else 100 | #define DXC_CP_WIDE DXC_CP_UTF32 101 | #endif 102 | 103 | // This flag indicates that the shader hash was computed taking into account source information (-Zss) 104 | #define DXC_HASHFLAG_INCLUDES_SOURCE 1 105 | 106 | // Hash digest type for ShaderHash 107 | typedef struct DxcShaderHash { 108 | UINT32 Flags; // DXC_HASHFLAG_* 109 | BYTE HashDigest[16]; 110 | } DxcShaderHash; 111 | 112 | #define DXC_FOURCC(ch0, ch1, ch2, ch3) ( \ 113 | (UINT32)(UINT8)(ch0) | (UINT32)(UINT8)(ch1) << 8 | \ 114 | (UINT32)(UINT8)(ch2) << 16 | (UINT32)(UINT8)(ch3) << 24 \ 115 | ) 116 | #define DXC_PART_PDB DXC_FOURCC('I', 'L', 'D', 'B') 117 | #define DXC_PART_PDB_NAME DXC_FOURCC('I', 'L', 'D', 'N') 118 | #define DXC_PART_PRIVATE_DATA DXC_FOURCC('P', 'R', 'I', 'V') 119 | #define DXC_PART_ROOT_SIGNATURE DXC_FOURCC('R', 'T', 'S', '0') 120 | #define DXC_PART_DXIL DXC_FOURCC('D', 'X', 'I', 'L') 121 | #define DXC_PART_REFLECTION_DATA DXC_FOURCC('S', 'T', 'A', 'T') 122 | #define DXC_PART_SHADER_HASH DXC_FOURCC('H', 'A', 'S', 'H') 123 | #define DXC_PART_INPUT_SIGNATURE DXC_FOURCC('I', 'S', 'G', '1') 124 | #define DXC_PART_OUTPUT_SIGNATURE DXC_FOURCC('O', 'S', 'G', '1') 125 | #define DXC_PART_PATCH_CONSTANT_SIGNATURE DXC_FOURCC('P', 'S', 'G', '1') 126 | 127 | // Some option arguments are defined here for continuity with D3DCompile interface 128 | #define DXC_ARG_DEBUG L"-Zi" 129 | #define DXC_ARG_SKIP_VALIDATION L"-Vd" 130 | #define DXC_ARG_SKIP_OPTIMIZATIONS L"-Od" 131 | #define DXC_ARG_PACK_MATRIX_ROW_MAJOR L"-Zpr" 132 | #define DXC_ARG_PACK_MATRIX_COLUMN_MAJOR L"-Zpc" 133 | #define DXC_ARG_AVOID_FLOW_CONTROL L"-Gfa" 134 | #define DXC_ARG_PREFER_FLOW_CONTROL L"-Gfp" 135 | #define DXC_ARG_ENABLE_STRICTNESS L"-Ges" 136 | #define DXC_ARG_ENABLE_BACKWARDS_COMPATIBILITY L"-Gec" 137 | #define DXC_ARG_IEEE_STRICTNESS L"-Gis" 138 | #define DXC_ARG_OPTIMIZATION_LEVEL0 L"-O0" 139 | #define DXC_ARG_OPTIMIZATION_LEVEL1 L"-O1" 140 | #define DXC_ARG_OPTIMIZATION_LEVEL2 L"-O2" 141 | #define DXC_ARG_OPTIMIZATION_LEVEL3 L"-O3" 142 | #define DXC_ARG_WARNINGS_ARE_ERRORS L"-WX" 143 | #define DXC_ARG_RESOURCES_MAY_ALIAS L"-res_may_alias" 144 | #define DXC_ARG_ALL_RESOURCES_BOUND L"-all_resources_bound" 145 | #define DXC_ARG_DEBUG_NAME_FOR_SOURCE L"-Zss" 146 | #define DXC_ARG_DEBUG_NAME_FOR_BINARY L"-Zsb" 147 | 148 | // IDxcBlob is an alias of ID3D10Blob and ID3DBlob 149 | CROSS_PLATFORM_UUIDOF(IDxcBlob, "8BA5FB08-5195-40e2-AC58-0D989C3A0102") 150 | struct IDxcBlob : public IUnknown { 151 | public: 152 | virtual LPVOID STDMETHODCALLTYPE GetBufferPointer(void) = 0; 153 | virtual SIZE_T STDMETHODCALLTYPE GetBufferSize(void) = 0; 154 | }; 155 | 156 | CROSS_PLATFORM_UUIDOF(IDxcBlobEncoding, "7241d424-2646-4191-97c0-98e96e42fc68") 157 | struct IDxcBlobEncoding : public IDxcBlob { 158 | public: 159 | virtual HRESULT STDMETHODCALLTYPE GetEncoding(_Out_ BOOL *pKnown, 160 | _Out_ UINT32 *pCodePage) = 0; 161 | }; 162 | 163 | // Notes on IDxcBlobWide and IDxcBlobUtf8 164 | // These guarantee null-terminated text and eithre utf8 or the native wide char encoding. 165 | // GetBufferSize() will return the size in bytes, including null-terminator 166 | // GetStringLength() will return the length in characters, excluding the null-terminator 167 | // Name strings will use IDxcBlobWide, while other string output blobs, 168 | // such as errors/warnings, preprocessed HLSL, or other text will be based 169 | // on the -encoding option. 170 | 171 | // The API will use this interface for output name strings 172 | CROSS_PLATFORM_UUIDOF(IDxcBlobWide, "A3F84EAB-0FAA-497E-A39C-EE6ED60B2D84") 173 | struct IDxcBlobWide : public IDxcBlobEncoding { 174 | public: 175 | virtual LPCWSTR STDMETHODCALLTYPE GetStringPointer(void) = 0; 176 | virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0; 177 | }; 178 | CROSS_PLATFORM_UUIDOF(IDxcBlobUtf8, "3DA636C9-BA71-4024-A301-30CBF125305B") 179 | struct IDxcBlobUtf8 : public IDxcBlobEncoding { 180 | public: 181 | virtual LPCSTR STDMETHODCALLTYPE GetStringPointer(void) = 0; 182 | virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0; 183 | }; 184 | 185 | // Define legacy name IDxcBlobUtf16 as IDxcBlobWide for Win32 186 | #ifdef _WIN32 187 | typedef IDxcBlobWide IDxcBlobUtf16; 188 | #endif 189 | 190 | CROSS_PLATFORM_UUIDOF(IDxcIncludeHandler, "7f61fc7d-950d-467f-b3e3-3c02fb49187c") 191 | struct IDxcIncludeHandler : public IUnknown { 192 | virtual HRESULT STDMETHODCALLTYPE LoadSource( 193 | _In_z_ LPCWSTR pFilename, // Candidate filename. 194 | _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource // Resultant source object for included file, nullptr if not found. 195 | ) = 0; 196 | }; 197 | 198 | // Structure for supplying bytes or text input to Dxc APIs. 199 | // Use Encoding = 0 for non-text bytes, ANSI text, or unknown with BOM. 200 | typedef struct DxcBuffer { 201 | LPCVOID Ptr; 202 | SIZE_T Size; 203 | UINT Encoding; 204 | } DxcText; 205 | 206 | struct DxcDefine { 207 | LPCWSTR Name; 208 | _Maybenull_ LPCWSTR Value; 209 | }; 210 | 211 | CROSS_PLATFORM_UUIDOF(IDxcCompilerArgs, "73EFFE2A-70DC-45F8-9690-EFF64C02429D") 212 | struct IDxcCompilerArgs : public IUnknown { 213 | // Pass GetArguments() and GetCount() to Compile 214 | virtual LPCWSTR* STDMETHODCALLTYPE GetArguments() = 0; 215 | virtual UINT32 STDMETHODCALLTYPE GetCount() = 0; 216 | 217 | // Add additional arguments or defines here, if desired. 218 | virtual HRESULT STDMETHODCALLTYPE AddArguments( 219 | _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments to add 220 | _In_ UINT32 argCount // Number of arguments to add 221 | ) = 0; 222 | virtual HRESULT STDMETHODCALLTYPE AddArgumentsUTF8( 223 | _In_opt_count_(argCount)LPCSTR *pArguments, // Array of pointers to UTF-8 arguments to add 224 | _In_ UINT32 argCount // Number of arguments to add 225 | ) = 0; 226 | virtual HRESULT STDMETHODCALLTYPE AddDefines( 227 | _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines 228 | _In_ UINT32 defineCount // Number of defines 229 | ) = 0; 230 | }; 231 | 232 | ////////////////////////// 233 | // Legacy Interfaces 234 | ///////////////////////// 235 | 236 | // NOTE: IDxcUtils replaces IDxcLibrary 237 | CROSS_PLATFORM_UUIDOF(IDxcLibrary, "e5204dc7-d18c-4c3c-bdfb-851673980fe7") 238 | struct IDxcLibrary : public IUnknown { 239 | virtual HRESULT STDMETHODCALLTYPE SetMalloc(_In_opt_ IMalloc *pMalloc) = 0; 240 | virtual HRESULT STDMETHODCALLTYPE CreateBlobFromBlob( 241 | _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) = 0; 242 | virtual HRESULT STDMETHODCALLTYPE CreateBlobFromFile( 243 | _In_z_ LPCWSTR pFileName, _In_opt_ UINT32* codePage, 244 | _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 245 | virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingFromPinned( 246 | _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, 247 | _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 248 | virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnHeapCopy( 249 | _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage, 250 | _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 251 | virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnMalloc( 252 | _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, 253 | _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 254 | virtual HRESULT STDMETHODCALLTYPE CreateIncludeHandler( 255 | _COM_Outptr_ IDxcIncludeHandler **ppResult) = 0; 256 | virtual HRESULT STDMETHODCALLTYPE CreateStreamFromBlobReadOnly( 257 | _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0; 258 | virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8( 259 | _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 260 | 261 | // Renamed from GetBlobAsUtf16 to GetBlobAsWide 262 | virtual HRESULT STDMETHODCALLTYPE GetBlobAsWide( 263 | _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 264 | 265 | #ifdef _WIN32 266 | // Alias to GetBlobAsWide on Win32 267 | inline HRESULT GetBlobAsUtf16( 268 | _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) { 269 | return this->GetBlobAsWide(pBlob, pBlobEncoding); 270 | } 271 | #endif 272 | }; 273 | 274 | // NOTE: IDxcResult replaces IDxcOperationResult 275 | CROSS_PLATFORM_UUIDOF(IDxcOperationResult, "CEDB484A-D4E9-445A-B991-CA21CA157DC2") 276 | struct IDxcOperationResult : public IUnknown { 277 | virtual HRESULT STDMETHODCALLTYPE GetStatus(_Out_ HRESULT *pStatus) = 0; 278 | 279 | // GetResult returns the main result of the operation. 280 | // This corresponds to: 281 | // DXC_OUT_OBJECT - Compile() with shader or library target 282 | // DXC_OUT_DISASSEMBLY - Disassemble() 283 | // DXC_OUT_HLSL - Compile() with -P 284 | // DXC_OUT_ROOT_SIGNATURE - Compile() with rootsig_* target 285 | virtual HRESULT STDMETHODCALLTYPE GetResult(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0; 286 | 287 | // GetErrorBuffer Corresponds to DXC_OUT_ERRORS. 288 | virtual HRESULT STDMETHODCALLTYPE GetErrorBuffer(_COM_Outptr_result_maybenull_ IDxcBlobEncoding **ppErrors) = 0; 289 | }; 290 | 291 | // NOTE: IDxcCompiler3 replaces IDxcCompiler and IDxcCompiler2 292 | CROSS_PLATFORM_UUIDOF(IDxcCompiler, "8c210bf3-011f-4422-8d70-6f9acb8db617") 293 | struct IDxcCompiler : public IUnknown { 294 | // Compile a single entry point to the target shader model 295 | virtual HRESULT STDMETHODCALLTYPE Compile( 296 | _In_ IDxcBlob *pSource, // Source text to compile 297 | _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. 298 | _In_opt_z_ LPCWSTR pEntryPoint, // entry point name 299 | _In_z_ LPCWSTR pTargetProfile, // shader profile to compile 300 | _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments 301 | _In_ UINT32 argCount, // Number of arguments 302 | _In_count_(defineCount) 303 | const DxcDefine *pDefines, // Array of defines 304 | _In_ UINT32 defineCount, // Number of defines 305 | _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) 306 | _COM_Outptr_ IDxcOperationResult **ppResult // Compiler output status, buffer, and errors 307 | ) = 0; 308 | 309 | // Preprocess source text 310 | virtual HRESULT STDMETHODCALLTYPE Preprocess( 311 | _In_ IDxcBlob *pSource, // Source text to preprocess 312 | _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. 313 | _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments 314 | _In_ UINT32 argCount, // Number of arguments 315 | _In_count_(defineCount) 316 | const DxcDefine *pDefines, // Array of defines 317 | _In_ UINT32 defineCount, // Number of defines 318 | _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) 319 | _COM_Outptr_ IDxcOperationResult **ppResult // Preprocessor output status, buffer, and errors 320 | ) = 0; 321 | 322 | // Disassemble a program. 323 | virtual HRESULT STDMETHODCALLTYPE Disassemble( 324 | _In_ IDxcBlob *pSource, // Program to disassemble. 325 | _COM_Outptr_ IDxcBlobEncoding **ppDisassembly // Disassembly text. 326 | ) = 0; 327 | }; 328 | 329 | // NOTE: IDxcCompiler3 replaces IDxcCompiler and IDxcCompiler2 330 | CROSS_PLATFORM_UUIDOF(IDxcCompiler2, "A005A9D9-B8BB-4594-B5C9-0E633BEC4D37") 331 | struct IDxcCompiler2 : public IDxcCompiler { 332 | // Compile a single entry point to the target shader model with debug information. 333 | virtual HRESULT STDMETHODCALLTYPE CompileWithDebug( 334 | _In_ IDxcBlob *pSource, // Source text to compile 335 | _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. 336 | _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name 337 | _In_z_ LPCWSTR pTargetProfile, // Shader profile to compile 338 | _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments 339 | _In_ UINT32 argCount, // Number of arguments 340 | _In_count_(defineCount) 341 | const DxcDefine *pDefines, // Array of defines 342 | _In_ UINT32 defineCount, // Number of defines 343 | _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) 344 | _COM_Outptr_ IDxcOperationResult **ppResult, // Compiler output status, buffer, and errors 345 | _Outptr_opt_result_z_ LPWSTR *ppDebugBlobName,// Suggested file name for debug blob. (Must be CoTaskMemFree()'d!) 346 | _COM_Outptr_opt_ IDxcBlob **ppDebugBlob // Debug blob 347 | ) = 0; 348 | }; 349 | 350 | CROSS_PLATFORM_UUIDOF(IDxcLinker, "F1B5BE2A-62DD-4327-A1C2-42AC1E1E78E6") 351 | struct IDxcLinker : public IUnknown { 352 | public: 353 | // Register a library with name to ref it later. 354 | virtual HRESULT RegisterLibrary( 355 | _In_opt_ LPCWSTR pLibName, // Name of the library. 356 | _In_ IDxcBlob *pLib // Library blob. 357 | ) = 0; 358 | 359 | // Links the shader and produces a shader blob that the Direct3D runtime can 360 | // use. 361 | virtual HRESULT STDMETHODCALLTYPE Link( 362 | _In_opt_ LPCWSTR pEntryName, // Entry point name 363 | _In_ LPCWSTR pTargetProfile, // shader profile to link 364 | _In_count_(libCount) 365 | const LPCWSTR *pLibNames, // Array of library names to link 366 | _In_ UINT32 libCount, // Number of libraries to link 367 | _In_opt_count_(argCount) const LPCWSTR *pArguments, // Array of pointers to arguments 368 | _In_ UINT32 argCount, // Number of arguments 369 | _COM_Outptr_ 370 | IDxcOperationResult **ppResult // Linker output status, buffer, and errors 371 | ) = 0; 372 | }; 373 | 374 | ///////////////////////// 375 | // Latest interfaces. Please use these 376 | //////////////////////// 377 | 378 | // NOTE: IDxcUtils replaces IDxcLibrary 379 | CROSS_PLATFORM_UUIDOF(IDxcUtils, "4605C4CB-2019-492A-ADA4-65F20BB7D67F") 380 | struct IDxcUtils : public IUnknown { 381 | // Create a sub-blob that holds a reference to the outer blob and points to its memory. 382 | virtual HRESULT STDMETHODCALLTYPE CreateBlobFromBlob( 383 | _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) = 0; 384 | 385 | // For codePage, use 0 (or DXC_CP_ACP) for raw binary or ANSI code page 386 | 387 | // Creates a blob referencing existing memory, with no copy. 388 | // User must manage the memory lifetime separately. 389 | // (was: CreateBlobWithEncodingFromPinned) 390 | virtual HRESULT STDMETHODCALLTYPE CreateBlobFromPinned( 391 | _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage, 392 | _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 393 | 394 | // Create blob, taking ownership of memory allocated with supplied allocator. 395 | // (was: CreateBlobWithEncodingOnMalloc) 396 | virtual HRESULT STDMETHODCALLTYPE MoveToBlob( 397 | _In_bytecount_(size) LPCVOID pData, IMalloc *pIMalloc, UINT32 size, UINT32 codePage, 398 | _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 399 | 400 | //// 401 | // New blobs and copied contents are allocated with the current allocator 402 | 403 | // Copy blob contents to memory owned by the new blob. 404 | // (was: CreateBlobWithEncodingOnHeapCopy) 405 | virtual HRESULT STDMETHODCALLTYPE CreateBlob( 406 | _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage, 407 | _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 408 | 409 | // (was: CreateBlobFromFile) 410 | virtual HRESULT STDMETHODCALLTYPE LoadFile( 411 | _In_z_ LPCWSTR pFileName, _In_opt_ UINT32* pCodePage, 412 | _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0; 413 | 414 | virtual HRESULT STDMETHODCALLTYPE CreateReadOnlyStreamFromBlob( 415 | _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0; 416 | 417 | // Create default file-based include handler 418 | virtual HRESULT STDMETHODCALLTYPE CreateDefaultIncludeHandler( 419 | _COM_Outptr_ IDxcIncludeHandler **ppResult) = 0; 420 | 421 | // Convert or return matching encoded text blobs 422 | virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8( 423 | _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobUtf8 **pBlobEncoding) = 0; 424 | 425 | // Renamed from GetBlobAsUtf16 to GetBlobAsWide 426 | virtual HRESULT STDMETHODCALLTYPE GetBlobAsWide( 427 | _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobWide **pBlobEncoding) = 0; 428 | 429 | #ifdef _WIN32 430 | // Alias to GetBlobAsWide on Win32 431 | inline HRESULT GetBlobAsUtf16( 432 | _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobWide **pBlobEncoding) { 433 | return this->GetBlobAsWide(pBlob, pBlobEncoding); 434 | } 435 | #endif 436 | 437 | virtual HRESULT STDMETHODCALLTYPE GetDxilContainerPart( 438 | _In_ const DxcBuffer *pShader, 439 | _In_ UINT32 DxcPart, 440 | _Outptr_result_nullonfailure_ void **ppPartData, 441 | _Out_ UINT32 *pPartSizeInBytes) = 0; 442 | 443 | // Create reflection interface from serialized Dxil container, or DXC_PART_REFLECTION_DATA. 444 | // TBD: Require part header for RDAT? (leaning towards yes) 445 | virtual HRESULT STDMETHODCALLTYPE CreateReflection( 446 | _In_ const DxcBuffer *pData, REFIID iid, void **ppvReflection) = 0; 447 | 448 | virtual HRESULT STDMETHODCALLTYPE BuildArguments( 449 | _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in errors and include handlers. 450 | _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name. (-E) 451 | _In_z_ LPCWSTR pTargetProfile, // Shader profile to compile. (-T) 452 | _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments 453 | _In_ UINT32 argCount, // Number of arguments 454 | _In_count_(defineCount) 455 | const DxcDefine *pDefines, // Array of defines 456 | _In_ UINT32 defineCount, // Number of defines 457 | _COM_Outptr_ IDxcCompilerArgs **ppArgs // Arguments you can use with Compile() method 458 | ) = 0; 459 | 460 | // Takes the shader PDB and returns the hash and the container inside it 461 | virtual HRESULT STDMETHODCALLTYPE GetPDBContents( 462 | _In_ IDxcBlob *pPDBBlob, _COM_Outptr_ IDxcBlob **ppHash, _COM_Outptr_ IDxcBlob **ppContainer) = 0; 463 | }; 464 | 465 | // For use with IDxcResult::[Has|Get]Output dxcOutKind argument 466 | // Note: text outputs returned from version 2 APIs are UTF-8 or UTF-16 based on -encoding option 467 | typedef enum DXC_OUT_KIND { 468 | DXC_OUT_NONE = 0, 469 | DXC_OUT_OBJECT = 1, // IDxcBlob - Shader or library object 470 | DXC_OUT_ERRORS = 2, // IDxcBlobUtf8 or IDxcBlobWide 471 | DXC_OUT_PDB = 3, // IDxcBlob 472 | DXC_OUT_SHADER_HASH = 4, // IDxcBlob - DxcShaderHash of shader or shader with source info (-Zsb/-Zss) 473 | DXC_OUT_DISASSEMBLY = 5, // IDxcBlobUtf8 or IDxcBlobWide - from Disassemble 474 | DXC_OUT_HLSL = 6, // IDxcBlobUtf8 or IDxcBlobWide - from Preprocessor or Rewriter 475 | DXC_OUT_TEXT = 7, // IDxcBlobUtf8 or IDxcBlobWide - other text, such as -ast-dump or -Odump 476 | DXC_OUT_REFLECTION = 8, // IDxcBlob - RDAT part with reflection data 477 | DXC_OUT_ROOT_SIGNATURE = 9, // IDxcBlob - Serialized root signature output 478 | DXC_OUT_EXTRA_OUTPUTS = 10,// IDxcExtraResults - Extra outputs 479 | DXC_OUT_REMARKS = 11, // IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout 480 | DXC_OUT_TIME_REPORT = 12, // IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout 481 | DXC_OUT_TIME_TRACE = 13, // IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout 482 | 483 | DXC_OUT_LAST = DXC_OUT_TIME_TRACE, // Last value for a counter 484 | 485 | DXC_OUT_NUM_ENUMS, 486 | DXC_OUT_FORCE_DWORD = 0xFFFFFFFF 487 | } DXC_OUT_KIND; 488 | 489 | static_assert(DXC_OUT_NUM_ENUMS == DXC_OUT_LAST + 1, 490 | "DXC_OUT_* Enum added and last value not updated."); 491 | 492 | CROSS_PLATFORM_UUIDOF(IDxcResult, "58346CDA-DDE7-4497-9461-6F87AF5E0659") 493 | struct IDxcResult : public IDxcOperationResult { 494 | virtual BOOL STDMETHODCALLTYPE HasOutput(_In_ DXC_OUT_KIND dxcOutKind) = 0; 495 | virtual HRESULT STDMETHODCALLTYPE GetOutput(_In_ DXC_OUT_KIND dxcOutKind, 496 | _In_ REFIID iid, _COM_Outptr_opt_result_maybenull_ void **ppvObject, 497 | _COM_Outptr_ IDxcBlobWide **ppOutputName) = 0; 498 | 499 | virtual UINT32 GetNumOutputs() = 0; 500 | virtual DXC_OUT_KIND GetOutputByIndex(UINT32 Index) = 0; 501 | virtual DXC_OUT_KIND PrimaryOutput() = 0; 502 | }; 503 | 504 | // Special names for extra output that should get written to specific streams 505 | #define DXC_EXTRA_OUTPUT_NAME_STDOUT L"*stdout*" 506 | #define DXC_EXTRA_OUTPUT_NAME_STDERR L"*stderr*" 507 | 508 | CROSS_PLATFORM_UUIDOF(IDxcExtraOutputs, "319b37a2-a5c2-494a-a5de-4801b2faf989") 509 | struct IDxcExtraOutputs : public IUnknown { 510 | 511 | virtual UINT32 STDMETHODCALLTYPE GetOutputCount() = 0; 512 | virtual HRESULT STDMETHODCALLTYPE GetOutput(_In_ UINT32 uIndex, 513 | _In_ REFIID iid, _COM_Outptr_opt_result_maybenull_ void **ppvObject, 514 | _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputType, 515 | _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputName) = 0; 516 | }; 517 | 518 | CROSS_PLATFORM_UUIDOF(IDxcCompiler3, "228B4687-5A6A-4730-900C-9702B2203F54") 519 | struct IDxcCompiler3 : public IUnknown { 520 | // Compile a single entry point to the target shader model, 521 | // Compile a library to a library target (-T lib_*), 522 | // Compile a root signature (-T rootsig_*), or 523 | // Preprocess HLSL source (-P) 524 | virtual HRESULT STDMETHODCALLTYPE Compile( 525 | _In_ const DxcBuffer *pSource, // Source text to compile 526 | _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments 527 | _In_ UINT32 argCount, // Number of arguments 528 | _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional) 529 | _In_ REFIID riid, _Out_ LPVOID *ppResult // IDxcResult: status, buffer, and errors 530 | ) = 0; 531 | 532 | // Disassemble a program. 533 | virtual HRESULT STDMETHODCALLTYPE Disassemble( 534 | _In_ const DxcBuffer *pObject, // Program to disassemble: dxil container or bitcode. 535 | _In_ REFIID riid, _Out_ LPVOID *ppResult // IDxcResult: status, disassembly text, and errors 536 | ) = 0; 537 | }; 538 | 539 | static const UINT32 DxcValidatorFlags_Default = 0; 540 | static const UINT32 DxcValidatorFlags_InPlaceEdit = 1; // Validator is allowed to update shader blob in-place. 541 | static const UINT32 DxcValidatorFlags_RootSignatureOnly = 2; 542 | static const UINT32 DxcValidatorFlags_ModuleOnly = 4; 543 | static const UINT32 DxcValidatorFlags_ValidMask = 0x7; 544 | 545 | CROSS_PLATFORM_UUIDOF(IDxcValidator, "A6E82BD2-1FD7-4826-9811-2857E797F49A") 546 | struct IDxcValidator : public IUnknown { 547 | // Validate a shader. 548 | virtual HRESULT STDMETHODCALLTYPE Validate( 549 | _In_ IDxcBlob *pShader, // Shader to validate. 550 | _In_ UINT32 Flags, // Validation flags. 551 | _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors 552 | ) = 0; 553 | }; 554 | 555 | CROSS_PLATFORM_UUIDOF(IDxcValidator2, "458e1fd1-b1b2-4750-a6e1-9c10f03bed92") 556 | struct IDxcValidator2 : public IDxcValidator { 557 | // Validate a shader. 558 | virtual HRESULT STDMETHODCALLTYPE ValidateWithDebug( 559 | _In_ IDxcBlob *pShader, // Shader to validate. 560 | _In_ UINT32 Flags, // Validation flags. 561 | _In_opt_ DxcBuffer *pOptDebugBitcode, // Optional debug module bitcode to provide line numbers 562 | _COM_Outptr_ IDxcOperationResult **ppResult // Validation output status, buffer, and errors 563 | ) = 0; 564 | }; 565 | 566 | CROSS_PLATFORM_UUIDOF(IDxcContainerBuilder, "334b1f50-2292-4b35-99a1-25588d8c17fe") 567 | struct IDxcContainerBuilder : public IUnknown { 568 | virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pDxilContainerHeader) = 0; // Loads DxilContainer to the builder 569 | virtual HRESULT STDMETHODCALLTYPE AddPart(_In_ UINT32 fourCC, _In_ IDxcBlob *pSource) = 0; // Part to add to the container 570 | virtual HRESULT STDMETHODCALLTYPE RemovePart(_In_ UINT32 fourCC) = 0; // Remove the part with fourCC 571 | virtual HRESULT STDMETHODCALLTYPE SerializeContainer(_Out_ IDxcOperationResult **ppResult) = 0; // Builds a container of the given container builder state 572 | }; 573 | 574 | CROSS_PLATFORM_UUIDOF(IDxcAssembler, "091f7a26-1c1f-4948-904b-e6e3a8a771d5") 575 | struct IDxcAssembler : public IUnknown { 576 | // Assemble dxil in ll or llvm bitcode to DXIL container. 577 | virtual HRESULT STDMETHODCALLTYPE AssembleToContainer( 578 | _In_ IDxcBlob *pShader, // Shader to assemble. 579 | _COM_Outptr_ IDxcOperationResult **ppResult // Assembly output status, buffer, and errors 580 | ) = 0; 581 | }; 582 | 583 | CROSS_PLATFORM_UUIDOF(IDxcContainerReflection, "d2c21b26-8350-4bdc-976a-331ce6f4c54c") 584 | struct IDxcContainerReflection : public IUnknown { 585 | virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pContainer) = 0; // Container to load. 586 | virtual HRESULT STDMETHODCALLTYPE GetPartCount(_Out_ UINT32 *pResult) = 0; 587 | virtual HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx, _Out_ UINT32 *pResult) = 0; 588 | virtual HRESULT STDMETHODCALLTYPE GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) = 0; 589 | virtual HRESULT STDMETHODCALLTYPE FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) = 0; 590 | virtual HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid, void **ppvObject) = 0; 591 | }; 592 | 593 | CROSS_PLATFORM_UUIDOF(IDxcOptimizerPass, "AE2CD79F-CC22-453F-9B6B-B124E7A5204C") 594 | struct IDxcOptimizerPass : public IUnknown { 595 | virtual HRESULT STDMETHODCALLTYPE GetOptionName(_COM_Outptr_ LPWSTR *ppResult) = 0; 596 | virtual HRESULT STDMETHODCALLTYPE GetDescription(_COM_Outptr_ LPWSTR *ppResult) = 0; 597 | virtual HRESULT STDMETHODCALLTYPE GetOptionArgCount(_Out_ UINT32 *pCount) = 0; 598 | virtual HRESULT STDMETHODCALLTYPE GetOptionArgName(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0; 599 | virtual HRESULT STDMETHODCALLTYPE GetOptionArgDescription(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0; 600 | }; 601 | 602 | CROSS_PLATFORM_UUIDOF(IDxcOptimizer, "25740E2E-9CBA-401B-9119-4FB42F39F270") 603 | struct IDxcOptimizer : public IUnknown { 604 | virtual HRESULT STDMETHODCALLTYPE GetAvailablePassCount(_Out_ UINT32 *pCount) = 0; 605 | virtual HRESULT STDMETHODCALLTYPE GetAvailablePass(UINT32 index, _COM_Outptr_ IDxcOptimizerPass** ppResult) = 0; 606 | virtual HRESULT STDMETHODCALLTYPE RunOptimizer(IDxcBlob *pBlob, 607 | _In_count_(optionCount) LPCWSTR *ppOptions, UINT32 optionCount, 608 | _COM_Outptr_ IDxcBlob **pOutputModule, 609 | _COM_Outptr_opt_ IDxcBlobEncoding **ppOutputText) = 0; 610 | }; 611 | 612 | static const UINT32 DxcVersionInfoFlags_None = 0; 613 | static const UINT32 DxcVersionInfoFlags_Debug = 1; // Matches VS_FF_DEBUG 614 | static const UINT32 DxcVersionInfoFlags_Internal = 2; // Internal Validator (non-signing) 615 | 616 | CROSS_PLATFORM_UUIDOF(IDxcVersionInfo, "b04f5b50-2059-4f12-a8ff-a1e0cde1cc7e") 617 | struct IDxcVersionInfo : public IUnknown { 618 | virtual HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor) = 0; 619 | virtual HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags) = 0; 620 | }; 621 | 622 | CROSS_PLATFORM_UUIDOF(IDxcVersionInfo2, "fb6904c4-42f0-4b62-9c46-983af7da7c83") 623 | struct IDxcVersionInfo2 : public IDxcVersionInfo { 624 | virtual HRESULT STDMETHODCALLTYPE GetCommitInfo( 625 | _Out_ UINT32 *pCommitCount, // The total number commits. 626 | _Outptr_result_z_ char **pCommitHash // The SHA of the latest commit. (Must be CoTaskMemFree()'d!) 627 | ) = 0; 628 | }; 629 | 630 | CROSS_PLATFORM_UUIDOF(IDxcVersionInfo3, "5e13e843-9d25-473c-9ad2-03b2d0b44b1e") 631 | struct IDxcVersionInfo3 : public IUnknown { 632 | virtual HRESULT STDMETHODCALLTYPE GetCustomVersionString( 633 | _Outptr_result_z_ char **pVersionString // Custom version string for compiler. (Must be CoTaskMemFree()'d!) 634 | ) = 0; 635 | }; 636 | 637 | struct DxcArgPair { 638 | const WCHAR *pName; 639 | const WCHAR *pValue; 640 | }; 641 | 642 | CROSS_PLATFORM_UUIDOF(IDxcPdbUtils, "E6C9647E-9D6A-4C3B-B94C-524B5A6C343D") 643 | struct IDxcPdbUtils : public IUnknown { 644 | virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) = 0; 645 | 646 | virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) = 0; 647 | virtual HRESULT STDMETHODCALLTYPE GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0; 648 | virtual HRESULT STDMETHODCALLTYPE GetSourceName(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; 649 | 650 | virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) = 0; 651 | virtual HRESULT STDMETHODCALLTYPE GetFlag(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; 652 | 653 | virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) = 0; 654 | virtual HRESULT STDMETHODCALLTYPE GetArg(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; 655 | 656 | virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) = 0; 657 | virtual HRESULT STDMETHODCALLTYPE GetArgPair(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pName, _Outptr_result_z_ BSTR *pValue) = 0; 658 | 659 | virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) = 0; 660 | virtual HRESULT STDMETHODCALLTYPE GetDefine(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0; 661 | 662 | virtual HRESULT STDMETHODCALLTYPE GetTargetProfile(_Outptr_result_z_ BSTR *pResult) = 0; 663 | virtual HRESULT STDMETHODCALLTYPE GetEntryPoint(_Outptr_result_z_ BSTR *pResult) = 0; 664 | virtual HRESULT STDMETHODCALLTYPE GetMainFileName(_Outptr_result_z_ BSTR *pResult) = 0; 665 | 666 | virtual HRESULT STDMETHODCALLTYPE GetHash(_COM_Outptr_ IDxcBlob **ppResult) = 0; 667 | virtual HRESULT STDMETHODCALLTYPE GetName(_Outptr_result_z_ BSTR *pResult) = 0; 668 | 669 | virtual BOOL STDMETHODCALLTYPE IsFullPDB() = 0; 670 | virtual HRESULT STDMETHODCALLTYPE GetFullPDB(_COM_Outptr_ IDxcBlob **ppFullPDB) = 0; 671 | 672 | virtual HRESULT STDMETHODCALLTYPE GetVersionInfo(_COM_Outptr_ IDxcVersionInfo **ppVersionInfo) = 0; 673 | 674 | virtual HRESULT STDMETHODCALLTYPE SetCompiler(_In_ IDxcCompiler3 *pCompiler) = 0; 675 | virtual HRESULT STDMETHODCALLTYPE CompileForFullPDB(_COM_Outptr_ IDxcResult **ppResult) = 0; 676 | virtual HRESULT STDMETHODCALLTYPE OverrideArgs(_In_ DxcArgPair *pArgPairs, UINT32 uNumArgPairs) = 0; 677 | virtual HRESULT STDMETHODCALLTYPE OverrideRootSignature(_In_ const WCHAR *pRootSignature) = 0; 678 | }; 679 | 680 | CROSS_PLATFORM_UUIDOF(IDxcPdbUtils2, "4315D938-F369-4F93-95A2-252017CC3807") 681 | struct IDxcPdbUtils2 : public IUnknown { 682 | virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) = 0; 683 | 684 | virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) = 0; 685 | virtual HRESULT STDMETHODCALLTYPE GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0; 686 | virtual HRESULT STDMETHODCALLTYPE GetSourceName(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; 687 | 688 | virtual HRESULT STDMETHODCALLTYPE GetLibraryPDBCount(UINT32 *pCount) = 0; 689 | virtual HRESULT STDMETHODCALLTYPE GetLibraryPDB(_In_ UINT32 uIndex, _COM_Outptr_ IDxcPdbUtils2 **ppOutPdbUtils, _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppLibraryName) = 0; 690 | 691 | virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) = 0; 692 | virtual HRESULT STDMETHODCALLTYPE GetFlag(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; 693 | 694 | virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) = 0; 695 | virtual HRESULT STDMETHODCALLTYPE GetArg(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; 696 | 697 | virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) = 0; 698 | virtual HRESULT STDMETHODCALLTYPE GetArgPair(_In_ UINT32 uIndex, _COM_Outptr_result_maybenull_ IDxcBlobWide **ppName, _COM_Outptr_result_maybenull_ IDxcBlobWide **ppValue) = 0; 699 | 700 | virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) = 0; 701 | virtual HRESULT STDMETHODCALLTYPE GetDefine(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0; 702 | 703 | virtual HRESULT STDMETHODCALLTYPE GetTargetProfile(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; 704 | virtual HRESULT STDMETHODCALLTYPE GetEntryPoint(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; 705 | virtual HRESULT STDMETHODCALLTYPE GetMainFileName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; 706 | 707 | virtual HRESULT STDMETHODCALLTYPE GetHash(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0; 708 | virtual HRESULT STDMETHODCALLTYPE GetName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0; 709 | 710 | virtual HRESULT STDMETHODCALLTYPE GetVersionInfo(_COM_Outptr_result_maybenull_ IDxcVersionInfo **ppVersionInfo) = 0; 711 | 712 | virtual HRESULT STDMETHODCALLTYPE GetCustomToolchainID(_Out_ UINT32 *pID) = 0; 713 | virtual HRESULT STDMETHODCALLTYPE GetCustomToolchainData(_COM_Outptr_result_maybenull_ IDxcBlob **ppBlob) = 0; 714 | 715 | virtual HRESULT STDMETHODCALLTYPE GetWholeDxil(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0; 716 | 717 | virtual BOOL STDMETHODCALLTYPE IsFullPDB() = 0; 718 | virtual BOOL STDMETHODCALLTYPE IsPDBRef() = 0; 719 | }; 720 | 721 | // Note: __declspec(selectany) requires 'extern' 722 | // On Linux __declspec(selectany) is removed and using 'extern' results in link error. 723 | #ifdef _MSC_VER 724 | #define CLSID_SCOPE __declspec(selectany) extern 725 | #else 726 | #define CLSID_SCOPE 727 | #endif 728 | 729 | CLSID_SCOPE const CLSID CLSID_DxcCompiler = { 730 | 0x73e22d93, 731 | 0xe6ce, 732 | 0x47f3, 733 | {0xb5, 0xbf, 0xf0, 0x66, 0x4f, 0x39, 0xc1, 0xb0}}; 734 | 735 | // {EF6A8087-B0EA-4D56-9E45-D07E1A8B7806} 736 | CLSID_SCOPE const GUID CLSID_DxcLinker = { 737 | 0xef6a8087, 738 | 0xb0ea, 739 | 0x4d56, 740 | {0x9e, 0x45, 0xd0, 0x7e, 0x1a, 0x8b, 0x78, 0x6}}; 741 | 742 | // {CD1F6B73-2AB0-484D-8EDC-EBE7A43CA09F} 743 | CLSID_SCOPE const CLSID CLSID_DxcDiaDataSource = { 744 | 0xcd1f6b73, 745 | 0x2ab0, 746 | 0x484d, 747 | {0x8e, 0xdc, 0xeb, 0xe7, 0xa4, 0x3c, 0xa0, 0x9f}}; 748 | 749 | // {3E56AE82-224D-470F-A1A1-FE3016EE9F9D} 750 | CLSID_SCOPE const CLSID CLSID_DxcCompilerArgs = { 751 | 0x3e56ae82, 752 | 0x224d, 753 | 0x470f, 754 | {0xa1, 0xa1, 0xfe, 0x30, 0x16, 0xee, 0x9f, 0x9d}}; 755 | 756 | // {6245D6AF-66E0-48FD-80B4-4D271796748C} 757 | CLSID_SCOPE const GUID CLSID_DxcLibrary = { 758 | 0x6245d6af, 759 | 0x66e0, 760 | 0x48fd, 761 | {0x80, 0xb4, 0x4d, 0x27, 0x17, 0x96, 0x74, 0x8c}}; 762 | 763 | CLSID_SCOPE const GUID CLSID_DxcUtils = CLSID_DxcLibrary; 764 | 765 | // {8CA3E215-F728-4CF3-8CDD-88AF917587A1} 766 | CLSID_SCOPE const GUID CLSID_DxcValidator = { 767 | 0x8ca3e215, 768 | 0xf728, 769 | 0x4cf3, 770 | {0x8c, 0xdd, 0x88, 0xaf, 0x91, 0x75, 0x87, 0xa1}}; 771 | 772 | // {D728DB68-F903-4F80-94CD-DCCF76EC7151} 773 | CLSID_SCOPE const GUID CLSID_DxcAssembler = { 774 | 0xd728db68, 775 | 0xf903, 776 | 0x4f80, 777 | {0x94, 0xcd, 0xdc, 0xcf, 0x76, 0xec, 0x71, 0x51}}; 778 | 779 | // {b9f54489-55b8-400c-ba3a-1675e4728b91} 780 | CLSID_SCOPE const GUID CLSID_DxcContainerReflection = { 781 | 0xb9f54489, 782 | 0x55b8, 783 | 0x400c, 784 | {0xba, 0x3a, 0x16, 0x75, 0xe4, 0x72, 0x8b, 0x91}}; 785 | 786 | // {AE2CD79F-CC22-453F-9B6B-B124E7A5204C} 787 | CLSID_SCOPE const GUID CLSID_DxcOptimizer = { 788 | 0xae2cd79f, 789 | 0xcc22, 790 | 0x453f, 791 | {0x9b, 0x6b, 0xb1, 0x24, 0xe7, 0xa5, 0x20, 0x4c}}; 792 | 793 | // {94134294-411f-4574-b4d0-8741e25240d2} 794 | CLSID_SCOPE const GUID CLSID_DxcContainerBuilder = { 795 | 0x94134294, 796 | 0x411f, 797 | 0x4574, 798 | {0xb4, 0xd0, 0x87, 0x41, 0xe2, 0x52, 0x40, 0xd2}}; 799 | 800 | // {54621dfb-f2ce-457e-ae8c-ec355faeec7c} 801 | CLSID_SCOPE const GUID CLSID_DxcPdbUtils = { 802 | 0x54621dfb, 803 | 0xf2ce, 804 | 0x457e, 805 | {0xae, 0x8c, 0xec, 0x35, 0x5f, 0xae, 0xec, 0x7c}}; 806 | 807 | #endif 808 | -------------------------------------------------------------------------------- /third-party/dxc/inc/dxcerrors.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // dxcerror.h // 4 | // Copyright (C) Microsoft Corporation. All rights reserved. // 5 | // This file is distributed under the University of Illinois Open Source // 6 | // License. See LICENSE.TXT for details. // 7 | // // 8 | // Provides definition of error codes. // 9 | // // 10 | /////////////////////////////////////////////////////////////////////////////// 11 | 12 | #ifndef __DXC_ERRORS__ 13 | #define __DXC_ERRORS__ 14 | 15 | #ifndef FACILITY_GRAPHICS 16 | #define FACILITY_GRAPHICS 36 17 | #endif 18 | 19 | #define DXC_EXCEPTION_CODE(name, status) \ 20 | static constexpr DWORD EXCEPTION_##name = \ 21 | (0xc0000000u | (FACILITY_GRAPHICS << 16) | (0xff00u | (status & 0xffu))); 22 | 23 | DXC_EXCEPTION_CODE(LOAD_LIBRARY_FAILED, 0x00u) 24 | DXC_EXCEPTION_CODE(NO_HMODULE, 0x01u) 25 | DXC_EXCEPTION_CODE(GET_PROC_FAILED, 0x02u) 26 | 27 | #undef DXC_EXCEPTION_CODE 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /third-party/dxc/inc/dxcisense.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // dxcisense.h // 4 | // Copyright (C) Microsoft Corporation. All rights reserved. // 5 | // This file is distributed under the University of Illinois Open Source // 6 | // License. See LICENSE.TXT for details. // 7 | // // 8 | // Provides declarations for the DirectX Compiler IntelliSense component. // 9 | // // 10 | /////////////////////////////////////////////////////////////////////////////// 11 | 12 | #ifndef __DXC_ISENSE__ 13 | #define __DXC_ISENSE__ 14 | 15 | #include "dxcapi.h" 16 | #ifndef _WIN32 17 | #include "Support/WinAdapter.h" 18 | #endif 19 | 20 | typedef enum DxcGlobalOptions 21 | { 22 | DxcGlobalOpt_None = 0x0, 23 | DxcGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, 24 | DxcGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, 25 | DxcGlobalOpt_ThreadBackgroundPriorityForAll = 26 | DxcGlobalOpt_ThreadBackgroundPriorityForIndexing | DxcGlobalOpt_ThreadBackgroundPriorityForEditing 27 | } DxcGlobalOptions; 28 | 29 | typedef enum DxcTokenKind 30 | { 31 | DxcTokenKind_Punctuation = 0, // A token that contains some kind of punctuation. 32 | DxcTokenKind_Keyword = 1, // A language keyword. 33 | DxcTokenKind_Identifier = 2, // An identifier (that is not a keyword). 34 | DxcTokenKind_Literal = 3, // A numeric, string, or character literal. 35 | DxcTokenKind_Comment = 4, // A comment. 36 | DxcTokenKind_Unknown = 5, // An unknown token (possibly known to a future version). 37 | DxcTokenKind_BuiltInType = 6, // A built-in type like int, void or float3. 38 | } DxcTokenKind; 39 | 40 | typedef enum DxcTypeKind 41 | { 42 | DxcTypeKind_Invalid = 0, // Reprents an invalid type (e.g., where no type is available). 43 | DxcTypeKind_Unexposed = 1, // A type whose specific kind is not exposed via this interface. 44 | // Builtin types 45 | DxcTypeKind_Void = 2, 46 | DxcTypeKind_Bool = 3, 47 | DxcTypeKind_Char_U = 4, 48 | DxcTypeKind_UChar = 5, 49 | DxcTypeKind_Char16 = 6, 50 | DxcTypeKind_Char32 = 7, 51 | DxcTypeKind_UShort = 8, 52 | DxcTypeKind_UInt = 9, 53 | DxcTypeKind_ULong = 10, 54 | DxcTypeKind_ULongLong = 11, 55 | DxcTypeKind_UInt128 = 12, 56 | DxcTypeKind_Char_S = 13, 57 | DxcTypeKind_SChar = 14, 58 | DxcTypeKind_WChar = 15, 59 | DxcTypeKind_Short = 16, 60 | DxcTypeKind_Int = 17, 61 | DxcTypeKind_Long = 18, 62 | DxcTypeKind_LongLong = 19, 63 | DxcTypeKind_Int128 = 20, 64 | DxcTypeKind_Float = 21, 65 | DxcTypeKind_Double = 22, 66 | DxcTypeKind_LongDouble = 23, 67 | DxcTypeKind_NullPtr = 24, 68 | DxcTypeKind_Overload = 25, 69 | DxcTypeKind_Dependent = 26, 70 | DxcTypeKind_ObjCId = 27, 71 | DxcTypeKind_ObjCClass = 28, 72 | DxcTypeKind_ObjCSel = 29, 73 | DxcTypeKind_FirstBuiltin = DxcTypeKind_Void, 74 | DxcTypeKind_LastBuiltin = DxcTypeKind_ObjCSel, 75 | 76 | DxcTypeKind_Complex = 100, 77 | DxcTypeKind_Pointer = 101, 78 | DxcTypeKind_BlockPointer = 102, 79 | DxcTypeKind_LValueReference = 103, 80 | DxcTypeKind_RValueReference = 104, 81 | DxcTypeKind_Record = 105, 82 | DxcTypeKind_Enum = 106, 83 | DxcTypeKind_Typedef = 107, 84 | DxcTypeKind_ObjCInterface = 108, 85 | DxcTypeKind_ObjCObjectPointer = 109, 86 | DxcTypeKind_FunctionNoProto = 110, 87 | DxcTypeKind_FunctionProto = 111, 88 | DxcTypeKind_ConstantArray = 112, 89 | DxcTypeKind_Vector = 113, 90 | DxcTypeKind_IncompleteArray = 114, 91 | DxcTypeKind_VariableArray = 115, 92 | DxcTypeKind_DependentSizedArray = 116, 93 | DxcTypeKind_MemberPointer = 117 94 | } DxcTypeKind; 95 | 96 | // Describes the severity of a particular diagnostic. 97 | typedef enum DxcDiagnosticSeverity 98 | { 99 | // A diagnostic that has been suppressed, e.g., by a command-line option. 100 | DxcDiagnostic_Ignored = 0, 101 | 102 | // This diagnostic is a note that should be attached to the previous (non-note) diagnostic. 103 | DxcDiagnostic_Note = 1, 104 | 105 | // This diagnostic indicates suspicious code that may not be wrong. 106 | DxcDiagnostic_Warning = 2, 107 | 108 | // This diagnostic indicates that the code is ill-formed. 109 | DxcDiagnostic_Error = 3, 110 | 111 | // This diagnostic indicates that the code is ill-formed such that future 112 | // parser rec unlikely to produce useful results. 113 | DxcDiagnostic_Fatal = 4 114 | 115 | } DxcDiagnosticSeverity; 116 | 117 | // Options to control the display of diagnostics. 118 | typedef enum DxcDiagnosticDisplayOptions 119 | { 120 | // Display the source-location information where the diagnostic was located. 121 | DxcDiagnostic_DisplaySourceLocation = 0x01, 122 | 123 | // If displaying the source-location information of the diagnostic, 124 | // also include the column number. 125 | DxcDiagnostic_DisplayColumn = 0x02, 126 | 127 | // If displaying the source-location information of the diagnostic, 128 | // also include information about source ranges in a machine-parsable format. 129 | DxcDiagnostic_DisplaySourceRanges = 0x04, 130 | 131 | // Display the option name associated with this diagnostic, if any. 132 | DxcDiagnostic_DisplayOption = 0x08, 133 | 134 | // Display the category number associated with this diagnostic, if any. 135 | DxcDiagnostic_DisplayCategoryId = 0x10, 136 | 137 | // Display the category name associated with this diagnostic, if any. 138 | DxcDiagnostic_DisplayCategoryName = 0x20, 139 | 140 | // Display the severity of the diagnostic message. 141 | DxcDiagnostic_DisplaySeverity = 0x200 142 | } DxcDiagnosticDisplayOptions; 143 | 144 | typedef enum DxcTranslationUnitFlags 145 | { 146 | // Used to indicate that no special translation-unit options are needed. 147 | DxcTranslationUnitFlags_None = 0x0, 148 | 149 | // Used to indicate that the parser should construct a "detailed" 150 | // preprocessing record, including all macro definitions and instantiations. 151 | DxcTranslationUnitFlags_DetailedPreprocessingRecord = 0x01, 152 | 153 | // Used to indicate that the translation unit is incomplete. 154 | DxcTranslationUnitFlags_Incomplete = 0x02, 155 | 156 | // Used to indicate that the translation unit should be built with an 157 | // implicit precompiled header for the preamble. 158 | DxcTranslationUnitFlags_PrecompiledPreamble = 0x04, 159 | 160 | // Used to indicate that the translation unit should cache some 161 | // code-completion results with each reparse of the source file. 162 | DxcTranslationUnitFlags_CacheCompletionResults = 0x08, 163 | 164 | // Used to indicate that the translation unit will be serialized with 165 | // SaveTranslationUnit. 166 | DxcTranslationUnitFlags_ForSerialization = 0x10, 167 | 168 | // DEPRECATED 169 | DxcTranslationUnitFlags_CXXChainedPCH = 0x20, 170 | 171 | // Used to indicate that function/method bodies should be skipped while parsing. 172 | DxcTranslationUnitFlags_SkipFunctionBodies = 0x40, 173 | 174 | // Used to indicate that brief documentation comments should be 175 | // included into the set of code completions returned from this translation 176 | // unit. 177 | DxcTranslationUnitFlags_IncludeBriefCommentsInCodeCompletion = 0x80, 178 | 179 | // Used to indicate that compilation should occur on the caller's thread. 180 | DxcTranslationUnitFlags_UseCallerThread = 0x800 181 | } DxcTranslationUnitFlags; 182 | 183 | typedef enum DxcCursorFormatting 184 | { 185 | DxcCursorFormatting_Default = 0x0, // Default rules, language-insensitive formatting. 186 | DxcCursorFormatting_UseLanguageOptions = 0x1, // Language-sensitive formatting. 187 | DxcCursorFormatting_SuppressSpecifiers = 0x2, // Supresses type specifiers. 188 | DxcCursorFormatting_SuppressTagKeyword = 0x4, // Suppressed tag keyword (eg, 'class'). 189 | DxcCursorFormatting_IncludeNamespaceKeyword = 0x8, // Include namespace keyword. 190 | } DxcCursorFormatting; 191 | 192 | enum DxcCursorKind { 193 | /* Declarations */ 194 | DxcCursor_UnexposedDecl = 1, // A declaration whose specific kind is not exposed via this interface. 195 | DxcCursor_StructDecl = 2, // A C or C++ struct. 196 | DxcCursor_UnionDecl = 3, // A C or C++ union. 197 | DxcCursor_ClassDecl = 4, // A C++ class. 198 | DxcCursor_EnumDecl = 5, // An enumeration. 199 | DxcCursor_FieldDecl = 6, // A field (in C) or non-static data member (in C++) in a struct, union, or C++ class. 200 | DxcCursor_EnumConstantDecl = 7, // An enumerator constant. 201 | DxcCursor_FunctionDecl = 8, // A function. 202 | DxcCursor_VarDecl = 9, // A variable. 203 | DxcCursor_ParmDecl = 10, // A function or method parameter. 204 | DxcCursor_ObjCInterfaceDecl = 11, // An Objective-C interface. 205 | DxcCursor_ObjCCategoryDecl = 12, // An Objective-C interface for a category. 206 | DxcCursor_ObjCProtocolDecl = 13, // An Objective-C protocol declaration. 207 | DxcCursor_ObjCPropertyDecl = 14, // An Objective-C property declaration. 208 | DxcCursor_ObjCIvarDecl = 15, // An Objective-C instance variable. 209 | DxcCursor_ObjCInstanceMethodDecl = 16, // An Objective-C instance method. 210 | DxcCursor_ObjCClassMethodDecl = 17, // An Objective-C class method. 211 | DxcCursor_ObjCImplementationDecl = 18, // An Objective-C \@implementation. 212 | DxcCursor_ObjCCategoryImplDecl = 19, // An Objective-C \@implementation for a category. 213 | DxcCursor_TypedefDecl = 20, // A typedef 214 | DxcCursor_CXXMethod = 21, // A C++ class method. 215 | DxcCursor_Namespace = 22, // A C++ namespace. 216 | DxcCursor_LinkageSpec = 23, // A linkage specification, e.g. 'extern "C"'. 217 | DxcCursor_Constructor = 24, // A C++ constructor. 218 | DxcCursor_Destructor = 25, // A C++ destructor. 219 | DxcCursor_ConversionFunction = 26, // A C++ conversion function. 220 | DxcCursor_TemplateTypeParameter = 27, // A C++ template type parameter. 221 | DxcCursor_NonTypeTemplateParameter = 28, // A C++ non-type template parameter. 222 | DxcCursor_TemplateTemplateParameter = 29, // A C++ template template parameter. 223 | DxcCursor_FunctionTemplate = 30, // A C++ function template. 224 | DxcCursor_ClassTemplate = 31, // A C++ class template. 225 | DxcCursor_ClassTemplatePartialSpecialization = 32, // A C++ class template partial specialization. 226 | DxcCursor_NamespaceAlias = 33, // A C++ namespace alias declaration. 227 | DxcCursor_UsingDirective = 34, // A C++ using directive. 228 | DxcCursor_UsingDeclaration = 35, // A C++ using declaration. 229 | DxcCursor_TypeAliasDecl = 36, // A C++ alias declaration 230 | DxcCursor_ObjCSynthesizeDecl = 37, // An Objective-C \@synthesize definition. 231 | DxcCursor_ObjCDynamicDecl = 38, // An Objective-C \@dynamic definition. 232 | DxcCursor_CXXAccessSpecifier = 39, // An access specifier. 233 | 234 | DxcCursor_FirstDecl = DxcCursor_UnexposedDecl, 235 | DxcCursor_LastDecl = DxcCursor_CXXAccessSpecifier, 236 | 237 | /* References */ 238 | DxcCursor_FirstRef = 40, /* Decl references */ 239 | DxcCursor_ObjCSuperClassRef = 40, 240 | DxcCursor_ObjCProtocolRef = 41, 241 | DxcCursor_ObjCClassRef = 42, 242 | /** 243 | * \brief A reference to a type declaration. 244 | * 245 | * A type reference occurs anywhere where a type is named but not 246 | * declared. For example, given: 247 | * 248 | * \code 249 | * typedef unsigned size_type; 250 | * size_type size; 251 | * \endcode 252 | * 253 | * The typedef is a declaration of size_type (DxcCursor_TypedefDecl), 254 | * while the type of the variable "size" is referenced. The cursor 255 | * referenced by the type of size is the typedef for size_type. 256 | */ 257 | DxcCursor_TypeRef = 43, // A reference to a type declaration. 258 | DxcCursor_CXXBaseSpecifier = 44, 259 | DxcCursor_TemplateRef = 45, // A reference to a class template, function template, template template parameter, or class template partial specialization. 260 | DxcCursor_NamespaceRef = 46, // A reference to a namespace or namespace alias. 261 | DxcCursor_MemberRef = 47, // A reference to a member of a struct, union, or class that occurs in some non-expression context, e.g., a designated initializer. 262 | /** 263 | * \brief A reference to a labeled statement. 264 | * 265 | * This cursor kind is used to describe the jump to "start_over" in the 266 | * goto statement in the following example: 267 | * 268 | * \code 269 | * start_over: 270 | * ++counter; 271 | * 272 | * goto start_over; 273 | * \endcode 274 | * 275 | * A label reference cursor refers to a label statement. 276 | */ 277 | DxcCursor_LabelRef = 48, // A reference to a labeled statement. 278 | 279 | // A reference to a set of overloaded functions or function templates 280 | // that has not yet been resolved to a specific function or function template. 281 | // 282 | // An overloaded declaration reference cursor occurs in C++ templates where 283 | // a dependent name refers to a function. 284 | DxcCursor_OverloadedDeclRef = 49, 285 | DxcCursor_VariableRef = 50, // A reference to a variable that occurs in some non-expression context, e.g., a C++ lambda capture list. 286 | 287 | DxcCursor_LastRef = DxcCursor_VariableRef, 288 | 289 | /* Error conditions */ 290 | DxcCursor_FirstInvalid = 70, 291 | DxcCursor_InvalidFile = 70, 292 | DxcCursor_NoDeclFound = 71, 293 | DxcCursor_NotImplemented = 72, 294 | DxcCursor_InvalidCode = 73, 295 | DxcCursor_LastInvalid = DxcCursor_InvalidCode, 296 | 297 | /* Expressions */ 298 | DxcCursor_FirstExpr = 100, 299 | 300 | /** 301 | * \brief An expression whose specific kind is not exposed via this 302 | * interface. 303 | * 304 | * Unexposed expressions have the same operations as any other kind 305 | * of expression; one can extract their location information, 306 | * spelling, children, etc. However, the specific kind of the 307 | * expression is not reported. 308 | */ 309 | DxcCursor_UnexposedExpr = 100, // An expression whose specific kind is not exposed via this interface. 310 | DxcCursor_DeclRefExpr = 101, // An expression that refers to some value declaration, such as a function, varible, or enumerator. 311 | DxcCursor_MemberRefExpr = 102, // An expression that refers to a member of a struct, union, class, Objective-C class, etc. 312 | DxcCursor_CallExpr = 103, // An expression that calls a function. 313 | DxcCursor_ObjCMessageExpr = 104, // An expression that sends a message to an Objective-C object or class. 314 | DxcCursor_BlockExpr = 105, // An expression that represents a block literal. 315 | DxcCursor_IntegerLiteral = 106, // An integer literal. 316 | DxcCursor_FloatingLiteral = 107, // A floating point number literal. 317 | DxcCursor_ImaginaryLiteral = 108, // An imaginary number literal. 318 | DxcCursor_StringLiteral = 109, // A string literal. 319 | DxcCursor_CharacterLiteral = 110, // A character literal. 320 | DxcCursor_ParenExpr = 111, // A parenthesized expression, e.g. "(1)". This AST node is only formed if full location information is requested. 321 | DxcCursor_UnaryOperator = 112, // This represents the unary-expression's (except sizeof and alignof). 322 | DxcCursor_ArraySubscriptExpr = 113, // [C99 6.5.2.1] Array Subscripting. 323 | DxcCursor_BinaryOperator = 114, // A builtin binary operation expression such as "x + y" or "x <= y". 324 | DxcCursor_CompoundAssignOperator = 115, // Compound assignment such as "+=". 325 | DxcCursor_ConditionalOperator = 116, // The ?: ternary operator. 326 | DxcCursor_CStyleCastExpr = 117, // An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr, eg: (int)f. 327 | DxcCursor_CompoundLiteralExpr = 118, // [C99 6.5.2.5] 328 | DxcCursor_InitListExpr = 119, // Describes an C or C++ initializer list. 329 | DxcCursor_AddrLabelExpr = 120, // The GNU address of label extension, representing &&label. 330 | DxcCursor_StmtExpr = 121, // This is the GNU Statement Expression extension: ({int X=4; X;}) 331 | DxcCursor_GenericSelectionExpr = 122, // Represents a C11 generic selection. 332 | 333 | /** \brief Implements the GNU __null extension, which is a name for a null 334 | * pointer constant that has integral type (e.g., int or long) and is the same 335 | * size and alignment as a pointer. 336 | * 337 | * The __null extension is typically only used by system headers, which define 338 | * NULL as __null in C++ rather than using 0 (which is an integer that may not 339 | * match the size of a pointer). 340 | */ 341 | DxcCursor_GNUNullExpr = 123, 342 | DxcCursor_CXXStaticCastExpr = 124, // C++'s static_cast<> expression. 343 | DxcCursor_CXXDynamicCastExpr = 125, // C++'s dynamic_cast<> expression. 344 | DxcCursor_CXXReinterpretCastExpr = 126, // C++'s reinterpret_cast<> expression. 345 | DxcCursor_CXXConstCastExpr = 127, // C++'s const_cast<> expression. 346 | 347 | /** \brief Represents an explicit C++ type conversion that uses "functional" 348 | * notion (C++ [expr.type.conv]). 349 | * 350 | * Example: 351 | * \code 352 | * x = int(0.5); 353 | * \endcode 354 | */ 355 | DxcCursor_CXXFunctionalCastExpr = 128, 356 | DxcCursor_CXXTypeidExpr = 129, // A C++ typeid expression (C++ [expr.typeid]). 357 | DxcCursor_CXXBoolLiteralExpr = 130, // [C++ 2.13.5] C++ Boolean Literal. 358 | DxcCursor_CXXNullPtrLiteralExpr = 131, // [C++0x 2.14.7] C++ Pointer Literal. 359 | DxcCursor_CXXThisExpr = 132, // Represents the "this" expression in C++ 360 | DxcCursor_CXXThrowExpr = 133, // [C++ 15] C++ Throw Expression, both 'throw' and 'throw' assignment-expression. 361 | DxcCursor_CXXNewExpr = 134, // A new expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)". 362 | DxcCursor_CXXDeleteExpr = 135, // A delete expression for memory deallocation and destructor calls, e.g. "delete[] pArray". 363 | DxcCursor_UnaryExpr = 136, // A unary expression. 364 | DxcCursor_ObjCStringLiteral = 137, // An Objective-C string literal i.e. @"foo". 365 | DxcCursor_ObjCEncodeExpr = 138, // An Objective-C \@encode expression. 366 | DxcCursor_ObjCSelectorExpr = 139, // An Objective-C \@selector expression. 367 | DxcCursor_ObjCProtocolExpr = 140, // An Objective-C \@protocol expression. 368 | 369 | /** \brief An Objective-C "bridged" cast expression, which casts between 370 | * Objective-C pointers and C pointers, transferring ownership in the process. 371 | * 372 | * \code 373 | * NSString *str = (__bridge_transfer NSString *)CFCreateString(); 374 | * \endcode 375 | */ 376 | DxcCursor_ObjCBridgedCastExpr = 141, 377 | 378 | /** \brief Represents a C++0x pack expansion that produces a sequence of 379 | * expressions. 380 | * 381 | * A pack expansion expression contains a pattern (which itself is an 382 | * expression) followed by an ellipsis. For example: 383 | * 384 | * \code 385 | * template 386 | * void forward(F f, Types &&...args) { 387 | * f(static_cast(args)...); 388 | * } 389 | * \endcode 390 | */ 391 | DxcCursor_PackExpansionExpr = 142, 392 | 393 | /** \brief Represents an expression that computes the length of a parameter 394 | * pack. 395 | * 396 | * \code 397 | * template 398 | * struct count { 399 | * static const unsigned value = sizeof...(Types); 400 | * }; 401 | * \endcode 402 | */ 403 | DxcCursor_SizeOfPackExpr = 143, 404 | 405 | /* \brief Represents a C++ lambda expression that produces a local function 406 | * object. 407 | * 408 | * \code 409 | * void abssort(float *x, unsigned N) { 410 | * std::sort(x, x + N, 411 | * [](float a, float b) { 412 | * return std::abs(a) < std::abs(b); 413 | * }); 414 | * } 415 | * \endcode 416 | */ 417 | DxcCursor_LambdaExpr = 144, 418 | DxcCursor_ObjCBoolLiteralExpr = 145, // Objective-c Boolean Literal. 419 | DxcCursor_ObjCSelfExpr = 146, // Represents the "self" expression in a ObjC method. 420 | DxcCursor_LastExpr = DxcCursor_ObjCSelfExpr, 421 | 422 | /* Statements */ 423 | DxcCursor_FirstStmt = 200, 424 | /** 425 | * \brief A statement whose specific kind is not exposed via this 426 | * interface. 427 | * 428 | * Unexposed statements have the same operations as any other kind of 429 | * statement; one can extract their location information, spelling, 430 | * children, etc. However, the specific kind of the statement is not 431 | * reported. 432 | */ 433 | DxcCursor_UnexposedStmt = 200, 434 | 435 | /** \brief A labelled statement in a function. 436 | * 437 | * This cursor kind is used to describe the "start_over:" label statement in 438 | * the following example: 439 | * 440 | * \code 441 | * start_over: 442 | * ++counter; 443 | * \endcode 444 | * 445 | */ 446 | DxcCursor_LabelStmt = 201, 447 | DxcCursor_CompoundStmt = 202, // A group of statements like { stmt stmt }. This cursor kind is used to describe compound statements, e.g. function bodies. 448 | DxcCursor_CaseStmt = 203, // A case statement. 449 | DxcCursor_DefaultStmt = 204, // A default statement. 450 | DxcCursor_IfStmt = 205, // An if statement 451 | DxcCursor_SwitchStmt = 206, // A switch statement. 452 | DxcCursor_WhileStmt = 207, // A while statement. 453 | DxcCursor_DoStmt = 208, // A do statement. 454 | DxcCursor_ForStmt = 209, // A for statement. 455 | DxcCursor_GotoStmt = 210, // A goto statement. 456 | DxcCursor_IndirectGotoStmt = 211, // An indirect goto statement. 457 | DxcCursor_ContinueStmt = 212, // A continue statement. 458 | DxcCursor_BreakStmt = 213, // A break statement. 459 | DxcCursor_ReturnStmt = 214, // A return statement. 460 | DxcCursor_GCCAsmStmt = 215, // A GCC inline assembly statement extension. 461 | DxcCursor_AsmStmt = DxcCursor_GCCAsmStmt, 462 | 463 | DxcCursor_ObjCAtTryStmt = 216, // Objective-C's overall \@try-\@catch-\@finally statement. 464 | DxcCursor_ObjCAtCatchStmt = 217, // Objective-C's \@catch statement. 465 | DxcCursor_ObjCAtFinallyStmt = 218, // Objective-C's \@finally statement. 466 | DxcCursor_ObjCAtThrowStmt = 219, // Objective-C's \@throw statement. 467 | DxcCursor_ObjCAtSynchronizedStmt = 220, // Objective-C's \@synchronized statement. 468 | DxcCursor_ObjCAutoreleasePoolStmt = 221, // Objective-C's autorelease pool statement. 469 | DxcCursor_ObjCForCollectionStmt = 222, // Objective-C's collection statement. 470 | 471 | DxcCursor_CXXCatchStmt = 223, // C++'s catch statement. 472 | DxcCursor_CXXTryStmt = 224, // C++'s try statement. 473 | DxcCursor_CXXForRangeStmt = 225, // C++'s for (* : *) statement. 474 | 475 | DxcCursor_SEHTryStmt = 226, // Windows Structured Exception Handling's try statement. 476 | DxcCursor_SEHExceptStmt = 227, // Windows Structured Exception Handling's except statement. 477 | DxcCursor_SEHFinallyStmt = 228, // Windows Structured Exception Handling's finally statement. 478 | 479 | DxcCursor_MSAsmStmt = 229, // A MS inline assembly statement extension. 480 | DxcCursor_NullStmt = 230, // The null satement ";": C99 6.8.3p3. 481 | DxcCursor_DeclStmt = 231, // Adaptor class for mixing declarations with statements and expressions. 482 | DxcCursor_OMPParallelDirective = 232, // OpenMP parallel directive. 483 | DxcCursor_OMPSimdDirective = 233, // OpenMP SIMD directive. 484 | DxcCursor_OMPForDirective = 234, // OpenMP for directive. 485 | DxcCursor_OMPSectionsDirective = 235, // OpenMP sections directive. 486 | DxcCursor_OMPSectionDirective = 236, // OpenMP section directive. 487 | DxcCursor_OMPSingleDirective = 237, // OpenMP single directive. 488 | DxcCursor_OMPParallelForDirective = 238, // OpenMP parallel for directive. 489 | DxcCursor_OMPParallelSectionsDirective = 239, // OpenMP parallel sections directive. 490 | DxcCursor_OMPTaskDirective = 240, // OpenMP task directive. 491 | DxcCursor_OMPMasterDirective = 241, // OpenMP master directive. 492 | DxcCursor_OMPCriticalDirective = 242, // OpenMP critical directive. 493 | DxcCursor_OMPTaskyieldDirective = 243, // OpenMP taskyield directive. 494 | DxcCursor_OMPBarrierDirective = 244, // OpenMP barrier directive. 495 | DxcCursor_OMPTaskwaitDirective = 245, // OpenMP taskwait directive. 496 | DxcCursor_OMPFlushDirective = 246, // OpenMP flush directive. 497 | DxcCursor_SEHLeaveStmt = 247, // Windows Structured Exception Handling's leave statement. 498 | DxcCursor_OMPOrderedDirective = 248, // OpenMP ordered directive. 499 | DxcCursor_OMPAtomicDirective = 249, // OpenMP atomic directive. 500 | DxcCursor_OMPForSimdDirective = 250, // OpenMP for SIMD directive. 501 | DxcCursor_OMPParallelForSimdDirective = 251, // OpenMP parallel for SIMD directive. 502 | DxcCursor_OMPTargetDirective = 252, // OpenMP target directive. 503 | DxcCursor_OMPTeamsDirective = 253, // OpenMP teams directive. 504 | DxcCursor_OMPTaskgroupDirective = 254, // OpenMP taskgroup directive. 505 | DxcCursor_OMPCancellationPointDirective = 255, // OpenMP cancellation point directive. 506 | DxcCursor_OMPCancelDirective = 256, // OpenMP cancel directive. 507 | DxcCursor_LastStmt = DxcCursor_OMPCancelDirective, 508 | 509 | DxcCursor_TranslationUnit = 300, // Cursor that represents the translation unit itself. 510 | 511 | /* Attributes */ 512 | DxcCursor_FirstAttr = 400, 513 | /** 514 | * \brief An attribute whose specific kind is not exposed via this 515 | * interface. 516 | */ 517 | DxcCursor_UnexposedAttr = 400, 518 | 519 | DxcCursor_IBActionAttr = 401, 520 | DxcCursor_IBOutletAttr = 402, 521 | DxcCursor_IBOutletCollectionAttr = 403, 522 | DxcCursor_CXXFinalAttr = 404, 523 | DxcCursor_CXXOverrideAttr = 405, 524 | DxcCursor_AnnotateAttr = 406, 525 | DxcCursor_AsmLabelAttr = 407, 526 | DxcCursor_PackedAttr = 408, 527 | DxcCursor_PureAttr = 409, 528 | DxcCursor_ConstAttr = 410, 529 | DxcCursor_NoDuplicateAttr = 411, 530 | DxcCursor_CUDAConstantAttr = 412, 531 | DxcCursor_CUDADeviceAttr = 413, 532 | DxcCursor_CUDAGlobalAttr = 414, 533 | DxcCursor_CUDAHostAttr = 415, 534 | DxcCursor_CUDASharedAttr = 416, 535 | DxcCursor_LastAttr = DxcCursor_CUDASharedAttr, 536 | 537 | /* Preprocessing */ 538 | DxcCursor_PreprocessingDirective = 500, 539 | DxcCursor_MacroDefinition = 501, 540 | DxcCursor_MacroExpansion = 502, 541 | DxcCursor_MacroInstantiation = DxcCursor_MacroExpansion, 542 | DxcCursor_InclusionDirective = 503, 543 | DxcCursor_FirstPreprocessing = DxcCursor_PreprocessingDirective, 544 | DxcCursor_LastPreprocessing = DxcCursor_InclusionDirective, 545 | 546 | /* Extra Declarations */ 547 | /** 548 | * \brief A module import declaration. 549 | */ 550 | DxcCursor_ModuleImportDecl = 600, 551 | DxcCursor_FirstExtraDecl = DxcCursor_ModuleImportDecl, 552 | DxcCursor_LastExtraDecl = DxcCursor_ModuleImportDecl 553 | }; 554 | 555 | enum DxcCursorKindFlags 556 | { 557 | DxcCursorKind_None = 0, 558 | DxcCursorKind_Declaration = 0x1, 559 | DxcCursorKind_Reference = 0x2, 560 | DxcCursorKind_Expression = 0x4, 561 | DxcCursorKind_Statement = 0x8, 562 | DxcCursorKind_Attribute = 0x10, 563 | DxcCursorKind_Invalid = 0x20, 564 | DxcCursorKind_TranslationUnit = 0x40, 565 | DxcCursorKind_Preprocessing = 0x80, 566 | DxcCursorKind_Unexposed = 0x100, 567 | }; 568 | 569 | enum DxcCodeCompleteFlags 570 | { 571 | DxcCodeCompleteFlags_None = 0, 572 | DxcCodeCompleteFlags_IncludeMacros = 0x1, 573 | DxcCodeCompleteFlags_IncludeCodePatterns = 0x2, 574 | DxcCodeCompleteFlags_IncludeBriefComments = 0x4, 575 | }; 576 | 577 | enum DxcCompletionChunkKind 578 | { 579 | DxcCompletionChunk_Optional = 0, 580 | DxcCompletionChunk_TypedText = 1, 581 | DxcCompletionChunk_Text = 2, 582 | DxcCompletionChunk_Placeholder = 3, 583 | DxcCompletionChunk_Informative = 4, 584 | DxcCompletionChunk_CurrentParameter = 5, 585 | DxcCompletionChunk_LeftParen = 6, 586 | DxcCompletionChunk_RightParen = 7, 587 | DxcCompletionChunk_LeftBracket = 8, 588 | DxcCompletionChunk_RightBracket = 9, 589 | DxcCompletionChunk_LeftBrace = 10, 590 | DxcCompletionChunk_RightBrace = 11, 591 | DxcCompletionChunk_LeftAngle = 12, 592 | DxcCompletionChunk_RightAngle = 13, 593 | DxcCompletionChunk_Comma = 14, 594 | DxcCompletionChunk_ResultType = 15, 595 | DxcCompletionChunk_Colon = 16, 596 | DxcCompletionChunk_SemiColon = 17, 597 | DxcCompletionChunk_Equal = 18, 598 | DxcCompletionChunk_HorizontalSpace = 19, 599 | DxcCompletionChunk_VerticalSpace = 20, 600 | }; 601 | 602 | struct IDxcCursor; 603 | struct IDxcDiagnostic; 604 | struct IDxcFile; 605 | struct IDxcInclusion; 606 | struct IDxcIntelliSense; 607 | struct IDxcIndex; 608 | struct IDxcSourceLocation; 609 | struct IDxcSourceRange; 610 | struct IDxcToken; 611 | struct IDxcTranslationUnit; 612 | struct IDxcType; 613 | struct IDxcUnsavedFile; 614 | struct IDxcCodeCompleteResults; 615 | struct IDxcCompletionResult; 616 | struct IDxcCompletionString; 617 | 618 | CROSS_PLATFORM_UUIDOF(IDxcCursor, "1467b985-288d-4d2a-80c1-ef89c42c40bc") 619 | struct IDxcCursor : public IUnknown 620 | { 621 | virtual HRESULT STDMETHODCALLTYPE GetExtent(_Outptr_result_nullonfailure_ IDxcSourceRange** pRange) = 0; 622 | virtual HRESULT STDMETHODCALLTYPE GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) = 0; 623 | virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcCursorKind* pResult) = 0; 624 | virtual HRESULT STDMETHODCALLTYPE GetKindFlags(_Out_ DxcCursorKindFlags* pResult) = 0; 625 | virtual HRESULT STDMETHODCALLTYPE GetSemanticParent(_Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0; 626 | virtual HRESULT STDMETHODCALLTYPE GetLexicalParent(_Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0; 627 | virtual HRESULT STDMETHODCALLTYPE GetCursorType(_Outptr_result_nullonfailure_ IDxcType** pResult) = 0; 628 | virtual HRESULT STDMETHODCALLTYPE GetNumArguments(_Out_ int* pResult) = 0; 629 | virtual HRESULT STDMETHODCALLTYPE GetArgumentAt(int index, _Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0; 630 | virtual HRESULT STDMETHODCALLTYPE GetReferencedCursor(_Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0; 631 | /// For a cursor that is either a reference to or a declaration of some entity, retrieve a cursor that describes the definition of that entity. 632 | /// Some entities can be declared multiple times within a translation unit, but only one of those declarations can also be a definition. 633 | /// A cursor to the definition of this entity; nullptr if there is no definition in this translation unit. 634 | virtual HRESULT STDMETHODCALLTYPE GetDefinitionCursor(_Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0; 635 | virtual HRESULT STDMETHODCALLTYPE FindReferencesInFile( 636 | _In_ IDxcFile* file, unsigned skip, unsigned top, 637 | _Out_ unsigned* pResultLength, _Outptr_result_buffer_maybenull_(*pResultLength) IDxcCursor*** pResult) = 0; 638 | /// Gets the name for the entity references by the cursor, e.g. foo for an 'int foo' variable. 639 | virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_maybenull_ LPSTR* pResult) = 0; 640 | virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcCursor* other, _Out_ BOOL* pResult) = 0; 641 | virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL* pResult) = 0; 642 | virtual HRESULT STDMETHODCALLTYPE IsDefinition(_Out_ BOOL* pResult) = 0; 643 | /// Gets the display name for the cursor, including e.g. parameter types for a function. 644 | virtual HRESULT STDMETHODCALLTYPE GetDisplayName(_Out_ BSTR* pResult) = 0; 645 | /// Gets the qualified name for the symbol the cursor refers to. 646 | virtual HRESULT STDMETHODCALLTYPE GetQualifiedName(BOOL includeTemplateArgs, _Outptr_result_maybenull_ BSTR* pResult) = 0; 647 | /// Gets a name for the cursor, applying the specified formatting flags. 648 | virtual HRESULT STDMETHODCALLTYPE GetFormattedName(DxcCursorFormatting formatting , _Outptr_result_maybenull_ BSTR* pResult) = 0; 649 | /// Gets children in pResult up to top elements. 650 | virtual HRESULT STDMETHODCALLTYPE GetChildren( 651 | unsigned skip, unsigned top, 652 | _Out_ unsigned* pResultLength, _Outptr_result_buffer_maybenull_(*pResultLength) IDxcCursor*** pResult) = 0; 653 | /// Gets the cursor following a location within a compound cursor. 654 | virtual HRESULT STDMETHODCALLTYPE GetSnappedChild(_In_ IDxcSourceLocation* location, _Outptr_result_maybenull_ IDxcCursor** pResult) = 0; 655 | }; 656 | 657 | CROSS_PLATFORM_UUIDOF(IDxcDiagnostic, "4f76b234-3659-4d33-99b0-3b0db994b564") 658 | struct IDxcDiagnostic : public IUnknown 659 | { 660 | virtual HRESULT STDMETHODCALLTYPE FormatDiagnostic( 661 | DxcDiagnosticDisplayOptions options, 662 | _Outptr_result_maybenull_ LPSTR* pResult) = 0; 663 | virtual HRESULT STDMETHODCALLTYPE GetSeverity(_Out_ DxcDiagnosticSeverity* pResult) = 0; 664 | virtual HRESULT STDMETHODCALLTYPE GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) = 0; 665 | virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_maybenull_ LPSTR* pResult) = 0; 666 | virtual HRESULT STDMETHODCALLTYPE GetCategoryText(_Outptr_result_maybenull_ LPSTR* pResult) = 0; 667 | virtual HRESULT STDMETHODCALLTYPE GetNumRanges(_Out_ unsigned* pResult) = 0; 668 | virtual HRESULT STDMETHODCALLTYPE GetRangeAt(unsigned index, _Outptr_result_nullonfailure_ IDxcSourceRange** pResult) = 0; 669 | virtual HRESULT STDMETHODCALLTYPE GetNumFixIts(_Out_ unsigned* pResult) = 0; 670 | virtual HRESULT STDMETHODCALLTYPE GetFixItAt(unsigned index, 671 | _Outptr_result_nullonfailure_ IDxcSourceRange** pReplacementRange, _Outptr_result_maybenull_ LPSTR* pText) = 0; 672 | }; 673 | 674 | CROSS_PLATFORM_UUIDOF(IDxcFile, "bb2fca9e-1478-47ba-b08c-2c502ada4895") 675 | struct IDxcFile : public IUnknown 676 | { 677 | /// Gets the file name for this file. 678 | virtual HRESULT STDMETHODCALLTYPE GetName(_Outptr_result_maybenull_ LPSTR* pResult) = 0; 679 | /// Checks whether this file is equal to the other specified file. 680 | virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcFile* other, _Out_ BOOL* pResult) = 0; 681 | }; 682 | 683 | CROSS_PLATFORM_UUIDOF(IDxcInclusion, "0c364d65-df44-4412-888e-4e552fc5e3d6") 684 | struct IDxcInclusion : public IUnknown 685 | { 686 | virtual HRESULT STDMETHODCALLTYPE GetIncludedFile(_Outptr_result_nullonfailure_ IDxcFile** pResult) = 0; 687 | virtual HRESULT STDMETHODCALLTYPE GetStackLength(_Out_ unsigned *pResult) = 0; 688 | virtual HRESULT STDMETHODCALLTYPE GetStackItem(unsigned index, _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0; 689 | }; 690 | 691 | CROSS_PLATFORM_UUIDOF(IDxcIntelliSense, "b1f99513-46d6-4112-8169-dd0d6053f17d") 692 | struct IDxcIntelliSense : public IUnknown 693 | { 694 | virtual HRESULT STDMETHODCALLTYPE CreateIndex(_Outptr_result_nullonfailure_ IDxcIndex** index) = 0; 695 | virtual HRESULT STDMETHODCALLTYPE GetNullLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** location) = 0; 696 | virtual HRESULT STDMETHODCALLTYPE GetNullRange(_Outptr_result_nullonfailure_ IDxcSourceRange** location) = 0; 697 | virtual HRESULT STDMETHODCALLTYPE GetRange( 698 | _In_ IDxcSourceLocation* start, 699 | _In_ IDxcSourceLocation* end, 700 | _Outptr_result_nullonfailure_ IDxcSourceRange** location) = 0; 701 | virtual HRESULT STDMETHODCALLTYPE GetDefaultDiagnosticDisplayOptions( 702 | _Out_ DxcDiagnosticDisplayOptions* pValue) = 0; 703 | virtual HRESULT STDMETHODCALLTYPE GetDefaultEditingTUOptions(_Out_ DxcTranslationUnitFlags* pValue) = 0; 704 | virtual HRESULT STDMETHODCALLTYPE CreateUnsavedFile(_In_ LPCSTR fileName, _In_ LPCSTR contents, unsigned contentLength, _Outptr_result_nullonfailure_ IDxcUnsavedFile** pResult) = 0; 705 | }; 706 | 707 | CROSS_PLATFORM_UUIDOF(IDxcIndex, "937824a0-7f5a-4815-9ba7-7fc0424f4173") 708 | struct IDxcIndex : public IUnknown 709 | { 710 | virtual HRESULT STDMETHODCALLTYPE SetGlobalOptions(DxcGlobalOptions options) = 0; 711 | virtual HRESULT STDMETHODCALLTYPE GetGlobalOptions(_Out_ DxcGlobalOptions* options) = 0; 712 | virtual HRESULT STDMETHODCALLTYPE ParseTranslationUnit( 713 | _In_z_ const char *source_filename, 714 | _In_count_(num_command_line_args) const char * const *command_line_args, 715 | int num_command_line_args, 716 | _In_count_(num_unsaved_files) IDxcUnsavedFile** unsaved_files, 717 | unsigned num_unsaved_files, 718 | DxcTranslationUnitFlags options, 719 | _Out_ IDxcTranslationUnit** pTranslationUnit) = 0; 720 | }; 721 | 722 | CROSS_PLATFORM_UUIDOF(IDxcSourceLocation, "8e7ddf1c-d7d3-4d69-b286-85fccba1e0cf") 723 | struct IDxcSourceLocation : public IUnknown 724 | { 725 | virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcSourceLocation* other, _Out_ BOOL* pResult) = 0; 726 | virtual HRESULT STDMETHODCALLTYPE GetSpellingLocation( 727 | _Outptr_opt_ IDxcFile** pFile, 728 | _Out_opt_ unsigned* pLine, 729 | _Out_opt_ unsigned* pCol, 730 | _Out_opt_ unsigned* pOffset) = 0; 731 | virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL* pResult) = 0; 732 | virtual HRESULT STDMETHODCALLTYPE GetPresumedLocation( 733 | _Outptr_opt_ LPSTR* pFilename, 734 | _Out_opt_ unsigned* pLine, 735 | _Out_opt_ unsigned* pCol) = 0; 736 | }; 737 | 738 | CROSS_PLATFORM_UUIDOF(IDxcSourceRange, "f1359b36-a53f-4e81-b514-b6b84122a13f") 739 | struct IDxcSourceRange : public IUnknown 740 | { 741 | virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL* pValue) = 0; 742 | virtual HRESULT STDMETHODCALLTYPE GetStart(_Out_ IDxcSourceLocation** pValue) = 0; 743 | virtual HRESULT STDMETHODCALLTYPE GetEnd(_Out_ IDxcSourceLocation** pValue) = 0; 744 | virtual HRESULT STDMETHODCALLTYPE GetOffsets(_Out_ unsigned* startOffset, _Out_ unsigned* endOffset) = 0; 745 | }; 746 | 747 | CROSS_PLATFORM_UUIDOF(IDxcToken, "7f90b9ff-a275-4932-97d8-3cfd234482a2") 748 | struct IDxcToken : public IUnknown 749 | { 750 | virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTokenKind* pValue) = 0; 751 | virtual HRESULT STDMETHODCALLTYPE GetLocation(_Out_ IDxcSourceLocation** pValue) = 0; 752 | virtual HRESULT STDMETHODCALLTYPE GetExtent(_Out_ IDxcSourceRange** pValue) = 0; 753 | virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Out_ LPSTR* pValue) = 0; 754 | }; 755 | 756 | CROSS_PLATFORM_UUIDOF(IDxcTranslationUnit, "9677dee0-c0e5-46a1-8b40-3db3168be63d") 757 | struct IDxcTranslationUnit : public IUnknown 758 | { 759 | virtual HRESULT STDMETHODCALLTYPE GetCursor(_Out_ IDxcCursor** pCursor) = 0; 760 | virtual HRESULT STDMETHODCALLTYPE Tokenize( 761 | _In_ IDxcSourceRange* range, 762 | _Outptr_result_buffer_maybenull_(*pTokenCount) IDxcToken*** pTokens, 763 | _Out_ unsigned* pTokenCount) = 0; 764 | virtual HRESULT STDMETHODCALLTYPE GetLocation( 765 | _In_ IDxcFile* file, 766 | unsigned line, unsigned column, 767 | _Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) = 0; 768 | virtual HRESULT STDMETHODCALLTYPE GetNumDiagnostics(_Out_ unsigned* pValue) = 0; 769 | virtual HRESULT STDMETHODCALLTYPE GetDiagnostic(unsigned index, _Outptr_result_nullonfailure_ IDxcDiagnostic** pValue) = 0; 770 | virtual HRESULT STDMETHODCALLTYPE GetFile(_In_ const char* name, _Outptr_result_nullonfailure_ IDxcFile** pResult) = 0; 771 | virtual HRESULT STDMETHODCALLTYPE GetFileName(_Outptr_result_maybenull_ LPSTR* pResult) = 0; 772 | virtual HRESULT STDMETHODCALLTYPE Reparse( 773 | _In_count_(num_unsaved_files) IDxcUnsavedFile** unsaved_files, 774 | unsigned num_unsaved_files) = 0; 775 | virtual HRESULT STDMETHODCALLTYPE GetCursorForLocation(_In_ IDxcSourceLocation* location, _Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0; 776 | virtual HRESULT STDMETHODCALLTYPE GetLocationForOffset(_In_ IDxcFile* file, unsigned offset, _Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) = 0; 777 | virtual HRESULT STDMETHODCALLTYPE GetSkippedRanges(_In_ IDxcFile* file, _Out_ unsigned* pResultCount, _Outptr_result_buffer_(*pResultCount) IDxcSourceRange*** pResult) = 0; 778 | virtual HRESULT STDMETHODCALLTYPE GetDiagnosticDetails(unsigned index, DxcDiagnosticDisplayOptions options, 779 | _Out_ unsigned* errorCode, 780 | _Out_ unsigned* errorLine, 781 | _Out_ unsigned* errorColumn, 782 | _Out_ BSTR* errorFile, 783 | _Out_ unsigned* errorOffset, 784 | _Out_ unsigned* errorLength, 785 | _Out_ BSTR* errorMessage) = 0; 786 | virtual HRESULT STDMETHODCALLTYPE GetInclusionList(_Out_ unsigned* pResultCount, _Outptr_result_buffer_(*pResultCount) IDxcInclusion*** pResult) = 0; 787 | virtual HRESULT STDMETHODCALLTYPE CodeCompleteAt( 788 | _In_ const char *fileName, unsigned line, unsigned column, 789 | _In_ IDxcUnsavedFile** pUnsavedFiles, unsigned numUnsavedFiles, 790 | _In_ DxcCodeCompleteFlags options, 791 | _Outptr_result_nullonfailure_ IDxcCodeCompleteResults **pResult) = 0; 792 | }; 793 | 794 | CROSS_PLATFORM_UUIDOF(IDxcType, "2ec912fd-b144-4a15-ad0d-1c5439c81e46") 795 | struct IDxcType : public IUnknown 796 | { 797 | virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_z_ LPSTR* pResult) = 0; 798 | virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcType* other, _Out_ BOOL* pResult) = 0; 799 | virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTypeKind* pResult) = 0; 800 | }; 801 | 802 | CROSS_PLATFORM_UUIDOF(IDxcUnsavedFile, "8ec00f98-07d0-4e60-9d7c-5a50b5b0017f") 803 | struct IDxcUnsavedFile : public IUnknown 804 | { 805 | virtual HRESULT STDMETHODCALLTYPE GetFileName(_Outptr_result_z_ LPSTR* pFileName) = 0; 806 | virtual HRESULT STDMETHODCALLTYPE GetContents(_Outptr_result_z_ LPSTR* pContents) = 0; 807 | virtual HRESULT STDMETHODCALLTYPE GetLength(_Out_ unsigned* pLength) = 0; 808 | }; 809 | 810 | 811 | CROSS_PLATFORM_UUIDOF(IDxcCodeCompleteResults, "1E06466A-FD8B-45F3-A78F-8A3F76EBB552") 812 | struct IDxcCodeCompleteResults : public IUnknown 813 | { 814 | virtual HRESULT STDMETHODCALLTYPE GetNumResults(_Out_ unsigned* pResult) = 0; 815 | virtual HRESULT STDMETHODCALLTYPE GetResultAt(unsigned index, _Outptr_result_nullonfailure_ IDxcCompletionResult** pResult) = 0; 816 | }; 817 | 818 | CROSS_PLATFORM_UUIDOF(IDxcCompletionResult, "943C0588-22D0-4784-86FC-701F802AC2B6") 819 | struct IDxcCompletionResult : public IUnknown 820 | { 821 | virtual HRESULT STDMETHODCALLTYPE GetCursorKind(_Out_ DxcCursorKind* pResult) = 0; 822 | virtual HRESULT STDMETHODCALLTYPE GetCompletionString(_Outptr_result_nullonfailure_ IDxcCompletionString** pResult) = 0; 823 | }; 824 | 825 | CROSS_PLATFORM_UUIDOF(IDxcCompletionString, "06B51E0F-A605-4C69-A110-CD6E14B58EEC") 826 | struct IDxcCompletionString : public IUnknown 827 | { 828 | virtual HRESULT STDMETHODCALLTYPE GetNumCompletionChunks(_Out_ unsigned* pResult) = 0; 829 | virtual HRESULT STDMETHODCALLTYPE GetCompletionChunkKind(unsigned chunkNumber, _Out_ DxcCompletionChunkKind* pResult) = 0; 830 | virtual HRESULT STDMETHODCALLTYPE GetCompletionChunkText(unsigned chunkNumber, _Out_ LPSTR* pResult) = 0; 831 | }; 832 | 833 | // Fun fact: 'extern' is required because const is by default static in C++, so 834 | // CLSID_DxcIntelliSense is not visible externally (this is OK in C, since const is 835 | // not by default static in C) 836 | 837 | #ifdef _MSC_VER 838 | #define CLSID_SCOPE __declspec(selectany) extern 839 | #else 840 | #define CLSID_SCOPE 841 | #endif 842 | 843 | CLSID_SCOPE const CLSID 844 | CLSID_DxcIntelliSense = {/* 3047833c-d1c0-4b8e-9d40-102878605985 */ 845 | 0x3047833c, 846 | 0xd1c0, 847 | 0x4b8e, 848 | {0x9d, 0x40, 0x10, 0x28, 0x78, 0x60, 0x59, 0x85}}; 849 | 850 | #endif 851 | -------------------------------------------------------------------------------- /third-party/dxc/lib/arm64/dxcompiler.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/lib/arm64/dxcompiler.lib -------------------------------------------------------------------------------- /third-party/dxc/lib/x64/dxcompiler.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/lib/x64/dxcompiler.lib -------------------------------------------------------------------------------- /third-party/dxc/lib/x86/dxcompiler.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/dxc/lib/x86/dxcompiler.lib -------------------------------------------------------------------------------- /third-party/imgui.lua: -------------------------------------------------------------------------------- 1 | project "ImGui" 2 | kind "StaticLib" 3 | language "C++" 4 | cppdialect "C++17" 5 | flags { 6 | "MultiProcessorCompile" 7 | } 8 | 9 | targetdir (target_dir .. "/%{prj.name}") 10 | objdir (obj_dir .. "/%{prj.name}") 11 | location (build_dir .. "/%{prj.name}") 12 | 13 | includedirs { 14 | "imgui", 15 | } 16 | 17 | externalincludedirs { 18 | "imgui", 19 | dawn_include_dir, 20 | dawn_gen_include_dir, 21 | sdl_include_dir, 22 | } 23 | 24 | files { 25 | "imgui/*.h", 26 | "imgui/*.cpp", 27 | "imgui/backends/imgui_impl_wgpu.h", 28 | "imgui/backends/imgui_impl_wgpu.cpp", 29 | "imgui/backends/imgui_impl_sdl2.h", 30 | "imgui/backends/imgui_impl_sdl2.cpp", 31 | } 32 | 33 | filter "system:macosx" 34 | systemversion "11.0" 35 | 36 | filter "configurations:Debug" 37 | defines { "DEBUG" } 38 | symbols "On" 39 | 40 | filter "configurations:Release" 41 | defines { "NDEBUG" } 42 | optimize "On" -------------------------------------------------------------------------------- /third-party/premake/libluasocket.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/premake/libluasocket.dylib -------------------------------------------------------------------------------- /third-party/premake/premake5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/premake/premake5 -------------------------------------------------------------------------------- /third-party/premake/premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottosson/webgpu-sdl-imgui-cpp-starter/f953a0bb4db4dfdc1dfcb965f1545bcb5ad627fb/third-party/premake/premake5.exe -------------------------------------------------------------------------------- /third-party/sdl.lua: -------------------------------------------------------------------------------- 1 | project "SDL" 2 | kind "StaticLib" 3 | language "C++" 4 | cppdialect "C++17" 5 | flags { 6 | "MultiProcessorCompile" 7 | } 8 | 9 | targetdir (target_dir .. "/%{prj.name}") 10 | objdir (obj_dir .. "/%{prj.name}") 11 | location (build_dir .. "/%{prj.name}") 12 | 13 | externalincludedirs { 14 | "sdl/include", 15 | "sdl/src/", 16 | } 17 | 18 | files { 19 | "sdl/include/**.h", 20 | "sdl/src/*.h", 21 | "sdl/src/*.c", 22 | "sdl/src/*/*.h", 23 | "sdl/src/*/*.c", 24 | "sdl/src/audio/disk/*.h", 25 | "sdl/src/audio/disk/*.c", 26 | "sdl/src/audio/dummy/*.h", 27 | "sdl/src/audio/dummy/*.c", 28 | "sdl/src/joystick/hidapi/*.h", 29 | "sdl/src/joystick/hidapi/*.c", 30 | "sdl/src/joystick/virtual/*.h", 31 | "sdl/src/joystick/virtual/*.c", 32 | "sdl/src/video/dummy/*.h", 33 | "sdl/src/video/dummy/*.c", 34 | "sdl/src/video/yuv2rgb/*.h", 35 | "sdl/src/video/yuv2rgb/*.c", 36 | } 37 | 38 | filter "system:macosx" 39 | buildoptions ( "-fobjc-arc" ) 40 | systemversion "11.0" 41 | files { 42 | "sdl/src/audio/coreaudio/*.h", 43 | "sdl/src/audio/coreaudio/*.m", 44 | "sdl/src/*/unix/*.h", 45 | "sdl/src/*/unix/*.c", 46 | "sdl/src/*/mac/*.h", 47 | "sdl/src/*/mac/*.c", 48 | "sdl/src/*/mac/*.m", 49 | "sdl/src/*/macosx/*.h", 50 | "sdl/src/*/macosx/*.c", 51 | "sdl/src/*/macosx/*.m", 52 | "sdl/src/*/metal/*.h", 53 | "sdl/src/*/metal/*.c", 54 | "sdl/src/*/metal/*.m", 55 | "sdl/src/*/cocoa/*.h", 56 | "sdl/src/*/cocoa/*.c", 57 | "sdl/src/*/cocoa/*.m", 58 | "sdl/src/*/darwin/*.h", 59 | "sdl/src/*/darwin/*.c", 60 | "sdl/src/*/darwin/*.m", 61 | "sdl/src/loadso/dlopen/*.h", 62 | "sdl/src/loadso/dlopen/*.c", 63 | "sdl/src/sensor/dummy/*.h", 64 | "sdl/src/sensor/dummy/*.c", 65 | "sdl/src/joystick/iphoneos/*.h", 66 | "sdl/src/joystick/iphoneos/*.c", 67 | "sdl/src/joystick/iphoneos/*.m", 68 | "sdl/src/thread/pthread/*.h", 69 | "sdl/src/thread/pthread/*.c", 70 | } 71 | defines { 72 | "SDL_VIDEO_RENDER_OGL=0", 73 | "SDL_VIDEO_RENDER_OGL_ES2=0", 74 | "SDL_VIDEO_RENDER_SW=0", 75 | "SDL_VIDEO_OPENGL_EGL=0", 76 | } 77 | 78 | filter "system:windows" 79 | links { 80 | "d3d12", 81 | "dxgi", 82 | "d3dcompiler", 83 | "winmm", 84 | "setupapi", 85 | "imm32", 86 | "version", 87 | } 88 | files { 89 | "sdl/src/audio/directsound/*.h", 90 | "sdl/src/audio/directsound/*.c", 91 | "sdl/src/audio/wasapi/*.h", 92 | "sdl/src/audio/wasapi/*.c", 93 | "sdl/src/audio/winmm/*.h", 94 | "sdl/src/audio/winmm/*.c", 95 | "sdl/src/*/windows/*.h", 96 | "sdl/src/*/windows/*.c", 97 | "sdl/src/*/direct3d/*.h", 98 | "sdl/src/*/direct3d/*.c", 99 | "sdl/src/*/direct3d11/*.h", 100 | "sdl/src/*/direct3d11/*.c", 101 | "sdl/src/*/direct3d12/*.h", 102 | "sdl/src/*/direct3d12/*.c", 103 | "sdl/src/thread/generic/SDL_syscond_c.h", 104 | "sdl/src/thread/generic/SDL_syscond.c", 105 | } 106 | removefiles { 107 | "sdl/src/hidapi/windows/hid.c", 108 | "sdl/src/main/windows/**", 109 | } 110 | defines { 111 | "SDL_VIDEO_RENDER_OGL=0", 112 | "SDL_VIDEO_RENDER_OGL_ES2=0", 113 | "SDL_VIDEO_RENDER_SW=0", 114 | } 115 | 116 | filter "configurations:Debug" 117 | defines { "DEBUG" } 118 | symbols "On" 119 | 120 | filter "configurations:Release" 121 | defines { "NDEBUG" } 122 | optimize "On" 123 | 124 | project "SDL_main" 125 | kind "StaticLib" 126 | language "C++" 127 | cppdialect "C++17" 128 | flags { 129 | "MultiProcessorCompile" 130 | } 131 | 132 | targetdir (target_dir .. "/%{prj.name}") 133 | objdir (obj_dir .. "/%{prj.name}") 134 | location (build_dir .. "/%{prj.name}") 135 | 136 | includedirs { 137 | "sdl/include", 138 | } 139 | externalincludedirs { 140 | "sdl/include", 141 | } 142 | links { 143 | "SDL" 144 | } 145 | files { 146 | "sdl/src/main/windows/**" 147 | } 148 | 149 | filter "system:macosx" 150 | systemversion "11.0" 151 | 152 | filter "configurations:Debug" 153 | defines { "DEBUG" } 154 | symbols "On" 155 | 156 | filter "configurations:Release" 157 | defines { "NDEBUG" } 158 | optimize "On" --------------------------------------------------------------------------------