diff --git a/src/gfxstream/codegen/scripts/cereal/decoder.py b/src/gfxstream/codegen/scripts/cereal/decoder.py index 0f57215be53..9d49808e00f 100644 --- a/src/gfxstream/codegen/scripts/cereal/decoder.py +++ b/src/gfxstream/codegen/scripts/cereal/decoder.py @@ -48,6 +48,7 @@ class IOStream; } // namespace gfxstream namespace gfxstream { +namespace host { namespace vk { class VkDecoder { @@ -63,12 +64,14 @@ private: }; } // namespace vk +} // namespace host } // namespace gfxstream """ decoder_impl_preamble =""" namespace gfxstream { +namespace host { namespace vk { class VkDecoder::Impl { @@ -129,6 +132,7 @@ size_t VkDecoder::decode(void* buf, size_t bufsize, IOStream* stream, decoder_impl_postamble = """ } // namespace vk +} // namespace host } // namespace gfxstream """ diff --git a/src/gfxstream/codegen/scripts/cereal/decodersnapshot.py b/src/gfxstream/codegen/scripts/cereal/decodersnapshot.py index b4aa20bada4..87303303b65 100644 --- a/src/gfxstream/codegen/scripts/cereal/decodersnapshot.py +++ b/src/gfxstream/codegen/scripts/cereal/decodersnapshot.py @@ -18,7 +18,7 @@ decoder_snapshot_decl_preamble = """ namespace gfxstream { class Stream; -} // namespace gfxstream +} // namespace gfxstream namespace gfxstream { namespace base { @@ -27,6 +27,7 @@ class BumpPool; } // namespace gfxstream namespace gfxstream { +namespace host { namespace vk { class VkDecoderSnapshot { @@ -56,12 +57,14 @@ decoder_snapshot_decl_postamble = """ }; } // namespace vk +} // namespace host } // namespace gfxstream """ decoder_snapshot_impl_preamble =""" namespace gfxstream { +namespace host { namespace vk { class VkDecoderSnapshot::Impl { @@ -139,6 +142,7 @@ VkDecoderSnapshot::~VkDecoderSnapshot() = default; decoder_snapshot_namespace_postamble = """ } // namespace vk +} // namespace host } // namespace gfxstream """ diff --git a/src/gfxstream/codegen/scripts/cerealgenerator.py b/src/gfxstream/codegen/scripts/cerealgenerator.py index e3dd0f1d08f..a171af83641 100644 --- a/src/gfxstream/codegen/scripts/cerealgenerator.py +++ b/src/gfxstream/codegen/scripts/cerealgenerator.py @@ -158,8 +158,8 @@ SUPPORTED_FEATURES = [ HOST_MODULES = ["goldfish_vk_extension_structs", "goldfish_vk_marshaling", "goldfish_vk_reserved_marshaling", "goldfish_vk_deepcopy", - "goldfish_vk_dispatch", "goldfish_vk_transform", "VkDecoder", - "VkDecoderSnapshot", "VkSubDecoder"] + "goldfish_vk_dispatch", "goldfish_vk_transform", "vk_decoder", + "vk_decoder_snapshot", "vk_sub_decoder"] # By default, the all wrappers are run all on all features. In certain cases, # we wish run wrappers when the module requires it. For example, `VK_GOOGLE_gfxstream` @@ -257,6 +257,18 @@ autogeneratedHeaderTemplate = """ // python3 $VULKAN_REGISTRY_SCRIPTS_DIR/genvk.py -registry $VULKAN_REGISTRY_XML_DIR/vk.xml cereal -o $CEREAL_OUTPUT_DIR // """ +namespaceHostBegin =""" +namespace gfxstream { +namespace host { +namespace vk {\n +""" + +namespaceHostEnd = """ +} // namespace vk +} // namespace host +} // namespace gfxstream +""" + namespaceBegin =""" namespace gfxstream { namespace vk {\n @@ -415,7 +427,7 @@ class IOStream; """ % VULKAN_STREAM_TYPE_GUEST reservedMarshalingHostIncludes = """ -#include "VulkanBoxedHandles.h" +#include "vulkan_boxed_handles.h" """ @@ -426,10 +438,9 @@ class IOStream; vulkanStreamIncludeHost = f""" {self.hostCommonExtraVulkanHeaders} #include "goldfish_vk_private_defs.h" - -#include "%s.h" #include "gfxstream/host/stream_utils.h" -""" % VULKAN_STREAM_TYPE +#include "vulkan_stream.h" +""" poolInclude = f""" {self.hostCommonExtraVulkanHeaders} @@ -450,14 +461,14 @@ using gfxstream::base::BumpPool; #include "ResourceTracker.h" """ transformImplInclude = """ -#include "VkDecoderGlobalState.h" +#include "vk_decoder_global_state.h" """ deepcopyInclude = """ #include "vk_util.h" """ deepcopyHostInclude = """ -#include "VkUtils.h" +#include "vk_utils.h" """ poolIncludeGuest = f""" @@ -476,11 +487,13 @@ using gfxstream::aemu::BumpPool; {self.hostCommonExtraVulkanHeaders} #include "goldfish_vk_private_defs.h" namespace gfxstream {{ +namespace host {{ namespace vk {{ struct VulkanDispatch; }} // namespace vk +}} // namespace host }} // namespace gfxstream using DlOpenFunc = void* (void); using DlSymFunc = void* (void*, const char*); @@ -531,22 +544,22 @@ using DlSymFunc = void* (void*, const char*); decoderSnapshotHeaderIncludes = f""" #include -#include "VkSnapshotHandles.h" #include "gfxstream/host/GfxApiLogger.h" #include "goldfish_vk_private_defs.h" +#include "vk_snapshot_handles.h" """ decoderSnapshotImplIncludes = f""" #include -#include "VulkanBoxedHandles.h" -#include "VulkanHandleMapping.h" -#include "VkDecoderGlobalState.h" -#include "VkReconstruction.h" #include "gfxstream/ThreadAnnotations.h" +#include "vk_decoder_global_state.h" +#include "vk_reconstruction.h" +#include "vulkan_boxed_handles.h" +#include "vulkan_handle_mapping.h" """ decoderHeaderIncludes = f""" -#include "VkDecoderContext.h" +#include "vk_decoder_context.h" #include "gfxstream/host/ProcessResources.h" #include @@ -560,30 +573,29 @@ class BumpPool; """ decoderImplIncludes = f""" -#include "common/goldfish_vk_marshaling.h" -#include "common/goldfish_vk_reserved_marshaling.h" -#include "goldfish_vk_private_defs.h" -#include "common/goldfish_vk_transform.h" - -#include "gfxstream/BumpPool.h" -#include "gfxstream/system/System.h" -#include "FrameBuffer.h" -#include "gfxstream/host/Tracing.h" -#include "gfxstream/host/iostream.h" -#include "gfxstream/threads/Thread.h" -#include "gfxstream/common/logging.h" -#include "VkDecoderGlobalState.h" -#include "VkDecoderSnapshot.h" - -#include "VulkanBoxedHandles.h" -#include "VulkanDispatch.h" -#include "%s.h" - #include #include #include #include -""" % VULKAN_STREAM_TYPE + +#include "common/goldfish_vk_marshaling.h" +#include "common/goldfish_vk_reserved_marshaling.h" +#include "common/goldfish_vk_transform.h" +#include "frame_buffer.h" +#include "gfxstream/BumpPool.h" +#include "gfxstream/common/logging.h" +#include "gfxstream/host/iostream.h" +#include "gfxstream/host/tracing.h" +#include "gfxstream/system/System.h" +#include "gfxstream/threads/Thread.h" +#include "goldfish_vk_private_defs.h" +#include "vk_decoder_global_state.h" +#include "vk_decoder_snapshot.h" +#include "vulkan_boxed_handles.h" +#include "vulkan_dispatch.h" +#include "vulkan_stream.h" + +""" def createVkExtensionStructureTypePreamble(extensionName: str) -> str: return f""" @@ -674,15 +686,15 @@ class BumpPool; self.addCppModule("common", "goldfish_vk_transform", extraHeader=transformInclude, extraImpl=transformImplInclude) - self.addHostModule("VkDecoder", + self.addHostModule("vk_decoder", extraHeader=decoderHeaderIncludes, extraImpl=decoderImplIncludes, useNamespace=False) - self.addHostModule("VkDecoderSnapshot", + self.addHostModule("vk_decoder_snapshot", extraHeader=decoderSnapshotHeaderIncludes, extraImpl=decoderSnapshotImplIncludes, useNamespace=False) - self.addHostModule("VkSubDecoder", + self.addHostModule("vk_sub_decoder", extraHeader="", extraImpl="", useNamespace=False, @@ -707,9 +719,9 @@ class BumpPool; self.addWrapper(cereal.VulkanDeepcopy, "goldfish_vk_deepcopy") self.addWrapper(cereal.VulkanDispatch, "goldfish_vk_dispatch") self.addWrapper(cereal.VulkanTransform, "goldfish_vk_transform", resourceTrackerTypeName="VkDecoderGlobalState") - self.addWrapper(cereal.VulkanDecoder, "VkDecoder") - self.addWrapper(cereal.VulkanDecoderSnapshot, "VkDecoderSnapshot") - self.addWrapper(cereal.VulkanSubDecoder, "VkSubDecoder") + self.addWrapper(cereal.VulkanDecoder, "vk_decoder") + self.addWrapper(cereal.VulkanDecoderSnapshot, "vk_decoder_snapshot") + self.addWrapper(cereal.VulkanSubDecoder, "vk_sub_decoder") self.addWrapper(cereal.ApiLogDecoder, "ApiLogDecoder") self.addWrapper(cereal.VulkanGfxstreamStructureType, "vulkan_gfxstream_structure_type_host") self.addWrapper(cereal.VulkanAndroidNativeBufferStructureType, @@ -771,8 +783,12 @@ class BumpPool; module.headerPreamble += '#include "vulkan_gfxstream.h"\n' module.headerPreamble += '#include "vk_android_native_buffer_gfxstream.h"\n' module.headerPreamble += extraHeader + '\n' + + usedNamespaceBegin = namespaceHostBegin if self.cerealFlags & VK_CEREAL_FLAG_HOST else namespaceBegin + usedNamespaceEnd = namespaceHostEnd if self.cerealFlags & VK_CEREAL_FLAG_HOST else namespaceEnd + if useNamespace: - module.headerPreamble += namespaceBegin + module.headerPreamble += usedNamespaceBegin module.implPreamble = copyrightHeader module.implPreamble += \ @@ -786,9 +802,10 @@ class BumpPool; module.implPreamble += extraImpl if useNamespace: - module.implPreamble += namespaceBegin - module.implPostamble += namespaceEnd - module.headerPostamble += namespaceEnd + + module.implPreamble += usedNamespaceBegin + module.implPostamble += usedNamespaceEnd + module.headerPostamble += usedNamespaceEnd def addWrapper(self, moduleType, moduleName, **kwargs): if moduleName not in self.modules: