|
10 | 10 |
|
11 | 11 | #include <filesystem> |
12 | 12 |
|
| 13 | +const char* codeSlang = R"( |
| 14 | +struct VertexOutput { |
| 15 | + float4 sv_Position : SV_Position; |
| 16 | + float2 uv : TEXCOORD0; |
| 17 | +}; |
| 18 | +
|
| 19 | +static const float2 pos[4] = { |
| 20 | + float2(-1.0, -1.0), |
| 21 | + float2(-1.0, +1.0), |
| 22 | + float2(+1.0, -1.0), |
| 23 | + float2(+1.0, +1.0) |
| 24 | +}; |
| 25 | +
|
| 26 | +[[vk::constant_id(0)]] const uint textureId = 0; |
| 27 | +
|
| 28 | +[shader("vertex")] |
| 29 | +VertexOutput vertexMain(uint vertexID : SV_VertexID) { |
| 30 | + VertexOutput out; |
| 31 | + out.sv_Position = float4(pos[vertexID], 0.0, 1.0); |
| 32 | + out.uv = pos[vertexID] * 0.5 + 0.5; |
| 33 | + out.uv.y = 1.0 - out.uv.y; |
| 34 | + return out; |
| 35 | +} |
| 36 | +
|
| 37 | +[shader("fragment")] |
| 38 | +float4 fragmentMain(VertexOutput input) : SV_Target0 { |
| 39 | + return kSamplersYUV[textureId].Sample(input.uv); |
| 40 | +} |
| 41 | +)"; |
| 42 | + |
13 | 43 | const char* codeVS = R"( |
14 | 44 | #version 460 |
15 | 45 | layout (location=0) out vec2 uv; |
@@ -116,8 +146,13 @@ VULKAN_APP_MAIN { |
116 | 146 |
|
117 | 147 | lvk::IContext* ctx = app.ctx_.get(); |
118 | 148 |
|
| 149 | +#if defined(LVK_DEMO_WITH_SLANG) |
| 150 | + res_.vert = ctx->createShaderModule({codeSlang, lvk::Stage_Vert, "Shader Module: main (vert)"}); |
| 151 | + res_.frag = ctx->createShaderModule({codeSlang, lvk::Stage_Frag, "Shader Module: main (frag)"}); |
| 152 | +#else |
119 | 153 | res_.vert = ctx->createShaderModule({codeVS, lvk::Stage_Vert, "Shader Module: main (vert)"}); |
120 | 154 | res_.frag = ctx->createShaderModule({codeFS, lvk::Stage_Frag, "Shader Module: main (frag)"}); |
| 155 | +#endif // defined(LVK_DEMO_WITH_SLANG) |
121 | 156 |
|
122 | 157 | createDemo(ctx, app.folderContentRoot_.c_str(), "YUV NV12", lvk::Format_YUV_NV12, "igl-samples/output_frame_900.nv12.yuv"); |
123 | 158 | createDemo(ctx, app.folderContentRoot_.c_str(), "YUV 420p", lvk::Format_YUV_420p, "igl-samples/output_frame_900.420p.yuv"); |
|
0 commit comments