1 /*-------------------------------------------------------------------------
2 * Vulkan CTS Framework
3 * --------------------
4 *
5 * Copyright (c) 2021 The Khronos Group Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *-------------------------------------------------------------------------*/
20
21 #include "vksJson.hpp"
22
23 #define VULKAN_JSON_CTS
24 #ifdef __GNUC__
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wunused-parameter"
27 #pragma GCC diagnostic ignored "-Wunused-function"
28 #pragma GCC diagnostic ignored "-Wunused-variable"
29 #endif // __GNUC__
30 #ifdef __clang__
31 #pragma clang diagnostic push
32 #pragma clang diagnostic ignored "-Wpointer-bool-conversion"
33 #endif
34
35 #include "vulkan_json_parser.hpp"
36 #include "vulkan_json_data.hpp"
37
38 #ifdef __GNUC__
39 #pragma GCC diagnostic pop
40 #endif // __GNUC__
41 #ifdef __clang__
42 #pragma clang diagnostic pop
43 #endif
44
45 #include "vksStructsVKSC.hpp"
46
47 namespace vksc_server
48 {
49
50 namespace json
51 {
52
Context()53 Context::Context()
54 {
55 Json::CharReaderBuilder builder;
56 builder.settings_["allowSpecialFloats"] = 1;
57 reader.reset(builder.newCharReader());
58 }
59
~Context()60 Context::~Context()
61 {
62 }
63
runGarbageCollection()64 void runGarbageCollection()
65 {
66 vk_json_parser::s_globalMem.clear();
67 }
68
VkObjectToString(const vk::VkDeviceObjectReservationCreateInfo & in,string & out)69 void VkObjectToString(const vk::VkDeviceObjectReservationCreateInfo &in, string &out)
70 {
71 vk_json::_string_stream.str({});
72 vk_json::_string_stream.clear();
73 vk_json::print_VkDeviceObjectReservationCreateInfo(&in, "", false);
74 out = vk_json::_string_stream.str();
75 }
76
StringToVkObject(const string & in,vk::VkDeviceObjectReservationCreateInfo & out)77 void StringToVkObject(const string &in, vk::VkDeviceObjectReservationCreateInfo &out)
78 {
79 Json::CharReaderBuilder builder;
80 builder.settings_["allowSpecialFloats"] = 1;
81 std::unique_ptr<Json::CharReader> jsonReader(builder.newCharReader());
82
83 Json::Value jsonRoot;
84 string errors;
85 if (!jsonReader->parse(in.data(), in.data() + in.size(), &jsonRoot, &errors))
86 {
87 throw std::runtime_error("json parse error");
88 }
89 vk_json_parser::parse_VkDeviceObjectReservationCreateInfo("", jsonRoot, out);
90 }
91
writeJSON_VkGraphicsPipelineCreateInfo(const VkGraphicsPipelineCreateInfo & pCreateInfo)92 string writeJSON_VkGraphicsPipelineCreateInfo(const VkGraphicsPipelineCreateInfo &pCreateInfo)
93 {
94 vk_json::_string_stream.str({});
95 vk_json::_string_stream.clear();
96 vk_json::print_VkGraphicsPipelineCreateInfo(pCreateInfo, "", 0);
97 return vk_json::_string_stream.str();
98 }
99
writeJSON_VkComputePipelineCreateInfo(const VkComputePipelineCreateInfo & pCreateInfo)100 string writeJSON_VkComputePipelineCreateInfo(const VkComputePipelineCreateInfo &pCreateInfo)
101 {
102 vk_json::_string_stream.str({});
103 vk_json::_string_stream.clear();
104 vk_json::print_VkComputePipelineCreateInfo(pCreateInfo, "", 0);
105 return vk_json::_string_stream.str();
106 }
107
writeJSON_VkRenderPassCreateInfo(const VkRenderPassCreateInfo & pCreateInfo)108 string writeJSON_VkRenderPassCreateInfo(const VkRenderPassCreateInfo &pCreateInfo)
109 {
110
111 vk_json::_string_stream.str({});
112 vk_json::_string_stream.clear();
113 vk_json::print_VkRenderPassCreateInfo(&pCreateInfo, "", false);
114 return vk_json::_string_stream.str();
115 }
116
writeJSON_VkRenderPassCreateInfo2(const VkRenderPassCreateInfo2 & pCreateInfo)117 string writeJSON_VkRenderPassCreateInfo2(const VkRenderPassCreateInfo2 &pCreateInfo)
118 {
119 vk_json::_string_stream.str({});
120 vk_json::_string_stream.clear();
121 vk_json::print_VkRenderPassCreateInfo2(&pCreateInfo, "", false);
122 return vk_json::_string_stream.str();
123 }
124
writeJSON_VkPipelineLayoutCreateInfo(const VkPipelineLayoutCreateInfo & pCreateInfo)125 string writeJSON_VkPipelineLayoutCreateInfo(const VkPipelineLayoutCreateInfo &pCreateInfo)
126 {
127 vk_json::_string_stream.str({});
128 vk_json::_string_stream.clear();
129 vk_json::print_VkPipelineLayoutCreateInfo(&pCreateInfo, "", false);
130 return vk_json::_string_stream.str();
131 }
132
writeJSON_VkDescriptorSetLayoutCreateInfo(const VkDescriptorSetLayoutCreateInfo & pCreateInfo)133 string writeJSON_VkDescriptorSetLayoutCreateInfo(const VkDescriptorSetLayoutCreateInfo &pCreateInfo)
134 {
135 vk_json::_string_stream.str({});
136 vk_json::_string_stream.clear();
137 vk_json::print_VkDescriptorSetLayoutCreateInfo(&pCreateInfo, "", false);
138 return vk_json::_string_stream.str();
139 }
140
writeJSON_VkSamplerCreateInfo(const VkSamplerCreateInfo & pCreateInfo)141 string writeJSON_VkSamplerCreateInfo(const VkSamplerCreateInfo &pCreateInfo)
142 {
143 vk_json::_string_stream.str({});
144 vk_json::_string_stream.clear();
145 vk_json::print_VkSamplerCreateInfo(&pCreateInfo, "", false);
146 return vk_json::_string_stream.str();
147 }
148
writeJSON_VkDeviceObjectReservationCreateInfo(const VkDeviceObjectReservationCreateInfo & dmrCI)149 string writeJSON_VkDeviceObjectReservationCreateInfo(const VkDeviceObjectReservationCreateInfo &dmrCI)
150 {
151 vk_json::_string_stream.str({});
152 vk_json::_string_stream.clear();
153 vk_json::print_VkDeviceObjectReservationCreateInfo(&dmrCI, "", false);
154 return vk_json::_string_stream.str();
155 }
156
writeJSON_VkPipelineOfflineCreateInfo(const vk::VkPipelineOfflineCreateInfo & piInfo)157 string writeJSON_VkPipelineOfflineCreateInfo(const vk::VkPipelineOfflineCreateInfo &piInfo)
158 {
159 vk_json::_string_stream.str({});
160 vk_json::_string_stream.clear();
161 vk_json::print_VkPipelineOfflineCreateInfo(&piInfo, "", false);
162 return vk_json::_string_stream.str();
163 }
164
writeJSON_GraphicsPipeline_vkpccjson(const std::string & filePrefix,uint32_t pipelineIndex,const vk::VkPipelineOfflineCreateInfo id,const VkGraphicsPipelineCreateInfo & gpCI,const vk::VkPhysicalDeviceFeatures2 & deviceFeatures2,const std::vector<std::string> & deviceExtensions,const std::map<VkSamplerYcbcrConversion,VkSamplerYcbcrConversionCreateInfo> & samplerYcbcrConversions,const std::map<VkSampler,VkSamplerCreateInfo> & samplers,const std::map<VkDescriptorSetLayout,VkDescriptorSetLayoutCreateInfo> & descriptorSetLayouts,const std::map<VkRenderPass,VkRenderPassCreateInfo> & renderPasses,const std::map<VkRenderPass,VkRenderPassCreateInfo2> & renderPasses2,const std::map<VkPipelineLayout,VkPipelineLayoutCreateInfo> & pipelineLayouts)165 string writeJSON_GraphicsPipeline_vkpccjson(
166 const std::string &filePrefix, uint32_t pipelineIndex, const vk::VkPipelineOfflineCreateInfo id,
167 const VkGraphicsPipelineCreateInfo &gpCI, const vk::VkPhysicalDeviceFeatures2 &deviceFeatures2,
168 const std::vector<std::string> &deviceExtensions,
169 const std::map<VkSamplerYcbcrConversion, VkSamplerYcbcrConversionCreateInfo> &samplerYcbcrConversions,
170 const std::map<VkSampler, VkSamplerCreateInfo> &samplers,
171 const std::map<VkDescriptorSetLayout, VkDescriptorSetLayoutCreateInfo> &descriptorSetLayouts,
172 const std::map<VkRenderPass, VkRenderPassCreateInfo> &renderPasses,
173 const std::map<VkRenderPass, VkRenderPassCreateInfo2> &renderPasses2,
174 const std::map<VkPipelineLayout, VkPipelineLayoutCreateInfo> &pipelineLayouts)
175 {
176 vk_json::_string_stream.str({});
177 vk_json::_string_stream.clear();
178
179 for (int i = 0; i < vk_json::s_num_spaces; i++)
180 vk_json::_string_stream << " ";
181 vk_json::_string_stream << "{" << std::endl;
182 vk_json::s_num_spaces += 4;
183
184 for (int i = 0; i < vk_json::s_num_spaces; i++)
185 vk_json::_string_stream << " ";
186 vk_json::_string_stream << "\"GraphicsPipelineState\" :" << std::endl;
187 for (int i = 0; i < vk_json::s_num_spaces; i++)
188 vk_json::_string_stream << " ";
189 vk_json::_string_stream << "{" << std::endl;
190 vk_json::s_num_spaces += 4;
191
192 if (!renderPasses.empty())
193 {
194 for (int i = 0; i < vk_json::s_num_spaces; i++)
195 vk_json::_string_stream << " ";
196 vk_json::_string_stream << "\"Renderpass\" : " << std::endl;
197 vk_json::print_VkRenderPassCreateInfo(begin(renderPasses)->second, "", true);
198 }
199 if (!renderPasses2.empty())
200 {
201 for (int i = 0; i < vk_json::s_num_spaces; i++)
202 vk_json::_string_stream << " ";
203 vk_json::_string_stream << "\"Renderpass2\" : " << std::endl;
204 vk_json::print_VkRenderPassCreateInfo2(begin(renderPasses2)->second, "", true);
205 }
206 if (!samplerYcbcrConversions.empty())
207 {
208 for (int i = 0; i < vk_json::s_num_spaces; i++)
209 vk_json::_string_stream << " ";
210 vk_json::_string_stream << "\"YcbcrSamplers\" :" << std::endl;
211 for (int i = 0; i < vk_json::s_num_spaces; i++)
212 vk_json::_string_stream << " ";
213 vk_json::_string_stream << "[" << std::endl;
214 vk_json::s_num_spaces += 4;
215
216 size_t j = 0u;
217 for (auto it = begin(samplerYcbcrConversions); it != end(samplerYcbcrConversions); ++it, ++j)
218 {
219 for (int i = 0; i < vk_json::s_num_spaces; i++)
220 vk_json::_string_stream << " ";
221 vk_json::_string_stream << "{" << std::endl;
222 vk_json::s_num_spaces += 4;
223
224 for (int i = 0; i < vk_json::s_num_spaces; i++)
225 vk_json::_string_stream << " ";
226 vk_json::_string_stream << "\"" << it->first.getInternal() << "\":" << std::endl;
227
228 vk_json::print_VkSamplerYcbcrConversionCreateInfo(it->second, "", false);
229
230 vk_json::s_num_spaces -= 4;
231 for (int i = 0; i < vk_json::s_num_spaces; i++)
232 vk_json::_string_stream << " ";
233 if ((j + 1) < samplerYcbcrConversions.size())
234 vk_json::_string_stream << "}," << std::endl;
235 else
236 vk_json::_string_stream << "}" << std::endl;
237 }
238
239 vk_json::s_num_spaces -= 4;
240 for (int i = 0; i < vk_json::s_num_spaces; i++)
241 vk_json::_string_stream << " ";
242 vk_json::_string_stream << "]," << std::endl;
243 }
244
245 if (!samplers.empty())
246 {
247 for (int i = 0; i < vk_json::s_num_spaces; i++)
248 vk_json::_string_stream << " ";
249 vk_json::_string_stream << "\"ImmutableSamplers\" :" << std::endl;
250 for (int i = 0; i < vk_json::s_num_spaces; i++)
251 vk_json::_string_stream << " ";
252 vk_json::_string_stream << "[" << std::endl;
253 vk_json::s_num_spaces += 4;
254
255 size_t j = 0u;
256 for (auto it = begin(samplers); it != end(samplers); ++it, ++j)
257 {
258 for (int i = 0; i < vk_json::s_num_spaces; i++)
259 vk_json::_string_stream << " ";
260 vk_json::_string_stream << "{" << std::endl;
261 vk_json::s_num_spaces += 4;
262
263 for (int i = 0; i < vk_json::s_num_spaces; i++)
264 vk_json::_string_stream << " ";
265 vk_json::_string_stream << "\"" << it->first.getInternal() << "\":" << std::endl;
266
267 vk_json::print_VkSamplerCreateInfo(it->second, "", false);
268
269 vk_json::s_num_spaces -= 4;
270 for (int i = 0; i < vk_json::s_num_spaces; i++)
271 vk_json::_string_stream << " ";
272
273 if ((j + 1) < samplers.size())
274 vk_json::_string_stream << "}," << std::endl;
275 else
276 vk_json::_string_stream << "}" << std::endl;
277 }
278
279 vk_json::s_num_spaces -= 4;
280 for (int i = 0; i < vk_json::s_num_spaces; i++)
281 vk_json::_string_stream << " ";
282 vk_json::_string_stream << "]," << std::endl;
283 }
284
285 if (!descriptorSetLayouts.empty())
286 {
287 for (int i = 0; i < vk_json::s_num_spaces; i++)
288 vk_json::_string_stream << " ";
289 vk_json::_string_stream << "\"DescriptorSetLayouts\" :" << std::endl;
290 for (int i = 0; i < vk_json::s_num_spaces; i++)
291 vk_json::_string_stream << " ";
292 vk_json::_string_stream << "[" << std::endl;
293 vk_json::s_num_spaces += 4;
294
295 size_t j = 0u;
296 for (auto it = begin(descriptorSetLayouts); it != end(descriptorSetLayouts); ++it, ++j)
297 {
298 for (int i = 0; i < vk_json::s_num_spaces; i++)
299 vk_json::_string_stream << " ";
300 vk_json::_string_stream << "{" << std::endl;
301 vk_json::s_num_spaces += 4;
302
303 for (int i = 0; i < vk_json::s_num_spaces; i++)
304 vk_json::_string_stream << " ";
305 vk_json::_string_stream << "\"" << it->first.getInternal() << "\":" << std::endl;
306
307 vk_json::print_VkDescriptorSetLayoutCreateInfo(it->second, "", false);
308
309 vk_json::s_num_spaces -= 4;
310 for (int i = 0; i < vk_json::s_num_spaces; i++)
311 vk_json::_string_stream << " ";
312
313 if ((j + 1) < descriptorSetLayouts.size())
314 vk_json::_string_stream << "}," << std::endl;
315 else
316 vk_json::_string_stream << "}" << std::endl;
317 }
318
319 vk_json::s_num_spaces -= 4;
320 for (int i = 0; i < vk_json::s_num_spaces; i++)
321 vk_json::_string_stream << " ";
322 vk_json::_string_stream << "]," << std::endl;
323 }
324
325 for (int i = 0; i < vk_json::s_num_spaces; i++)
326 vk_json::_string_stream << " ";
327 vk_json::_string_stream << "\"PipelineLayout\" : " << std::endl;
328 vk_json::print_VkPipelineLayoutCreateInfo(begin(pipelineLayouts)->second, "", true);
329
330 for (int i = 0; i < vk_json::s_num_spaces; i++)
331 vk_json::_string_stream << " ";
332 vk_json::_string_stream << "\"GraphicsPipeline\" : " << std::endl;
333 vk_json::print_VkGraphicsPipelineCreateInfo(gpCI, "", true);
334
335 // shaders
336 {
337 for (int i = 0; i < vk_json::s_num_spaces; i++)
338 vk_json::_string_stream << " ";
339 vk_json::_string_stream << "\"ShaderFileNames\" :" << std::endl;
340 for (int i = 0; i < vk_json::s_num_spaces; i++)
341 vk_json::_string_stream << " ";
342 vk_json::_string_stream << "[" << std::endl;
343 vk_json::s_num_spaces += 4;
344
345 for (uint32_t j = 0; j < gpCI.stageCount; ++j)
346 {
347 for (int i = 0; i < vk_json::s_num_spaces; i++)
348 vk_json::_string_stream << " ";
349 vk_json::_string_stream << "{" << std::endl;
350 vk_json::s_num_spaces += 4;
351
352 vk_json::print_VkShaderStageFlagBits(gpCI.pStages[j].stage, "stage", 1);
353
354 std::stringstream shaderName;
355 shaderName << filePrefix << "shader_" << pipelineIndex << "_" << gpCI.pStages[j].module.getInternal()
356 << ".";
357
358 switch (gpCI.pStages[j].stage)
359 {
360 case VK_SHADER_STAGE_VERTEX_BIT:
361 shaderName << "vert";
362 break;
363 case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT:
364 shaderName << "tesc";
365 break;
366 case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT:
367 shaderName << "tese";
368 break;
369 case VK_SHADER_STAGE_GEOMETRY_BIT:
370 shaderName << "geom";
371 break;
372 case VK_SHADER_STAGE_FRAGMENT_BIT:
373 shaderName << "frag";
374 break;
375 default:
376 TCU_THROW(InternalError, "Unrecognized shader stage");
377 }
378 shaderName << ".spv";
379
380 for (int i = 0; i < vk_json::s_num_spaces; i++)
381 vk_json::_string_stream << " ";
382 vk_json::_string_stream << "\"filename\" : \"" << shaderName.str() << "\"" << std::endl;
383 vk_json::s_num_spaces -= 4;
384 for (int i = 0; i < vk_json::s_num_spaces; i++)
385 vk_json::_string_stream << " ";
386
387 if ((j + 1) >= gpCI.stageCount)
388 vk_json::_string_stream << "}" << std::endl;
389 else
390 vk_json::_string_stream << "}," << std::endl;
391 }
392
393 vk_json::s_num_spaces -= 4;
394 for (int i = 0; i < vk_json::s_num_spaces; i++)
395 vk_json::_string_stream << " ";
396 vk_json::_string_stream << "]," << std::endl;
397 }
398
399 // device features
400 for (int i = 0; i < vk_json::s_num_spaces; i++)
401 vk_json::_string_stream << " ";
402 vk_json::_string_stream << "\"PhysicalDeviceFeatures\" : " << std::endl;
403 vk_json::print_VkPhysicalDeviceFeatures2(deviceFeatures2, "", false);
404
405 // close GraphicsPipelineState
406 vk_json::s_num_spaces -= 4;
407 for (int i = 0; i < vk_json::s_num_spaces; i++)
408 vk_json::_string_stream << " ";
409 vk_json::_string_stream << "}," << std::endl;
410
411 // device extensions
412 {
413 for (int i = 0; i < vk_json::s_num_spaces; i++)
414 vk_json::_string_stream << " ";
415 vk_json::_string_stream << "\"EnabledExtensions\" : " << std::endl;
416 for (int i = 0; i < vk_json::s_num_spaces; i++)
417 vk_json::_string_stream << " ";
418 vk_json::_string_stream << "[" << std::endl;
419 vk_json::s_num_spaces += 4;
420
421 for (unsigned int j = 0; j < deviceExtensions.size(); j++)
422 vk_json::print_char(deviceExtensions[j].data(), "", (j + 1) != deviceExtensions.size());
423
424 vk_json::s_num_spaces -= 4;
425 for (int i = 0; i < vk_json::s_num_spaces; i++)
426 vk_json::_string_stream << " ";
427 vk_json::_string_stream << "]," << std::endl;
428 }
429
430 // pipeline identifier
431 for (int i = 0; i < vk_json::s_num_spaces; i++)
432 vk_json::_string_stream << " ";
433 vk_json::_string_stream << "\"PipelineUUID\" : " << std::endl;
434 for (int i = 0; i < vk_json::s_num_spaces; i++)
435 vk_json::_string_stream << " ";
436 vk_json::_string_stream << "[" << std::endl;
437 vk_json::s_num_spaces += 4;
438 for (unsigned int j = 0; j < VK_UUID_SIZE; j++)
439 vk_json::print_uint32_t((uint32_t)id.pipelineIdentifier[j], "", (j + 1) != VK_UUID_SIZE);
440 vk_json::s_num_spaces -= 4;
441 for (int i = 0; i < vk_json::s_num_spaces; i++)
442 vk_json::_string_stream << " ";
443 vk_json::_string_stream << "]" << std::endl;
444
445 vk_json::s_num_spaces -= 4;
446 for (int i = 0; i < vk_json::s_num_spaces; i++)
447 vk_json::_string_stream << " ";
448 vk_json::_string_stream << "}" << std::endl;
449
450 return vk_json::_string_stream.str();
451 }
452
writeJSON_ComputePipeline_vkpccjson(const std::string & filePrefix,uint32_t pipelineIndex,const vk::VkPipelineOfflineCreateInfo id,const VkComputePipelineCreateInfo & cpCI,const vk::VkPhysicalDeviceFeatures2 & deviceFeatures2,const std::vector<std::string> & deviceExtensions,const std::map<VkSamplerYcbcrConversion,VkSamplerYcbcrConversionCreateInfo> & samplerYcbcrConversions,const std::map<VkSampler,VkSamplerCreateInfo> & samplers,const std::map<VkDescriptorSetLayout,VkDescriptorSetLayoutCreateInfo> & descriptorSetLayouts,const std::map<VkPipelineLayout,VkPipelineLayoutCreateInfo> & pipelineLayouts)453 string writeJSON_ComputePipeline_vkpccjson(
454 const std::string &filePrefix, uint32_t pipelineIndex, const vk::VkPipelineOfflineCreateInfo id,
455 const VkComputePipelineCreateInfo &cpCI, const vk::VkPhysicalDeviceFeatures2 &deviceFeatures2,
456 const std::vector<std::string> &deviceExtensions,
457 const std::map<VkSamplerYcbcrConversion, VkSamplerYcbcrConversionCreateInfo> &samplerYcbcrConversions,
458 const std::map<VkSampler, VkSamplerCreateInfo> &samplers,
459 const std::map<VkDescriptorSetLayout, VkDescriptorSetLayoutCreateInfo> &descriptorSetLayouts,
460 const std::map<VkPipelineLayout, VkPipelineLayoutCreateInfo> &pipelineLayouts)
461 {
462 vk_json::_string_stream.str({});
463 vk_json::_string_stream.clear();
464
465 for (int i = 0; i < vk_json::s_num_spaces; i++)
466 vk_json::_string_stream << " ";
467 vk_json::_string_stream << "{" << std::endl;
468 vk_json::s_num_spaces += 4;
469
470 for (int i = 0; i < vk_json::s_num_spaces; i++)
471 vk_json::_string_stream << " ";
472 vk_json::_string_stream << "\"ComputePipelineState\" :" << std::endl;
473 for (int i = 0; i < vk_json::s_num_spaces; i++)
474 vk_json::_string_stream << " ";
475 vk_json::_string_stream << "{" << std::endl;
476 vk_json::s_num_spaces += 4;
477
478 if (!samplerYcbcrConversions.empty())
479 {
480 for (int i = 0; i < vk_json::s_num_spaces; i++)
481 vk_json::_string_stream << " ";
482 vk_json::_string_stream << "\"YcbcrSamplers\" :" << std::endl;
483 for (int i = 0; i < vk_json::s_num_spaces; i++)
484 vk_json::_string_stream << " ";
485 vk_json::_string_stream << "[" << std::endl;
486 vk_json::s_num_spaces += 4;
487
488 size_t j = 0u;
489 for (auto it = begin(samplerYcbcrConversions); it != end(samplerYcbcrConversions); ++it, ++j)
490 {
491 for (int i = 0; i < vk_json::s_num_spaces; i++)
492 vk_json::_string_stream << " ";
493 vk_json::_string_stream << "{" << std::endl;
494 vk_json::s_num_spaces += 4;
495
496 for (int i = 0; i < vk_json::s_num_spaces; i++)
497 vk_json::_string_stream << " ";
498 vk_json::_string_stream << "\"" << it->first.getInternal() << "\":" << std::endl;
499
500 vk_json::print_VkSamplerYcbcrConversionCreateInfo(it->second, "", false);
501
502 vk_json::s_num_spaces -= 4;
503 for (int i = 0; i < vk_json::s_num_spaces; i++)
504 vk_json::_string_stream << " ";
505 if ((j + 1) < samplerYcbcrConversions.size())
506 vk_json::_string_stream << "}," << std::endl;
507 else
508 vk_json::_string_stream << "}" << std::endl;
509 }
510
511 vk_json::s_num_spaces -= 4;
512 for (int i = 0; i < vk_json::s_num_spaces; i++)
513 vk_json::_string_stream << " ";
514 vk_json::_string_stream << "]," << std::endl;
515 }
516
517 if (!samplers.empty())
518 {
519 for (int i = 0; i < vk_json::s_num_spaces; i++)
520 vk_json::_string_stream << " ";
521 vk_json::_string_stream << "\"ImmutableSamplers\" :" << std::endl;
522 for (int i = 0; i < vk_json::s_num_spaces; i++)
523 vk_json::_string_stream << " ";
524 vk_json::_string_stream << "[" << std::endl;
525 vk_json::s_num_spaces += 4;
526
527 size_t j = 0u;
528 for (auto it = begin(samplers); it != end(samplers); ++it, ++j)
529 {
530 for (int i = 0; i < vk_json::s_num_spaces; i++)
531 vk_json::_string_stream << " ";
532 vk_json::_string_stream << "{" << std::endl;
533 vk_json::s_num_spaces += 4;
534
535 for (int i = 0; i < vk_json::s_num_spaces; i++)
536 vk_json::_string_stream << " ";
537 vk_json::_string_stream << "\"" << it->first.getInternal() << "\":" << std::endl;
538
539 vk_json::print_VkSamplerCreateInfo(it->second, "", false);
540
541 vk_json::s_num_spaces -= 4;
542 for (int i = 0; i < vk_json::s_num_spaces; i++)
543 vk_json::_string_stream << " ";
544
545 if ((j + 1) < samplers.size())
546 vk_json::_string_stream << "}," << std::endl;
547 else
548 vk_json::_string_stream << "}" << std::endl;
549 }
550
551 vk_json::s_num_spaces -= 4;
552 for (int i = 0; i < vk_json::s_num_spaces; i++)
553 vk_json::_string_stream << " ";
554 vk_json::_string_stream << "]," << std::endl;
555 }
556
557 if (!descriptorSetLayouts.empty())
558 {
559 for (int i = 0; i < vk_json::s_num_spaces; i++)
560 vk_json::_string_stream << " ";
561 vk_json::_string_stream << "\"DescriptorSetLayouts\" :" << std::endl;
562 for (int i = 0; i < vk_json::s_num_spaces; i++)
563 vk_json::_string_stream << " ";
564 vk_json::_string_stream << "[" << std::endl;
565 vk_json::s_num_spaces += 4;
566
567 size_t j = 0u;
568 for (auto it = begin(descriptorSetLayouts); it != end(descriptorSetLayouts); ++it, ++j)
569 {
570 for (int i = 0; i < vk_json::s_num_spaces; i++)
571 vk_json::_string_stream << " ";
572 vk_json::_string_stream << "{" << std::endl;
573 vk_json::s_num_spaces += 4;
574
575 for (int i = 0; i < vk_json::s_num_spaces; i++)
576 vk_json::_string_stream << " ";
577 vk_json::_string_stream << "\"" << it->first.getInternal() << "\":" << std::endl;
578
579 vk_json::print_VkDescriptorSetLayoutCreateInfo(it->second, "", false);
580
581 vk_json::s_num_spaces -= 4;
582 for (int i = 0; i < vk_json::s_num_spaces; i++)
583 vk_json::_string_stream << " ";
584
585 if ((j + 1) < descriptorSetLayouts.size())
586 vk_json::_string_stream << "}," << std::endl;
587 else
588 vk_json::_string_stream << "}" << std::endl;
589 }
590
591 vk_json::s_num_spaces -= 4;
592 for (int i = 0; i < vk_json::s_num_spaces; i++)
593 vk_json::_string_stream << " ";
594 vk_json::_string_stream << "]," << std::endl;
595 }
596
597 for (int i = 0; i < vk_json::s_num_spaces; i++)
598 vk_json::_string_stream << " ";
599 vk_json::_string_stream << "\"PipelineLayout\" : " << std::endl;
600 vk_json::print_VkPipelineLayoutCreateInfo(begin(pipelineLayouts)->second, "", true);
601
602 for (int i = 0; i < vk_json::s_num_spaces; i++)
603 vk_json::_string_stream << " ";
604 vk_json::_string_stream << "\"ComputePipeline\" : " << std::endl;
605 vk_json::print_VkComputePipelineCreateInfo(cpCI, "", true);
606
607 // shaders
608 {
609 for (int i = 0; i < vk_json::s_num_spaces; i++)
610 vk_json::_string_stream << " ";
611 vk_json::_string_stream << "\"ShaderFileNames\" :" << std::endl;
612 for (int i = 0; i < vk_json::s_num_spaces; i++)
613 vk_json::_string_stream << " ";
614 vk_json::_string_stream << "[" << std::endl;
615 vk_json::s_num_spaces += 4;
616
617 {
618 for (int i = 0; i < vk_json::s_num_spaces; i++)
619 vk_json::_string_stream << " ";
620 vk_json::_string_stream << "{" << std::endl;
621 vk_json::s_num_spaces += 4;
622
623 vk_json::print_VkShaderStageFlagBits(cpCI.stage.stage, "stage", 1);
624
625 std::stringstream shaderName;
626 shaderName << filePrefix << "shader_" << pipelineIndex << "_" << cpCI.stage.module.getInternal() << ".";
627
628 switch (cpCI.stage.stage)
629 {
630 case VK_SHADER_STAGE_COMPUTE_BIT:
631 shaderName << "comp";
632 break;
633 default:
634 TCU_THROW(InternalError, "Unrecognized shader stage");
635 }
636 shaderName << ".spv";
637
638 for (int i = 0; i < vk_json::s_num_spaces; i++)
639 vk_json::_string_stream << " ";
640 vk_json::_string_stream << "\"filename\" : \"" << shaderName.str() << "\"" << std::endl;
641 vk_json::s_num_spaces -= 4;
642 for (int i = 0; i < vk_json::s_num_spaces; i++)
643 vk_json::_string_stream << " ";
644
645 vk_json::_string_stream << "}" << std::endl;
646 }
647
648 vk_json::s_num_spaces -= 4;
649 for (int i = 0; i < vk_json::s_num_spaces; i++)
650 vk_json::_string_stream << " ";
651 vk_json::_string_stream << "]," << std::endl;
652 }
653
654 // device features
655 for (int i = 0; i < vk_json::s_num_spaces; i++)
656 vk_json::_string_stream << " ";
657 vk_json::_string_stream << "\"PhysicalDeviceFeatures\" : " << std::endl;
658 vk_json::print_VkPhysicalDeviceFeatures2(deviceFeatures2, "", false);
659
660 // close ComputePipelineState
661 vk_json::s_num_spaces -= 4;
662 for (int i = 0; i < vk_json::s_num_spaces; i++)
663 vk_json::_string_stream << " ";
664 vk_json::_string_stream << "}," << std::endl;
665
666 // device extensions
667 {
668 for (int i = 0; i < vk_json::s_num_spaces; i++)
669 vk_json::_string_stream << " ";
670 vk_json::_string_stream << "\"EnabledExtensions\" : " << std::endl;
671 for (int i = 0; i < vk_json::s_num_spaces; i++)
672 vk_json::_string_stream << " ";
673 vk_json::_string_stream << "[" << std::endl;
674 vk_json::s_num_spaces += 4;
675
676 for (unsigned int j = 0; j < deviceExtensions.size(); j++)
677 vk_json::print_char(deviceExtensions[j].data(), "", (j + 1) != deviceExtensions.size());
678
679 vk_json::s_num_spaces -= 4;
680 for (int i = 0; i < vk_json::s_num_spaces; i++)
681 vk_json::_string_stream << " ";
682 vk_json::_string_stream << "]," << std::endl;
683 }
684
685 // pipeline identifier
686 for (int i = 0; i < vk_json::s_num_spaces; i++)
687 vk_json::_string_stream << " ";
688 vk_json::_string_stream << "\"PipelineUUID\" : " << std::endl;
689 for (int i = 0; i < vk_json::s_num_spaces; i++)
690 vk_json::_string_stream << " ";
691 vk_json::_string_stream << "[" << std::endl;
692 vk_json::s_num_spaces += 4;
693 for (unsigned int j = 0; j < VK_UUID_SIZE; j++)
694 vk_json::print_uint32_t((uint32_t)id.pipelineIdentifier[j], "", (j + 1) != VK_UUID_SIZE);
695 vk_json::s_num_spaces -= 4;
696 for (int i = 0; i < vk_json::s_num_spaces; i++)
697 vk_json::_string_stream << " ";
698 vk_json::_string_stream << "]" << std::endl;
699
700 vk_json::s_num_spaces -= 4;
701 for (int i = 0; i < vk_json::s_num_spaces; i++)
702 vk_json::_string_stream << " ";
703 vk_json::_string_stream << "}" << std::endl;
704
705 return vk_json::_string_stream.str();
706 }
707
writeJSON_VkPhysicalDeviceFeatures2(const vk::VkPhysicalDeviceFeatures2 & features)708 string writeJSON_VkPhysicalDeviceFeatures2(const vk::VkPhysicalDeviceFeatures2 &features)
709 {
710 vk_json::_string_stream.str({});
711 vk_json::_string_stream.clear();
712 vk_json::print_VkPhysicalDeviceFeatures2(&features, "", false);
713 return vk_json::_string_stream.str();
714 }
715
writeJSON_pNextChain(const void * pNext)716 string writeJSON_pNextChain(const void *pNext)
717 {
718 vk_json::_string_stream.str({});
719 vk_json::_string_stream.clear();
720 vk_json::dumpPNextChain(pNext);
721 std::string result = vk_json::_string_stream.str();
722 // remove "pNext" at the beggining of result and trailing comma
723 return std::string(begin(result) + result.find_first_of('{'), begin(result) + result.find_last_of('}') + 1u);
724 }
725
writeJSON_VkSamplerYcbcrConversionCreateInfo(const VkSamplerYcbcrConversionCreateInfo & pCreateInfo)726 string writeJSON_VkSamplerYcbcrConversionCreateInfo(const VkSamplerYcbcrConversionCreateInfo &pCreateInfo)
727 {
728 vk_json::_string_stream.str({});
729 vk_json::_string_stream.clear();
730 vk_json::print_VkSamplerYcbcrConversionCreateInfo(&pCreateInfo, "", false);
731 return vk_json::_string_stream.str();
732 }
733
print_VkShaderModuleCreateInfo(const VkShaderModuleCreateInfo * obj,const string & s,bool commaNeeded)734 static void print_VkShaderModuleCreateInfo(const VkShaderModuleCreateInfo *obj, const string &s, bool commaNeeded)
735 {
736 DE_UNREF(s);
737
738 for (int i = 0; i < vk_json::s_num_spaces; i++)
739 vk_json::_string_stream << " ";
740 vk_json::_string_stream << "{" << std::endl;
741 vk_json::s_num_spaces += 4;
742
743 vk_json::print_VkStructureType(obj->sType, "sType", 1);
744
745 if (obj->pNext)
746 {
747 vk_json::dumpPNextChain(obj->pNext);
748 }
749 else
750 {
751 for (int i = 0; i < vk_json::s_num_spaces; i++)
752 vk_json::_string_stream << " ";
753 vk_json::_string_stream << "\"pNext\":"
754 << "\"NULL\""
755 << "," << std::endl;
756 }
757
758 // VkShaderModuleCreateFlags is reserved for future use and must be 0.
759 vk_json::print_uint32_t((uint32_t)obj->flags, "flags", 1);
760 vk_json::print_uint64_t((uint64_t)obj->codeSize, "codeSize", 1);
761
762 // pCode must be translated into base64, because JSON
763 vk_json::print_void_data(obj->pCode, static_cast<int>(obj->codeSize), "pCode", 0);
764
765 vk_json::s_num_spaces -= 4;
766 for (int i = 0; i < vk_json::s_num_spaces; i++)
767 vk_json::_string_stream << " ";
768 if (commaNeeded)
769 vk_json::_string_stream << "}," << std::endl;
770 else
771 vk_json::_string_stream << "}" << std::endl;
772 }
773
writeJSON_VkShaderModuleCreateInfo(const VkShaderModuleCreateInfo & smCI)774 string writeJSON_VkShaderModuleCreateInfo(const VkShaderModuleCreateInfo &smCI)
775 {
776 vk_json::_string_stream.str({});
777 vk_json::_string_stream.clear();
778 print_VkShaderModuleCreateInfo(&smCI, "", false);
779 return vk_json::_string_stream.str();
780 }
781
readJSON_VkGraphicsPipelineCreateInfo(Context & context,const string & graphicsPipelineCreateInfo,VkGraphicsPipelineCreateInfo & gpCI)782 void readJSON_VkGraphicsPipelineCreateInfo(Context &context, const string &graphicsPipelineCreateInfo,
783 VkGraphicsPipelineCreateInfo &gpCI)
784 {
785 Json::Value jsonRoot;
786 string errors;
787 bool parsingSuccessful = context.reader->parse(
788 graphicsPipelineCreateInfo.c_str(), graphicsPipelineCreateInfo.c_str() + graphicsPipelineCreateInfo.size(),
789 &jsonRoot, &errors);
790 if (!parsingSuccessful)
791 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
792 vk_json_parser::parse_VkGraphicsPipelineCreateInfo("", jsonRoot, gpCI);
793 }
794
readJSON_VkComputePipelineCreateInfo(Context & context,const string & computePipelineCreateInfo,VkComputePipelineCreateInfo & cpCI)795 void readJSON_VkComputePipelineCreateInfo(Context &context, const string &computePipelineCreateInfo,
796 VkComputePipelineCreateInfo &cpCI)
797 {
798 Json::Value jsonRoot;
799 string errors;
800 bool parsingSuccessful =
801 context.reader->parse(computePipelineCreateInfo.c_str(),
802 computePipelineCreateInfo.c_str() + computePipelineCreateInfo.size(), &jsonRoot, &errors);
803 if (!parsingSuccessful)
804 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
805 vk_json_parser::parse_VkComputePipelineCreateInfo("", jsonRoot, cpCI);
806 }
807
readJSON_VkRenderPassCreateInfo(Context & context,const string & renderPassCreateInfo,VkRenderPassCreateInfo & rpCI)808 void readJSON_VkRenderPassCreateInfo(Context &context, const string &renderPassCreateInfo, VkRenderPassCreateInfo &rpCI)
809 {
810 Json::Value jsonRoot;
811 string errors;
812 bool parsingSuccessful = context.reader->parse(
813 renderPassCreateInfo.c_str(), renderPassCreateInfo.c_str() + renderPassCreateInfo.size(), &jsonRoot, &errors);
814 if (!parsingSuccessful)
815 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
816 vk_json_parser::parse_VkRenderPassCreateInfo("", jsonRoot, rpCI);
817 }
818
readJSON_VkRenderPassCreateInfo2(Context & context,const string & renderPassCreateInfo,VkRenderPassCreateInfo2 & rpCI)819 void readJSON_VkRenderPassCreateInfo2(Context &context, const string &renderPassCreateInfo,
820 VkRenderPassCreateInfo2 &rpCI)
821 {
822 Json::Value jsonRoot;
823 string errors;
824 bool parsingSuccessful = context.reader->parse(
825 renderPassCreateInfo.c_str(), renderPassCreateInfo.c_str() + renderPassCreateInfo.size(), &jsonRoot, &errors);
826 if (!parsingSuccessful)
827 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
828 vk_json_parser::parse_VkRenderPassCreateInfo2("", jsonRoot, rpCI);
829 }
830
readJSON_VkDescriptorSetLayoutCreateInfo(Context & context,const string & descriptorSetLayoutCreateInfo,VkDescriptorSetLayoutCreateInfo & dsCI)831 void readJSON_VkDescriptorSetLayoutCreateInfo(Context &context, const string &descriptorSetLayoutCreateInfo,
832 VkDescriptorSetLayoutCreateInfo &dsCI)
833 {
834 Json::Value jsonRoot;
835 string errors;
836 bool parsingSuccessful = context.reader->parse(
837 descriptorSetLayoutCreateInfo.c_str(),
838 descriptorSetLayoutCreateInfo.c_str() + descriptorSetLayoutCreateInfo.size(), &jsonRoot, &errors);
839 if (!parsingSuccessful)
840 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
841 vk_json_parser::parse_VkDescriptorSetLayoutCreateInfo("", jsonRoot, dsCI);
842 }
843
readJSON_VkPipelineLayoutCreateInfo(Context & context,const string & pipelineLayoutCreateInfo,VkPipelineLayoutCreateInfo & plCI)844 void readJSON_VkPipelineLayoutCreateInfo(Context &context, const string &pipelineLayoutCreateInfo,
845 VkPipelineLayoutCreateInfo &plCI)
846 {
847 Json::Value jsonRoot;
848 string errors;
849 bool parsingSuccessful =
850 context.reader->parse(pipelineLayoutCreateInfo.c_str(),
851 pipelineLayoutCreateInfo.c_str() + pipelineLayoutCreateInfo.size(), &jsonRoot, &errors);
852 if (!parsingSuccessful)
853 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
854 vk_json_parser::parse_VkPipelineLayoutCreateInfo("", jsonRoot, plCI);
855 }
856
readJSON_VkDeviceObjectReservationCreateInfo(Context & context,const string & deviceMemoryReservation,VkDeviceObjectReservationCreateInfo & dmrCI)857 void readJSON_VkDeviceObjectReservationCreateInfo(Context &context, const string &deviceMemoryReservation,
858 VkDeviceObjectReservationCreateInfo &dmrCI)
859 {
860 Json::Value jsonRoot;
861 string errors;
862 bool parsingSuccessful =
863 context.reader->parse(deviceMemoryReservation.c_str(),
864 deviceMemoryReservation.c_str() + deviceMemoryReservation.size(), &jsonRoot, &errors);
865 if (!parsingSuccessful)
866 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
867 vk_json_parser::parse_VkDeviceObjectReservationCreateInfo("", jsonRoot, dmrCI);
868 }
869
readJSON_VkPipelineOfflineCreateInfo(Context & context,const string & pipelineIdentifierInfo,vk::VkPipelineOfflineCreateInfo & piInfo)870 void readJSON_VkPipelineOfflineCreateInfo(Context &context, const string &pipelineIdentifierInfo,
871 vk::VkPipelineOfflineCreateInfo &piInfo)
872 {
873 Json::Value jsonRoot;
874 string errors;
875 bool parsingSuccessful =
876 context.reader->parse(pipelineIdentifierInfo.c_str(),
877 pipelineIdentifierInfo.c_str() + pipelineIdentifierInfo.size(), &jsonRoot, &errors);
878 if (!parsingSuccessful)
879 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
880 vk_json_parser::parse_VkPipelineOfflineCreateInfo("", jsonRoot, piInfo);
881 }
882
readJSON_VkSamplerCreateInfo(Context & context,const string & samplerCreateInfo,VkSamplerCreateInfo & sCI)883 void readJSON_VkSamplerCreateInfo(Context &context, const string &samplerCreateInfo, VkSamplerCreateInfo &sCI)
884 {
885 Json::Value jsonRoot;
886 string errors;
887 bool parsingSuccessful = context.reader->parse(
888 samplerCreateInfo.c_str(), samplerCreateInfo.c_str() + samplerCreateInfo.size(), &jsonRoot, &errors);
889 if (!parsingSuccessful)
890 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
891 vk_json_parser::parse_VkSamplerCreateInfo("", jsonRoot, sCI);
892 }
893
readJSON_VkSamplerYcbcrConversionCreateInfo(Context & context,const std::string & samplerYcbcrConversionCreateInfo,VkSamplerYcbcrConversionCreateInfo & sycCI)894 void readJSON_VkSamplerYcbcrConversionCreateInfo(Context &context, const std::string &samplerYcbcrConversionCreateInfo,
895 VkSamplerYcbcrConversionCreateInfo &sycCI)
896 {
897 Json::Value jsonRoot;
898 std::string errors;
899 bool parsingSuccessful = context.reader->parse(
900 samplerYcbcrConversionCreateInfo.c_str(),
901 samplerYcbcrConversionCreateInfo.c_str() + samplerYcbcrConversionCreateInfo.size(), &jsonRoot, &errors);
902 if (!parsingSuccessful)
903 TCU_THROW(InternalError, (std::string("JSON parsing error: ") + errors).c_str());
904 vk_json_parser::parse_VkSamplerYcbcrConversionCreateInfo("", jsonRoot, sycCI);
905 }
906
readJSON_VkPhysicalDeviceFeatures2(Context & context,const std::string & featuresJson,vk::VkPhysicalDeviceFeatures2 & features)907 void readJSON_VkPhysicalDeviceFeatures2(Context &context, const std::string &featuresJson,
908 vk::VkPhysicalDeviceFeatures2 &features)
909 {
910 Json::Value jsonRoot;
911 std::string errors;
912 bool parsingSuccessful =
913 context.reader->parse(featuresJson.c_str(), featuresJson.c_str() + featuresJson.size(), &jsonRoot, &errors);
914 if (!parsingSuccessful)
915 TCU_THROW(InternalError, (std::string("JSON parsing error: ") + errors).c_str());
916 vk_json_parser::parse_VkPhysicalDeviceFeatures2("", jsonRoot, features);
917 }
918
readJSON_pNextChain(Context & context,const std::string & chainJson)919 void *readJSON_pNextChain(Context &context, const std::string &chainJson)
920 {
921 Json::Value jsonRoot;
922 std::string errors;
923 bool parsingSuccessful =
924 context.reader->parse(chainJson.c_str(), chainJson.c_str() + chainJson.size(), &jsonRoot, &errors);
925 if (!parsingSuccessful)
926 TCU_THROW(InternalError, (std::string("JSON parsing error: ") + errors).c_str());
927 return vk_json_parser::parsePNextChain(jsonRoot);
928 }
929
parse_VkShaderModuleCreateInfo(const char * s,Json::Value & obj,VkShaderModuleCreateInfo & o,std::vector<uint8_t> & spirvShader)930 static void parse_VkShaderModuleCreateInfo(const char *s, Json::Value &obj, VkShaderModuleCreateInfo &o,
931 std::vector<uint8_t> &spirvShader)
932 {
933 DE_UNREF(s);
934
935 vk_json_parser::parse_VkStructureType("sType", obj["sType"], (o.sType));
936
937 o.pNext = (VkDeviceObjectReservationCreateInfo *)vk_json_parser::parsePNextChain(obj);
938
939 vk_json_parser::parse_uint32_t("flags", obj["flags"], (o.flags));
940 uint64_t codeSizeValue;
941 vk_json_parser::parse_uint64_t("codeSize", obj["codeSize"], (codeSizeValue));
942 o.codeSize = (uintptr_t)codeSizeValue;
943
944 // pCode is encoded using Base64.
945 spirvShader = vk_json_parser::base64decode(obj["pCode"].asString());
946 // Base64 always decodes a multiple of 3 bytes, so the size could mismatch the module
947 // size by one or two bytes. resize spirvShader to match.
948 spirvShader.resize(o.codeSize);
949 o.pCode = (uint32_t *)spirvShader.data();
950 }
951
readJSON_VkShaderModuleCreateInfo(Context & context,const string & shaderModuleCreate,VkShaderModuleCreateInfo & smCI,std::vector<uint8_t> & spirvShader)952 void readJSON_VkShaderModuleCreateInfo(Context &context, const string &shaderModuleCreate,
953 VkShaderModuleCreateInfo &smCI, std::vector<uint8_t> &spirvShader)
954 {
955 Json::Value jsonRoot;
956 string errors;
957 bool parsingSuccessful = context.reader->parse(
958 shaderModuleCreate.c_str(), shaderModuleCreate.c_str() + shaderModuleCreate.size(), &jsonRoot, &errors);
959 if (!parsingSuccessful)
960 TCU_THROW(InternalError, ("JSON parsing error: " + errors).c_str());
961 parse_VkShaderModuleCreateInfo("", jsonRoot, smCI, spirvShader);
962 }
963
964 } // namespace json
965
966 } // namespace vksc_server
967