Archived
1
Fork 0

Only call vkGetPhysicalDeviceMemoryProperties once

This commit is contained in:
Joshua Goins 2018-10-16 09:04:57 -04:00
parent da6f245c79
commit d946ba28e3
2 changed files with 8 additions and 7 deletions

View file

@ -37,7 +37,7 @@ public:
VkShaderModule createShader(const char* path); VkShaderModule createShader(const char* path);
uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties); uint32_t findMemoryType(const uint32_t typeFilter, const VkMemoryPropertyFlags properties);
void fillMeshBuffers(Mesh* mesh); void fillMeshBuffers(Mesh* mesh);
void destroyMeshBuffers(Mesh* mesh); void destroyMeshBuffers(Mesh* mesh);
@ -75,6 +75,8 @@ private:
#endif #endif
VkPhysicalDevice physicalDevice_ = nullptr; VkPhysicalDevice physicalDevice_ = nullptr;
VkPhysicalDeviceMemoryProperties deviceMemoryProperties_ = {};
VkDevice device_ = nullptr; VkDevice device_ = nullptr;
struct { struct {

View file

@ -278,12 +278,9 @@ VkShaderModule Renderer::createShader(const char* path) {
return shaderModule; return shaderModule;
} }
uint32_t Renderer::findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) { uint32_t Renderer::findMemoryType(const uint32_t typeFilter, const VkMemoryPropertyFlags properties) {
VkPhysicalDeviceMemoryProperties memProperties; for (uint32_t i = 0; i < deviceMemoryProperties_.memoryTypeCount; i++) {
vkGetPhysicalDeviceMemoryProperties(physicalDevice_, &memProperties); if ((typeFilter & (1 << i)) && (deviceMemoryProperties_.memoryTypes[i].propertyFlags & properties) == properties) {
for (uint32_t i = 0; i < memProperties.memoryTypeCount; i++) {
if ((typeFilter & (1 << i)) && (memProperties.memoryTypes[i].propertyFlags & properties) == properties) {
return i; return i;
} }
} }
@ -440,6 +437,8 @@ void Renderer::createLogicalDevice() {
delete[] physicalDevices; delete[] physicalDevices;
vkGetPhysicalDeviceMemoryProperties(physicalDevice_, &deviceMemoryProperties_);
uint32_t queueFamilyPropertiesCount = 0; uint32_t queueFamilyPropertiesCount = 0;
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice_, &queueFamilyPropertiesCount, nullptr); vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice_, &queueFamilyPropertiesCount, nullptr);