Skip to content

Commit 699e841

Browse files
committed
update ImGUI extension to allow hijacking precompiled SPIRV shaders (experimental, no real validation), update examples_tests submodule
1 parent 77e9e57 commit 699e841

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

include/nbl/ext/ImGui/ImGui.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ class UI final : public core::IReferenceCounted
9999

100100
//! optional, no cache used if not provided
101101
core::smart_refctd_ptr<video::IGPUPipelineCache> pipelineCache = nullptr;
102+
103+
struct PrecompiledShaders
104+
{
105+
core::smart_refctd_ptr<asset::IShader> vertex = nullptr, fragment = nullptr;
106+
};
107+
108+
//! optional, precompiled spirv shaders (experimental)
109+
std::optional<PrecompiledShaders> spirv = std::nullopt;
102110
};
103111

104112
//! parameters which may change every frame, used with the .update call to interact with ImGuiIO; we require a very *required* minimum - if you need to cover more IO options simply get the IO with ImGui::GetIO() to customize them (they all have default values you can change before calling the .update)

include/nbl/ext/ImGui/builtin/hlsl/fragment.hlsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ using namespace nbl::ext::imgui;
3939
to request per object data with BDA
4040
*/
4141

42+
[shader("pixel")]
4243
float4 PSMain(PSInput input) : SV_Target0
4344
{
4445
// BDA for requesting object data

include/nbl/ext/ImGui/builtin/hlsl/vertex.hlsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct VSInput
1818
to request per object data with BDA
1919
*/
2020

21+
[shader("vertex")]
2122
PSInput VSMain(VSInput input, uint drawID : SV_InstanceID)
2223
{
2324
PSInput output;

src/nbl/ext/ImGui/ImGui.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ core::smart_refctd_ptr<video::IGPUGraphicsPipeline> UI::createPipeline(SCreation
154154
smart_refctd_ptr<IShader> vertex, fragment;
155155
} shaders;
156156

157+
if (creationParams.spirv.has_value())
158+
{
159+
// TODO: since prebuild is experminetal currently I don't validate anything
160+
auto& spirv = creationParams.spirv.value();
161+
shaders.vertex = spirv.vertex;
162+
shaders.fragment = spirv.fragment;
163+
}
164+
else
157165
{
158166
//! proxy the system, we will touch it gently
159167
auto system = smart_refctd_ptr<ISystem>(creationParams.assetManager->getSystem());
@@ -269,18 +277,18 @@ core::smart_refctd_ptr<video::IGPUGraphicsPipeline> UI::createPipeline(SCreation
269277

270278
shaders.vertex = createShader.template operator() < NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("vertex.hlsl"), IShader::E_SHADER_STAGE::ESS_VERTEX > ();
271279
shaders.fragment = createShader.template operator() < NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("fragment.hlsl"), IShader::E_SHADER_STAGE::ESS_FRAGMENT > ();
280+
}
272281

273-
if (!shaders.vertex)
274-
{
275-
creationParams.utilities->getLogger()->log("Failed to compile vertex shader!", ILogger::ELL_ERROR);
276-
return nullptr;
277-
}
282+
if (!shaders.vertex)
283+
{
284+
creationParams.utilities->getLogger()->log("Failed to create vertex shader!", ILogger::ELL_ERROR);
285+
return nullptr;
286+
}
278287

279-
if (!shaders.fragment)
280-
{
281-
creationParams.utilities->getLogger()->log("Failed to compile fragment shader!", ILogger::ELL_ERROR);
282-
return nullptr;
283-
}
288+
if (!shaders.fragment)
289+
{
290+
creationParams.utilities->getLogger()->log("Failed to create fragment shader!", ILogger::ELL_ERROR);
291+
return nullptr;
284292
}
285293

286294
SVertexInputParams vertexInputParams{};

0 commit comments

Comments
 (0)