Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example for using the reflection API #5839

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ if(SLANG_ENABLE_EXAMPLES)
example(platform-test WIN32_EXECUTABLE)
example(ray-tracing WIN32_EXECUTABLE)
example(ray-tracing-pipeline WIN32_EXECUTABLE)
example(reflection-api)
example(shader-object)
example(shader-toy WIN32_EXECUTABLE)
example(triangle WIN32_EXECUTABLE)
Expand Down
6 changes: 6 additions & 0 deletions examples/reflection-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Slang Reflection API Example
============================

This example shows basic usage of the Slang reflection API to
traverse the parameters of a program, including type and
layout information.
21 changes: 21 additions & 0 deletions examples/reflection-api/compute-simple.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// compute-simple.slang

struct ImageProcessingOptions
{
float3 tintColor;
float blurRadius;

bool useLookupTable;
StructuredBuffer<float4> lookupTable;
}

[shader("compute")]
[numthreads(8, 8)]
void processImage(
uint3 threadID : SV_DispatchThreadID,
uniform Texture2D inputImage,
uniform RWTexture2D outputImage,
uniform ImageProcessingOptions options)
{
/* actual logic would go here */
}
Loading
Loading