|
7 | 7 |
|
8 | 8 | #include "VulkanApp.h" |
9 | 9 |
|
| 10 | +const char* codeSlang = R"( |
| 11 | +struct PushConstants { |
| 12 | + float3 col[3]; |
| 13 | +}; |
| 14 | +
|
| 15 | +[[vk::push_constant]] PushConstants pc; |
| 16 | +
|
| 17 | +struct VSOutput { |
| 18 | + float4 sv_Position : SV_Position; |
| 19 | + float3 color : COLOR0; |
| 20 | +}; |
| 21 | +
|
| 22 | +[shader("vertex")] |
| 23 | +VSOutput vertexMain(uint vertexID : SV_VertexID) { |
| 24 | + const float2 pos[3] = { |
| 25 | + float2(-0.6, -0.4), |
| 26 | + float2( 0.6, -0.4), |
| 27 | + float2( 0.0, 0.6) |
| 28 | + }; |
| 29 | +
|
| 30 | + VSOutput out; |
| 31 | + out.sv_Position = float4(pos[vertexID], 0.0, 1.0); |
| 32 | + out.color = pc.col[vertexID]; |
| 33 | +
|
| 34 | + return out; |
| 35 | +} |
| 36 | +
|
| 37 | +[shader("fragment")] |
| 38 | +float4 fragmentMain(float3 color : COLOR0) : SV_Target0 { |
| 39 | + return float4(color, 1.0); |
| 40 | +} |
| 41 | +)"; |
| 42 | + |
10 | 43 | const char* codeVS = R"( |
11 | 44 | #version 460 |
12 | 45 | #extension GL_EXT_scalar_block_layout : require |
@@ -54,8 +87,13 @@ VULKAN_APP_MAIN { |
54 | 87 | LLOGL("Swapchain color space: %u\n", ctx->getSwapchainColorSpace()); |
55 | 88 |
|
56 | 89 | { |
| 90 | +#if defined(LVK_DEMO_WITH_SLANG) |
| 91 | + lvk::Holder<lvk::ShaderModuleHandle> vert_ = ctx->createShaderModule({codeSlang, lvk::Stage_Vert, "Shader Module: main (vert)"}); |
| 92 | + lvk::Holder<lvk::ShaderModuleHandle> frag_ = ctx->createShaderModule({codeSlang, lvk::Stage_Frag, "Shader Module: main (frag)"}); |
| 93 | +#else |
57 | 94 | lvk::Holder<lvk::ShaderModuleHandle> vert_ = ctx->createShaderModule({codeVS, lvk::Stage_Vert, "Shader Module: main (vert)"}); |
58 | 95 | lvk::Holder<lvk::ShaderModuleHandle> frag_ = ctx->createShaderModule({codeFS, lvk::Stage_Frag, "Shader Module: main (frag)"}); |
| 96 | +#endif // defined(LVK_DEMO_WITH_SLANG) |
59 | 97 |
|
60 | 98 | lvk::Holder<lvk::RenderPipelineHandle> renderPipelineState_Triangle_ = ctx->createRenderPipeline( |
61 | 99 | { |
|
0 commit comments