Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: Split up chasssis.{h,cpp} #8904

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ vvl_sources = [
"layers/best_practices/bp_synchronization.cpp",
"layers/best_practices/bp_video.cpp",
"layers/best_practices/bp_wsi.cpp",
"layers/chassis/chassis.h",
"layers/chassis/chassis_handle_data.h",
"layers/chassis/chassis_manual.cpp",
"layers/chassis/chassis_modification_state.h",
"layers/chassis/layer_chassis_dispatch_manual.cpp",
"layers/chassis/dispatch_object.h",
"layers/chassis/dispatch_object_manual.cpp",
"layers/chassis/validation_object.h",
"layers/containers/custom_containers.h",
"layers/containers/qfo_transfer.h",
"layers/containers/range_vector.h",
Expand Down Expand Up @@ -347,8 +351,6 @@ vvl_sources = [
"layers/vulkan/generated/best_practices.cpp",
"layers/vulkan/generated/best_practices.h",
"layers/vulkan/generated/chassis.cpp",
"layers/vulkan/generated/chassis.h",
"layers/vulkan/generated/chassis_dispatch_helper.h",
"layers/vulkan/generated/cmd_validation_copy_buffer_to_image_comp.cpp",
"layers/vulkan/generated/cmd_validation_copy_buffer_to_image_comp.h",
"layers/vulkan/generated/cmd_validation_dispatch_comp.cpp",
Expand All @@ -360,6 +362,10 @@ vvl_sources = [
"layers/vulkan/generated/command_validation.cpp",
"layers/vulkan/generated/device_features.cpp",
"layers/vulkan/generated/device_features.h",
"layers/vulkan/generated/dispatch_object.cpp",
"layers/vulkan/generated/dispatch_object_methods.h",
"layers/vulkan/generated/dispatch_vector.cpp",
"layers/vulkan/generated/dispatch_vector.h",
"layers/vulkan/generated/dynamic_state_helper.cpp",
"layers/vulkan/generated/dynamic_state_helper.h",
"layers/vulkan/generated/enum_flag_bits.h",
Expand All @@ -381,8 +387,6 @@ vvl_sources = [
"layers/vulkan/generated/instrumentation_ray_query_comp.h",
"layers/vulkan/generated/instrumentation_post_process_descriptor_index_comp.cpp",
"layers/vulkan/generated/instrumentation_post_process_descriptor_index_comp.h",
"layers/vulkan/generated/layer_chassis_dispatch.cpp",
"layers/vulkan/generated/layer_chassis_dispatch.h",
"layers/vulkan/generated/object_tracker.cpp",
"layers/vulkan/generated/object_tracker.h",
"layers/vulkan/generated/pnext_chain_extraction.cpp",
Expand All @@ -403,6 +407,8 @@ vvl_sources = [
"layers/vulkan/generated/valid_enum_values.cpp",
"layers/vulkan/generated/valid_enum_values.h",
"layers/vulkan/generated/valid_flag_values.cpp",
"layers/vulkan/generated/validation_object.cpp",
"layers/vulkan/generated/validation_object_methods.h",
"layers/vulkan/generated/vk_api_version.h",
"layers/vulkan/generated/vk_api_version.h",
"layers/vulkan/generated/vk_dispatch_table_helper.cpp",
Expand Down
6 changes: 3 additions & 3 deletions docs/generated_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ NOTE: `VVL_CODEGEN` is `OFF` by default to allow users to build `VVL` via `add_s
If only dealing with a single file, run `scripts/generate_source.py` with `--target`

```bash
# Example - only generates chassis.h
scripts/generate_source.py external/Vulkan-Headers/registry/ external/SPIRV-Headers/include/spirv/unified1/ --target chassis.h
# Example - only generates chassis.cpp
scripts/generate_source.py external/Vulkan-Headers/registry/ external/SPIRV-Headers/include/spirv/unified1/ --target chassis.cpp
```

# Adding and Editing code generation
Expand Down Expand Up @@ -177,4 +177,4 @@ The `VulkanObject` makes use of the [Python 3.7 Dataclasses](https://docs.python
If a developer needs something new, it can be added in the `VulkanObject` class. This provides 2 large advantages

1. Code to create a container around the XML is properly reused between scripts
2. Only one file (`base_generator.py`) use to understand the inner working of the `registry`. A developer can just view the `vulkan_object.py` file to see what it can grab in the single pass
2. Only one file (`base_generator.py`) use to understand the inner working of the `registry`. A developer can just view the `vulkan_object.py` file to see what it can grab in the single pass
7 changes: 5 additions & 2 deletions layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ target_sources(vvl PRIVATE
best_practices/bp_wsi.cpp
best_practices/best_practices_validation.h
chassis/chassis_modification_state.h
chassis/layer_chassis_dispatch_manual.cpp
chassis/chassis_manual.cpp
chassis/dispatch_object_manual.cpp
containers/qfo_transfer.h
containers/range_vector.h
containers/subresource_adapter.cpp
Expand Down Expand Up @@ -202,7 +203,9 @@ target_sources(vvl PRIVATE
${API_TYPE}/generated/dynamic_state_helper.cpp
${API_TYPE}/generated/dynamic_state_helper.h
${API_TYPE}/generated/enum_flag_bits.h
${API_TYPE}/generated/layer_chassis_dispatch.cpp
${API_TYPE}/generated/dispatch_vector.cpp
${API_TYPE}/generated/dispatch_object.cpp
${API_TYPE}/generated/validation_object.cpp
${API_TYPE}/generated/object_tracker.cpp
${API_TYPE}/generated/object_tracker.h
${API_TYPE}/generated/spirv_grammar_helper.cpp
Expand Down
2 changes: 1 addition & 1 deletion layers/best_practices/best_practices_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

#include "generated/chassis.h"
#include "chassis/validation_object.h"
#include "state_tracker/state_tracker.h"
#include "state_tracker/cmd_buffer_state.h"
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion layers/best_practices/bp_instance_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

#include "best_practices/best_practices_validation.h"
#include "generated/layer_chassis_dispatch.h"
#include "generated/dispatch_functions.h"
#include "best_practices/bp_state.h"
#include "state_tracker/queue_state.h"

Expand Down
89 changes: 89 additions & 0 deletions layers/chassis/chassis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/***************************************************************************
*
* Copyright (c) 2015-2024 The Khronos Group Inc.
* Copyright (c) 2015-2024 Valve Corporation
* Copyright (c) 2015-2024 LunarG, Inc.
* Copyright (c) 2015-2024 Google Inc.
* Copyright (c) 2023-2024 RasterGrid Kft.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
****************************************************************************/
#include <vulkan/vulkan.h>

namespace vulkan_layer_chassis {
typedef enum ApiFunctionType { kFuncTypeInst = 0, kFuncTypePdev = 1, kFuncTypeDev = 2 } ApiFunctionType;
typedef struct {
ApiFunctionType function_type;
void* funcptr;
} function_data;

// Manually written functions referenced from generated code in chassis.cpp

VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char* funcName);
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char* funcName);
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char* funcName);

VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t* pCount, VkLayerProperties* pProperties);
VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t* pCount,
VkLayerProperties* pProperties);

VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
VkInstance* pInstance);
VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator);

VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator, VkDevice* pDevice);
VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator);

VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
const VkGraphicsPipelineCreateInfo* pCreateInfos,
const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
const VkComputePipelineCreateInfo* pCreateInfos,
const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
VKAPI_ATTR VkResult VKAPI_CALL CreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
const VkRayTracingPipelineCreateInfoNV* pCreateInfos,
const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
VKAPI_ATTR VkResult VKAPI_CALL CreateRayTracingPipelinesKHR(VkDevice device, VkDeferredOperationKHR deferredOperation,
VkPipelineCache pipelineCache, uint32_t createInfoCount,
const VkRayTracingPipelineCreateInfoKHR* pCreateInfos,
const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
VKAPI_ATTR VkResult VKAPI_CALL CreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout);
VKAPI_ATTR VkResult VKAPI_CALL CreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule);
VKAPI_ATTR VkResult VKAPI_CALL CreateShadersEXT(VkDevice device, uint32_t createInfoCount,
const VkShaderCreateInfoEXT* pCreateInfos, const VkAllocationCallbacks* pAllocator,
VkShaderEXT* pShaders);
VKAPI_ATTR VkResult VKAPI_CALL AllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo,
VkDescriptorSet* pDescriptorSets);
VKAPI_ATTR VkResult VKAPI_CALL CreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer);
VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* pPresentInfo);
VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo);
VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceToolPropertiesEXT(VkPhysicalDevice physicalDevice, uint32_t* pToolCount,
VkPhysicalDeviceToolPropertiesEXT* pToolProperties);
VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceToolProperties(VkPhysicalDevice physicalDevice, uint32_t* pToolCount,
VkPhysicalDeviceToolProperties* pToolProperties);
VKAPI_ATTR VkResult VKAPI_CALL CreateValidationCacheEXT(VkDevice device, const VkValidationCacheCreateInfoEXT* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkValidationCacheEXT* pValidationCache);
VKAPI_ATTR void VKAPI_CALL DestroyValidationCacheEXT(VkDevice device, VkValidationCacheEXT validationCache,
const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL MergeValidationCachesEXT(VkDevice device, VkValidationCacheEXT dstCache, uint32_t srcCacheCount,
const VkValidationCacheEXT* pSrcCaches);
VKAPI_ATTR VkResult VKAPI_CALL GetValidationCacheDataEXT(VkDevice device, VkValidationCacheEXT validationCache, size_t* pDataSize,
void* pData);
VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount,
VkPhysicalDevice* pPhysicalDevices);
} // namespace vulkan_layer_chassis
Loading