fix some buffer stuff or smt

This commit is contained in:
Gregory Wells
2025-07-09 16:45:16 -04:00
parent 6ecaad4d7a
commit cbda103fd9
3 changed files with 11 additions and 14 deletions

View File

@@ -101,10 +101,9 @@ void vulkanBufferSubData(gnBufferHandle buffer, size_t offset, size_t dataSize,
if (buffer->buffer->useStagingBuffer) { if (buffer->buffer->useStagingBuffer) {
VkGryphnBuffer* stagingBuffer = &buffer->device->outputDevice->stagingBuffer; VkGryphnBuffer* stagingBuffer = &buffer->device->outputDevice->stagingBuffer;
VkDeviceSize sizeLeft = dataSize; VkDeviceSize sizeLeft = dataSize;
int copies = 0;
while (sizeLeft > 0) { while (sizeLeft > 0) {
VkDeviceSize chunkSize = (buffer->device->outputDevice->stagingBufferSize < sizeLeft) ? buffer->device->outputDevice->stagingBufferSize : sizeLeft; VkDeviceSize chunkSize = (buffer->device->outputDevice->stagingBufferSize < sizeLeft) ? buffer->device->outputDevice->stagingBufferSize : sizeLeft;
vkMapMemory(buffer->device->outputDevice->device, stagingBuffer->memory, 0, dataSize, 0, &bufferData); vkMapMemory(buffer->device->outputDevice->device, stagingBuffer->memory, 0, chunkSize, 0, &bufferData);
memcpy(bufferData, data + (dataSize - sizeLeft), chunkSize); memcpy(bufferData, data + (dataSize - sizeLeft), chunkSize);
vkUnmapMemory(buffer->device->outputDevice->device, stagingBuffer->memory); vkUnmapMemory(buffer->device->outputDevice->device, stagingBuffer->memory);
@@ -115,7 +114,6 @@ void vulkanBufferSubData(gnBufferHandle buffer, size_t offset, size_t dataSize,
}; };
VkCopyBuffer(buffer->device, stagingBuffer->buffer, buffer->buffer->buffer.buffer, copyRegion); VkCopyBuffer(buffer->device, stagingBuffer->buffer, buffer->buffer->buffer.buffer, copyRegion);
sizeLeft -= chunkSize; sizeLeft -= chunkSize;
copies++;
} }
} else { } else {
vkMapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory, 0, dataSize, 0, &bufferData); vkMapMemory(buffer->device->outputDevice->device, buffer->buffer->buffer.memory, 0, dataSize, 0, &bufferData);

View File

@@ -5,13 +5,13 @@
gnMultisampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts) { gnMultisampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts) {
gnMultisampleCountFlags sampleCount = 0; gnMultisampleCountFlags sampleCount = 0;
if (counts & VK_SAMPLE_COUNT_64_BIT) { sampleCount |= GN_SAMPLE_BIT_64; } if ((counts & VK_SAMPLE_COUNT_64_BIT) == VK_SAMPLE_COUNT_64_BIT) { sampleCount |= GN_SAMPLE_BIT_64; }
if (counts & VK_SAMPLE_COUNT_32_BIT) { sampleCount |= GN_SAMPLE_BIT_32; } if ((counts & VK_SAMPLE_COUNT_32_BIT) == VK_SAMPLE_COUNT_32_BIT) { sampleCount |= GN_SAMPLE_BIT_32; }
if (counts & VK_SAMPLE_COUNT_16_BIT) { sampleCount |= GN_SAMPLE_BIT_16; } if ((counts & VK_SAMPLE_COUNT_16_BIT) == VK_SAMPLE_COUNT_16_BIT) { sampleCount |= GN_SAMPLE_BIT_16; }
if (counts & VK_SAMPLE_COUNT_8_BIT) { sampleCount |= GN_SAMPLE_BIT_8; } if ((counts & VK_SAMPLE_COUNT_8_BIT) == VK_SAMPLE_COUNT_8_BIT) { sampleCount |= GN_SAMPLE_BIT_8; }
if (counts & VK_SAMPLE_COUNT_4_BIT) { sampleCount |= GN_SAMPLE_BIT_4; } if ((counts & VK_SAMPLE_COUNT_4_BIT) == VK_SAMPLE_COUNT_4_BIT) { sampleCount |= GN_SAMPLE_BIT_4; }
if (counts & VK_SAMPLE_COUNT_2_BIT) { sampleCount |= GN_SAMPLE_BIT_2; } if ((counts & VK_SAMPLE_COUNT_2_BIT) == VK_SAMPLE_COUNT_2_BIT) { sampleCount |= GN_SAMPLE_BIT_2; }
if (counts & VK_SAMPLE_COUNT_1_BIT) { sampleCount |= GN_SAMPLE_BIT_1; } if ((counts & VK_SAMPLE_COUNT_1_BIT) == VK_SAMPLE_COUNT_1_BIT) { sampleCount |= GN_SAMPLE_BIT_1; }
return sampleCount; return sampleCount;
} }
@@ -74,9 +74,8 @@ gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* device
VkPhysicalDeviceProperties physicalDeviceProperties; VkPhysicalDeviceProperties physicalDeviceProperties;
vkGetPhysicalDeviceProperties(physicalDevices[i], &physicalDeviceProperties); vkGetPhysicalDeviceProperties(physicalDevices[i], &physicalDeviceProperties);
VkSampleCountFlags counts = physicalDeviceProperties.limits.framebufferColorSampleCounts & physicalDeviceProperties.limits.framebufferDepthSampleCounts; outputDevices[i].features.maxColorSamples = vkSampleCountToGryphn(physicalDeviceProperties.limits.framebufferColorSampleCounts);
outputDevices[i].features.maxDepthSamples = vkSampleCountToGryphn(physicalDeviceProperties.limits.framebufferDepthSampleCounts);
outputDevices[i].features.avaliableSamples = vkSampleCountToGryphn(counts);
outputDevices[i].features.maxMemoryAllocations = physicalDeviceProperties.limits.maxMemoryAllocationCount; outputDevices[i].features.maxMemoryAllocations = physicalDeviceProperties.limits.maxMemoryAllocationCount;
outputDevices[i].features.maxPushConstantSize = physicalDeviceProperties.limits.maxPushConstantsSize; outputDevices[i].features.maxPushConstantSize = physicalDeviceProperties.limits.maxPushConstantsSize;
} }

View File

@@ -23,7 +23,7 @@ typedef struct gnPhysicalDeviceProperties {
} gnPhysicalDeviceProperties; } gnPhysicalDeviceProperties;
typedef struct gnPhysicalDeviceFeatures { typedef struct gnPhysicalDeviceFeatures {
gnMultisampleCountFlags avaliableSamples; gnMultisampleCountFlags maxColorSamples, maxDepthSamples;
uint32_t maxMemoryAllocations; uint32_t maxMemoryAllocations;
uint32_t maxPushConstantSize; uint32_t maxPushConstantSize;
} gnPhysicalDeviceFeatures; } gnPhysicalDeviceFeatures;