File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -25,20 +25,18 @@ constexpr uint32_t hash(std::string_view data) noexcept {
25
25
}
26
26
27
27
namespace spvrc {
28
- auto load(std::string_view path) -> std::vector<uint32_t> {
29
- std::vector<uint32_t> data;
28
+ auto load(std::string_view path) -> std::pair<const uint32_t*, std::size_t> {
30
29
switch (hash(path)) {"
31
30
)
32
31
# insert shader data
33
32
foreach (SPIRV_FILE SPIRV_SYMBOL IN ZIP_LISTS SPVRC_SPIRV_FILES SPVRC_SPIRV_SYMBOLS )
34
33
file (APPEND "${SPVRC_SRC} " "
35
- case hash(\" ${SPIRV_FILE} \" ): data = { ${SPIRV_SYMBOL} , ${SPIRV_SYMBOL} + std::size(${SPIRV_SYMBOL} )}; break ;"
34
+ case hash(\" ${SPIRV_FILE} \" ): return std::make_pair( ${SPIRV_SYMBOL} , std::size(${SPIRV_SYMBOL} )) ;"
36
35
)
37
36
endforeach (SPIRV_FILE SPIRV_SYMBOL )
38
37
# end namespace
39
38
file (APPEND "${SPVRC_SRC} " "
40
- default: assert(false && \" Shader not found\" );
39
+ default: assert(false && \" Shader not found\" ); return { nullptr, 0 };
41
40
}
42
- return data;
43
41
}
44
42
}" )
Original file line number Diff line number Diff line change 4
4
#include < vector>
5
5
6
6
namespace spvrc {
7
- auto load (std::string_view path) -> std::vector< uint32_t>;
8
- auto inline load (const char * path) -> std::vector< uint32_t> {
7
+ auto load (std::string_view path) -> std::pair< const uint32_t*, std::size_t >;
8
+ auto inline load (const char * path) -> std::pair< const uint32_t*, std::size_t > {
9
9
return load (std::string_view (path));
10
10
}
11
11
}
Original file line number Diff line number Diff line change 3
3
#include < string_view>
4
4
5
5
int main () {
6
- auto data = spvrc::load (" example.comp" );
7
- std::cout << " data. size() = " << data. size () << std::endl;
6
+ auto [arr, size] = spvrc::load (" example.comp" );
7
+ std::cout << " data size: " << size << std::endl;
8
8
return 0 ;
9
9
}
You can’t perform that action at this time.
0 commit comments