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

Add tests for external sharing not dependant on semaphores. #1648

Merged
merged 16 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
47 changes: 47 additions & 0 deletions test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,37 @@ VulkanQueue &VulkanDevice::getQueue(const VulkanQueueFamily &queueFamily,

VulkanDevice::operator VkDevice() const { return m_vkDevice; }

////////////////////////////////
// VulkanFence implementation //
////////////////////////////////

VulkanFence::VulkanFence(const VulkanDevice &vkDevice)
{

device = vkDevice;

VkFenceCreateInfo fenceInfo{};
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fenceInfo.pNext = nullptr;
fenceInfo.flags = 0;

VkResult vkStatus = vkCreateFence(device, &fenceInfo, nullptr, &fence);

if (vkStatus != VK_SUCCESS)
{
throw std::runtime_error("Error: Failed create fence.");
}
}

VulkanFence::~VulkanFence() { vkDestroyFence(device, fence, nullptr); }

void VulkanFence::reset() { vkResetFences(device, 1, &fence); }

void VulkanFence::wait()
{
vkWaitForFences(device, 1, &fence, VK_TRUE, UINT64_MAX);
}

////////////////////////////////
// VulkanQueue implementation //
////////////////////////////////
Expand All @@ -615,6 +646,22 @@ VulkanQueue::VulkanQueue(VkQueue vkQueue): m_vkQueue(vkQueue) {}

VulkanQueue::~VulkanQueue() {}

void VulkanQueue::submit(const VulkanCommandBuffer &commandBuffer,
const std::shared_ptr<VulkanFence> &vkFence)
{
VulkanCommandBufferList commandBufferList;
commandBufferList.add(commandBuffer);

VkSubmitInfo vkSubmitInfo = {};
vkSubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
vkSubmitInfo.pNext = NULL;
vkSubmitInfo.waitSemaphoreCount = (uint32_t)0;
vkSubmitInfo.commandBufferCount = (uint32_t)commandBufferList.size();
vkSubmitInfo.pCommandBuffers = commandBufferList();

vkQueueSubmit(m_vkQueue, 1, &vkSubmitInfo, vkFence->fence);
}

void VulkanQueue::submit(const VulkanSemaphoreList &waitSemaphoreList,
const VulkanCommandBufferList &commandBufferList,
const VulkanSemaphoreList &signalSemaphoreList)
Expand Down
18 changes: 17 additions & 1 deletion test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "vulkan_wrapper_types.hpp"
#include "vulkan_list_map.hpp"
#include "vulkan_api_list.hpp"
#include <memory>

class VulkanInstance {
friend const VulkanInstance &getVulkanInstance();
Expand Down Expand Up @@ -145,6 +146,20 @@ class VulkanDevice {
operator VkDevice() const;
};

class VulkanFence {
friend class VulkanQueue;

protected:
VkFence fence;
VkDevice device;

public:
VulkanFence(const VulkanDevice &device);
virtual ~VulkanFence();
void reset();
void wait();
};

class VulkanQueue {
friend class VulkanDevice;

Expand All @@ -157,6 +172,8 @@ class VulkanQueue {

public:
const VulkanQueueFamily &getQueueFamily();
void submit(const VulkanCommandBuffer &commandBuffer,
const std::shared_ptr<VulkanFence> &fence);
void submit(const VulkanSemaphoreList &waitSemaphoreList,
const VulkanCommandBufferList &commandBufferList,
const VulkanSemaphoreList &signalSemaphoreList);
Expand Down Expand Up @@ -569,7 +586,6 @@ class VulkanSemaphore {
operator VkSemaphore() const;
};


#define VK_FUNC_DECL(name) extern "C" PFN_##name _##name;
VK_FUNC_LIST
#if defined(_WIN32) || defined(_WIN64)
Expand Down
53 changes: 48 additions & 5 deletions test_conformance/vulkan/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ static void params_reset()
}

extern int test_buffer_common(cl_device_id device_, cl_context context_,
cl_command_queue queue_, int numElements_);
cl_command_queue queue_, int numElements_,
float use_fence);
extern int test_image_common(cl_device_id device_, cl_context context_,
cl_command_queue queue_, int numElements_);

Expand All @@ -61,15 +62,15 @@ int test_buffer_single_queue(cl_device_id device_, cl_context context_,
{
params_reset();
log_info("RUNNING TEST WITH ONE QUEUE...... \n\n");
return test_buffer_common(device_, context_, queue_, numElements_);
return test_buffer_common(device_, context_, queue_, numElements_, false);
}
int test_buffer_multiple_queue(cl_device_id device_, cl_context context_,
cl_command_queue queue_, int numElements_)
{
params_reset();
numCQ = 2;
log_info("RUNNING TEST WITH TWO QUEUE...... \n\n");
return test_buffer_common(device_, context_, queue_, numElements_);
return test_buffer_common(device_, context_, queue_, numElements_, false);
}
int test_buffer_multiImport_sameCtx(cl_device_id device_, cl_context context_,
cl_command_queue queue_, int numElements_)
Expand All @@ -78,7 +79,7 @@ int test_buffer_multiImport_sameCtx(cl_device_id device_, cl_context context_,
multiImport = true;
log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT "
"IN SAME CONTEXT...... \n\n");
return test_buffer_common(device_, context_, queue_, numElements_);
return test_buffer_common(device_, context_, queue_, numElements_, false);
}
int test_buffer_multiImport_diffCtx(cl_device_id device_, cl_context context_,
cl_command_queue queue_, int numElements_)
Expand All @@ -88,7 +89,45 @@ int test_buffer_multiImport_diffCtx(cl_device_id device_, cl_context context_,
multiCtx = true;
log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT "
"IN DIFFERENT CONTEXT...... \n\n");
return test_buffer_common(device_, context_, queue_, numElements_);
return test_buffer_common(device_, context_, queue_, numElements_, false);
}
int test_buffer_single_queue_fence(cl_device_id device_, cl_context context_,
cl_command_queue queue_, int numElements_)
{
params_reset();
log_info("RUNNING TEST WITH ONE QUEUE...... \n\n");
return test_buffer_common(device_, context_, queue_, numElements_, true);
}
int test_buffer_multiple_queue_fence(cl_device_id device_, cl_context context_,
cl_command_queue queue_, int numElements_)
{
params_reset();
numCQ = 2;
log_info("RUNNING TEST WITH TWO QUEUE...... \n\n");
return test_buffer_common(device_, context_, queue_, numElements_, true);
}
int test_buffer_multiImport_sameCtx_fence(cl_device_id device_,
cl_context context_,
cl_command_queue queue_,
int numElements_)
{
params_reset();
multiImport = true;
log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT "
"IN SAME CONTEXT...... \n\n");
return test_buffer_common(device_, context_, queue_, numElements_, true);
}
int test_buffer_multiImport_diffCtx_fence(cl_device_id device_,
cl_context context_,
cl_command_queue queue_,
int numElements_)
{
params_reset();
multiImport = true;
multiCtx = true;
log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT "
"IN DIFFERENT CONTEXT...... \n\n");
return test_buffer_common(device_, context_, queue_, numElements_, true);
}
int test_image_single_queue(cl_device_id device_, cl_context context_,
cl_command_queue queue_, int numElements_)
Expand All @@ -110,6 +149,10 @@ test_definition test_list[] = { ADD_TEST(buffer_single_queue),
ADD_TEST(buffer_multiple_queue),
ADD_TEST(buffer_multiImport_sameCtx),
ADD_TEST(buffer_multiImport_diffCtx),
ADD_TEST(buffer_single_queue_fence),
ADD_TEST(buffer_multiple_queue_fence),
ADD_TEST(buffer_multiImport_sameCtx_fence),
ADD_TEST(buffer_multiImport_diffCtx_fence),
ADD_TEST(image_single_queue),
ADD_TEST(image_multiple_queue),
ADD_TEST(consistency_external_buffer),
Expand Down
Loading