Skip to content

Commit 53c084b

Browse files
Samples: 006_SwapchainHDR is now bilingual (GLSL + Slang)
1 parent 0f0a669 commit 53c084b

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

samples/006_SwapchainHDR.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,39 @@
77

88
#include "VulkanApp.h"
99

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+
1043
const char* codeVS = R"(
1144
#version 460
1245
#extension GL_EXT_scalar_block_layout : require
@@ -54,8 +87,13 @@ VULKAN_APP_MAIN {
5487
LLOGL("Swapchain color space: %u\n", ctx->getSwapchainColorSpace());
5588

5689
{
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
5794
lvk::Holder<lvk::ShaderModuleHandle> vert_ = ctx->createShaderModule({codeVS, lvk::Stage_Vert, "Shader Module: main (vert)"});
5895
lvk::Holder<lvk::ShaderModuleHandle> frag_ = ctx->createShaderModule({codeFS, lvk::Stage_Frag, "Shader Module: main (frag)"});
96+
#endif // defined(LVK_DEMO_WITH_SLANG)
5997

6098
lvk::Holder<lvk::RenderPipelineHandle> renderPipelineState_Triangle_ = ctx->createRenderPipeline(
6199
{

samples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ if(WIN32 OR UNIX AND NOT (APPLE))
155155
# Windows and Linux
156156
ADD_DEMO("005_MeshShaders" LVK_WITH_SLANG)
157157
endif()
158-
ADD_DEMO("006_SwapchainHDR")
158+
ADD_DEMO("006_SwapchainHDR" LVK_WITH_SLANG)
159159
ADD_DEMO("009_TriplanarMapping" LVK_WITH_SLANG)
160160
if((WIN32 OR UNIX AND NOT (APPLE)) OR LVK_WITH_SAMPLES_ANDROID)
161161
# Windows, Linux and Android

0 commit comments

Comments
 (0)