FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Switch to use embedded reflection (#250) · codeplaysoftware/clvk@d118090 · GitHub

Repository navigation

Commit d118090

Browse files
authored
Switch to use embedded reflection (kpet#250)
* Switch to use embedded reflection info * Descriptor maps for both online and offline compiles use embedded reflection information * replaced old parsers with a single unified parser * If VK_KHR_non_semantic_info is not supported, the reflection is stripped from the binary before creating a shader module * Descriptor maps are no longer written to saved binaries * Fix offline clspv mode * Add clspv include dirs for both modes * Don't pass -desriptormap to clspv anymore * Update submodules * formatting * formatting * Fix offline compile * update spirv-llvm-translator deps * Update deps * Update clspv * Update SPIRV-LLVM-Translator (also point at KhronosGroup) * Fix normalized coordinate parsing * Changes for review * Update SPIRV-Tools to include fix handling of non-semantic instructions in the optimizer * Improving naming * Use extension name macro instead of raw string
1 parent 694f53d commit d118090

8 files changed

Lines changed: 379 additions & 595 deletions

File tree

‎.gitmodules‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
url = https://github.com/KhronosGroup/SPIRV-Headers.git
1010
[submodule "spirv-llvm-translator"]
1111
path = external/SPIRV-LLVM-Translator
12-
url = https://github.com/kpet/SPIRV-LLVM-Translator
12+
url = https://github.com/KhronosGroup/SPIRV-LLVM-Translator
1313
[submodule "spirv-tools"]
1414
path = external/SPIRV-Tools
1515
url = https://github.com/KhronosGroup/SPIRV-Tools.git

‎external/SPIRV-Headers‎

‎external/SPIRV-LLVM-Translator‎

‎external/SPIRV-Tools‎

Submodule SPIRV-Tools updated 93 files

‎external/clspv‎

Submodule clspv updated 107 files

‎src/CMakeLists.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ set(OpenCL-dependencies
7272
${Vulkan_LIBRARIES}
7373
)
7474

75+
# The reflection parser requires the headers.
76+
target_include_directories(OpenCL-objects PRIVATE
77+
"${CLSPV_SOURCE_DIR}/include")
7578
if (CLVK_CLSPV_ONLINE_COMPILER)
76-
target_include_directories(OpenCL-objects PRIVATE
77-
"${CLSPV_SOURCE_DIR}/include")
7879
set(OpenCL-dependencies ${OpenCL-dependencies} clspv_core)
7980
else()
8081
add_dependencies(OpenCL-objects clspv)

‎src/program.cpp‎

Lines changed: 346 additions & 567 deletions
Large diffs are not rendered by default.

‎src/program.hpp‎

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323

2424
#include <vulkan/vulkan.h>
2525

26-
#ifdef CLSPV_ONLINE_COMPILER
27-
#include "clspv/DescriptorMap.h"
28-
#endif
2926
#include "spirv-tools/libspirv.h"
3027
#include "spirv/1.0/spirv.hpp"
3128

@@ -111,18 +108,14 @@ class spir_binary {
111108
const uint32_t MAGIC = 0x00BEEF00;
112109

113110
public:
114-
spir_binary(spv_target_env env) : m_loaded_from_binary(false) {
111+
spir_binary(spv_target_env env)
112+
: m_loaded_from_binary(false), m_target_env(env) {
115113
m_context = spvContextCreate(env);
116114
}
117115
~spir_binary() { spvContextDestroy(m_context); }
118116
CHECK_RETURN bool load_spir(const char* fname);
119117
CHECK_RETURN bool load_spir(std::istream& istream, uint32_t size);
120-
CHECK_RETURN bool load_descriptor_map(const char* fname);
121-
CHECK_RETURN bool load_descriptor_map(std::istream& istream);
122-
#ifdef CLSPV_ONLINE_COMPILER
123-
CHECK_RETURN bool load_descriptor_map(
124-
const std::vector<clspv::version0::DescriptorMapEntry>& entries);
125-
#endif
118+
CHECK_RETURN bool load_descriptor_map();
126119
void insert_descriptor_map(const spir_binary& other);
127120
CHECK_RETURN bool save_spir(const char* fname) const;
128121
CHECK_RETURN bool load(std::istream& istream);
@@ -165,18 +158,27 @@ class spir_binary {
165158
}
166159
}
167160

168-
private:
169-
CHECK_RETURN bool parse_sampler(const std::vector<std::string>& tokens,
170-
int toknum);
171-
CHECK_RETURN bool parse_kernel(const std::vector<std::string>& tokens,
172-
int toknum);
173-
CHECK_RETURN bool parse_kernel_decl(const std::vector<std::string>& tokens,
174-
int toknum);
175-
CHECK_RETURN bool parse_pushconstant(const std::vector<std::string>& tokens,
176-
int toknum);
177-
CHECK_RETURN bool parse_specconstant(const std::vector<std::string>& tokens,
178-
int toknum);
161+
void add_kernel(const std::string& name) { m_dmaps[name] = {}; }
162+
163+
void add_kernel_argument(const std::string& name, kernel_argument&& arg) {
164+
m_dmaps[name].push_back(arg);
165+
}
179166

167+
void add_spec_constant(spec_constant constant, uint32_t spec_id) {
168+
m_spec_constants[constant] = spec_id;
169+
}
170+
171+
void add_push_constant(pushconstant pc, pushconstant_desc&& desc) {
172+
m_push_constants[pc] = desc;
173+
}
174+
175+
void add_literal_sampler(sampler_desc&& desc) {
176+
m_literal_samplers.push_back(desc);
177+
}
178+
179+
bool strip_reflection(std::vector<uint32_t>* stripped);
180+
181+
private:
180182
spv_context m_context;
181183
std::vector<uint32_t> m_code;
182184
std::vector<sampler_desc> m_literal_samplers;
@@ -185,6 +187,7 @@ class spir_binary {
185187
kernels_arguments_map m_dmaps;
186188
std::string m_dmaps_text;
187189
bool m_loaded_from_binary;
190+
spv_target_env m_target_env;
188191
};
189192

190193
enum class build_operation
@@ -507,6 +510,7 @@ struct cvk_program : public _cl_program, api_object {
507510
VkPushConstantRange m_push_constant_range;
508511
std::unordered_map<std::string, std::unique_ptr<cvk_entry_point>>
509512
m_entry_points;
513+
std::vector<uint32_t> m_stripped_binary;
510514
};
511515

512516
static inline cvk_program* icd_downcast(cl_program program) {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL