Skip to content

Commit 56a524d

Browse files
authored
Merge pull request #465 from pollend/bugfix/address-build-problems-builtin-linux-window
bugfix: address build issues with embedded assets for clang and gnu compiler
2 parents 46b2b71 + 51b95d5 commit 56a524d

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

src/nbl/asset/IAssetManager.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,38 +239,38 @@ void IAssetManager::insertBuiltinAssets()
239239
};
240240
auto fileSystem = getSystem();
241241

242-
buildInGLSLShader(fileSystem->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/specialized_shader/fullscreentriangle.vert")>(),
242+
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/specialized_shader/fullscreentriangle.vert")>(),
243243
asset::IShader::ESS_VERTEX,
244244
{
245245
"nbl/builtin/specialized_shader/fullscreentriangle.vert"
246246
});
247-
buildInGLSLShader(fileSystem->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/lambertian/singletexture/specialized_shader.vert")>(),
247+
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/lambertian/singletexture/specialized_shader.vert")>(),
248248
asset::IShader::ESS_VERTEX,
249249
{
250250
"nbl/builtin/material/lambertian/singletexture/specialized_shader.vert",
251251
"nbl/builtin/material/debug/vertex_uv/specialized_shader.vert"
252252
});
253-
buildInGLSLShader(fileSystem->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/lambertian/singletexture/specialized_shader.frag")>(), // it somehow adds an extra "tt" raw string to the end of the returned value, beware
253+
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/lambertian/singletexture/specialized_shader.frag")>(), // it somehow adds an extra "tt" raw string to the end of the returned value, beware
254254
asset::IShader::ESS_FRAGMENT,
255255
{
256256
"nbl/builtin/material/lambertian/singletexture/specialized_shader.frag"
257257
});
258258

259-
buildInGLSLShader(fileSystem->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_normal/specialized_shader.vert")>(),
259+
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_normal/specialized_shader.vert")>(),
260260
asset::IShader::ESS_VERTEX,
261261
{
262262
"nbl/builtin/material/debug/vertex_normal/specialized_shader.vert"});
263-
buildInGLSLShader(fileSystem->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_color/specialized_shader.vert")>(),
263+
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_color/specialized_shader.vert")>(),
264264
asset::IShader::ESS_VERTEX,
265265
{
266266
"nbl/builtin/material/debug/vertex_color/specialized_shader.vert"
267267
});
268-
buildInGLSLShader(fileSystem->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_uv/specialized_shader.frag")>(),
268+
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_uv/specialized_shader.frag")>(),
269269
asset::IShader::ESS_FRAGMENT,
270270
{
271271
"nbl/builtin/material/debug/vertex_uv/specialized_shader.frag"
272272
});
273-
buildInGLSLShader(fileSystem->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_normal/specialized_shader.frag")>(),
273+
buildInGLSLShader(fileSystem->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/material/debug/vertex_normal/specialized_shader.frag")>(),
274274
asset::IShader::ESS_FRAGMENT,
275275
{
276276
"nbl/builtin/material/debug/vertex_normal/specialized_shader.frag",

src/nbl/builtin/builtinDataGen.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,26 @@
1717
cmakeSourceDir = sys.argv[2]
1818
resourcesFile = sys.argv[3]
1919
resourcesNamespace = sys.argv[4]
20-
correspondingHeaderFile = sys.argv[5]
2120

2221
with open(resourcesFile, "r") as f:
2322
resourcePaths = f.read().rstrip().split(',')
2423

2524
#opening a file
2625
outp = open(outputFilename,"w+")
2726

28-
outp.write("#include \"" + correspondingHeaderFile + "\"\n")
27+
28+
outp.write("#include \"nbl/core/string/StringLiteral.h\"\n")
29+
outp.write("#include <cstdint>\n")
30+
outp.write("#include <unordered_map>\n");
31+
outp.write("#include <string>\n");
2932
outp.write("\tnamespace " + resourcesNamespace + " {\n")
33+
34+
outp.write("template<nbl::core::StringLiteral Path>")
35+
outp.write("const std::pair<const uint8_t*, size_t> get_resource();")
3036

3137
# writing binary data of all files in a loop
3238
for x in resourcePaths:
33-
outp.write('\n\ttemplate<> const std::pair<const uint8_t*, size_t> get_resource<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>()' % x)
39+
outp.write('\n\ttemplate<> const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>()' % x)
3440
outp.write('\n\t{')
3541
outp.write('\n\t\tstatic const uint8_t data[] = {\n\t\t\t')
3642
try:
@@ -53,7 +59,6 @@
5359
outp.write('\n\t\t};')
5460
outp.write('\n\t\treturn { data, sizeof(data) };')
5561
outp.write('\n\t}')
56-
outp.write('\n\ttemplate const std::pair<const uint8_t*, size_t> get_resource<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();\n\n\n'%x)
5762

5863

5964
outp.write("\tstd::pair<const uint8_t*, size_t> get_resource_runtime(const std::string& filename) {\n")
@@ -68,7 +73,7 @@
6873
outp.write("\t\tswitch (resource->second) \n\t\t\t{\n")
6974
counter = 1
7075
for x in resourcePaths:
71-
outp.write("\t\t\tcase %d:\n\t\t\t\t\treturn get_resource<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE(\"%s\")>();\n" % (counter,x))
76+
outp.write("\t\t\tcase %d:\n\t\t\t\t\treturn get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE(\"%s\")>();\n" % (counter,x))
7277
counter+= 1
7378

7479
outp.write("\t\t\tdefault:\n")

src/nbl/builtin/builtinHeaderGen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
#Iterating through input list
4040
for x in resourcePaths:
41-
outp.write('\n\t\textern template const std::pair<const uint8_t*, size_t> get_resource<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % x)
41+
outp.write('\n\t\textern template const std::pair<const uint8_t*, size_t> get_resource<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("%s")>();' % x)
4242

4343
outp.write("\n\t}")
4444
outp.write("\n#endif // _" + guardSuffix + "_BUILTINRESOURCEDATA_H_")

src/nbl/video/utilities/CPropertyPoolHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CPropertyPoolHandler::CPropertyPoolHandler(core::smart_refctd_ptr<ILogicalDevice
1515
auto system = m_device->getPhysicalDevice()->getSystem();
1616
core::smart_refctd_ptr<asset::ICPUBuffer> glsl;
1717
{
18-
auto glslFile = system->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/glsl/property_pool/copy.comp")>();
18+
auto glslFile = system->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/glsl/property_pool/copy.comp")>();
1919
glsl = core::make_smart_refctd_ptr<asset::ICPUBuffer>(glslFile->getSize());
2020
memcpy(glsl->getPointer(), glslFile->getMappedPointer(), glsl->getSize());
2121
}

src/nbl/video/utilities/CScanner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ core::smart_refctd_ptr<asset::ICPUShader> CScanner::createShader(const bool indi
99
core::smart_refctd_ptr<const system::IFile> glsl;
1010
{
1111
if(indirect)
12-
glsl = system->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/glsl/scan/indirect.comp")>();
12+
glsl = system->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/glsl/scan/indirect.comp")>();
1313
else
14-
glsl = system->loadBuiltinData<typename NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/glsl/scan/direct.comp")>();
14+
glsl = system->loadBuiltinData<NBL_CORE_UNIQUE_STRING_LITERAL_TYPE("nbl/builtin/glsl/scan/direct.comp")>();
1515
}
1616
auto buffer = core::make_smart_refctd_ptr<asset::ICPUBuffer>(glsl->getSize());
1717
memcpy(buffer->getPointer(), glsl->getMappedPointer(), glsl->getSize());

0 commit comments

Comments
 (0)