Skip to content

Commit 20e120c

Browse files
committed
62_CAD: now it works
1 parent 9ac5bbd commit 20e120c

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

62_CAD/main.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,8 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
861861
pipelineLayout = m_device->createPipelineLayout({}, core::smart_refctd_ptr(descriptorSetLayout0), core::smart_refctd_ptr(descriptorSetLayout1), nullptr, nullptr);
862862
}
863863

864-
smart_refctd_ptr<IGPUShader> mainPipelineShader = {};
865-
smart_refctd_ptr<IGPUShader> mainPipelineResolveAlphasShader = {};
864+
smart_refctd_ptr<IGPUShader> mainPipelineFragmentShaders = {};
865+
smart_refctd_ptr<IGPUShader> mainPipelineVertexShader = {};
866866
std::array<smart_refctd_ptr<IGPUShader>, 2u> geoTexturePipelineShaders = {};
867867
{
868868
smart_refctd_ptr<IShaderCompiler::CCache> shaderReadCache = nullptr;
@@ -916,10 +916,12 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
916916
return m_device->createShader({ cpuShader.get(), nullptr, shaderReadCache.get(), shaderWriteCache.get() });
917917
};
918918

919-
mainPipelineShader = loadCompileAndCreateShader("../shaders/main_pipeline/vs_fs.hlsl", IShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY);
920-
mainPipelineResolveAlphasShader = loadCompileAndCreateShader("../shaders/main_pipeline/resolve_alphas.hlsl", IShader::E_SHADER_STAGE::ESS_FRAGMENT);
919+
mainPipelineFragmentShaders = loadCompileAndCreateShader("../shaders/main_pipeline/fragment.hlsl", IShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY);
920+
mainPipelineVertexShader = loadCompileAndCreateShader("../shaders/main_pipeline/vertex_shader.hlsl", IShader::E_SHADER_STAGE::ESS_VERTEX);
921921
geoTexturePipelineShaders[0] = loadCompileAndCreateShader(GeoTextureRenderer::VertexShaderRelativePath, IShader::E_SHADER_STAGE::ESS_VERTEX);
922922
geoTexturePipelineShaders[1] = loadCompileAndCreateShader(GeoTextureRenderer::FragmentShaderRelativePath, IShader::E_SHADER_STAGE::ESS_FRAGMENT);
923+
924+
mainPipelineFragmentShaders->setShaderStage(IShader::E_SHADER_STAGE::ESS_FRAGMENT);
923925

924926
core::smart_refctd_ptr<system::IFile> shaderWriteCacheFile;
925927
{
@@ -963,7 +965,7 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
963965
// Load FSTri Shader
964966
ext::FullScreenTriangle::ProtoPipeline fsTriangleProtoPipe(m_assetMgr.get(),m_device.get(),m_logger.get());
965967

966-
const IGPUShader::SSpecInfo fragSpec = { .shader = mainPipelineResolveAlphasShader.get() };
968+
const IGPUShader::SSpecInfo fragSpec = { .entryPoint = "resolveAlphaMain", .shader = mainPipelineFragmentShaders.get() };
967969

968970
resolveAlphaGraphicsPipeline = fsTriangleProtoPipe.createPipeline(fragSpec, pipelineLayout.get(), compatibleRenderPass.get(), 0u, blendParams);
969971
if (!resolveAlphaGraphicsPipeline)
@@ -976,12 +978,12 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
976978

977979
IGPUShader::SSpecInfo specInfo[2] = {
978980
{
979-
.entryPoint = "vertMain",
980-
.shader = mainPipelineShader.get()
981+
.entryPoint = "main",
982+
.shader = mainPipelineVertexShader.get()
981983
},
982984
{
983985
.entryPoint = "fragMain",
984-
.shader = mainPipelineShader.get()
986+
.shader = mainPipelineFragmentShaders.get()
985987
},
986988
};
987989

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
#include "vertex_shader.hlsl"
2-
#include "fragment_shader.hlsl"
3-
#include "fragment_shader_debug.hlsl"
1+
#include "fragment_shader.hlsl"
2+
#include "fragment_shader_debug.hlsl"
3+
#include "resolve_alphas.hlsl"
4+

62_CAD/shaders/main_pipeline/fragment_shader.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ float32_t4 calculateFinalColor<true>(const uint2 fragCoord, const float localAlp
398398

399399
[[vk::spvexecutionmode(spv::ExecutionModePixelInterlockOrderedEXT)]]
400400
[shader("pixel")]
401-
float4 fragmentMain(PSInput input) : SV_TARGET
401+
float4 fragMain(PSInput input) : SV_TARGET
402402
{
403403
float localAlpha = 0.0f;
404404
ObjectType objType = input.getObjType();

62_CAD/shaders/main_pipeline/fragment_shader_debug.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct PSInputDebug
77
};
88

99
[shader("pixel")]
10-
float4 fragmentDebugMain(PSInputDebug input) : SV_TARGET
10+
float4 fragDebugMain(PSInputDebug input) : SV_TARGET
1111
{
1212
return float4(1.0, 1.0, 1.0, 1.0);
1313
// return input.color;

62_CAD/shaders/main_pipeline/resolve_alphas.hlsl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#pragma shader_stage(fragment)
2-
31
#include "common.hlsl"
42
#include <nbl/builtin/hlsl/spirv_intrinsics/fragment_shader_pixel_interlock.hlsl>
53
#include <nbl/builtin/hlsl/jit/device_capabilities.hlsl>
@@ -19,7 +17,6 @@ float32_t4 calculateFinalColor<true>(const uint2 fragCoord)
1917
{
2018
float32_t4 color;
2119

22-
nbl::hlsl::spirv::execution_mode::PixelInterlockOrderedEXT();
2320
nbl::hlsl::spirv::beginInvocationInterlockEXT();
2421

2522
const uint32_t packedData = pseudoStencil[fragCoord];
@@ -41,7 +38,9 @@ float32_t4 calculateFinalColor<true>(const uint2 fragCoord)
4138
return color;
4239
}
4340

44-
float4 main(float4 position : SV_Position) : SV_TARGET
41+
[[vk::spvexecutionmode(spv::ExecutionModePixelInterlockOrderedEXT)]]
42+
[shader("pixel")]
43+
float4 resolveAlphaMain(float4 position : SV_Position) : SV_TARGET
4544
{
4645
return calculateFinalColor<nbl::hlsl::jit::device_capabilities::fragmentShaderPixelInterlock>(position.xy);
4746
}

62_CAD/shaders/main_pipeline/vertex_shader.hlsl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ void dilateHatch<false>(out float2 outOffsetVec, out float2 outUV, const float2
8585
// Or optionally we could dilate and stuff when we know this hatch is opaque (alpha = 1.0)
8686
}
8787

88-
[shader("vertex")]
89-
PSInput vertMain(uint vertexID : SV_VertexID)
88+
PSInput main(uint vertexID : SV_VertexID)
9089
{
9190
const uint vertexIdx = vertexID & 0x3u;
9291
const uint objectID = vertexID >> 2;

0 commit comments

Comments
 (0)