MCPcopy Create free account
hub / github.com/defold/defold / CreateScratchBuffer

Function CreateScratchBuffer

engine/graphics/src/vulkan/graphics_vulkan_device.cpp:780–814  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778 }
779
780 VkResult CreateScratchBuffer(VkPhysicalDevice vk_physical_device, VkDevice vk_device,
781 uint32_t bufferSize, bool clearData, DescriptorAllocator* descriptorAllocator, ScratchBuffer* scratchBufferOut)
782 {
783 scratchBufferOut->m_DeviceBuffer.m_Usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
784
785 DeviceBuffer& device_buffer = scratchBufferOut->m_DeviceBuffer;
786
787 // Note: While scratch buffer creates and initializes the device buffer for
788 // backing, it does not reset it or tear it down.
789 VkResult res = CreateDeviceBuffer(vk_physical_device, vk_device, bufferSize,
790 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &scratchBufferOut->m_DeviceBuffer);
791 if (res != VK_SUCCESS)
792 {
793 return res;
794 }
795
796 if (clearData)
797 {
798 res = device_buffer.MapMemory(vk_device);
799
800 if (res != VK_SUCCESS)
801 {
802 DestroyDeviceBuffer(vk_device, &device_buffer.m_Handle);
803 return res;
804 }
805
806 // Clear buffer data
807 memset(device_buffer.m_MappedDataPtr, 0, bufferSize);
808 device_buffer.UnmapMemory(vk_device);
809 }
810
811 scratchBufferOut->m_DescriptorAllocator = descriptorAllocator;
812
813 return VK_SUCCESS;
814 }
815
816 VkResult CreateTexture(
817 VkPhysicalDevice vk_physical_device,

Callers 2

CreateMainScratchBuffersFunction · 0.85
ResizeScratchBufferFunction · 0.85

Calls 4

DestroyDeviceBufferFunction · 0.85
MapMemoryMethod · 0.80
UnmapMemoryMethod · 0.80
CreateDeviceBufferFunction · 0.70

Tested by

no test coverage detected