mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2025-04-20 09:22:21 +08:00
WIP
This commit is contained in:
parent
b312abaa07
commit
cbd0b5f506
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.o
|
||||
bin/
|
|
@ -168,8 +168,8 @@ void MonteCarloPiSimulation::computePiCallback(void *args) {
|
|||
cbData->m_totalPointsSimulated += cbData->m_numPoints;
|
||||
double piValue = 4.0 * ((double)cbData->m_totalPointsInsideCircle /
|
||||
(double)cbData->m_totalPointsSimulated);
|
||||
printf("Approximate Pi value for %zd data points: %lf \n",
|
||||
cbData->m_totalPointsSimulated, piValue);
|
||||
//printf("Approximate Pi value for %zd data points: %lf \n",
|
||||
// cbData->m_totalPointsSimulated, piValue);
|
||||
}
|
||||
|
||||
void MonteCarloPiSimulation::getIdealExecutionConfiguration() {
|
||||
|
|
|
@ -622,8 +622,15 @@ void VulkanBaseApp::createDevice() {
|
|||
queueCreateInfos.push_back(queueCreateInfo);
|
||||
}
|
||||
|
||||
VkPhysicalDeviceFeatures deviceFeatures = {};
|
||||
deviceFeatures.fillModeNonSolid = true;
|
||||
// (SE) change to VkPhysicalDeviceFeatures2 to allow chaining
|
||||
VkPhysicalDeviceFeatures2 deviceFeatures2 = {};
|
||||
deviceFeatures2.features.fillModeNonSolid = true;
|
||||
|
||||
// (SE) add enable for BDA
|
||||
VkPhysicalDeviceBufferAddressFeaturesEXT buffer_device_address_features{};
|
||||
buffer_device_address_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT;
|
||||
buffer_device_address_features.bufferDeviceAddress = VK_TRUE;
|
||||
deviceFeatures2.pNext = &buffer_device_address_features;
|
||||
|
||||
VkDeviceCreateInfo createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
||||
|
@ -632,7 +639,9 @@ void VulkanBaseApp::createDevice() {
|
|||
createInfo.queueCreateInfoCount =
|
||||
static_cast<uint32_t>(queueCreateInfos.size());
|
||||
|
||||
createInfo.pEnabledFeatures = &deviceFeatures;
|
||||
// (SE) now chained
|
||||
// createInfo.pEnabledFeatures = &deviceFeatures;
|
||||
createInfo.pNext = &deviceFeatures2;
|
||||
|
||||
std::vector<const char *> deviceExtensions = getRequiredDeviceExtensions();
|
||||
deviceExtensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
||||
|
|
|
@ -226,6 +226,17 @@ class VulkanCudaPi : public VulkanBaseApp {
|
|||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, m_inCircleBuffer,
|
||||
m_inCircleMemory);
|
||||
|
||||
// (SE) get function ptr
|
||||
auto* vkGetBufferDeviceAddressKHR = (PFN_vkGetBufferDeviceAddressKHR)vkGetDeviceProcAddr(m_device, "vkGetBufferDeviceAddressKHR");
|
||||
std::cout << "DEBUG: vkGetBufferDeviceAddressKHR = " << (void*)vkGetBufferDeviceAddressKHR << std::endl;
|
||||
|
||||
// get BDA for the circle buffer
|
||||
VkBufferDeviceAddressInfoKHR bda_info{VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_KHR,
|
||||
nullptr,
|
||||
m_inCircleBuffer};
|
||||
auto bda = vkGetBufferDeviceAddressKHR(m_device, &bda_info);
|
||||
std::cout << "DEBUG: BDA = " << (void*)bda << std::endl;
|
||||
|
||||
// Create the semaphore vulkan will signal when it's done with the vertex
|
||||
// buffer
|
||||
createExternalSemaphore(m_vkSignalSemaphore,
|
||||
|
@ -306,6 +317,8 @@ class VulkanCudaPi : public VulkanBaseApp {
|
|||
extensions.push_back(VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
|
||||
extensions.push_back(VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME);
|
||||
#endif /* _WIN64 */
|
||||
// (SE) add BDA as required device extension
|
||||
extensions.push_back(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
|
||||
return extensions;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user