https://github.com/heroseh/hcc Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} heroseh / hcc Public * * Notifications You must be signed in to change notification settings * Fork 11 * Star 360 C Compiler to SPIR-V License MIT license 360 stars 11 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 2 * Pull requests 1 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights heroseh/hcc main BranchesTags [ ] Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 155 Commits .github .github docs docs interop interop libc libc libhccintrinsics libhccintrinsics libhmaths @ libhmaths @ 3f61a6b 3f61a6b logo logo playground playground samples samples scripts scripts src src tools tools .clangd .clangd .gitignore .gitignore .gitmodules .gitmodules LICENSE LICENSE README.md README.md compile_flags.txt compile_flags.txt View all files Repository files navigation * README * MIT license [logo-256] Hero C Compiler HCC is a C compiler that allows you to compile your C codebase (with limitations) to SPIR-V for the Vulkan graphics API. This means you can share struct's, enum's and functions between your CPU & GPU code. HCC targets the future of GPU programming so is designed around features such as bindless resources and scalar alignment. This makes it easier to interop with the GPU and focus on writing shader code without writing your own shader build system. The project is currently in alpha, so expect bugs and please help by filing bugs and contributing back to the codebase :) Features * Windows & Linux support * Vulkan 1.3+ * Aims for C11 support * Vertex, Pixel & Compute shader support * Included Maths library for CPU & GPU programming More Info * Textures, Atomics, Quad & Wave Intrinsics More Info * _Generic support for Maths & Intrinsics functions for C compliant overloads * Vulkan interop code to help setup with your engine More Info * 5 working samples and a samples application to see how it can plug into your engine More Info * live playground application to have a play by writing shader code! More Info * multiple shaders in a single file * Compiler only depends on libc, optionally uses the SPIR-V tools for validation and optimization * Swizzling * Printing from any shader with hprintf Limitations * No pointer support outside compiler intrinsics (possible but needs work) * No union support (possible with pointer support) * Limited string support (works with hprintf, full support possible with pointer support) * Limited structure bitfields (works on Linux, the rest of the platform need work) * No function scope struct, enum declarations (needs work) * No vector operator (planned soon after release) * No function pointers * Minimal libc bundled with the compiler * Vulkan 1.3+ with the following features: + vulkanMemoryModel + vulkanMemoryModelDeviceScope + shaderSampledImageArrayNonUniformIndexing + shaderStorageBufferArrayNonUniformIndexing + shaderStorageImageArrayNonUniformIndexing + shaderStorageTexelBufferArrayNonUniformIndexing + descriptorBindingSampledImageUpdateAfterBind + descriptorBindingStorageImageUpdateAfterBind + descriptorBindingStorageBufferUpdateAfterBind + descriptorBindingStorageTexelBufferUpdateAfterBind + descriptorBindingPartiallyBound + scalarBlockLayout + shaderDemoteToHelperInvocation What does it look like? Here is a vertex & pixel shader triangle sample: typedef struct Vertex Vertex; struct Vertex { f32x2 pos; uint32_t color; }; typedef struct TriangleBC TriangleBC; struct TriangleBC { HccRoBuffer(Vertex) vertices; f32x4 tint; }; typedef struct RasterizerState RasterizerState; HCC_RASTERIZER_STATE struct RasterizerState { HCC_INTERP f32x4 color; }; HCC_VERTEX void triangle_vs( HccVertexSV const* const sv, HccVertexSVOut* const sv_out, TriangleBC const* const bc, RasterizerState* const state_out ) { Vertex vertex = bc->vertices[sv->vertex_idx]; sv_out->position = f32x4(vertex.pos.x, vertex.pos.y, 0.f, 1.f); state_out->color = mulG(unpack_u8x4_f32x4(vertex.color), bc->tint); } typedef struct Pixel Pixel; HCC_PIXEL_STATE struct Pixel { f32x4 color; }; HCC_PIXEL void triangle_ps( HccPixelSV const* const sv, HccPixelSVOut* const sv_out, TriangleBC const* const bc, RasterizerState const* const state, Pixel* const pixel_out ) { pixel_out->color = state->color; } Great, how do I find out more? You can download the latest release here: We also have the documentation you can check out here Support If enjoy using the project, please consider sending a tip to show your support. Thank you! :) [6874747073] FAQ * Q: Do you plan on DX12 or Metal support? + A: Yes, when I personally need to port a project of mine over. If you would like to speed this up, I am open to work with a contributor who is willing to do the port. The compiler is structured in such a way where you 'just' need to do a DXIL or MSL backend. Please use the Discord or file an Github issue if you wish to coordinate on one of these backends. * Q: Do you plan on supporting Mesh & Ray Tracing shaders? + A: Yes in future when I need them personally, but I am open to coordinate with someone who is willing to implement them. Please use the Discord or file an Github issue if you wish to work on this. * Q: Do you plan on supporting OpenGL or DX11? + A: No, unfortunately we are targeting the future of graphics programming and this is in compatible with older graphics APIs :( Community We have a Discord community for any HCC discussion or to be involved in a low-level C / Gamedev / Graphics community Catch live development on the compiler at Twitch Contributor If you like the project and are a competent C programmer, please consider being a contributor. Join the Discord or open up some Github issues related to the features you want to work on. About C Compiler to SPIR-V Resources Readme License MIT license Activity Stars 360 stars Watchers 13 watching Forks 11 forks Report repository Releases 7 0.4.0 Latest Nov 16, 2024 + 6 releases Sponsor this project * ko_fi ko-fi.com/hero_dev Packages 0 No packages published Contributors 2 * @heroseh heroseh Henry Rose * @ransel117 ransel117 Languages * C 86.3% * C++ 13.5% * Other 0.2% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.