1e5c31af7Sopenharmony_ci#ifndef _VKSSERIALIZERVKSC_HPP 2e5c31af7Sopenharmony_ci#define _VKSSERIALIZERVKSC_HPP 3e5c31af7Sopenharmony_ci 4e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 5e5c31af7Sopenharmony_ci * Vulkan CTS Framework 6e5c31af7Sopenharmony_ci * -------------------- 7e5c31af7Sopenharmony_ci * 8e5c31af7Sopenharmony_ci * Copyright (c) 2021 The Khronos Group Inc. 9e5c31af7Sopenharmony_ci * 10e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 11e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 12e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 13e5c31af7Sopenharmony_ci * 14e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 15e5c31af7Sopenharmony_ci * 16e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 17e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 18e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 20e5c31af7Sopenharmony_ci * limitations under the License. 21e5c31af7Sopenharmony_ci * 22e5c31af7Sopenharmony_ci *-------------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "vksSerializer.hpp" 25e5c31af7Sopenharmony_ci#include "vksJson.hpp" 26e5c31af7Sopenharmony_ci 27e5c31af7Sopenharmony_ci#include "vkPrograms.hpp" 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_cinamespace vksc_server 30e5c31af7Sopenharmony_ci{ 31e5c31af7Sopenharmony_ci 32e5c31af7Sopenharmony_citemplate <typename ENUM> 33e5c31af7Sopenharmony_ciinline void SerializeEnum (Serializer<ToWrite>& serializer, ENUM& v) 34e5c31af7Sopenharmony_ci{ 35e5c31af7Sopenharmony_ci static_assert(std::is_enum<ENUM>::value, "enums only"); 36e5c31af7Sopenharmony_ci s32 raw = v; 37e5c31af7Sopenharmony_ci serializer.Serialize(raw); 38e5c31af7Sopenharmony_ci} 39e5c31af7Sopenharmony_ci 40e5c31af7Sopenharmony_citemplate <typename ENUM> 41e5c31af7Sopenharmony_ciinline void SerializeEnum (Serializer<ToRead>& serializer, ENUM& v) 42e5c31af7Sopenharmony_ci{ 43e5c31af7Sopenharmony_ci static_assert(std::is_enum<ENUM>::value, "enums only"); 44e5c31af7Sopenharmony_ci s32 raw; 45e5c31af7Sopenharmony_ci serializer.Serialize(raw); 46e5c31af7Sopenharmony_ci v = static_cast<ENUM>(raw); 47e5c31af7Sopenharmony_ci} 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_citemplate <typename TYPE> 50e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<TYPE>& serializer, vk::SpirvVersion& v) 51e5c31af7Sopenharmony_ci{ 52e5c31af7Sopenharmony_ci SerializeEnum(serializer, v); 53e5c31af7Sopenharmony_ci} 54e5c31af7Sopenharmony_ci 55e5c31af7Sopenharmony_citemplate <typename TYPE> 56e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<TYPE>& serializer, vk::SpirVAsmBuildOptions& v) 57e5c31af7Sopenharmony_ci{ 58e5c31af7Sopenharmony_ci serializer.Serialize(v.vulkanVersion, v.targetVersion, v.supports_VK_KHR_spirv_1_4); 59e5c31af7Sopenharmony_ci} 60e5c31af7Sopenharmony_ci 61e5c31af7Sopenharmony_citemplate <typename TYPE> 62e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<TYPE>& serializer, vk::SpirVAsmSource& v) 63e5c31af7Sopenharmony_ci{ 64e5c31af7Sopenharmony_ci serializer.Serialize(v.buildOptions, v.source); 65e5c31af7Sopenharmony_ci} 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_citemplate <typename TYPE> 68e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<TYPE>& serializer, vk::SpirVProgramInfo& v) 69e5c31af7Sopenharmony_ci{ 70e5c31af7Sopenharmony_ci serializer.Serialize(v.source, v.infoLog, v.compileTimeUs, v.compileOk); 71e5c31af7Sopenharmony_ci} 72e5c31af7Sopenharmony_ci 73e5c31af7Sopenharmony_citemplate <typename TYPE> 74e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<TYPE>& serializer, vk::ShaderBuildOptions& v) 75e5c31af7Sopenharmony_ci{ 76e5c31af7Sopenharmony_ci serializer.Serialize(v.vulkanVersion, v.targetVersion, v.flags, v.supports_VK_KHR_spirv_1_4); 77e5c31af7Sopenharmony_ci} 78e5c31af7Sopenharmony_ci 79e5c31af7Sopenharmony_citemplate <typename TYPE> 80e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<TYPE>& serializer, vk::GlslSource& v) 81e5c31af7Sopenharmony_ci{ 82e5c31af7Sopenharmony_ci for (msize i{}; i < glu::SHADERTYPE_LAST; ++i) 83e5c31af7Sopenharmony_ci { 84e5c31af7Sopenharmony_ci serializer.Serialize(v.sources[i]); 85e5c31af7Sopenharmony_ci } 86e5c31af7Sopenharmony_ci serializer.Serialize(v.buildOptions); 87e5c31af7Sopenharmony_ci} 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_citemplate <typename TYPE> 90e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<TYPE>& serializer, vk::HlslSource& v) 91e5c31af7Sopenharmony_ci{ 92e5c31af7Sopenharmony_ci for (msize i{}; i < glu::SHADERTYPE_LAST; ++i) 93e5c31af7Sopenharmony_ci { 94e5c31af7Sopenharmony_ci serializer.Serialize(v.sources[i]); 95e5c31af7Sopenharmony_ci } 96e5c31af7Sopenharmony_ci serializer.Serialize(v.buildOptions); 97e5c31af7Sopenharmony_ci} 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_citemplate <vk::HandleType VKTYPE> 100e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<ToRead>& serializer, vk::Handle<VKTYPE>& v) 101e5c31af7Sopenharmony_ci{ 102e5c31af7Sopenharmony_ci u64 handle; 103e5c31af7Sopenharmony_ci serializer.Serialize(handle); 104e5c31af7Sopenharmony_ci v = handle; 105e5c31af7Sopenharmony_ci} 106e5c31af7Sopenharmony_ci 107e5c31af7Sopenharmony_citemplate <vk::HandleType VKTYPE> 108e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<ToWrite>& serializer, const vk::Handle<VKTYPE>& v) 109e5c31af7Sopenharmony_ci{ 110e5c31af7Sopenharmony_ci serializer.Serialize(v.getInternal()); 111e5c31af7Sopenharmony_ci} 112e5c31af7Sopenharmony_ci 113e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<ToRead>& serializer, vk::VkDeviceObjectReservationCreateInfo& v) 114e5c31af7Sopenharmony_ci{ 115e5c31af7Sopenharmony_ci string input; 116e5c31af7Sopenharmony_ci serializer.Serialize(input); 117e5c31af7Sopenharmony_ci json::Context ctx; 118e5c31af7Sopenharmony_ci json::readJSON_VkDeviceObjectReservationCreateInfo(ctx, input, v); 119e5c31af7Sopenharmony_ci} 120e5c31af7Sopenharmony_ci 121e5c31af7Sopenharmony_ciinline void SerializeItem (Serializer<ToWrite>& serializer, vk::VkDeviceObjectReservationCreateInfo& v) 122e5c31af7Sopenharmony_ci{ 123e5c31af7Sopenharmony_ci string output = json::writeJSON_VkDeviceObjectReservationCreateInfo(v); 124e5c31af7Sopenharmony_ci serializer.Serialize(output); 125e5c31af7Sopenharmony_ci} 126e5c31af7Sopenharmony_ci 127e5c31af7Sopenharmony_ciinline void SerializeItem(Serializer<ToRead>& serializer, vk::VkPipelineOfflineCreateInfo& v) 128e5c31af7Sopenharmony_ci{ 129e5c31af7Sopenharmony_ci string input; 130e5c31af7Sopenharmony_ci serializer.Serialize(input); 131e5c31af7Sopenharmony_ci json::Context ctx; 132e5c31af7Sopenharmony_ci json::readJSON_VkPipelineOfflineCreateInfo(ctx, input, v); 133e5c31af7Sopenharmony_ci} 134e5c31af7Sopenharmony_ci 135e5c31af7Sopenharmony_ciinline void SerializeItem(Serializer<ToWrite>& serializer, vk::VkPipelineOfflineCreateInfo& v) 136e5c31af7Sopenharmony_ci{ 137e5c31af7Sopenharmony_ci string output = json::writeJSON_VkPipelineOfflineCreateInfo(v); 138e5c31af7Sopenharmony_ci serializer.Serialize(output); 139e5c31af7Sopenharmony_ci} 140e5c31af7Sopenharmony_ci 141e5c31af7Sopenharmony_ciinline void SerializeItem(Serializer<ToRead>& serializer, vk::VkPhysicalDeviceFeatures2& v) 142e5c31af7Sopenharmony_ci{ 143e5c31af7Sopenharmony_ci string input; 144e5c31af7Sopenharmony_ci serializer.Serialize(input); 145e5c31af7Sopenharmony_ci json::Context ctx; 146e5c31af7Sopenharmony_ci json::readJSON_VkPhysicalDeviceFeatures2(ctx, input, v); 147e5c31af7Sopenharmony_ci} 148e5c31af7Sopenharmony_ci 149e5c31af7Sopenharmony_ciinline void SerializeItem(Serializer<ToWrite>& serializer, vk::VkPhysicalDeviceFeatures2& v) 150e5c31af7Sopenharmony_ci{ 151e5c31af7Sopenharmony_ci string output = json::writeJSON_VkPhysicalDeviceFeatures2(v); 152e5c31af7Sopenharmony_ci serializer.Serialize(output); 153e5c31af7Sopenharmony_ci} 154e5c31af7Sopenharmony_ci 155e5c31af7Sopenharmony_ci} 156e5c31af7Sopenharmony_ci 157e5c31af7Sopenharmony_ci#endif // _VKSSERIALIZERVKSC_HPP 158