Skip to content

Commit 43adb6b

Browse files
Merge pull request #754 from Devsh-Graphics-Programming/ali_lib_shader
lib shader stage
2 parents 2bc145c + 02cacd2 commit 43adb6b

File tree

6 files changed

+273
-240
lines changed

6 files changed

+273
-240
lines changed

include/nbl/asset/IDescriptorSetLayout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class IDescriptorSetLayout : public IDescriptorSetLayoutBase
330330
bindings[i].binding = i;
331331
bindings[i].type = type;
332332
bindings[i].createFlags = SBinding::E_CREATE_FLAGS::ECF_NONE;
333-
bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:asset::IShader::ESS_ALL;
333+
bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:asset::IShader::ESS_ALL_OR_LIBRARY;
334334
bindings[i].count = counts ? counts[i]:1u;
335335
bindings[i].samplers = nullptr;
336336
}

include/nbl/builtin/hlsl/enums.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ enum ShaderStage : uint32_t
2929
ESS_INTERSECTION = 1 << 12,
3030
ESS_CALLABLE = 1 << 13,
3131
ESS_ALL_GRAPHICS = 0x0000001F,
32-
ESS_ALL = 0x7fffffff
32+
ESS_ALL_OR_LIBRARY = 0x7fffffff
3333
};
3434

3535
enum TextureClamp : uint16_t

include/nbl/video/CVulkanCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ inline VkShaderStageFlags getVkShaderStageFlagsFromShaderStage(const core::bitfl
464464
if(in.hasFlags(IGPUShader::E_SHADER_STAGE::ESS_INTERSECTION)) ret |= VK_SHADER_STAGE_INTERSECTION_BIT_KHR;
465465
if(in.hasFlags(IGPUShader::E_SHADER_STAGE::ESS_CALLABLE)) ret |= VK_SHADER_STAGE_CALLABLE_BIT_KHR;
466466
if(in.hasFlags(IGPUShader::E_SHADER_STAGE::ESS_ALL_GRAPHICS)) ret |= VK_SHADER_STAGE_ALL_GRAPHICS;
467-
if(in.hasFlags(IGPUShader::E_SHADER_STAGE::ESS_ALL)) ret |= VK_SHADER_STAGE_ALL;
467+
if(in.hasFlags(IGPUShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY)) ret |= VK_SHADER_STAGE_ALL;
468468
return ret;
469469
}
470470

include/nbl/video/ILogicalDevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,8 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
666666
asset::IShaderCompiler::CCache* writeCache;
667667
};
668668

669+
core::smart_refctd_ptr<asset::ICPUShader> compileShader(const SShaderCreationParameters& creationParams);
670+
669671
// New version below has caching options
670672
[[deprecated]]
671673
core::smart_refctd_ptr<IGPUShader> createShader(const asset::ICPUShader* cpushader, const asset::ISPIRVOptimizer* optimizer=nullptr);

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ static const wchar_t* ShaderStageToString(asset::IShader::E_SHADER_STAGE stage)
4444
return L"as";
4545
case asset::IShader::E_SHADER_STAGE::ESS_MESH:
4646
return L"ms";
47+
case asset::IShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY:
48+
return L"lib";
4749
default:
4850
return nullptr;
4951
};
@@ -425,8 +427,10 @@ core::smart_refctd_ptr<ICPUShader> CHLSLCompiler::compileToSPIRV_impl(const std:
425427
arguments.push_back(L"-HV");
426428
arguments.push_back(L"202x");
427429
// TODO: add this to `CHLSLCompiler::SOptions` and handle it properly in `dxc_compile_flags.empty()`
428-
arguments.push_back(L"-E");
429-
arguments.push_back(L"main");
430+
if (stage != asset::IShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY) {
431+
arguments.push_back(L"-E");
432+
arguments.push_back(L"main");
433+
}
430434
// If a custom SPIR-V optimizer is specified, use that instead of DXC's spirv-opt.
431435
// This is how we can get more optimizer options.
432436
//

0 commit comments

Comments
 (0)