mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2024-11-24 17:39:16 +08:00
update simpleVulkan sample
This commit is contained in:
parent
3a05f29b94
commit
0563025cde
|
@ -1683,8 +1683,8 @@ void VulkanBaseApp::copyBuffer(VkBuffer dst, VkBuffer src, VkDeviceSize size) {
|
||||||
}
|
}
|
||||||
#ifdef _VK_TIMELINE_SEMAPHORE
|
#ifdef _VK_TIMELINE_SEMAPHORE
|
||||||
void VulkanBaseApp::drawFrame() {
|
void VulkanBaseApp::drawFrame() {
|
||||||
const uint64_t waitValue = 0;
|
static uint64_t waitValue = 0;
|
||||||
const uint64_t signalValue = 1;
|
static uint64_t signalValue = 1;
|
||||||
|
|
||||||
VkSemaphoreWaitInfo semaphoreWaitInfo = {};
|
VkSemaphoreWaitInfo semaphoreWaitInfo = {};
|
||||||
semaphoreWaitInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO;
|
semaphoreWaitInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO;
|
||||||
|
@ -1761,6 +1761,9 @@ void VulkanBaseApp::drawFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentFrame++;
|
m_currentFrame++;
|
||||||
|
|
||||||
|
waitValue += 2;
|
||||||
|
signalValue += 2;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void VulkanBaseApp::drawFrame() {
|
void VulkanBaseApp::drawFrame() {
|
||||||
|
|
|
@ -482,13 +482,16 @@ class VulkanCudaSineWave : public VulkanBaseApp {
|
||||||
VulkanBaseApp::drawFrame();
|
VulkanBaseApp::drawFrame();
|
||||||
|
|
||||||
#ifdef _VK_TIMELINE_SEMAPHORE
|
#ifdef _VK_TIMELINE_SEMAPHORE
|
||||||
|
static uint64_t waitValue = 1;
|
||||||
|
static uint64_t signalValue = 2;
|
||||||
|
|
||||||
cudaExternalSemaphoreWaitParams waitParams = {};
|
cudaExternalSemaphoreWaitParams waitParams = {};
|
||||||
waitParams.flags = 0;
|
waitParams.flags = 0;
|
||||||
waitParams.params.fence.value = 1;
|
waitParams.params.fence.value = waitValue;
|
||||||
|
|
||||||
cudaExternalSemaphoreSignalParams signalParams = {};
|
cudaExternalSemaphoreSignalParams signalParams = {};
|
||||||
signalParams.flags = 0;
|
signalParams.flags = 0;
|
||||||
signalParams.params.fence.value = 0;
|
signalParams.params.fence.value = signalValue;
|
||||||
// Wait for vulkan to complete it's work
|
// Wait for vulkan to complete it's work
|
||||||
checkCudaErrors(cudaWaitExternalSemaphoresAsync(&m_cudaTimelineSemaphore,
|
checkCudaErrors(cudaWaitExternalSemaphoresAsync(&m_cudaTimelineSemaphore,
|
||||||
&waitParams, 1, m_stream));
|
&waitParams, 1, m_stream));
|
||||||
|
@ -497,6 +500,9 @@ class VulkanCudaSineWave : public VulkanBaseApp {
|
||||||
// Signal vulkan to continue with the updated buffers
|
// Signal vulkan to continue with the updated buffers
|
||||||
checkCudaErrors(cudaSignalExternalSemaphoresAsync(
|
checkCudaErrors(cudaSignalExternalSemaphoresAsync(
|
||||||
&m_cudaTimelineSemaphore, &signalParams, 1, m_stream));
|
&m_cudaTimelineSemaphore, &signalParams, 1, m_stream));
|
||||||
|
|
||||||
|
waitValue += 2;
|
||||||
|
signalValue += 2;
|
||||||
#else
|
#else
|
||||||
cudaExternalSemaphoreWaitParams waitParams = {};
|
cudaExternalSemaphoreWaitParams waitParams = {};
|
||||||
waitParams.flags = 0;
|
waitParams.flags = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user