diff --git a/layers/layer_chassis_dispatch_manual.cpp b/layers/layer_chassis_dispatch_manual.cpp index d91a002ddf4..6b94c43c50a 100644 --- a/layers/layer_chassis_dispatch_manual.cpp +++ b/layers/layer_chassis_dispatch_manual.cpp @@ -1449,7 +1449,7 @@ VkResult DispatchBuildAccelerationStructuresKHR( if (pInfos) { local_pInfos = new safe_VkAccelerationStructureBuildGeometryInfoKHR[infoCount]; for (uint32_t index0 = 0; index0 < infoCount; ++index0) { - local_pInfos[index0].initialize(&pInfos[index0], true, ppBuildRangeInfos[index0]); + local_pInfos[index0].initialize(&pInfos[index0]); if (pInfos[index0].srcAccelerationStructure) { local_pInfos[index0].srcAccelerationStructure = layer_data->Unwrap(pInfos[index0].srcAccelerationStructure); } @@ -1506,7 +1506,7 @@ void DispatchGetAccelerationStructureBuildSizesKHR( { if (pBuildInfo) { local_pBuildInfo = &var_local_pBuildInfo; - local_pBuildInfo->initialize(pBuildInfo, false, nullptr); + local_pBuildInfo->initialize(pBuildInfo); if (pBuildInfo->srcAccelerationStructure) { local_pBuildInfo->srcAccelerationStructure = layer_data->Unwrap(pBuildInfo->srcAccelerationStructure); } diff --git a/layers/state_tracker/ray_tracing_state.h b/layers/state_tracker/ray_tracing_state.h index 5b7d246ac12..cb7669a1e62 100644 --- a/layers/state_tracker/ray_tracing_state.h +++ b/layers/state_tracker/ray_tracing_state.h @@ -97,10 +97,10 @@ class AccelerationStructureKHR : public StateObject { StateObject::Destroy(); } - void Build(const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, const bool is_host, - const VkAccelerationStructureBuildRangeInfoKHR *build_range_info) { + void Build(const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, const bool, + const VkAccelerationStructureBuildRangeInfoKHR *) { built = true; - build_info_khr.initialize(pInfo, is_host, build_range_info); + build_info_khr.initialize(pInfo); }; void UpdateBuildRangeInfos(const VkAccelerationStructureBuildRangeInfoKHR *p_build_range_infos, uint32_t geometry_count) { diff --git a/layers/vulkan/generated/layer_chassis_dispatch.cpp b/layers/vulkan/generated/layer_chassis_dispatch.cpp index 0d56657d137..77040dac8eb 100644 --- a/layers/vulkan/generated/layer_chassis_dispatch.cpp +++ b/layers/vulkan/generated/layer_chassis_dispatch.cpp @@ -8800,7 +8800,7 @@ void DispatchCmdBuildAccelerationStructuresKHR(VkCommandBuffer commandBuffer, ui if (pInfos) { local_pInfos = new safe_VkAccelerationStructureBuildGeometryInfoKHR[infoCount]; for (uint32_t index0 = 0; index0 < infoCount; ++index0) { - local_pInfos[index0].initialize(&pInfos[index0], false, nullptr); + local_pInfos[index0].initialize(&pInfos[index0]); if (pInfos[index0].srcAccelerationStructure) { local_pInfos[index0].srcAccelerationStructure = layer_data->Unwrap(pInfos[index0].srcAccelerationStructure); @@ -8832,7 +8832,7 @@ void DispatchCmdBuildAccelerationStructuresIndirectKHR(VkCommandBuffer commandBu if (pInfos) { local_pInfos = new safe_VkAccelerationStructureBuildGeometryInfoKHR[infoCount]; for (uint32_t index0 = 0; index0 < infoCount; ++index0) { - local_pInfos[index0].initialize(&pInfos[index0], false, nullptr); + local_pInfos[index0].initialize(&pInfos[index0]); if (pInfos[index0].srcAccelerationStructure) { local_pInfos[index0].srcAccelerationStructure = layer_data->Unwrap(pInfos[index0].srcAccelerationStructure); diff --git a/layers/vulkan/generated/vk_safe_struct.h b/layers/vulkan/generated/vk_safe_struct.h index 4b058cca6e7..8411152a7af 100644 --- a/layers/vulkan/generated/vk_safe_struct.h +++ b/layers/vulkan/generated/vk_safe_struct.h @@ -18105,15 +18105,13 @@ struct safe_VkAccelerationStructureGeometryKHR { VkAccelerationStructureGeometryDataKHR geometry; VkGeometryFlagsKHR flags; - safe_VkAccelerationStructureGeometryKHR(const VkAccelerationStructureGeometryKHR* in_struct, const bool is_host, - const VkAccelerationStructureBuildRangeInfoKHR* build_range_info, - PNextCopyState* copy_state = {}, bool copy_pnext = true); + safe_VkAccelerationStructureGeometryKHR(const VkAccelerationStructureGeometryKHR* in_struct, PNextCopyState* copy_state = {}, + bool copy_pnext = true); safe_VkAccelerationStructureGeometryKHR(const safe_VkAccelerationStructureGeometryKHR& copy_src); safe_VkAccelerationStructureGeometryKHR& operator=(const safe_VkAccelerationStructureGeometryKHR& copy_src); safe_VkAccelerationStructureGeometryKHR(); ~safe_VkAccelerationStructureGeometryKHR(); - void initialize(const VkAccelerationStructureGeometryKHR* in_struct, const bool is_host, - const VkAccelerationStructureBuildRangeInfoKHR* build_range_info, PNextCopyState* copy_state = {}); + void initialize(const VkAccelerationStructureGeometryKHR* in_struct, PNextCopyState* copy_state = {}); void initialize(const safe_VkAccelerationStructureGeometryKHR* copy_src, PNextCopyState* copy_state = {}); VkAccelerationStructureGeometryKHR* ptr() { return reinterpret_cast(this); } VkAccelerationStructureGeometryKHR const* ptr() const { @@ -18134,15 +18132,12 @@ struct safe_VkAccelerationStructureBuildGeometryInfoKHR { safe_VkDeviceOrHostAddressKHR scratchData; safe_VkAccelerationStructureBuildGeometryInfoKHR(const VkAccelerationStructureBuildGeometryInfoKHR* in_struct, - const bool is_host, - const VkAccelerationStructureBuildRangeInfoKHR* build_range_infos, PNextCopyState* copy_state = {}, bool copy_pnext = true); safe_VkAccelerationStructureBuildGeometryInfoKHR(const safe_VkAccelerationStructureBuildGeometryInfoKHR& copy_src); safe_VkAccelerationStructureBuildGeometryInfoKHR& operator=(const safe_VkAccelerationStructureBuildGeometryInfoKHR& copy_src); safe_VkAccelerationStructureBuildGeometryInfoKHR(); ~safe_VkAccelerationStructureBuildGeometryInfoKHR(); - void initialize(const VkAccelerationStructureBuildGeometryInfoKHR* in_struct, const bool is_host, - const VkAccelerationStructureBuildRangeInfoKHR* build_range_infos, PNextCopyState* copy_state = {}); + void initialize(const VkAccelerationStructureBuildGeometryInfoKHR* in_struct, PNextCopyState* copy_state = {}); void initialize(const safe_VkAccelerationStructureBuildGeometryInfoKHR* copy_src, PNextCopyState* copy_state = {}); VkAccelerationStructureBuildGeometryInfoKHR* ptr() { return reinterpret_cast(this); diff --git a/layers/vulkan/generated/vk_safe_struct_khr.cpp b/layers/vulkan/generated/vk_safe_struct_khr.cpp index 0af01028852..9fcf7d37809 100644 --- a/layers/vulkan/generated/vk_safe_struct_khr.cpp +++ b/layers/vulkan/generated/vk_safe_struct_khr.cpp @@ -14359,58 +14359,12 @@ void safe_VkAccelerationStructureGeometryInstancesDataKHR::initialize( pNext = SafePnextCopy(copy_src->pNext); } -struct ASGeomKHRExtraData { - ASGeomKHRExtraData(uint8_t* alloc, uint32_t primOffset, uint32_t primCount) - : ptr(alloc), primitiveOffset(primOffset), primitiveCount(primCount) {} - ~ASGeomKHRExtraData() { - if (ptr) delete[] ptr; - } - uint8_t* ptr; - uint32_t primitiveOffset; - uint32_t primitiveCount; -}; - -vl_concurrent_unordered_map as_geom_khr_host_alloc; - safe_VkAccelerationStructureGeometryKHR::safe_VkAccelerationStructureGeometryKHR( - const VkAccelerationStructureGeometryKHR* in_struct, const bool is_host, - const VkAccelerationStructureBuildRangeInfoKHR* build_range_info, [[maybe_unused]] PNextCopyState* copy_state, bool copy_pnext) + const VkAccelerationStructureGeometryKHR* in_struct, [[maybe_unused]] PNextCopyState* copy_state, bool copy_pnext) : sType(in_struct->sType), geometryType(in_struct->geometryType), geometry(in_struct->geometry), flags(in_struct->flags) { if (copy_pnext) { pNext = SafePnextCopy(in_struct->pNext, copy_state); } - if (is_host && geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { - if (geometry.instances.arrayOfPointers) { - size_t pp_array_size = build_range_info->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR*); - size_t p_array_size = build_range_info->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - size_t array_size = build_range_info->primitiveOffset + pp_array_size + p_array_size; - uint8_t* allocation = new uint8_t[array_size]; - VkAccelerationStructureInstanceKHR** ppInstances = - reinterpret_cast(allocation + build_range_info->primitiveOffset); - VkAccelerationStructureInstanceKHR* pInstances = reinterpret_cast( - allocation + build_range_info->primitiveOffset + pp_array_size); - for (uint32_t i = 0; i < build_range_info->primitiveCount; ++i) { - const uint8_t* byte_ptr = reinterpret_cast(in_struct->geometry.instances.data.hostAddress); - pInstances[i] = *( - reinterpret_cast(byte_ptr + build_range_info->primitiveOffset)[i]); - ppInstances[i] = &pInstances[i]; - } - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, build_range_info->primitiveOffset, build_range_info->primitiveCount)); - } else { - const auto primitive_offset = build_range_info->primitiveOffset; - const auto primitive_count = build_range_info->primitiveCount; - size_t array_size = primitive_offset + primitive_count * sizeof(VkAccelerationStructureInstanceKHR); - uint8_t* allocation = new uint8_t[array_size]; - auto host_address = static_cast(in_struct->geometry.instances.data.hostAddress); - memcpy(allocation + primitive_offset, host_address + primitive_offset, - primitive_count * sizeof(VkAccelerationStructureInstanceKHR)); - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, build_range_info->primitiveOffset, build_range_info->primitiveCount)); - } - } } safe_VkAccelerationStructureGeometryKHR::safe_VkAccelerationStructureGeometryKHR() @@ -14422,142 +14376,34 @@ safe_VkAccelerationStructureGeometryKHR::safe_VkAccelerationStructureGeometryKHR geometryType = copy_src.geometryType; geometry = copy_src.geometry; flags = copy_src.flags; - pNext = SafePnextCopy(copy_src.pNext); - auto src_iter = as_geom_khr_host_alloc.find(©_src); - if (src_iter != as_geom_khr_host_alloc.end()) { - auto& src_alloc = src_iter->second; - if (geometry.instances.arrayOfPointers) { - size_t pp_array_size = src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR*); - size_t p_array_size = src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - size_t array_size = src_alloc->primitiveOffset + pp_array_size + p_array_size; - uint8_t* allocation = new uint8_t[array_size]; - VkAccelerationStructureInstanceKHR** ppInstances = - reinterpret_cast(allocation + src_alloc->primitiveOffset); - VkAccelerationStructureInstanceKHR* pInstances = - reinterpret_cast(allocation + src_alloc->primitiveOffset + pp_array_size); - for (uint32_t i = 0; i < src_alloc->primitiveCount; ++i) { - pInstances[i] = - *(reinterpret_cast(src_alloc->ptr + src_alloc->primitiveOffset)[i]); - ppInstances[i] = &pInstances[i]; - } - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, src_alloc->primitiveOffset, src_alloc->primitiveCount)); - } else { - size_t array_size = src_alloc->primitiveOffset + src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - uint8_t* allocation = new uint8_t[array_size]; - memcpy(allocation, src_alloc->ptr, array_size); - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, src_alloc->primitiveOffset, src_alloc->primitiveCount)); - } - } } safe_VkAccelerationStructureGeometryKHR& safe_VkAccelerationStructureGeometryKHR::operator=( const safe_VkAccelerationStructureGeometryKHR& copy_src) { if (©_src == this) return *this; - auto iter = as_geom_khr_host_alloc.pop(this); - if (iter != as_geom_khr_host_alloc.end()) { - delete iter->second; - } FreePnextChain(pNext); sType = copy_src.sType; geometryType = copy_src.geometryType; geometry = copy_src.geometry; flags = copy_src.flags; - pNext = SafePnextCopy(copy_src.pNext); - auto src_iter = as_geom_khr_host_alloc.find(©_src); - if (src_iter != as_geom_khr_host_alloc.end()) { - auto& src_alloc = src_iter->second; - if (geometry.instances.arrayOfPointers) { - size_t pp_array_size = src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR*); - size_t p_array_size = src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - size_t array_size = src_alloc->primitiveOffset + pp_array_size + p_array_size; - uint8_t* allocation = new uint8_t[array_size]; - VkAccelerationStructureInstanceKHR** ppInstances = - reinterpret_cast(allocation + src_alloc->primitiveOffset); - VkAccelerationStructureInstanceKHR* pInstances = - reinterpret_cast(allocation + src_alloc->primitiveOffset + pp_array_size); - for (uint32_t i = 0; i < src_alloc->primitiveCount; ++i) { - pInstances[i] = - *(reinterpret_cast(src_alloc->ptr + src_alloc->primitiveOffset)[i]); - ppInstances[i] = &pInstances[i]; - } - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, src_alloc->primitiveOffset, src_alloc->primitiveCount)); - } else { - size_t array_size = src_alloc->primitiveOffset + src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - uint8_t* allocation = new uint8_t[array_size]; - memcpy(allocation, src_alloc->ptr, array_size); - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, src_alloc->primitiveOffset, src_alloc->primitiveCount)); - } - } return *this; } -safe_VkAccelerationStructureGeometryKHR::~safe_VkAccelerationStructureGeometryKHR() { - auto iter = as_geom_khr_host_alloc.pop(this); - if (iter != as_geom_khr_host_alloc.end()) { - delete iter->second; - } - FreePnextChain(pNext); -} +safe_VkAccelerationStructureGeometryKHR::~safe_VkAccelerationStructureGeometryKHR() { FreePnextChain(pNext); } -void safe_VkAccelerationStructureGeometryKHR::initialize(const VkAccelerationStructureGeometryKHR* in_struct, const bool is_host, - const VkAccelerationStructureBuildRangeInfoKHR* build_range_info, +void safe_VkAccelerationStructureGeometryKHR::initialize(const VkAccelerationStructureGeometryKHR* in_struct, [[maybe_unused]] PNextCopyState* copy_state) { - auto iter = as_geom_khr_host_alloc.pop(this); - if (iter != as_geom_khr_host_alloc.end()) { - delete iter->second; - } FreePnextChain(pNext); sType = in_struct->sType; geometryType = in_struct->geometryType; geometry = in_struct->geometry; flags = in_struct->flags; pNext = SafePnextCopy(in_struct->pNext, copy_state); - - if (is_host && geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { - if (geometry.instances.arrayOfPointers) { - size_t pp_array_size = build_range_info->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR*); - size_t p_array_size = build_range_info->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - size_t array_size = build_range_info->primitiveOffset + pp_array_size + p_array_size; - uint8_t* allocation = new uint8_t[array_size]; - VkAccelerationStructureInstanceKHR** ppInstances = - reinterpret_cast(allocation + build_range_info->primitiveOffset); - VkAccelerationStructureInstanceKHR* pInstances = reinterpret_cast( - allocation + build_range_info->primitiveOffset + pp_array_size); - for (uint32_t i = 0; i < build_range_info->primitiveCount; ++i) { - const uint8_t* byte_ptr = reinterpret_cast(in_struct->geometry.instances.data.hostAddress); - pInstances[i] = *( - reinterpret_cast(byte_ptr + build_range_info->primitiveOffset)[i]); - ppInstances[i] = &pInstances[i]; - } - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, build_range_info->primitiveOffset, build_range_info->primitiveCount)); - } else { - const auto primitive_offset = build_range_info->primitiveOffset; - const auto primitive_count = build_range_info->primitiveCount; - size_t array_size = primitive_offset + primitive_count * sizeof(VkAccelerationStructureInstanceKHR); - uint8_t* allocation = new uint8_t[array_size]; - auto host_address = static_cast(in_struct->geometry.instances.data.hostAddress); - memcpy(allocation + primitive_offset, host_address + primitive_offset, - primitive_count * sizeof(VkAccelerationStructureInstanceKHR)); - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, build_range_info->primitiveOffset, build_range_info->primitiveCount)); - } - } } void safe_VkAccelerationStructureGeometryKHR::initialize(const safe_VkAccelerationStructureGeometryKHR* copy_src, @@ -14566,42 +14412,11 @@ void safe_VkAccelerationStructureGeometryKHR::initialize(const safe_VkAccelerati geometryType = copy_src->geometryType; geometry = copy_src->geometry; flags = copy_src->flags; - pNext = SafePnextCopy(copy_src->pNext); - auto src_iter = as_geom_khr_host_alloc.find(copy_src); - if (src_iter != as_geom_khr_host_alloc.end()) { - auto& src_alloc = src_iter->second; - if (geometry.instances.arrayOfPointers) { - size_t pp_array_size = src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR*); - size_t p_array_size = src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - size_t array_size = src_alloc->primitiveOffset + pp_array_size + p_array_size; - uint8_t* allocation = new uint8_t[array_size]; - VkAccelerationStructureInstanceKHR** ppInstances = - reinterpret_cast(allocation + src_alloc->primitiveOffset); - VkAccelerationStructureInstanceKHR* pInstances = - reinterpret_cast(allocation + src_alloc->primitiveOffset + pp_array_size); - for (uint32_t i = 0; i < src_alloc->primitiveCount; ++i) { - pInstances[i] = - *(reinterpret_cast(src_alloc->ptr + src_alloc->primitiveOffset)[i]); - ppInstances[i] = &pInstances[i]; - } - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, src_alloc->primitiveOffset, src_alloc->primitiveCount)); - } else { - size_t array_size = src_alloc->primitiveOffset + src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - uint8_t* allocation = new uint8_t[array_size]; - memcpy(allocation, src_alloc->ptr, array_size); - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert( - this, new ASGeomKHRExtraData(allocation, src_alloc->primitiveOffset, src_alloc->primitiveCount)); - } - } } safe_VkAccelerationStructureBuildGeometryInfoKHR::safe_VkAccelerationStructureBuildGeometryInfoKHR( - const VkAccelerationStructureBuildGeometryInfoKHR* in_struct, const bool is_host, - const VkAccelerationStructureBuildRangeInfoKHR* build_range_infos, [[maybe_unused]] PNextCopyState* copy_state, bool copy_pnext) + const VkAccelerationStructureBuildGeometryInfoKHR* in_struct, [[maybe_unused]] PNextCopyState* copy_state, bool copy_pnext) : sType(in_struct->sType), type(in_struct->type), flags(in_struct->flags), @@ -14619,14 +14434,12 @@ safe_VkAccelerationStructureBuildGeometryInfoKHR::safe_VkAccelerationStructureBu if (in_struct->ppGeometries) { ppGeometries = new safe_VkAccelerationStructureGeometryKHR*[geometryCount]; for (uint32_t i = 0; i < geometryCount; ++i) { - ppGeometries[i] = - new safe_VkAccelerationStructureGeometryKHR(in_struct->ppGeometries[i], is_host, &build_range_infos[i]); + ppGeometries[i] = new safe_VkAccelerationStructureGeometryKHR(in_struct->ppGeometries[i]); } } else { pGeometries = new safe_VkAccelerationStructureGeometryKHR[geometryCount]; for (uint32_t i = 0; i < geometryCount; ++i) { - (pGeometries)[i] = - safe_VkAccelerationStructureGeometryKHR(&(in_struct->pGeometries)[i], is_host, &build_range_infos[i]); + (pGeometries)[i] = safe_VkAccelerationStructureGeometryKHR(&(in_struct->pGeometries)[i]); } } } @@ -14727,8 +14540,6 @@ safe_VkAccelerationStructureBuildGeometryInfoKHR::~safe_VkAccelerationStructureB } void safe_VkAccelerationStructureBuildGeometryInfoKHR::initialize(const VkAccelerationStructureBuildGeometryInfoKHR* in_struct, - const bool is_host, - const VkAccelerationStructureBuildRangeInfoKHR* build_range_infos, [[maybe_unused]] PNextCopyState* copy_state) { if (ppGeometries) { for (uint32_t i = 0; i < geometryCount; ++i) { @@ -14755,14 +14566,12 @@ void safe_VkAccelerationStructureBuildGeometryInfoKHR::initialize(const VkAccele if (in_struct->ppGeometries) { ppGeometries = new safe_VkAccelerationStructureGeometryKHR*[geometryCount]; for (uint32_t i = 0; i < geometryCount; ++i) { - ppGeometries[i] = - new safe_VkAccelerationStructureGeometryKHR(in_struct->ppGeometries[i], is_host, &build_range_infos[i]); + ppGeometries[i] = new safe_VkAccelerationStructureGeometryKHR(in_struct->ppGeometries[i]); } } else { pGeometries = new safe_VkAccelerationStructureGeometryKHR[geometryCount]; for (uint32_t i = 0; i < geometryCount; ++i) { - (pGeometries)[i] = - safe_VkAccelerationStructureGeometryKHR(&(in_struct->pGeometries)[i], is_host, &build_range_infos[i]); + (pGeometries)[i] = safe_VkAccelerationStructureGeometryKHR(&(in_struct->pGeometries)[i]); } } } diff --git a/scripts/generators/layer_chassis_dispatch_generator.py b/scripts/generators/layer_chassis_dispatch_generator.py index dbe13b718a0..bc328346def 100644 --- a/scripts/generators/layer_chassis_dispatch_generator.py +++ b/scripts/generators/layer_chassis_dispatch_generator.py @@ -424,7 +424,7 @@ def uniquifyMembers(self, members: list[Member], prefix: str, arrayIndex: int, i if 'safe_' in safe_type: # Handle special initialize function for VkAccelerationStructureBuildGeometryInfoKHR if member.type == "VkAccelerationStructureBuildGeometryInfoKHR": - pre_code += f'{new_prefix}[{index}].initialize(&{member.name}[{index}], false, nullptr);\n' + pre_code += f'{new_prefix}[{index}].initialize(&{member.name}[{index}]);\n' else: pre_code += f'{new_prefix}[{index}].initialize(&{member.name}[{index}]);\n' else: @@ -463,7 +463,7 @@ def uniquifyMembers(self, members: list[Member], prefix: str, arrayIndex: int, i if 'safe_' in safe_type: # Handle special initialize function for VkAccelerationStructureBuildGeometryInfoKHR if member.type == "VkAccelerationStructureBuildGeometryInfoKHR": - pre_code += f'local_{prefix}{member.name}->initialize({member.name}, false, nullptr);\n' + pre_code += f'local_{prefix}{member.name}->initialize({member.name});\n' else: pre_code += f'local_{prefix}{member.name}->initialize({member.name});\n' else: diff --git a/scripts/generators/safe_struct_generator.py b/scripts/generators/safe_struct_generator.py index b15b8e9c3a9..4332d520f2f 100644 --- a/scripts/generators/safe_struct_generator.py +++ b/scripts/generators/safe_struct_generator.py @@ -47,12 +47,6 @@ def __init__(self): # safe_VkPipelineViewportStateCreateInfo needs to know if viewport and scissor is dynamic to use its pointers 'VkPipelineViewportStateCreateInfo' : ', const bool is_dynamic_viewports, const bool is_dynamic_scissors', - # safe_VkAccelerationStructureBuildGeometryInfoKHR needs to know if we're doing a host or device build - 'VkAccelerationStructureBuildGeometryInfoKHR' : - ', const bool is_host, const VkAccelerationStructureBuildRangeInfoKHR *build_range_infos', - # safe_VkAccelerationStructureGeometryKHR needs to know if we're doing a host or device build - 'VkAccelerationStructureGeometryKHR' : - ', const bool is_host, const VkAccelerationStructureBuildRangeInfoKHR *build_range_info', # safe_VkDescriptorDataEXT needs to know what field of union is intialized 'VkDescriptorDataEXT' : ', const VkDescriptorType type', @@ -358,28 +352,6 @@ def generateSource(self): #include ''') - custom_definitions = { - # as_geom_khr_host_alloc maps a VkAccelerationStructureGeometryKHR to its host allocated instance array, if the user supplied such an array. - 'VkAccelerationStructureGeometryKHR': ''' - struct ASGeomKHRExtraData { - ASGeomKHRExtraData(uint8_t *alloc, uint32_t primOffset, uint32_t primCount) : - ptr(alloc), - primitiveOffset(primOffset), - primitiveCount(primCount) - {} - ~ASGeomKHRExtraData() { - if (ptr) - delete[] ptr; - } - uint8_t *ptr; - uint32_t primitiveOffset; - uint32_t primitiveCount; - }; - - vl_concurrent_unordered_map as_geom_khr_host_alloc; - ''' - } - custom_defeault_construct_txt = { 'VkDescriptorDataEXT' : ''' VkDescriptorType* pType = (VkDescriptorType*)&type_at_end[sizeof(VkDescriptorDataEXT)]; @@ -544,44 +516,16 @@ def generateSource(self): if ( in_struct->ppGeometries) { ppGeometries = new safe_VkAccelerationStructureGeometryKHR *[geometryCount]; for (uint32_t i = 0; i < geometryCount; ++i) { - ppGeometries[i] = new safe_VkAccelerationStructureGeometryKHR(in_struct->ppGeometries[i], is_host, &build_range_infos[i]); + ppGeometries[i] = new safe_VkAccelerationStructureGeometryKHR(in_struct->ppGeometries[i]); } } else { pGeometries = new safe_VkAccelerationStructureGeometryKHR[geometryCount]; for (uint32_t i = 0; i < geometryCount; ++i) { - (pGeometries)[i] = safe_VkAccelerationStructureGeometryKHR(&(in_struct->pGeometries)[i], is_host, &build_range_infos[i]); + (pGeometries)[i] = safe_VkAccelerationStructureGeometryKHR(&(in_struct->pGeometries)[i]); } } } ''', - 'VkAccelerationStructureGeometryKHR': ''' - if (is_host && geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { - if (geometry.instances.arrayOfPointers) { - size_t pp_array_size = build_range_info->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR*); - size_t p_array_size = build_range_info->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - size_t array_size = build_range_info->primitiveOffset + pp_array_size + p_array_size; - uint8_t *allocation = new uint8_t[array_size]; - VkAccelerationStructureInstanceKHR **ppInstances = reinterpret_cast(allocation + build_range_info->primitiveOffset); - VkAccelerationStructureInstanceKHR *pInstances = reinterpret_cast(allocation + build_range_info->primitiveOffset + pp_array_size); - for (uint32_t i = 0; i < build_range_info->primitiveCount; ++i) { - const uint8_t *byte_ptr = reinterpret_cast(in_struct->geometry.instances.data.hostAddress); - pInstances[i] = *(reinterpret_cast(byte_ptr + build_range_info->primitiveOffset)[i]); - ppInstances[i] = &pInstances[i]; - } - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert(this, new ASGeomKHRExtraData(allocation, build_range_info->primitiveOffset, build_range_info->primitiveCount)); - } else { - const auto primitive_offset = build_range_info->primitiveOffset; - const auto primitive_count = build_range_info->primitiveCount; - size_t array_size = primitive_offset + primitive_count * sizeof(VkAccelerationStructureInstanceKHR); - uint8_t *allocation = new uint8_t[array_size]; - auto host_address = static_cast(in_struct->geometry.instances.data.hostAddress); - memcpy(allocation + primitive_offset, host_address + primitive_offset, primitive_count * sizeof(VkAccelerationStructureInstanceKHR)); - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert(this, new ASGeomKHRExtraData(allocation, build_range_info->primitiveOffset, build_range_info->primitiveCount)); - } - } - ''', 'VkMicromapBuildInfoEXT': ''' if (in_struct->pUsageCounts) { pUsageCounts = new VkMicromapUsageEXT[in_struct->usageCountsCount]; @@ -763,33 +707,6 @@ def generateSource(self): } } ''', - 'VkAccelerationStructureGeometryKHR': ''' - pNext = SafePnextCopy(copy_src.pNext); - auto src_iter = as_geom_khr_host_alloc.find(©_src); - if (src_iter != as_geom_khr_host_alloc.end()) { - auto &src_alloc = src_iter->second; - if (geometry.instances.arrayOfPointers) { - size_t pp_array_size = src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR*); - size_t p_array_size = src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - size_t array_size = src_alloc->primitiveOffset + pp_array_size + p_array_size; - uint8_t *allocation = new uint8_t[array_size]; - VkAccelerationStructureInstanceKHR **ppInstances = reinterpret_cast(allocation + src_alloc->primitiveOffset); - VkAccelerationStructureInstanceKHR *pInstances = reinterpret_cast(allocation + src_alloc->primitiveOffset + pp_array_size); - for (uint32_t i = 0; i < src_alloc->primitiveCount; ++i) { - pInstances[i] = *(reinterpret_cast(src_alloc->ptr + src_alloc->primitiveOffset)[i]); - ppInstances[i] = &pInstances[i]; - } - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert(this, new ASGeomKHRExtraData(allocation, src_alloc->primitiveOffset, src_alloc->primitiveCount)); - } else { - size_t array_size = src_alloc->primitiveOffset + src_alloc->primitiveCount * sizeof(VkAccelerationStructureInstanceKHR); - uint8_t *allocation = new uint8_t[array_size]; - memcpy(allocation, src_alloc->ptr, array_size); - geometry.instances.data.hostAddress = allocation; - as_geom_khr_host_alloc.insert(this, new ASGeomKHRExtraData(allocation, src_alloc->primitiveOffset, src_alloc->primitiveCount)); - } - } - ''', 'VkDescriptorDataEXT' : ''' VkDescriptorType* pType = (VkDescriptorType*)&type_at_end[sizeof(VkDescriptorDataEXT)]; VkDescriptorType type = *(VkDescriptorType*)©_src.type_at_end[sizeof(VkDescriptorDataEXT)]; @@ -837,12 +754,6 @@ def generateSource(self): delete[] pGeometries; } ''', - 'VkAccelerationStructureGeometryKHR': ''' - auto iter = as_geom_khr_host_alloc.pop(this); - if (iter != as_geom_khr_host_alloc.end()) { - delete iter->second; - } - ''', 'VkMicromapBuildInfoEXT': ''' if (pUsageCounts) delete[] pUsageCounts; @@ -1105,9 +1016,6 @@ def qfi_construct(item, member): if '' != init_list: init_list = init_list[:-1] # hack off final comma - if struct.name in custom_definitions: - out.append(custom_definitions[struct.name]) - if struct.name in custom_construct_txt: construct_txt = custom_construct_txt[struct.name]