Skip to content

Commit 5dab34f

Browse files
Merge pull request #143 from GPUOpen-LibrariesAndSDKs/update_wk13_2
Bug-fixes
2 parents e8c0154 + 550b5b8 commit 5dab34f

19 files changed

Lines changed: 126 additions & 55 deletions

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ endif()
2222

2323
# Do not modify anything after this line, unless you know what you're doing.
2424

25+
if (NOT MSVC)
26+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
27+
endif()
28+
2529
configure_file("include/config.h.in" "include/config.h")
2630

2731
include_directories("${Anvil_BINARY_DIR}/include"

include/misc/debug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <functional>
2828

2929

30-
#ifdef _DEBUG
30+
#if defined(_DEBUG)
3131
#define anvil_assert(assertion) \
3232
if (!(assertion)) \
3333
{ \
@@ -87,4 +87,4 @@ namespace Anvil
8787
void set_assertion_failure_handler(AssertionFailedCallbackFunction in_new_callback_func);
8888
};
8989

90-
#endif /* MISC_DEBUG_H */
90+
#endif /* MISC_DEBUG_H */

include/misc/external_handle.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,20 @@ namespace Anvil
4040
return m_handle;
4141
}
4242

43-
#if defined(_WIN32)
44-
/* If a payload of an object exported to a NT handle is imported to another object, the ownership is passed
45-
* to the new object.
46-
*
47-
* For NT handles, it is assumed the handle should be destroyed when the wrapper goes out of scope. If the above
48-
* import is performed, you MUST tell ExternalHandleWrapper to release the ownership of the handle, or else anything
49-
* can happen.
50-
*/
51-
void release_ownership()
52-
{
53-
m_close_at_destruction_time = false;
54-
}
55-
#endif
43+
/* If a payload of an object exported to a NT handle is imported to another object, the ownership is passed
44+
* to the new object.
45+
*
46+
* For NT handles, it is assumed the handle should be destroyed when the wrapper goes out of scope. If the above
47+
* import is performed, you MUST tell ExternalHandle to release the ownership of the handle, or else it will leak.
48+
*
49+
* Under Linux, ownership of the underlying FD is transferred to the app at export time, and back to the driver at import time.
50+
* If the wrapper has been created with in_close_at_destruction_time set to true and an exported external handle IS imported,
51+
* you need to call this function in order to avoid double release of the FD.
52+
*/
53+
void release_ownership()
54+
{
55+
m_close_at_destruction_time = false;
56+
}
5657

5758
private:
5859
ExternalHandle(const ExternalHandleType& in_handle,

include/misc/types_classes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ namespace Anvil
374374
{
375375
memory_block_owned_by_image = false;
376376
memory_block_ptr = nullptr;
377+
memory_block_start_offset = UINT32_MAX;
378+
offset.x = 0;
379+
offset.y = 0;
380+
offset.z = 0;
377381
}
378382
} ImageBindInfo;
379383

include/misc/types_struct.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ namespace Anvil
185185
static_assert(offsetof(SurfaceCapabilities, supported_usage_flags) == offsetof(VkSurfaceCapabilitiesKHR, supportedUsageFlags), "Member offsets must match");
186186

187187
/* NOTE: Maps 1:1 to VkImageSubresource */
188-
typedef struct
188+
typedef struct ImageSubresource
189189
{
190190
Anvil::ImageAspectFlags aspect_mask;
191191
uint32_t mip_level;
@@ -201,6 +201,13 @@ namespace Anvil
201201

202202
return result;
203203
}
204+
205+
ImageSubresource()
206+
:array_layer(UINT32_MAX),
207+
mip_level (UINT32_MAX)
208+
{
209+
/* Stub */
210+
}
204211
} ImageSubresource;
205212

206213
static_assert(sizeof(ImageSubresource) == sizeof(VkImageSubresource), "Struct sizes much match");

include/misc/types_utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ namespace Anvil
3131
bool convert_mt_safety_enum_to_boolean(MTSafety in_mt_safety,
3232
const Anvil::BaseDevice* in_device_ptr);
3333

34+
/* NOTE: in_api_version must NOT be Anvil::APIVersion::UNKNOWN */
35+
void get_version_chunks_for_api_version(const Anvil::APIVersion& in_api_version,
36+
uint32_t* out_major_version_ptr,
37+
uint32_t* out_minor_version_ptr);
38+
3439
Anvil::QueueFamilyFlags get_queue_family_flags_from_queue_family_type(Anvil::QueueFamilyType in_queue_family_type);
3540

3641
/** Converts a queue family bitfield value to an array of queue family indices.

src/misc/base_pipeline_manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Anvil::BasePipelineManager::BasePipelineManager(const Anvil::BaseDevice* in_devi
4141
m_pipeline_cache_ptr (nullptr),
4242
m_pipeline_counter (0)
4343
{
44-
anvil_assert(!in_use_pipeline_cache && in_pipeline_cache_to_reuse_ptr == nullptr ||
45-
in_use_pipeline_cache);
44+
anvil_assert((!in_use_pipeline_cache && in_pipeline_cache_to_reuse_ptr == nullptr) ||
45+
in_use_pipeline_cache);
4646

4747
m_pipeline_layout_manager_ptr = in_device_ptr->get_pipeline_layout_manager();
4848
anvil_assert(m_pipeline_layout_manager_ptr != nullptr);

src/misc/debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ void Anvil::on_assertion_failed(const char* in_filename,
7575
void Anvil::set_assertion_failure_handler(Anvil::AssertionFailedCallbackFunction in_new_callback_func)
7676
{
7777
g_anvil_assertion_check_failed_func = in_new_callback_func;
78-
}
78+
}

src/misc/memalloc_backends/backend_oneshot.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ bool Anvil::MemoryAllocatorBackends::OneShot::bake(Anvil::MemoryAllocator::Items
330330
(is_current_item_image && current_item_ptr->image_ptr->get_create_info_ptr()->get_tiling() == Anvil::ImageTiling::LINEAR);
331331

332332
anvil_assert(current_item_ptr->alloc_exportable_external_handle_types == 0);
333-
anvil_assert(current_item_ptr->alloc_external_nt_handle_info_ptr == nullptr);
333+
334+
#if defined(_WIN32)
335+
anvil_assert(current_item_ptr->alloc_external_nt_handle_info_ptr == nullptr);
336+
#endif
334337

335338
n_bytes_required = Anvil::Utils::round_up(n_bytes_required,
336339
current_item_ptr->alloc_memory_required_alignment);

src/misc/memory_allocator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,9 @@ bool Anvil::MemoryAllocator::add_sparse_image_miptail(Anvil::Image*
12051205
anvil_assert(result);
12061206

12071207
/* Even more sanity checks */
1208-
anvil_assert((aspect_props_ptr->flags & Anvil::SparseImageFormatFlagBits::SINGLE_MIPTAIL_BIT) != 0 &&
1209-
in_n_layer == 0 ||
1210-
(aspect_props_ptr->flags & Anvil::SparseImageFormatFlagBits::SINGLE_MIPTAIL_BIT) == 0);
1208+
anvil_assert(((aspect_props_ptr->flags & Anvil::SparseImageFormatFlagBits::SINGLE_MIPTAIL_BIT) != 0 &&
1209+
in_n_layer == 0) ||
1210+
((aspect_props_ptr->flags & Anvil::SparseImageFormatFlagBits::SINGLE_MIPTAIL_BIT) == 0));
12111211

12121212
/* Determine allocation properties */
12131213
miptail_memory_types = in_image_ptr->get_image_memory_types(n_plane);

0 commit comments

Comments
 (0)