Skip to content
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
48 changes: 32 additions & 16 deletions include/misc/extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,13 @@ namespace Anvil
ValueType khr_surface;

#ifdef _WIN32
ValueType khr_win32_surface;
#if defined(ANVIL_INCLUDE_WIN3264_WINDOW_SYSTEM_SUPPORT)
ValueType khr_win32_surface;
#endif
#else
ValueType khr_xcb_surface;
#if defined(ANVIL_INCLUDE_XCB_WINDOW_SYSTEM_SUPPORT)
ValueType khr_xcb_surface;
#endif
#endif

std::map<std::string, ValueType> values_by_extension_names;
Expand Down Expand Up @@ -198,9 +202,13 @@ namespace Anvil
{ExtensionData(VK_KHR_SURFACE_EXTENSION_NAME, &khr_surface)},

#ifdef _WIN32
{ExtensionData(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, &khr_win32_surface)},
#if defined(ANVIL_INCLUDE_WIN3264_WINDOW_SYSTEM_SUPPORT)
{ExtensionData(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, &khr_win32_surface)},
#endif
#else
{ExtensionData(VK_KHR_XCB_SURFACE_EXTENSION_NAME, &khr_xcb_surface)},
#if defined(ANVIL_INCLUDE_XCB_WINDOW_SYSTEM_SUPPORT)
{ExtensionData(VK_KHR_XCB_SURFACE_EXTENSION_NAME, &khr_xcb_surface)},
#endif
#endif
};

Expand Down Expand Up @@ -291,9 +299,13 @@ namespace Anvil
virtual bool khr_surface () const = 0;

#ifdef _WIN32
virtual bool khr_win32_surface() const = 0;
#if defined(ANVIL_INCLUDE_WIN3264_WINDOW_SYSTEM_SUPPORT)
virtual bool khr_win32_surface() const = 0;
#endif
#else
virtual bool khr_xcb_surface() const = 0;
#if defined(ANVIL_INCLUDE_XCB_WINDOW_SYSTEM_SUPPORT)
virtual bool khr_xcb_surface() const = 0;
#endif
#endif

virtual bool by_name(const std::string& in_name) const = 0;
Expand Down Expand Up @@ -676,19 +688,23 @@ namespace Anvil


#ifdef _WIN32
ValueType khr_win32_surface() const final
{
anvil_assert(!m_expose_device_extensions);
#if defined(ANVIL_INCLUDE_WIN3264_WINDOW_SYSTEM_SUPPORT)
ValueType khr_win32_surface() const final
{
anvil_assert(!m_expose_device_extensions);

return m_instance_extensions_ptr->khr_win32_surface;
}
return m_instance_extensions_ptr->khr_win32_surface;
}
#endif
#else
ValueType khr_xcb_surface() const final
{
anvil_assert(!m_expose_device_extensions);
#if defined(ANVIL_INCLUDE_XCB_WINDOW_SYSTEM_SUPPORT)
ValueType khr_xcb_surface() const final
{
anvil_assert(!m_expose_device_extensions);

return m_instance_extensions_ptr->khr_xcb_surface;
}
return m_instance_extensions_ptr->khr_xcb_surface;
}
#endif
#endif

/* Private variables */
Expand Down
16 changes: 15 additions & 1 deletion include/misc/external_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,25 @@ namespace Anvil
return m_handle;
}

#if defined(_WIN32)
/* If a payload of an object exported to a NT handle is imported to ano ther object, the ownership is passed
* to the new object.
*
* For NT handles, it is assumed the handle should be destroyed when th e wrapper goes out of scope. If the above
* import is performed, you MUST tell ExternalHandleWrapper to release the ownership of the handle, or else anything
* can happen.
*/
void release_ownership()
{
m_close_at_destruction_time = false;
}
#endif

private:
ExternalHandle(const ExternalHandleType& in_handle,
const bool& in_close_at_destruction_time);

const bool m_close_at_destruction_time;
bool m_close_at_destruction_time;
const ExternalHandleType m_handle;

ANVIL_DISABLE_ASSIGNMENT_OPERATOR(ExternalHandle);
Expand Down
3 changes: 0 additions & 3 deletions include/misc/graphics_pipeline_create_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ namespace Anvil

uint32_t get_n_viewports() const;

bool get_pipeline_color_blend_attachment_state(uint32_t in_n_subpass_color_attachment,
VkPipelineColorBlendAttachmentState* out_result_ptr) const;

/** Tells what primitive topology has been specified for this instance. **/
VkPrimitiveTopology get_primitive_topology() const;

Expand Down
4 changes: 1 addition & 3 deletions include/misc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@

/* The following #define is required to include Vulkan entry-point prototype declarations. */
#ifdef _WIN32
#if defined(ANVIL_INCLUDE_WIN3264_WINDOW_SYSTEM_SUPPORT)
#define VK_USE_PLATFORM_WIN32_KHR
#endif
#define VK_USE_PLATFORM_WIN32_KHR
#else
#if defined(ANVIL_INCLUDE_XCB_WINDOW_SYSTEM_SUPPORT)
#define VK_USE_PLATFORM_XCB_KHR
Expand Down
16 changes: 11 additions & 5 deletions include/misc/types_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ namespace Anvil
EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 1 << 0,
EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 1 << 1,
#else
EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT = 1 << 2,
EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT = 1 << 2,
EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT = 1 << 0,
EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT = 1 << 1,
#endif

/* Always last */
EXTERNAL_FENCE_HANDLE_TYPE_COUNT
} ExternalFenceHandleTypeBit;
typedef uint32_t ExternalFenceHandleTypeBits;

Expand All @@ -96,9 +98,11 @@ namespace Anvil
EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT = 1 << 4,
EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT = 1 << 5,
#else
EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT = 1 << 6,
EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT = 1 << 0,
#endif

/* Always last */
EXTERNAL_MEMORY_HANDLE_TYPE_COUNT
} ExternalMemoryHandleTypeBit;
typedef uint32_t ExternalMemoryHandleTypeBits;

Expand All @@ -111,10 +115,12 @@ namespace Anvil
EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 1 << 1,
EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT = 1 << 2,
#else
EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT = 1 << 3,
EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT = 1 << 4,
EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT = 1 << 0,
EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT = 1 << 1,
#endif

/* Always last */
EXTERNAL_SEMAPHORE_HANDLE_TYPE_COUNT
} ExternalSemaphoreHandleTypeBit;
typedef uint32_t ExternalSemaphoreHandleTypeBits;

Expand Down
3 changes: 0 additions & 3 deletions include/wrappers/fence.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ namespace Anvil
/** Retrieves a pointer to the raw handle to the underlying Vulkan fence instance */
const VkFence* get_fence_ptr() const
{
m_possibly_set = true;

return &m_fence;
}

Expand Down Expand Up @@ -158,7 +156,6 @@ namespace Anvil
Anvil::FenceCreateInfoUniquePtr m_create_info_ptr;
std::map<Anvil::ExternalFenceHandleTypeBit, bool> m_external_fence_created_for_handle_type;
VkFence m_fence;
mutable bool m_possibly_set;
};
}; /* namespace Anvil */

Expand Down
2 changes: 2 additions & 0 deletions include/wrappers/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ namespace Anvil
return m_supports_sparse_bindings;
}

void wait_idle();

private:
/* Private functions */
void present_lock_unlock(uint32_t in_n_swapchains,
Expand Down
9 changes: 1 addition & 8 deletions src/wrappers/fence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ Anvil::Fence::Fence(Anvil::FenceCreateInfoUniquePtr in_create_info_ptr)
VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT),
MTSafetySupportProvider (Anvil::Utils::convert_mt_safety_enum_to_boolean(in_create_info_ptr->get_mt_safety(),
in_create_info_ptr->get_device () )),
m_fence (VK_NULL_HANDLE),
m_possibly_set (false)
m_fence (VK_NULL_HANDLE)
{
m_create_info_ptr = std::move(in_create_info_ptr);

Expand Down Expand Up @@ -395,10 +394,6 @@ bool Anvil::Fence::reset()
}
unlock();

anvil_assert_vk_call_succeeded(result);

m_possibly_set = false;

return (result == VK_SUCCESS);
}

Expand Down Expand Up @@ -435,8 +430,6 @@ bool Anvil::Fence::reset_fences(const uint32_t in_n_fences,
device_ptr = current_fence.m_device_ptr;
fence_cache[n_fence] = current_fence.m_fence;

current_fence.m_possibly_set = false;

current_fence.lock();
}
{
Expand Down
20 changes: 14 additions & 6 deletions src/wrappers/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,13 @@ void Anvil::Instance::init(const std::vector<std::string>& in_disallowed_instanc
n_instance_layer < n_instance_layers;
++n_instance_layer)
{
const auto& layer_extensions = m_supported_layers[n_instance_layer].extensions;
const std::string& layer_name = m_supported_layers[n_instance_layer].name;
const std::string& layer_description = m_supported_layers[n_instance_layer].description;
const std::string& layer_name = m_supported_layers[n_instance_layer].name;

/* If validation is enabled and this is a layer which issues debug call-backs, cache it, so that
* we can request for it at vkCreateInstance() call time */
if (m_validation_callback_function != nullptr &&
std::find(layer_extensions.begin(),
layer_extensions.end(),
VK_EXT_DEBUG_REPORT_EXTENSION_NAME) != layer_extensions.end() )
if (m_validation_callback_function != nullptr &&
layer_description.find("Validation") != std::string::npos)
{
enabled_layers.push_back(layer_name.c_str() );
}
Expand Down Expand Up @@ -451,11 +449,21 @@ void Anvil::Instance::init(const std::vector<std::string>& in_disallowed_instanc
extension_enabled_status[VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME] = true;
}

if (is_instance_extension_supported(VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME) )
{
extension_enabled_status[VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME] = true;
}

if (is_instance_extension_supported(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME) )
{
extension_enabled_status[VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME] = true;
}

if (is_instance_extension_supported(VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME) )
{
extension_enabled_status[VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME] = true;
}

/* Filter out undesired extensions */
for (const auto& current_extension_name : in_disallowed_instance_level_extensions)
{
Expand Down
9 changes: 9 additions & 0 deletions src/wrappers/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,3 +875,12 @@ void Anvil::Queue::submit_command_buffers_lock_unlock(uint32_t
}
}
}

void Anvil::Queue::wait_idle()
{
lock();
{
vkQueueWaitIdle(m_queue);
}
unlock();
}