https://github.com/weakknight/shadercompiler
a Slang Compiler wrapper
https://github.com/weakknight/shadercompiler
Last synced: 3 months ago
JSON representation
a Slang Compiler wrapper
- Host: GitHub
- URL: https://github.com/weakknight/shadercompiler
- Owner: WeakKnight
- License: mit
- Created: 2021-10-16T14:58:43.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-11T08:52:10.000Z (over 3 years ago)
- Last Synced: 2025-01-17T20:35:44.312Z (4 months ago)
- Language: HLSL
- Size: 12.6 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# ShaderCompiler
ShaderCompiler is a wrapper of [Slang](https://github.com/shader-slang/slang).
## Features
* Slang To HLSL
* Slang To DXIL
* Reflection API## Examples
### Slang
```
cbuffer CB
{
int frameIndex;
int bufferSize;
}StructuredBuffer buffer0;
StructuredBuffer buffer1;
RWStructuredBuffer result;
StructuredBuffer bufferArray[_BUFFER_SIZE];[numthreads(16,16,1)]
void main(uint3 threadId : SV_DispatchThreadID)
{
uint index = threadId.x;
result[index] = buffer0[index] + buffer1[index];
}
```
### C++
```
auto compiler = shc::Compiler();
compiler.AddSearchPath("include/");shc::DefineList defines;
defines.AddDefine("_BUFFER_SIZE", "42");std::shared_ptr result = compiler.Compile("shader.hlsl", "main", "cs_6_5", defines, shc::Compiler::Target::DXIL);
// Reflection Information
assert(result->variables["bufferArray"].count == 42);// Binary
assert(result->data != nullptr);
assert(result->size > 0);
```