Skip to content

Commit 5441c9f

Browse files
Remove old stale builtin GLSL files from builtin SPec Shaders
Also add the new HLSL shaders for FSTri extension
1 parent 01ae824 commit 5441c9f

File tree

7 files changed

+97
-92
lines changed

7 files changed

+97
-92
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (C) 2018-2024 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
#ifndef _NBL_HLSL_EXT_FULL_SCREEN_TRIANGLE_S_VERTEX_ATTRIBUTE_H_
5+
#define _NBL_HLSL_EXT_FULL_SCREEN_TRIANGLE_S_VERTEX_ATTRIBUTE_H_
6+
7+
namespace nbl
8+
{
9+
namespace hlsl
10+
{
11+
namespace ext
12+
{
13+
namespace FullScreenTriangle
14+
{
15+
16+
struct VertexAttributes
17+
{
18+
[[vk::location(0)]] float32_t2 uv;
19+
};
20+
21+
}
22+
}
23+
}
24+
}
25+
#endif
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (C) 2018-2024 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
#include <nbl/builtin/hlsl/ext/FullScreenTriangle/SVertexAttributes.hlsl>
5+
//#include <nbl/builtin/glsl/utils/surface_transform.glsl>
6+
7+
namespace nbl
8+
{
9+
namespace hlsl
10+
{
11+
namespace ext
12+
{
13+
namespace FullScreenTriangle
14+
{
15+
16+
const static float32_t2 pos[3] = {
17+
float32_t2(-1.0,-1.0),
18+
float32_t2(-1.0, 3.0),
19+
float32_t2( 3.0,-1.0)
20+
};
21+
const static float32_t2 tc[3] = {
22+
float32_t2(0.0,0.0),
23+
float32_t2(0.0,2.0),
24+
float32_t2(2.0,0.0)
25+
};
26+
27+
/*
28+
layout (push_constant) uniform pushConstants
29+
{
30+
layout (offset = 0) uint swapchainTransform;
31+
} u_pushConstants;
32+
*/
33+
34+
VertexAttributes main()
35+
{
36+
using namespace nbl::hlsl::glsl;
37+
38+
VertexAttributes retval;
39+
// vec2 pos = nbl_glsl_surface_transform_applyToNDC(u_pushConstants.swapchainTransform, pos[gl_VertexIndex]);
40+
spirv::Position = vec4(pos[gl_VertexIndex()], 0.f, 1.f);
41+
retval.uv = tc[gl_VertexIndex()];
42+
return retval;
43+
}
44+
45+
}
46+
}
47+
}
48+
}

include/nbl/builtin/hlsl/glsl_compat/core.hlsl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,19 @@ T atomicCompSwap(NBL_REF_ARG(T) ptr, T comparator, T value)
5757
return spirv::atomicCompSwap<T>(ptr, spv::ScopeDevice, spv::DecorationRelaxedPrecision, spv::DecorationRelaxedPrecision, value, comparator);
5858
}
5959

60+
/**
61+
* For Vertex Shaders
62+
*/
63+
// TODO: Extemely annoying that HLSL doesn't have references, so we can't transparently alias the variables as `&` :(
64+
//void gl_Position() {spirv::}
65+
uint32_t gl_VertexIndex() {return spirv::VertexIndex;}
66+
uint32_t gl_InstanceIndex() {return spirv::InstanceIndex;}
67+
6068
/**
6169
* For Compute Shaders
6270
*/
6371

64-
// TODO: Extemely annoying that HLSL doesn't have referencies, so we can't transparently alias the variables as `const&` :(
72+
// TODO: Extemely annoying that HLSL doesn't have references, so we can't transparently alias the variables as `const&` :(
6573
uint32_t3 gl_NumWorkGroups() {return spirv::NumWorkGroups;}
6674
// TODO: DXC BUG prevents us from defining this!
6775
uint32_t3 gl_WorkGroupSize();

include/nbl/builtin/hlsl/spirv_intrinsics/core.hlsl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@ namespace hlsl
1818
#ifdef __HLSL_VERSION
1919
namespace spirv
2020
{
21+
//! General
2122
[[vk::ext_builtin_input(spv::BuiltInHelperInvocation)]]
2223
static const bool HelperInvocation;
2324

25+
//! Vertex Inputs
26+
[[vk::ext_builtin_input(spv::BuiltInVertexIndex)]]
27+
static const uint32_t VertexIndex;
28+
[[vk::ext_builtin_input(spv::BuiltInInstanceIndex)]]
29+
static const uint32_t InstanceIndex;
30+
31+
//! Vertex and friends
32+
[[vk::ext_builtin_output(spv::BuiltInPosition)]]
33+
static float32_t4 Position;
34+
35+
//! Compute Shader Builtins
2436
[[vk::ext_builtin_input(spv::BuiltInNumWorkgroups)]]
2537
static const uint32_t3 NumWorkGroups;
2638
// TODO: Doesn't work, find out why and file issue on DXC!

include/nbl/builtin/specialized_shader/fullscreentriangle.vert

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/nbl/asset/IAssetManager.cpp

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -223,72 +223,6 @@ void IAssetManager::insertBuiltinAssets()
223223
insertBuiltinAssetIntoCache(bundle);
224224
};
225225

226-
// materials
227-
{
228-
//
229-
auto buildInGLSLShader = [&]( core::smart_refctd_ptr<const system::IFile>&& data,
230-
asset::IShader::E_SHADER_STAGE type,
231-
std::initializer_list<const char*> paths) -> void
232-
{
233-
auto buffer = core::make_smart_refctd_ptr<asset::ICPUBuffer>(data->getSize() + 1u);
234-
memcpy(buffer->getPointer(), data->getMappedPointer(), data->getSize());
235-
char* bufferAsChar = reinterpret_cast<char*>(buffer->getPointer());
236-
bufferAsChar[data->getSize()] = '\0';
237-
238-
auto shader = core::make_smart_refctd_ptr<asset::ICPUShader>(std::move(buffer), type, asset::IShader::E_CONTENT_TYPE::ECT_GLSL, paths.begin()[0]);
239-
for (auto& path : paths)
240-
addBuiltInToCaches(std::move(shader), path);
241-
};
242-
auto fileSystem = getSystem();
243-
244-
auto loadBuiltinData = [&](const std::string _path) -> core::smart_refctd_ptr<const nbl::system::IFile>
245-
{
246-
nbl::system::ISystem::future_t<core::smart_refctd_ptr<nbl::system::IFile>> future;
247-
fileSystem->createFile(future, system::path(_path), core::bitflag(nbl::system::IFileBase::ECF_READ) | nbl::system::IFileBase::ECF_MAPPABLE);
248-
if (future.wait())
249-
return future.copy();
250-
return nullptr;
251-
};
252-
253-
buildInGLSLShader(loadBuiltinData("nbl/builtin/specialized_shader/fullscreentriangle.vert"),
254-
asset::IShader::ESS_VERTEX,
255-
{
256-
"nbl/builtin/specialized_shader/fullscreentriangle.vert"
257-
});
258-
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/lambertian/singletexture/specialized_shader.vert"),
259-
asset::IShader::ESS_VERTEX,
260-
{
261-
"nbl/builtin/material/lambertian/singletexture/specialized_shader.vert",
262-
"nbl/builtin/material/debug/vertex_uv/specialized_shader.vert"
263-
});
264-
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/lambertian/singletexture/specialized_shader.frag"), // it somehow adds an extra "tt" raw string to the end of the returned value, beware
265-
asset::IShader::ESS_FRAGMENT,
266-
{
267-
"nbl/builtin/material/lambertian/singletexture/specialized_shader.frag"
268-
});
269-
270-
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/debug/vertex_normal/specialized_shader.vert"),
271-
asset::IShader::ESS_VERTEX,
272-
{
273-
"nbl/builtin/material/debug/vertex_normal/specialized_shader.vert"});
274-
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/debug/vertex_color/specialized_shader.vert"),
275-
asset::IShader::ESS_VERTEX,
276-
{
277-
"nbl/builtin/material/debug/vertex_color/specialized_shader.vert"
278-
});
279-
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/debug/vertex_uv/specialized_shader.frag"),
280-
asset::IShader::ESS_FRAGMENT,
281-
{
282-
"nbl/builtin/material/debug/vertex_uv/specialized_shader.frag"
283-
});
284-
buildInGLSLShader(loadBuiltinData("nbl/builtin/material/debug/vertex_normal/specialized_shader.frag"),
285-
asset::IShader::ESS_FRAGMENT,
286-
{
287-
"nbl/builtin/material/debug/vertex_normal/specialized_shader.frag",
288-
"nbl/builtin/material/debug/vertex_color/specialized_shader.frag"
289-
});
290-
}
291-
292226
/*
293227
SBinding for UBO - basic view parameters.
294228
*/

src/nbl/builtin/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "shader/loader/gltf/fragment_impl.g
1515
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "shader/loader/gltf/uv.frag")
1616
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "shader/loader/gltf/color.frag")
1717
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "shader/loader/gltf/no_uv_color.frag")
18-
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "specialized_shader/fullscreentriangle.vert")
1918
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "material/lambertian/singletexture/specialized_shader.vert")
2019
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "material/lambertian/singletexture/specialized_shader.frag")
2120
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "material/debug/vertex_color/specialized_shader.vert")
@@ -299,5 +298,8 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/ballot.hlsl")
299298
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/broadcast.hlsl")
300299
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/scratch_size.hlsl")
301300
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/workgroup/shared_scan.hlsl")
301+
#Extensions
302+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/ext/FullScreenTriangle/SVertexAttributes.hlsl")
303+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/ext/FullScreenTriangle/default.vert.hlsl")
302304

303305
ADD_CUSTOM_BUILTIN_RESOURCES(nblBuiltinResourceData NBL_RESOURCES_TO_EMBED "${NBL_ROOT_PATH}/include" "nbl/builtin" "nbl::builtin" "${NBL_ROOT_PATH_BINARY}/include" "${NBL_ROOT_PATH_BINARY}/src" "STATIC" "INTERNAL")

0 commit comments

Comments
 (0)