{"id":21187856,"url":"https://github.com/lukasbanana/xshadercompiler","last_synced_at":"2025-12-23T01:06:41.695Z","repository":{"id":21682689,"uuid":"25003912","full_name":"LukasBanana/XShaderCompiler","owner":"LukasBanana","description":"Shader cross compiler to translate HLSL (Shader Model 4 and 5) to GLSL","archived":false,"fork":false,"pushed_at":"2019-09-07T03:42:42.000Z","size":7744,"stargazers_count":358,"open_issues_count":7,"forks_count":48,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-30T17:11:29.506Z","etag":null,"topics":["c","cpp","cpp11","csharp","glsl","hlsl","shader-cross-compiler"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LukasBanana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-09T18:56:52.000Z","updated_at":"2025-03-16T16:43:46.000Z","dependencies_parsed_at":"2022-09-18T06:56:25.503Z","dependency_job_id":null,"html_url":"https://github.com/LukasBanana/XShaderCompiler","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasBanana%2FXShaderCompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasBanana%2FXShaderCompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasBanana%2FXShaderCompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasBanana%2FXShaderCompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukasBanana","download_url":"https://codeload.github.com/LukasBanana/XShaderCompiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247535517,"owners_count":20954576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cpp","cpp11","csharp","glsl","hlsl","shader-cross-compiler"],"created_at":"2024-11-20T18:41:26.230Z","updated_at":"2025-12-23T01:06:41.616Z","avatar_url":"https://github.com/LukasBanana.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build status](https://ci.appveyor.com/api/projects/status/ihfukm86am2f27e5?svg=true)](https://ci.appveyor.com/project/LukasBanana/xshadercompiler)\n\n# XShaderCompiler (\"Cross Shader Compiler\") #\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"docu/Xsc_Logo.png\"/\u003e\u003c/p\u003e\n\nFeatures\n--------\n\n* Cross compiles HLSL shader code (Shader Model 4 and 5) into GLSL\n* Simple to integrate into other projects\n* Low overhead translation (i.e. avoidance of unnecessary wrapper functions)\n* Dead code removal\n* Code reflection\n* Meaningful report output\n* Commentary preserving\n* Written in C++11\n\nLanguage Bindings\n-----------------\n\n* C Wrapper (ISO C99)\n* C# Wrapper\n\nLicense\n-------\n\n3-Clause BSD License\n\nDocumentation\n-------------\n\n* [Getting Started with XShaderCompiler](https://github.com/LukasBanana/XShaderCompiler/blob/master/docu/GettingStarted/Getting%20Started%20with%20XShaderCompiler.pdf) (PDF)\n* [XShaderCompiler Reference Manual](https://github.com/LukasBanana/XShaderCompiler/blob/master/docu/refman.pdf) (PDF)\n\nProgress\n--------\n\n**Version: 0.11 Alpha** (*Do not use in production code!*)\n\nSee the [TODO.md](https://github.com/LukasBanana/XShaderCompiler/blob/master/TODO.md) file for more information.\n\n| Feature | Progress | Remarks |\n|---------|:--------:|---------|\n| Vertex Shader | ~80% | Few language features are still left |\n| Tessellation Control Shader | ~20% | InputPatch and patch-constant-function translation in progress |\n| Tessellation Evaluation Shader | ~20% | OutputPatch translation in progress |\n| Geometry Shader | ~60% | Code generation is incomplete |\n| Fragment Shader | ~80% | Few language features are still left |\n| Compute Shader | ~80% | Few language features are still left |\n\nOffline Compiler\n----------------\n\nThe following command line translates the \"Example.hlsl\" file with the vertex shader entry point \"VS\", and the fragment shader entry point \"PS\":\n\n```\nxsc -E VS -T vert Example.hlsl -E PS -T frag Example.hlsl\n```\n\nThe result are two GLSL shader files: \"Example.VS.vert\" and \"Example.PS.frag\".\n\nLibrary Usage (C++)\n-------------------\n\n```cpp\n#include \u003cXsc/Xsc.h\u003e\n#include \u003cfstream\u003e\n#include \u003ciostream\u003e\n\nint main()\n{\n    // Input file stream (use std::stringstream for in-code shaders).\n    auto inputStream = std::make_shared\u003cstd::ifstream\u003e(\"Example.hlsl\");\n\n    // Output file stream (GLSL vertex shader)\n    std::ofstream outputStream(\"Example.VS.vert\");\n\n    // Fill the shader input descriptor structure\n    Xsc::ShaderInput inputDesc;\n    inputDesc.sourceCode     = inputStream;\n    inputDesc.shaderVersion  = Xsc::InputShaderVersion::HLSL5;\n    inputDesc.entryPoint     = \"VS\";\n    inputDesc.shaderTarget   = Xsc::ShaderTarget::VertexShader;\n\n    // Fill the shader output descriptor structure\n    // Use outputDesc.options, outputDesc.formatting, and outputDesc.nameMangling for more settings\n    Xsc::ShaderOutput outputDesc;\n    outputDesc.sourceCode = \u0026outputStream;\n\n    // Optional output log (can also be a custom class)\n    Xsc::StdLog log;\n\n    // Optional shader reflection data (for shader code feedback)\n    Xsc::Reflection::ReflectionData reflectData;\n\n    // Translate HLSL code into GLSL\n    try\n    {\n        bool result = Xsc::CompileShader(inputDesc, outputDesc, \u0026log, \u0026reflectData);\n    }\n    catch (const std::exception\u0026 e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n    }\n\n    return 0;\n}\n```\n\nLibrary Usage (C#)\n------------------\n\n```cs\nusing System;\nusing System.IO;\n\nnamespace Example\n{\n    class Program\n    {\n        static void Main()\n        {\n            // Create instance of the XShaderCompiler\n            var compiler = new XscCompiler();\n\n            // Fill the shader input descriptor structure\n            var inputDesc = new XscCompiler.ShaderInput();\n            inputDesc.SourceCode     = File.ReadAllText(\"Example.hlsl\");\n            inputDesc.ShaderVersion  = XscCompiler.InputShaderVersion.HLSL5;\n            inputDesc.EntryPoint     = \"VS\";\n            inputDesc.Target         = XscCompiler.ShaderTarget.VertexShader;\n\n            // Fill the shader output descriptor structure\n            // Use outputDesc.Options, outputDesc.Formatting, and outputDesc.MameMangling for more settings\n            var outputDesc = new XscCompiler.ShaderOutput();\n\n            // Optional output log (can also be a custom class)\n            var log = compiler.StandardLog;\n\n            // Optional shader reflection data (for shader code feedback)\n            var reflectData = new XscCompiler.ReflectionData();\n\n            // Translate HLSL code into GLSL\n            try\n            {\n                bool result = compiler.CompileShader(inputDesc, outputDesc, log, reflectData);\n\n                if (result)\n                {\n                    // Write output shader code\n                    File.WriteAllText(\"Example.VS.vert\", outputDesc.SourceCode);\n                }\n            }\n            catch (Exception e)\n            {\n                Console.WriteLine(e);\n            }\n        }\n    }\n}\n```\n\nReal-time Debugger\n------------------\n\nA real-time debugger with UI is provided. Although this debugger is mainly used for developement of the compiler itself,\nit can also be used for a quick translation overview, to see how language constructs are being cross compiled.\n\n\u003cp align=\"center\"\u003eExample of the real-time debugger (requires \u003ca href=\"http://www.wxwidgets.org/\"\u003ewxWidgets 3.1.0\u003c/a\u003e or later):\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"docu/xsc_debugger_example_02.png\" alt=\"docu/xsc_debugger_example_02.png\"/\u003e\u003c/p\u003e\n\nLanguage Differences\n--------------------\n\nHere is a brief outline of High-Level differences between HLSL and GLSL, which XShaderCompiler is able to translate properly:\n\n| Feature | HLSL | GLSL |\n|---------|:----:|:----:|\n| Separation of Textures and Samplers | Yes | Only for Vulkan |\n| Structure Inheritance | Yes | No |\n| Nested Structures | Yes | No |\n| Anonymous Structures | Yes | No |\n| Structure Member Functions | Yes | No |\n| Default Parameters | Yes | No |\n| Object-Oriented Intrinsics | Yes | No |\n| Multiple Entry Points | Yes | No |\n| Type Aliasing | Yes | No |\n| L-Values of Input Semantics | Yes | No |\n| Implicit Type Conversion | Extensive | Restricted |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasbanana%2Fxshadercompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukasbanana%2Fxshadercompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasbanana%2Fxshadercompiler/lists"}