From e97c61afb0ba4916dcfaeb637a631c1d529332c7 Mon Sep 17 00:00:00 2001 From: Graeme Leese Date: Wed, 19 Sep 2018 13:04:34 +0100 Subject: [PATCH] Add a flushAlloc helper to fix valid usage Flushing/invalidating memory using the requested size (as the CTS code does all over the place) is not safe. If the implementation's MemoryRequirements make the allocation larger than the requested size then the whole (padded) allocation will be mapped. This means that flush and invalidate using a size which is not a multiple of the non-coherent atom size are invalid. Replace these usages with helper functions to flush/invalidate the whole block. The current implementation uses WHOLE_SIZE to ensure that flush / invalidate is valid, but sub-ranges could be implemented by storing how much of any allocation is mapped. The structure of the current code which maps memory at allocation time means that there cannot be any other users being flushed out by the use of WHOLE_SIZE. Includes a significant amount of work from @jbolz. Components: Framework, Vulkan Affects: dEQP-VK.* Change-Id: I24ac185d7d041239430c53a6b61cede5828a7afd --- external/vulkancts/framework/vulkan/vkMemUtil.cpp | 10 ++++ external/vulkancts/framework/vulkan/vkMemUtil.hpp | 3 ++ .../vulkan/api/vktApiBufferComputeInstance.cpp | 4 +- .../vulkan/api/vktApiBufferViewAccessTests.cpp | 8 ++-- .../api/vktApiComputeInstanceResultBuffer.cpp | 6 +-- .../vulkan/api/vktApiCopiesAndBlittingTests.cpp | 14 +++--- .../modules/vulkan/api/vktApiFillBufferTests.cpp | 6 +-- .../vulkan/api/vktApiImageClearingTests.cpp | 2 +- .../compute/vktComputeBasicComputeShaderTests.cpp | 54 +++++++++++----------- .../vktComputeIndirectComputeDispatchTests.cpp | 14 +++--- .../compute/vktComputeShaderBuiltinVarTests.cpp | 4 +- .../dynamic_state/vktDynamicStateBaseClass.cpp | 5 +- .../dynamic_state/vktDynamicStateDSTests.cpp | 10 +--- .../dynamic_state/vktDynamicStateRSTests.cpp | 5 +- .../modules/vulkan/image/vktImageMutableTests.cpp | 8 ++-- .../modules/vulkan/image/vktImageSizeTests.cpp | 2 +- .../vulkan/pipeline/vktPipelineBlendTests.cpp | 11 +---- .../vulkan/pipeline/vktPipelineCacheTests.cpp | 20 +++----- .../vulkan/pipeline/vktPipelineDepthTests.cpp | 2 +- .../vktPipelineFramebufferAttachmentTests.cpp | 12 ++--- .../pipeline/vktPipelineImageSamplingInstance.cpp | 2 +- .../vulkan/pipeline/vktPipelineImageUtil.cpp | 6 +-- .../pipeline/vktPipelineInputAssemblyTests.cpp | 22 +-------- .../pipeline/vktPipelineMultisampleBaseResolve.cpp | 4 +- ...lineMultisampleBaseResolveAndPerSampleFetch.cpp | 10 ++-- .../pipeline/vktPipelineMultisampleImageTests.cpp | 12 ++--- ...tPipelineMultisampleSampleLocationsExtTests.cpp | 18 ++++---- .../vktPipelineMultisampleShaderBuiltInTests.cpp | 2 +- .../pipeline/vktPipelineMultisampleTests.cpp | 2 +- .../pipeline/vktPipelinePushConstantTests.cpp | 6 +-- .../pipeline/vktPipelinePushDescriptorTests.cpp | 8 ++-- .../pipeline/vktPipelineRenderToImageTests.cpp | 12 ++--- .../pipeline/vktPipelineSpecConstantTests.cpp | 6 +-- .../pipeline/vktPipelineStencilExportTests.cpp | 4 +- .../vulkan/pipeline/vktPipelineStencilTests.cpp | 12 +---- .../vulkan/pipeline/vktPipelineTimestampTests.cpp | 8 ++-- .../pipeline/vktPipelineVertexInputTests.cpp | 2 +- .../vulkan/shaderexecutor/vktShaderExecutor.cpp | 22 ++------- .../vulkan/shaderrender/vktShaderRender.cpp | 10 ++-- .../vktShaderRenderBuiltinVarTests.cpp | 2 +- .../vktSparseResourcesBufferMemoryAliasing.cpp | 2 +- .../vktSparseResourcesBufferSparseBinding.cpp | 4 +- .../vktSparseResourcesBufferSparseResidency.cpp | 2 +- .../vktSparseResourcesBufferTests.cpp | 14 +++--- .../vktSparseResourcesImageMemoryAliasing.cpp | 4 +- .../vktSparseResourcesImageSparseBinding.cpp | 4 +- .../vktSparseResourcesImageSparseResidency.cpp | 2 +- .../vktSparseResourcesMipmapSparseResidency.cpp | 4 +- .../vktSparseResourcesShaderIntrinsicsBase.cpp | 6 +-- .../vktSparseResourcesShaderIntrinsicsSampled.cpp | 2 +- .../spirv_assembly/vktSpvAsmComputeShaderCase.cpp | 10 ++-- .../vktSpvAsmCrossStageInterfaceTests.cpp | 6 +-- .../vktSpvAsmGraphicsShaderTestUtil.cpp | 28 ++--------- .../vulkan/subgroups/vktSubgroupsTestsUtils.cpp | 47 ++++++------------- ...onizationInternallySynchronizedObjectsTests.cpp | 8 ++-- .../vktSynchronizationOperation.cpp | 30 ++++++------ .../vktSynchronizationSmokeTests.cpp | 41 ++-------------- .../vktTextureFilteringExplicitLodTests.cpp | 4 +- .../modules/vulkan/ubo/vktUniformBlockCase.cpp | 9 ++-- external/vulkancts/modules/vulkan/vktDrawUtil.cpp | 6 +-- .../vulkancts/modules/vulkan/vktShaderLibrary.cpp | 4 +- 61 files changed, 239 insertions(+), 368 deletions(-) mode change 100644 => 100755 external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferMemoryAliasing.cpp mode change 100644 => 100755 external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseBinding.cpp mode change 100644 => 100755 external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseResidency.cpp mode change 100644 => 100755 external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp mode change 100644 => 100755 external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageMemoryAliasing.cpp mode change 100644 => 100755 external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseBinding.cpp mode change 100644 => 100755 external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseResidency.cpp mode change 100644 => 100755 external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesMipmapSparseResidency.cpp mode change 100644 => 100755 external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesShaderIntrinsicsBase.cpp diff --git a/external/vulkancts/framework/vulkan/vkMemUtil.cpp b/external/vulkancts/framework/vulkan/vkMemUtil.cpp index f18b827..6fdb2e6 100644 --- a/external/vulkancts/framework/vulkan/vkMemUtil.cpp +++ b/external/vulkancts/framework/vulkan/vkMemUtil.cpp @@ -99,6 +99,16 @@ Allocation::~Allocation (void) { } +void flushAlloc (const DeviceInterface& vkd, VkDevice device, const Allocation& alloc) +{ + flushMappedMemoryRange(vkd, device, alloc.getMemory(), alloc.getOffset(), VK_WHOLE_SIZE); +} + +void invalidateAlloc (const DeviceInterface& vkd, VkDevice device, const Allocation& alloc) +{ + invalidateMappedMemoryRange(vkd, device, alloc.getMemory(), alloc.getOffset(), VK_WHOLE_SIZE); +} + // MemoryRequirement const MemoryRequirement MemoryRequirement::Any = MemoryRequirement(0x0u); diff --git a/external/vulkancts/framework/vulkan/vkMemUtil.hpp b/external/vulkancts/framework/vulkan/vkMemUtil.hpp index 065063f..041018c 100644 --- a/external/vulkancts/framework/vulkan/vkMemUtil.hpp +++ b/external/vulkancts/framework/vulkan/vkMemUtil.hpp @@ -71,6 +71,9 @@ private: void* const m_hostPtr; }; +void flushAlloc (const DeviceInterface& vkd, VkDevice device, const Allocation& alloc); +void invalidateAlloc (const DeviceInterface& vkd, VkDevice device, const Allocation& alloc); + //! Memory allocation requirements class MemoryRequirement { diff --git a/external/vulkancts/modules/vulkan/api/vktApiBufferComputeInstance.cpp b/external/vulkancts/modules/vulkan/api/vktApiBufferComputeInstance.cpp index 6ef677f..568fc3c 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiBufferComputeInstance.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiBufferComputeInstance.cpp @@ -75,7 +75,7 @@ Move createDataBuffer (vkt::Context& context, deMemset((deUint8 *)mapPtr + offset + initDataSize, uninitData, (size_t)bufferSize - (size_t)offset - initDataSize); - flushMappedMemoryRange(vki, device, allocation->getMemory(), allocation->getOffset(), bufferSize); + flushAlloc(vki, device, *allocation); *outAllocation = allocation; return buffer; @@ -123,7 +123,7 @@ Move createColorDataBuffer (deUint32 offset, deMemset((deUint8 *) mapPtr + offset + 2 * sizeof(tcu::Vec4), 0x5A, (size_t) bufferSize - (size_t) offset - 2 * sizeof(tcu::Vec4)); - flushMappedMemoryRange(vki, device, allocation->getMemory(), allocation->getOffset(), bufferSize); + flushAlloc(vki, device, *allocation); *outAllocation = allocation; return buffer; diff --git a/external/vulkancts/modules/vulkan/api/vktApiBufferViewAccessTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiBufferViewAccessTests.cpp index f55e081..4da95d9 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiBufferViewAccessTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiBufferViewAccessTests.cpp @@ -262,7 +262,7 @@ BufferViewTestInstance::BufferViewTestInstance (Context& context, BufferSuballocation().createTestBuffer(uniformSize, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, m_context, memAlloc, m_uniformBuffer, MemoryRequirement::HostVisible, m_uniformBufferAlloc); deMemcpy(m_uniformBufferAlloc->getHostPtr(), uniformData.data(), (size_t)uniformSize); - flushMappedMemoryRange(vk, vkDevice, m_uniformBufferAlloc->getMemory(), m_uniformBufferAlloc->getOffset(), uniformSize); + flushAlloc(vk, vkDevice, *m_uniformBufferAlloc); const VkBufferViewCreateInfo viewInfo = { @@ -378,7 +378,7 @@ BufferViewTestInstance::BufferViewTestInstance (Context& context, // Load vertices into vertex buffer deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), (size_t)vertexDataSize); - flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexDataSize); + flushAlloc(vk, vkDevice, *m_vertexBufferAlloc); } // Create command pool @@ -484,7 +484,7 @@ tcu::TestStatus BufferViewTestInstance::checkResult (deInt8 factor) const tcu::TextureFormat tcuFormat = mapVkFormat(m_colorFormat); de::MovePtr resultLevel (new tcu::TextureLevel(tcuFormat, m_renderSize.x(), m_renderSize.y())); - invalidateMappedMemoryRange(vk, vkDevice, m_resultBufferAlloc->getMemory(), m_resultBufferAlloc->getOffset(), m_pixelDataSize); + invalidateAlloc(vk, vkDevice, *m_resultBufferAlloc); tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_resultBufferAlloc->getHostPtr())); tcu::ConstPixelBufferAccess pixelBuffer = resultLevel->getAccess(); @@ -523,7 +523,7 @@ tcu::TestStatus BufferViewTestInstance::iterate (void) generateBuffer(uniformData, m_testCase.bufferSize, factor); deMemcpy(m_uniformBufferAlloc->getHostPtr(), uniformData.data(), (size_t)uniformSize); - flushMappedMemoryRange(vk, vkDevice, m_uniformBufferAlloc->getMemory(), m_uniformBufferAlloc->getOffset(), uniformSize); + flushAlloc(vk, vkDevice, *m_uniformBufferAlloc); submitCommandsAndWait(vk, vkDevice, queue, m_cmdBuffer.get()); diff --git a/external/vulkancts/modules/vulkan/api/vktApiComputeInstanceResultBuffer.cpp b/external/vulkancts/modules/vulkan/api/vktApiComputeInstanceResultBuffer.cpp index 8441e73..585d2e9 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiComputeInstanceResultBuffer.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiComputeInstanceResultBuffer.cpp @@ -45,13 +45,13 @@ ComputeInstanceResultBuffer::ComputeInstanceResultBuffer (const DeviceInterface void ComputeInstanceResultBuffer::readResultContentsTo(tcu::Vec4 (*results)[4]) const { - invalidateMappedMemoryRange(m_vki, m_device, m_bufferMem->getMemory(), m_bufferMem->getOffset(), sizeof(*results)); + invalidateAlloc(m_vki, m_device, *m_bufferMem); deMemcpy(*results, m_bufferMem->getHostPtr(), sizeof(*results)); } void ComputeInstanceResultBuffer::readResultContentsTo(deUint32 *result) const { - invalidateMappedMemoryRange(m_vki, m_device, m_bufferMem->getMemory(), m_bufferMem->getOffset(), sizeof(*result)); + invalidateAlloc(m_vki, m_device, *m_bufferMem); deMemcpy(result, m_bufferMem->getHostPtr(), sizeof(*result)); } @@ -86,7 +86,7 @@ Move ComputeInstanceResultBuffer::createResultBuffer(const DeviceInter for (size_t offset = 0; offset < DATA_SIZE; offset += sizeof(float)) deMemcpy(((deUint8 *) mapPtr) + offset, &clearValue, sizeof(float)); - flushMappedMemoryRange(vki, device, allocation->getMemory(), allocation->getOffset(), (VkDeviceSize) DATA_SIZE); + flushAlloc(vki, device, *allocation); *outAllocation = allocation; return buffer; diff --git a/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp index 9fddb5a..4252b68 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp @@ -452,7 +452,7 @@ void CopiesAndBlittingTestInstance::uploadBuffer (tcu::ConstPixelBufferAccess bu // Write buffer data deMemcpy(bufferAlloc.getHostPtr(), bufferAccess.getDataPtr(), bufferSize); - flushMappedMemoryRange(vk, vkDevice, bufferAlloc.getMemory(), bufferAlloc.getOffset(), bufferSize); + flushAlloc(vk, vkDevice, bufferAlloc); } void CopiesAndBlittingTestInstance::uploadImageAspect (const tcu::ConstPixelBufferAccess& imageAccess, const VkImage& image, const ImageParms& parms, const deUint32 mipLevels) @@ -576,7 +576,7 @@ void CopiesAndBlittingTestInstance::uploadImageAspect (const tcu::ConstPixelBuff // Write buffer data deMemcpy(bufferAlloc->getHostPtr(), imageAccess.getDataPtr(), bufferSize); - flushMappedMemoryRange(vk, vkDevice, bufferAlloc->getMemory(), bufferAlloc->getOffset(), bufferSize); + flushAlloc(vk, vkDevice, *bufferAlloc); // Copy buffer to image beginCommandBuffer(vk, *m_cmdBuffer); @@ -692,7 +692,7 @@ void CopiesAndBlittingTestInstance::readImageAspect (vk::VkImage image, VK_CHECK(vk.bindBufferMemory(device, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset())); deMemset(bufferAlloc->getHostPtr(), 0, static_cast(pixelDataSize)); - flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize); + flushAlloc(vk, device, *bufferAlloc); } // Barriers for copying image to buffer @@ -776,7 +776,7 @@ void CopiesAndBlittingTestInstance::readImageAspect (vk::VkImage image, submitCommandsAndWait(vk, device, queue, *m_cmdBuffer); // Read buffer data - invalidateMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize); + invalidateAlloc(vk, device, *bufferAlloc); tcu::copy(dst, tcu::ConstPixelBufferAccess(dst.getFormat(), dst.getSize(), bufferAlloc->getHostPtr())); } @@ -1319,7 +1319,7 @@ tcu::TestStatus CopyBufferToBuffer::iterate (void) // Read buffer data de::MovePtr resultLevel (new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), dstLevelWidth, 1)); - invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset(), m_params.dst.buffer.size); + invalidateAlloc(vk, vkDevice, *m_destinationBufferAlloc); tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr())); return checkTestResult(resultLevel->getAccess()); @@ -1500,7 +1500,7 @@ tcu::TestStatus CopyImageToBuffer::iterate (void) // Read buffer data de::MovePtr resultLevel (new tcu::TextureLevel(m_textureFormat, (int)m_params.dst.buffer.size, 1)); - invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset(), m_bufferSize); + invalidateAlloc(vk, vkDevice, *m_destinationBufferAlloc); tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr())); return checkTestResult(resultLevel->getAccess()); @@ -3553,7 +3553,7 @@ ResolveImageToImage::ResolveImageToImage (Context& context, TestParams params, c // Load vertices into vertex buffer. deMemcpy(vertexBufferAlloc->getHostPtr(), vertices.data(), (size_t)vertexDataSize); - flushMappedMemoryRange(vk, vkDevice, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexDataSize); + flushAlloc(vk, vkDevice, *vertexBufferAlloc); } { diff --git a/external/vulkancts/modules/vulkan/api/vktApiFillBufferTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiFillBufferTests.cpp index 67dca93..87a2aaa 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiFillBufferTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiFillBufferTests.cpp @@ -159,7 +159,7 @@ tcu::TestStatus FillBufferTestInstance::iterate (void) // Read buffer data de::MovePtr resultLevel (new tcu::TextureLevel(m_destinationTextureLevel->getAccess().getFormat(), dstLevelWidth, 1)); - invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset() + m_params.dstOffset, m_params.dstSize); + invalidateAlloc(vk, vkDevice, *m_destinationBufferAlloc); tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr())); return checkTestResult(resultLevel->getAccess()); @@ -192,7 +192,7 @@ void FillBufferTestInstance::uploadBuffer // Write buffer data deMemcpy(bufferAlloc.getHostPtr(), bufferAccess.getDataPtr(), bufferSize); - flushMappedMemoryRange(vk, vkDevice, bufferAlloc.getMemory(), bufferAlloc.getOffset(), bufferSize); + flushAlloc(vk, vkDevice, bufferAlloc); } tcu::TestStatus FillBufferTestInstance::checkTestResult @@ -301,7 +301,7 @@ tcu::TestStatus UpdateBufferTestInstance::iterate (void) // Read buffer data de::MovePtr resultLevel (new tcu::TextureLevel(m_destinationTextureLevel->getAccess().getFormat(), dstLevelWidth, 1)); - invalidateMappedMemoryRange(vk, vkDevice, m_destinationBufferAlloc->getMemory(), m_destinationBufferAlloc->getOffset(), m_params.dstOffset); + invalidateAlloc(vk, vkDevice, *m_destinationBufferAlloc); tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), m_destinationBufferAlloc->getHostPtr())); return checkTestResult(resultLevel->getAccess()); diff --git a/external/vulkancts/modules/vulkan/api/vktApiImageClearingTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiImageClearingTests.cpp index 84cb8e7..41e8a83 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiImageClearingTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiImageClearingTests.cpp @@ -978,7 +978,7 @@ de::MovePtr ImageClearingTestInstance::readImage (VkImageAs endCommandBuffer(); submitCommandBuffer(); - invalidateMappedMemoryRange(m_vkd, m_device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), imageTotalSize); + invalidateAlloc(m_vkd, m_device, *bufferAlloc); { deUint32 offset = 0u; diff --git a/external/vulkancts/modules/vulkan/compute/vktComputeBasicComputeShaderTests.cpp b/external/vulkancts/modules/vulkan/compute/vktComputeBasicComputeShaderTests.cpp index 3c311c0..4b2da00 100644 --- a/external/vulkancts/modules/vulkan/compute/vktComputeBasicComputeShaderTests.cpp +++ b/external/vulkancts/modules/vulkan/compute/vktComputeBasicComputeShaderTests.cpp @@ -254,7 +254,7 @@ tcu::TestStatus SharedVarTestInstance::iterate (void) // Validate the results const Allocation& bufferAllocation = buffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, bufferAllocation); const deUint32* bufferPtr = static_cast(bufferAllocation.getHostPtr()); @@ -425,7 +425,7 @@ tcu::TestStatus SharedVarAtomicOpTestInstance::iterate (void) // Validate the results const Allocation& bufferAllocation = buffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, bufferAllocation); const deUint32* bufferPtr = static_cast(bufferAllocation.getHostPtr()); @@ -598,7 +598,7 @@ tcu::TestStatus SSBOLocalBarrierTestInstance::iterate (void) // Validate the results const Allocation& bufferAllocation = buffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, bufferAllocation); const deUint32* bufferPtr = static_cast(bufferAllocation.getHostPtr()); @@ -728,7 +728,7 @@ tcu::TestStatus CopyImageToSSBOTestInstance::iterate (void) for (deUint32 i = 0; i < imageArea; ++i) *bufferPtr++ = rnd.getUint32(); - flushMappedMemoryRange(vk, device, stagingBufferAllocation.getMemory(), stagingBufferAllocation.getOffset(), bufferSizeBytes); + flushAlloc(vk, device, stagingBufferAllocation); } // Create a buffer to store shader output @@ -813,7 +813,7 @@ tcu::TestStatus CopyImageToSSBOTestInstance::iterate (void) // Validate the results const Allocation& outputBufferAllocation = outputBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, outputBufferAllocation.getMemory(), outputBufferAllocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, outputBufferAllocation); const deUint32* bufferPtr = static_cast(outputBufferAllocation.getHostPtr()); const deUint32* refBufferPtr = static_cast(stagingBuffer.getAllocation().getHostPtr()); @@ -938,7 +938,7 @@ tcu::TestStatus CopySSBOToImageTestInstance::iterate (void) for (deUint32 i = 0; i < imageArea; ++i) *bufferPtr++ = rnd.getUint32(); - flushMappedMemoryRange(vk, device, inputBufferAllocation.getMemory(), inputBufferAllocation.getOffset(), bufferSizeBytes); + flushAlloc(vk, device, inputBufferAllocation); } // Create a buffer to store shader output (copied from image data) @@ -1023,7 +1023,7 @@ tcu::TestStatus CopySSBOToImageTestInstance::iterate (void) // Validate the results const Allocation& outputBufferAllocation = outputBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, outputBufferAllocation.getMemory(), outputBufferAllocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, outputBufferAllocation); const deUint32* bufferPtr = static_cast(outputBufferAllocation.getHostPtr()); const deUint32* refBufferPtr = static_cast(inputBuffer.getAllocation().getHostPtr()); @@ -1225,7 +1225,7 @@ tcu::TestStatus BufferToBufferInvertTestInstance::iterate (void) for (deUint32 i = 0; i < m_numValues; ++i) bufferPtr[i].x() = rnd.getUint32(); - flushMappedMemoryRange(vk, device, inputBufferAllocation.getMemory(), inputBufferAllocation.getOffset(), bufferSizeBytes); + flushAlloc(vk, device, inputBufferAllocation); } // Create an output buffer @@ -1288,7 +1288,7 @@ tcu::TestStatus BufferToBufferInvertTestInstance::iterate (void) // Validate the results const Allocation& outputBufferAllocation = outputBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, outputBufferAllocation.getMemory(), outputBufferAllocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, outputBufferAllocation); const tcu::UVec4* bufferPtr = static_cast(outputBufferAllocation.getHostPtr()); const tcu::UVec4* refBufferPtr = static_cast(inputBuffer.getAllocation().getHostPtr()); @@ -1424,7 +1424,7 @@ tcu::TestStatus InvertSSBOInPlaceTestInstance::iterate (void) for (deUint32 i = 0; i < m_numValues; ++i) inputData[i] = *bufferPtr++ = rnd.getUint32(); - flushMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes); + flushAlloc(vk, device, bufferAllocation); } // Create descriptor set @@ -1479,7 +1479,7 @@ tcu::TestStatus InvertSSBOInPlaceTestInstance::iterate (void) // Validate the results const Allocation& bufferAllocation = buffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, bufferAllocation); const deUint32* bufferPtr = static_cast(bufferAllocation.getHostPtr()); @@ -1671,7 +1671,7 @@ tcu::TestStatus WriteToMultipleSSBOTestInstance::iterate (void) // Validate the results { const Allocation& buffer0Allocation = buffer0.getAllocation(); - invalidateMappedMemoryRange(vk, device, buffer0Allocation.getMemory(), buffer0Allocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, buffer0Allocation); const deUint32* buffer0Ptr = static_cast(buffer0Allocation.getHostPtr()); for (deUint32 ndx = 0; ndx < m_numValues; ++ndx) @@ -1689,7 +1689,7 @@ tcu::TestStatus WriteToMultipleSSBOTestInstance::iterate (void) } { const Allocation& buffer1Allocation = buffer1.getAllocation(); - invalidateMappedMemoryRange(vk, device, buffer1Allocation.getMemory(), buffer1Allocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, buffer1Allocation); const deUint32* buffer1Ptr = static_cast(buffer1Allocation.getHostPtr()); for (deUint32 ndx = 0; ndx < m_numValues; ++ndx) @@ -1811,7 +1811,7 @@ tcu::TestStatus SSBOBarrierTestInstance::iterate (void) const Allocation& outputBufferAllocation = outputBuffer.getAllocation(); deUint32* outputBufferPtr = static_cast(outputBufferAllocation.getHostPtr()); *outputBufferPtr = 0; - flushMappedMemoryRange(vk, device, outputBufferAllocation.getMemory(), outputBufferAllocation.getOffset(), outputBufferSizeBytes); + flushAlloc(vk, device, outputBufferAllocation); } // Create a uniform buffer (to pass uniform constants) @@ -1827,7 +1827,7 @@ tcu::TestStatus SSBOBarrierTestInstance::iterate (void) deUint32* uniformBufferPtr = static_cast(uniformBufferAllocation.getHostPtr()); uniformBufferPtr[0] = baseValue; - flushMappedMemoryRange(vk, device, uniformBufferAllocation.getMemory(), uniformBufferAllocation.getOffset(), uniformBufferSizeBytes); + flushAlloc(vk, device, uniformBufferAllocation); } // Create descriptor set @@ -1901,7 +1901,7 @@ tcu::TestStatus SSBOBarrierTestInstance::iterate (void) // Validate the results const Allocation& outputBufferAllocation = outputBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, outputBufferAllocation.getMemory(), outputBufferAllocation.getOffset(), outputBufferSizeBytes); + invalidateAlloc(vk, device, outputBufferAllocation); const deUint32* bufferPtr = static_cast(outputBufferAllocation.getHostPtr()); const deUint32 res = *bufferPtr; @@ -2028,7 +2028,7 @@ tcu::TestStatus ImageAtomicOpTestInstance::iterate (void) for (deUint32 i = 0; i < numInputValues; ++i) *bufferPtr++ = rnd.getUint32(); - flushMappedMemoryRange(vk, device, inputBufferAllocation.getMemory(), inputBufferAllocation.getOffset(), inputBufferSizeBytes); + flushAlloc(vk, device, inputBufferAllocation); } // Create a buffer to store shader output (copied from image data) @@ -2114,7 +2114,7 @@ tcu::TestStatus ImageAtomicOpTestInstance::iterate (void) // Validate the results const Allocation& outputBufferAllocation = outputBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, outputBufferAllocation.getMemory(), outputBufferAllocation.getOffset(), outputBufferSizeBytes); + invalidateAlloc(vk, device, outputBufferAllocation); const deUint32* bufferPtr = static_cast(outputBufferAllocation.getHostPtr()); const deUint32* refBufferPtr = static_cast(inputBuffer.getAllocation().getHostPtr()); @@ -2237,7 +2237,7 @@ tcu::TestStatus ImageBarrierTestInstance::iterate (void) const Allocation& outputBufferAllocation = outputBuffer.getAllocation(); deUint32* outputBufferPtr = static_cast(outputBufferAllocation.getHostPtr()); *outputBufferPtr = 0; - flushMappedMemoryRange(vk, device, outputBufferAllocation.getMemory(), outputBufferAllocation.getOffset(), outputBufferSizeBytes); + flushAlloc(vk, device, outputBufferAllocation); } // Create a uniform buffer (to pass uniform constants) @@ -2253,7 +2253,7 @@ tcu::TestStatus ImageBarrierTestInstance::iterate (void) deUint32* uniformBufferPtr = static_cast(uniformBufferAllocation.getHostPtr()); uniformBufferPtr[0] = baseValue; - flushMappedMemoryRange(vk, device, uniformBufferAllocation.getMemory(), uniformBufferAllocation.getOffset(), uniformBufferSizeBytes); + flushAlloc(vk, device, uniformBufferAllocation); } // Create descriptor set @@ -2336,7 +2336,7 @@ tcu::TestStatus ImageBarrierTestInstance::iterate (void) // Validate the results const Allocation& outputBufferAllocation = outputBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, outputBufferAllocation.getMemory(), outputBufferAllocation.getOffset(), outputBufferSizeBytes); + invalidateAlloc(vk, device, outputBufferAllocation); const int numValues = multiplyComponents(m_imageSize); const deUint32* bufferPtr = static_cast(outputBufferAllocation.getHostPtr()); @@ -2618,7 +2618,7 @@ tcu::TestStatus DispatchBaseTestInstance::iterate (void) uniformInputData[0] = *bufferPtr++ = m_workSize.x(); uniformInputData[1] = *bufferPtr++ = m_workSize.y(); uniformInputData[2] = *bufferPtr++ = m_workSize.z(); - flushMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), uniformBufferSizeBytes); + flushAlloc(vk, device, bufferAllocation); } { @@ -2628,7 +2628,7 @@ tcu::TestStatus DispatchBaseTestInstance::iterate (void) for (deUint32 i = 0; i < m_numValues; ++i) inputData[i] = *bufferPtr++ = rnd.getUint32(); - flushMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes); + flushAlloc(vk, device, bufferAllocation); } // Create descriptor set @@ -2712,7 +2712,7 @@ tcu::TestStatus DispatchBaseTestInstance::iterate (void) // Validate the results const Allocation& bufferAllocation = buffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, bufferAllocation); const deUint32* bufferPtr = static_cast(bufferAllocation.getHostPtr()); for (deUint32 ndx = 0; ndx < m_numValues; ++ndx) @@ -2896,7 +2896,7 @@ tcu::TestStatus DeviceIndexTestInstance::iterate (void) for (deUint32 i = 0; i < uniformBufSize; ++i) uniformInputData[i] = *bufferPtr++ = rnd.getUint32() / 10; // divide to prevent overflow in addition - flushMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), uniformBufferSizeBytes); + flushAlloc(vk, device, bufferAllocation); } // Create descriptor set @@ -2940,7 +2940,7 @@ tcu::TestStatus DeviceIndexTestInstance::iterate (void) const Allocation& bufferAllocation = uniformBuffer.getAllocation(); deUint32* bufferPtr = static_cast(bufferAllocation.getHostPtr()); constantValPerLoop = *bufferPtr = rnd.getUint32() / 10; // divide to prevent overflow in addition - flushMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), sizeof(constantValPerLoop)); + flushAlloc(vk, device, bufferAllocation); } beginCommandBuffer(vk, *cmdBuffer); @@ -2983,7 +2983,7 @@ tcu::TestStatus DeviceIndexTestInstance::iterate (void) submitCommandsAndWait(vk, device, queue, *cmdBuffer, true, deviceMask); const Allocation& bufferAllocation = checkBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, bufferAllocation.getMemory(), bufferAllocation.getOffset(), bufferSizeBytes); + invalidateAlloc(vk, device, bufferAllocation); const deUint32* bufferPtr = static_cast(bufferAllocation.getHostPtr()); for (deUint32 ndx = 0; ndx < m_numValues; ++ndx) diff --git a/external/vulkancts/modules/vulkan/compute/vktComputeIndirectComputeDispatchTests.cpp b/external/vulkancts/modules/vulkan/compute/vktComputeIndirectComputeDispatchTests.cpp index 74e2e91..e514564 100644 --- a/external/vulkancts/modules/vulkan/compute/vktComputeIndirectComputeDispatchTests.cpp +++ b/external/vulkancts/modules/vulkan/compute/vktComputeIndirectComputeDispatchTests.cpp @@ -134,8 +134,7 @@ protected: const Buffer& indirectBuffer); deBool verifyResultBuffer (const Buffer& resultBuffer, - const vk::VkDeviceSize resultBlockSize, - const vk::VkDeviceSize resultBufferSize) const; + const vk::VkDeviceSize resultBlockSize) const; Context& m_context; const std::string m_name; @@ -196,7 +195,7 @@ void IndirectDispatchInstanceBufferUpload::fillIndirectBufferData (const vk::VkC dstPtr[2] = cmdIter->m_numWorkGroups[2]; } - vk::flushMappedMemoryRange(m_device_interface, m_device, alloc.getMemory(), alloc.getOffset(), m_bufferSize); + vk::flushAlloc(m_device_interface, m_device, alloc); } tcu::TestStatus IndirectDispatchInstanceBufferUpload::iterate (void) @@ -239,7 +238,7 @@ tcu::TestStatus IndirectDispatchInstanceBufferUpload::iterate (void) *(deUint32*)(dstPtr + RESULT_BLOCK_NUM_PASSED_OFFSET) = 0; } - vk::flushMappedMemoryRange(m_device_interface, m_device, alloc.getMemory(), alloc.getOffset(), resultBufferSize); + vk::flushAlloc(m_device_interface, m_device, alloc); } // Create verify compute shader @@ -321,19 +320,18 @@ tcu::TestStatus IndirectDispatchInstanceBufferUpload::iterate (void) submitCommandsAndWait(m_device_interface, m_device, m_queue, *cmdBuffer); // Check if result buffer contains valid values - if (verifyResultBuffer(resultBuffer, resultBlockSize, resultBufferSize)) + if (verifyResultBuffer(resultBuffer, resultBlockSize)) return tcu::TestStatus(QP_TEST_RESULT_PASS, "Pass"); else return tcu::TestStatus(QP_TEST_RESULT_FAIL, "Invalid values in result buffer"); } deBool IndirectDispatchInstanceBufferUpload::verifyResultBuffer (const Buffer& resultBuffer, - const vk::VkDeviceSize resultBlockSize, - const vk::VkDeviceSize resultBufferSize) const + const vk::VkDeviceSize resultBlockSize) const { deBool allOk = true; const vk::Allocation& alloc = resultBuffer.getAllocation(); - vk::invalidateMappedMemoryRange(m_device_interface, m_device, alloc.getMemory(), alloc.getOffset(), resultBufferSize); + vk::invalidateAlloc(m_device_interface, m_device, alloc); const deUint8* const resultDataPtr = reinterpret_cast(alloc.getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/compute/vktComputeShaderBuiltinVarTests.cpp b/external/vulkancts/modules/vulkan/compute/vktComputeShaderBuiltinVarTests.cpp index 557fb29..c28a0eb 100644 --- a/external/vulkancts/modules/vulkan/compute/vktComputeShaderBuiltinVarTests.cpp +++ b/external/vulkancts/modules/vulkan/compute/vktComputeShaderBuiltinVarTests.cpp @@ -445,7 +445,7 @@ tcu::TestStatus ComputeBuiltinVarInstance::iterate (void) { const Allocation& alloc = uniformBuffer.getAllocation(); memcpy(alloc.getHostPtr(), &stride, sizeOfUniformBuffer); - flushMappedMemoryRange(m_vki, m_device, alloc.getMemory(), alloc.getOffset(), sizeOfUniformBuffer); + flushAlloc(m_vki, m_device, alloc); } // Create descriptorSetLayout @@ -504,7 +504,7 @@ tcu::TestStatus ComputeBuiltinVarInstance::iterate (void) submitCommandsAndWait(m_vki, m_device, m_queue, *cmdBuffer); const Allocation& resultAlloc = resultBuffer.getAllocation(); - invalidateMappedMemoryRange(m_vki, m_device, resultAlloc.getMemory(), resultAlloc.getOffset(), resultBufferSize); + invalidateAlloc(m_vki, m_device, resultAlloc); const deUint8* ptr = reinterpret_cast(resultAlloc.getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateBaseClass.cpp b/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateBaseClass.cpp index ed9c3b1..22baf45 100644 --- a/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateBaseClass.cpp +++ b/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateBaseClass.cpp @@ -98,10 +98,7 @@ void DynamicStateBaseClass::initialize (void) deUint8* ptr = reinterpret_cast(m_vertexBuffer->getBoundMemory().getHostPtr()); deMemcpy(ptr, &m_data[0], (size_t)dataSize); - vk::flushMappedMemoryRange(m_vk, device, - m_vertexBuffer->getBoundMemory().getMemory(), - m_vertexBuffer->getBoundMemory().getOffset(), - dataSize); + vk::flushAlloc(m_vk, device, m_vertexBuffer->getBoundMemory()); const CmdPoolCreateInfo cmdPoolCreateInfo(queueFamilyIndex); m_cmdPool = vk::createCommandPool(m_vk, device, &cmdPoolCreateInfo); diff --git a/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateDSTests.cpp b/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateDSTests.cpp index 20a7832..37f41d6 100644 --- a/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateDSTests.cpp +++ b/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateDSTests.cpp @@ -279,10 +279,7 @@ protected: deUint8* ptr = reinterpret_cast(m_vertexBuffer->getBoundMemory().getHostPtr()); deMemcpy(ptr, &m_data[0], (size_t)dataSize); - vk::flushMappedMemoryRange(m_vk, device, - m_vertexBuffer->getBoundMemory().getMemory(), - m_vertexBuffer->getBoundMemory().getOffset(), - dataSize); + vk::flushAlloc(m_vk, device, m_vertexBuffer->getBoundMemory()); const CmdPoolCreateInfo cmdPoolCreateInfo(m_context.getUniversalQueueFamilyIndex()); m_cmdPool = vk::createCommandPool(m_vk, device, &cmdPoolCreateInfo); @@ -668,10 +665,7 @@ tcu::TestStatus DepthBoundsTestInstance::iterate (void) deUint8* ptr = reinterpret_cast(stageBuffer->getBoundMemory().getHostPtr()); deMemcpy(ptr, depthData.getLevel(0).getDataPtr(), (size_t)dataSize); - vk::flushMappedMemoryRange(m_vk, device, - stageBuffer->getBoundMemory().getMemory(), - stageBuffer->getBoundMemory().getOffset(), - dataSize); + vk::flushAlloc(m_vk, device, stageBuffer->getBoundMemory()); beginCommandBuffer(m_vk, *m_cmdBuffer, 0u); diff --git a/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateRSTests.cpp b/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateRSTests.cpp index 0bd23da..77ad1b3 100644 --- a/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateRSTests.cpp +++ b/external/vulkancts/modules/vulkan/dynamic_state/vktDynamicStateRSTests.cpp @@ -251,10 +251,7 @@ protected: deUint8* ptr = reinterpret_cast(m_vertexBuffer->getBoundMemory().getHostPtr()); deMemcpy(ptr, &m_data[0], static_cast(dataSize)); - vk::flushMappedMemoryRange(m_vk, device, - m_vertexBuffer->getBoundMemory().getMemory(), - m_vertexBuffer->getBoundMemory().getOffset(), - dataSize); + vk::flushAlloc(m_vk, device, m_vertexBuffer->getBoundMemory()); const CmdPoolCreateInfo cmdPoolCreateInfo(m_context.getUniversalQueueFamilyIndex()); m_cmdPool = vk::createCommandPool(m_vk, device, &cmdPoolCreateInfo); diff --git a/external/vulkancts/modules/vulkan/image/vktImageMutableTests.cpp b/external/vulkancts/modules/vulkan/image/vktImageMutableTests.cpp index 29d198f..3fbe017 100644 --- a/external/vulkancts/modules/vulkan/image/vktImageMutableTests.cpp +++ b/external/vulkancts/modules/vulkan/image/vktImageMutableTests.cpp @@ -1107,7 +1107,7 @@ void UploadDownloadExecutor::uploadCopy(Context& context) layerOffset += layerSize; } - flushMappedMemoryRange(m_vk, m_device, m_uCopy.colorBufferAlloc->getMemory(), m_uCopy.colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(m_vk, m_device, *(m_uCopy.colorBufferAlloc)); // Prepare buffer and image for copy const VkBufferMemoryBarrier bufferInitBarrier = @@ -1192,7 +1192,7 @@ void UploadDownloadExecutor::uploadDraw(Context& context) m_uDraw.vertexBuffer = makeBuffer(m_vk, m_device, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); m_uDraw.vertexBufferAlloc = bindBuffer(m_vk, m_device, m_allocator, *m_uDraw.vertexBuffer, MemoryRequirement::HostVisible); deMemcpy(m_uDraw.vertexBufferAlloc->getHostPtr(), &vertices[0], static_cast(vertexBufferSize)); - flushMappedMemoryRange(m_vk, m_device, m_uDraw.vertexBufferAlloc->getMemory(), m_uDraw.vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(m_vk, m_device, *(m_uDraw.vertexBufferAlloc)); } // Create attachments and pipelines for each image layer @@ -1575,7 +1575,7 @@ tcu::TestStatus testMutable (Context& context, const CaseDef caseDef) const Unique colorBuffer (makeBuffer(vk, device, colorBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT)); const UniquePtr colorBufferAlloc (bindBuffer(vk, device, allocator, *colorBuffer, MemoryRequirement::HostVisible)); deMemset(colorBufferAlloc->getHostPtr(), 0, static_cast(colorBufferSize)); - flushMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(vk, device, *colorBufferAlloc); // Execute the test UploadDownloadExecutor executor(context, caseDef); @@ -1583,7 +1583,7 @@ tcu::TestStatus testMutable (Context& context, const CaseDef caseDef) // Verify results { - invalidateMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *colorBufferAlloc); // For verification purposes, we use the format of the upload to generate the expected image const VkFormat format = caseDef.upload == UPLOAD_CLEAR || caseDef.upload == UPLOAD_COPY ? caseDef.imageFormat : caseDef.viewFormat; diff --git a/external/vulkancts/modules/vulkan/image/vktImageSizeTests.cpp b/external/vulkancts/modules/vulkan/image/vktImageSizeTests.cpp index 9102fbb..c177f68 100644 --- a/external/vulkancts/modules/vulkan/image/vktImageSizeTests.cpp +++ b/external/vulkancts/modules/vulkan/image/vktImageSizeTests.cpp @@ -323,7 +323,7 @@ tcu::TestStatus SizeTestInstance::iterate (void) // Compare the result. const Allocation& bufferAlloc = m_resultBuffer->getAllocation(); - invalidateMappedMemoryRange(vk, device, bufferAlloc.getMemory(), bufferAlloc.getOffset(), m_resultBufferSizeBytes); + invalidateAlloc(vk, device, bufferAlloc); const tcu::IVec3 resultSize = readIVec3(bufferAlloc.getHostPtr()); const tcu::IVec3 expectedSize = getExpectedImageSizeResult(m_texture); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineBlendTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineBlendTests.cpp index 6b683fb..daf6274 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineBlendTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineBlendTests.cpp @@ -512,16 +512,7 @@ BlendTestInstance::BlendTestInstance (Context& context, // Upload vertex data deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA)); - const VkMappedMemoryRange flushRange = - { - VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // VkStructureType sType; - DE_NULL, // const void* pNext; - m_vertexBufferAlloc->getMemory(), // VkDeviceMemory memory; - m_vertexBufferAlloc->getOffset(), // VkDeviceSize offset; - vertexBufferParams.size // VkDeviceSize size; - }; - - vk.flushMappedMemoryRanges(vkDevice, 1, &flushRange); + flushAlloc(vk, vkDevice, *m_vertexBufferAlloc); } // Create command pool diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineCacheTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineCacheTests.cpp index 081b735..3ef1dd7 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineCacheTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineCacheTests.cpp @@ -756,7 +756,7 @@ GraphicsCacheTestInstance::GraphicsCacheTestInstance (Context& cont m_vertices = createOverlappingQuads(); // Load vertices into vertex buffer deMemcpy(m_vertexBufferMemory->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA)); - flushMappedMemoryRange(vk, vkDevice, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset(), 1024u); + flushAlloc(vk, vkDevice, *m_vertexBufferMemory); } // Create render pass @@ -1128,7 +1128,7 @@ void ComputeCacheTestInstance::buildBuffers (void) for (deUint32 component = 0u; component < 4u; component++) pVec[ndx][component]= (float)(ndx * (component + 1u)); } - flushMappedMemoryRange(vk, vkDevice, m_inputBufferAlloc->getMemory(), m_inputBufferAlloc->getOffset(), size); + flushAlloc(vk, vkDevice, *m_inputBufferAlloc); // Clear the output buffer for (deUint32 ndx = 0; ndx < PIPELINE_CACHE_NDX_COUNT; ndx++) @@ -1140,7 +1140,7 @@ void ComputeCacheTestInstance::buildBuffers (void) for (deUint32 i = 0; i < (size / sizeof(tcu::Vec4)); i++) pVec[i] = tcu::Vec4(0.0f); - flushMappedMemoryRange(vk, vkDevice, m_outputBufferAlloc[ndx]->getMemory(), m_outputBufferAlloc[ndx]->getOffset(), size); + flushAlloc(vk, vkDevice, *m_outputBufferAlloc[ndx]); } } @@ -1293,17 +1293,9 @@ tcu::TestStatus ComputeCacheTestInstance::verifyTestResult (void) const VkDevice vkDevice = m_context.getDevice(); // Read the content of output buffers - invalidateMappedMemoryRange(vk, - vkDevice, - m_outputBufferAlloc[PIPELINE_CACHE_NDX_NO_CACHE]->getMemory(), - m_outputBufferAlloc[PIPELINE_CACHE_NDX_NO_CACHE]->getOffset(), - sizeof(tcu::Vec4) * 128u); - - invalidateMappedMemoryRange(vk, - vkDevice, - m_outputBufferAlloc[PIPELINE_CACHE_NDX_CACHED]->getMemory(), - m_outputBufferAlloc[PIPELINE_CACHE_NDX_CACHED]->getOffset(), - sizeof(tcu::Vec4) * 128u); + invalidateAlloc(vk, vkDevice, *m_outputBufferAlloc[PIPELINE_CACHE_NDX_NO_CACHE]); + + invalidateAlloc(vk, vkDevice, *m_outputBufferAlloc[PIPELINE_CACHE_NDX_CACHED]); // Compare the content deUint8* bufNoCache = reinterpret_cast(m_outputBufferAlloc[PIPELINE_CACHE_NDX_NO_CACHE]->getHostPtr()); deUint8* bufCached = reinterpret_cast(m_outputBufferAlloc[PIPELINE_CACHE_NDX_CACHED]->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineDepthTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineDepthTests.cpp index 9804c1f..2f24cab 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineDepthTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineDepthTests.cpp @@ -551,7 +551,7 @@ DepthTestInstance::DepthTestInstance (Context& context, // Load vertices into vertex buffer deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA)); - flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferParams.size); + flushAlloc(vk, vkDevice, *m_vertexBufferAlloc); } // Create command pool diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineFramebufferAttachmentTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineFramebufferAttachmentTests.cpp index 297fa86..96bb6f7 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineFramebufferAttachmentTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineFramebufferAttachmentTests.cpp @@ -437,7 +437,7 @@ tcu::TestStatus test (Context& context, const CaseDef caseDef) vertexBufferAlloc = bindBuffer(vk, device, allocator, *vertexBuffer, MemoryRequirement::HostVisible); deMemcpy(vertexBufferAlloc->getHostPtr(), &vertices[0], static_cast(vertexBufferSize)); - flushMappedMemoryRange(vk, device, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, device, *vertexBufferAlloc); } // create colorImage (and msColorImage) using the configured attachmentsize @@ -648,7 +648,7 @@ tcu::TestStatus test (Context& context, const CaseDef caseDef) // Verify results { - invalidateMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *colorBufferAlloc); const tcu::TextureFormat format = mapVkFormat(COLOR_FORMAT); const int depth = deMax32(caseDef.attachmentSize.z(), caseDef.numLayers); tcu::TextureLevel textureLevel (format, caseDef.attachmentSize.x(), caseDef.attachmentSize.y(), depth); @@ -847,7 +847,7 @@ tcu::TestStatus testNoAtt (Context& context, const bool multisample) vertexBuffer = makeBuffer(vk, device, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); vertexBufferAlloc = bindBuffer(vk, device, allocator, *vertexBuffer, MemoryRequirement::HostVisible); deMemcpy(vertexBufferAlloc->getHostPtr(), &vertices[0], static_cast(vertexBufferSize)); - flushMappedMemoryRange(vk, device, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, device, *vertexBufferAlloc); } // Create render pass and pipeline @@ -941,7 +941,7 @@ tcu::TestStatus testNoAtt (Context& context, const bool multisample) // Verify results { - invalidateMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *colorBufferAlloc); const tcu::TextureFormat format = mapVkFormat(COLOR_FORMAT); tcu::TextureLevel textureLevel (format, imageWidth, imageHeight, imageDepth); const tcu::PixelBufferAccess expectedImage = getExpectedDataNoAtt(textureLevel); @@ -1098,7 +1098,7 @@ tcu::TestStatus testDifferentAttachmentSizes (Context& context, const CaseDef ca vertexBufferAlloc = bindBuffer(vk, device, allocator, *vertexBuffer, MemoryRequirement::HostVisible); deMemcpy(vertexBufferAlloc->getHostPtr(), &vertices[0], static_cast(vertexBufferSize)); - flushMappedMemoryRange(vk, device, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, device, *vertexBufferAlloc); } // create colorImages (and msColorImages) using the configured attachmentsize @@ -1308,7 +1308,7 @@ tcu::TestStatus testDifferentAttachmentSizes (Context& context, const CaseDef ca tcu::Vec4(0.25f, 0.5f, 1.0, 1.0f) }; - invalidateMappedMemoryRange(vk, device, colorBufferAllocs[renderTargetIdx]->getMemory(), colorBufferAllocs[renderTargetIdx]->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *colorBufferAllocs[renderTargetIdx]); for (int z = 0; z < expectedImage.getDepth(); ++z) { diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineImageSamplingInstance.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineImageSamplingInstance.cpp index d7aa9aa..e8feb72 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineImageSamplingInstance.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineImageSamplingInstance.cpp @@ -694,7 +694,7 @@ ImageSamplingInstance::ImageSamplingInstance (Context& context, // Load vertices into vertex buffer deMemcpy(m_vertexBufferAlloc->getHostPtr(), &m_vertices[0], (size_t)vertexBufferSize); - flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferParams.size); + flushAlloc(vk, vkDevice, *m_vertexBufferAlloc); } // Create command pool diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.cpp index a9d5bcc..3eeccd7 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.cpp @@ -318,7 +318,7 @@ de::MovePtr readColorAttachment (const vk::DeviceInterface& v submitCommandsAndWait(vk, device, queue, cmdBuffer.get()); // Read buffer data - invalidateMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *bufferAlloc); tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), bufferAlloc->getHostPtr())); return resultLevel; @@ -391,7 +391,7 @@ void uploadTestTextureInternal (const DeviceInterface& vk, } } - flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(vk, device, *bufferAlloc); } copyBufferToImage(vk, device, queue, queueFamilyIndex, *buffer, bufferSize, copyRegions, DE_NULL, imageAspectFlags, srcTexture.getNumLevels(), srcTexture.getArraySize(), destImage); @@ -484,7 +484,7 @@ void uploadTestTextureInternalSparse (const DeviceInterface& vk, } } - flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(vk, device, *bufferAlloc); } copyBufferToImage(vk, device, universalQueue, universalQueueFamilyIndex, *buffer, bufferSize, copyRegions, &(*imageMemoryBindSemaphore), imageAspectFlags, imageCreateInfo.mipLevels, imageCreateInfo.arrayLayers, destImage); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineInputAssemblyTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineInputAssemblyTests.cpp index ba760e2..da11f67 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineInputAssemblyTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineInputAssemblyTests.cpp @@ -1276,26 +1276,8 @@ InputAssemblyInstance::InputAssemblyInstance (Context& context, // Load vertices into vertex buffer deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA)); - // Flush memory - const VkMappedMemoryRange flushMemoryRanges[] = - { - { - VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // VkStructureType sType; - DE_NULL, // const void* pNext; - m_indexBufferAlloc->getMemory(), // VkDeviceMemory memory; - m_indexBufferAlloc->getOffset(), // VkDeviceSize offset; - indexBufferParams.size // VkDeviceSize size; - }, - { - VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // VkStructureType sType; - DE_NULL, // const void* pNext; - m_vertexBufferAlloc->getMemory(), // VkDeviceMemory memory; - m_vertexBufferAlloc->getOffset(), // VkDeviceSize offset; - vertexBufferParams.size // VkDeviceSize size; - }, - }; - - vk.flushMappedMemoryRanges(vkDevice, 2, flushMemoryRanges); + flushAlloc(vk, vkDevice, *m_indexBufferAlloc); + flushAlloc(vk, vkDevice, *m_vertexBufferAlloc); } // Create command pool diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleBaseResolve.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleBaseResolve.cpp index 1784ffc..838e6b1 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleBaseResolve.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleBaseResolve.cpp @@ -211,7 +211,7 @@ tcu::TestStatus MSInstanceBaseResolve::iterate (void) uploadVertexData(vertexBufferAllocation, vertexDataDesc); - flushMappedMemoryRange(deviceInterface, device, vertexBufferAllocation.getMemory(), vertexBufferAllocation.getOffset(), VK_WHOLE_SIZE); + flushAlloc(deviceInterface, device, vertexBufferAllocation); const VkVertexInputBindingDescription vertexBinding = { @@ -382,7 +382,7 @@ tcu::TestStatus MSInstanceBaseResolve::iterate (void) // Retrieve data from buffer to host memory const Allocation& bufferRSAllocation = bufferRS->getAllocation(); - invalidateMappedMemoryRange(deviceInterface, device, bufferRSAllocation.getMemory(), bufferRSAllocation.getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(deviceInterface, device, bufferRSAllocation); const tcu::ConstPixelBufferAccess bufferRSData (m_imageFormat, imageRSInfo.extent.width, diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleBaseResolveAndPerSampleFetch.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleBaseResolveAndPerSampleFetch.cpp index 11bb8b3..1149a3f 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleBaseResolveAndPerSampleFetch.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleBaseResolveAndPerSampleFetch.cpp @@ -378,7 +378,7 @@ tcu::TestStatus MSInstanceBaseResolveAndPerSampleFetch::iterate (void) uploadVertexData(vertexBufferAllocation, vertexDataDesc); - flushMappedMemoryRange(deviceInterface, device, vertexBufferAllocation.getMemory(), vertexBufferAllocation.getOffset(), VK_WHOLE_SIZE); + flushAlloc(deviceInterface, device, vertexBufferAllocation); const VkVertexInputBindingDescription vertexBinding = { @@ -457,7 +457,7 @@ tcu::TestStatus MSInstanceBaseResolveAndPerSampleFetch::iterate (void) deMemcpy(vertexAllocPerSampleFetchPass.getHostPtr(), dataPointer(vertices), static_cast(bufferPerSampleFetchPassSize)); - flushMappedMemoryRange(deviceInterface, device, vertexAllocPerSampleFetchPass.getMemory(), vertexAllocPerSampleFetchPass.getOffset(), VK_WHOLE_SIZE); + flushAlloc(deviceInterface, device, vertexAllocPerSampleFetchPass); for (deUint32 sampleNdx = 0u; sampleNdx < numSamples; ++sampleNdx) { @@ -512,7 +512,7 @@ tcu::TestStatus MSInstanceBaseResolveAndPerSampleFetch::iterate (void) deMemcpy(bufferSampleID->getAllocation().getHostPtr(), sampleIDs, static_cast(uboOffsetAlignment * numSamples)); - flushMappedMemoryRange(deviceInterface, device, bufferSampleID->getAllocation().getMemory(), bufferSampleID->getAllocation().getOffset(), VK_WHOLE_SIZE); + flushAlloc(deviceInterface, device, bufferSampleID->getAllocation()); delete[] sampleIDs; } @@ -734,7 +734,7 @@ tcu::TestStatus MSInstanceBaseResolveAndPerSampleFetch::iterate (void) // Retrieve data from bufferRS to host memory const Allocation& bufferRSAlloc = bufferRS->getAllocation(); - invalidateMappedMemoryRange(deviceInterface, device, bufferRSAlloc.getMemory(), bufferRSAlloc.getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(deviceInterface, device, bufferRSAlloc); const tcu::ConstPixelBufferAccess bufferRSData (m_imageFormat, imageRSInfo.extent.width, @@ -757,7 +757,7 @@ tcu::TestStatus MSInstanceBaseResolveAndPerSampleFetch::iterate (void) { const Allocation& bufferAlloc = buffersPerSample[sampleNdx]->getAllocation(); - invalidateMappedMemoryRange(deviceInterface, device, bufferAlloc.getMemory(), bufferAlloc.getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(deviceInterface, device, bufferAlloc); buffersPerSampleData[sampleNdx] = tcu::ConstPixelBufferAccess ( diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleImageTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleImageTests.cpp index 26d7836..77e0e11 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleImageTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleImageTests.cpp @@ -521,7 +521,7 @@ void checkImageFormatRequirements (const InstanceInterface& vki, void zeroBuffer (const DeviceInterface& vk, const VkDevice device, const Allocation& alloc, const VkDeviceSize bufferSize) { deMemset(alloc.getHostPtr(), 0, static_cast(bufferSize)); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), bufferSize); + flushAlloc(vk, device, alloc); } //! The default foreground color. @@ -788,7 +788,7 @@ void renderMultisampledImage (Context& context, const CaseDef& caseDef, const Vk { deMemcpy(vertexBufferAlloc->getHostPtr(), &vertices[0], static_cast(vertexBufferSize)); - flushMappedMemoryRange(vk, device, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, device, *vertexBufferAlloc); } const Unique vertexModule (createShaderModule (vk, device, context.getBinaryCollection().get("vert"), 0u)); @@ -964,7 +964,7 @@ tcu::TestStatus test (Context& context, const CaseDef caseDef) { deMemcpy(vertexBufferAlloc->getHostPtr(), &vertices[0], static_cast(vertexBufferSize)); - flushMappedMemoryRange(vk, device, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, device, *vertexBufferAlloc); } // Descriptors @@ -1092,7 +1092,7 @@ tcu::TestStatus test (Context& context, const CaseDef caseDef) // Verify result { - invalidateMappedMemoryRange(vk, device, checksumBufferAlloc->getMemory(), 0ull, checksumBufferSize); + invalidateAlloc(vk, device, *checksumBufferAlloc); const tcu::ConstPixelBufferAccess access(mapVkFormat(checksumFormat), caseDef.renderSize.x(), caseDef.renderSize.y(), 1, checksumBufferAlloc->getHostPtr()); const int numExpectedChecksum = getNumSamples(caseDef.numSamples) * caseDef.numLayers; @@ -1440,8 +1440,8 @@ tcu::TestStatus test (Context& context, const CaseDef caseDef) // Verify { - invalidateMappedMemoryRange(vk, device, resolveImageOneBufferAlloc->getMemory(), resolveImageOneBufferAlloc->getOffset(), resolveBufferSize); - invalidateMappedMemoryRange(vk, device, resolveImageTwoBufferAlloc->getMemory(), resolveImageTwoBufferAlloc->getOffset(), resolveBufferSize); + invalidateAlloc(vk, device, *resolveImageOneBufferAlloc); + invalidateAlloc(vk, device, *resolveImageTwoBufferAlloc); const tcu::PixelBufferAccess layeredImageOne (mapVkFormat(caseDef.colorFormat), caseDef.renderSize.x(), caseDef.renderSize.y(), caseDef.numLayers, resolveImageOneBufferAlloc->getHostPtr()); const tcu::ConstPixelBufferAccess layeredImageTwo (mapVkFormat(caseDef.colorFormat), caseDef.renderSize.x(), caseDef.renderSize.y(), caseDef.numLayers, resolveImageTwoBufferAlloc->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleSampleLocationsExtTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleSampleLocationsExtTests.cpp index ab35982..7f24747 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleSampleLocationsExtTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleSampleLocationsExtTests.cpp @@ -1657,7 +1657,7 @@ protected: endCommandBuffer(vk, *cmdBuffer); submitCommandsAndWait(vk, device, m_context.getUniversalQueue(), *cmdBuffer); - invalidateMappedMemoryRange(vk, device, m_colorBufferAlloc->getMemory(), m_colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *m_colorBufferAlloc); } void createSampleDataBufferAndDescriptors (const VkDeviceSize bufferSize) @@ -1691,7 +1691,7 @@ protected: SampleDataSSBO::gridSize (m_sampleDataBufferAlloc->getHostPtr()) = m_pixelGrid->size(); SampleDataSSBO::samplesPerPixel (m_sampleDataBufferAlloc->getHostPtr()) = m_pixelGrid->samplesPerPixel(); - flushMappedMemoryRange(vk, device, m_sampleDataBufferAlloc->getMemory(), m_sampleDataBufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(vk, device, *m_sampleDataBufferAlloc); } template @@ -1707,7 +1707,7 @@ protected: m_vertexBufferAlloc = bindBuffer(vk, device, allocator, *m_vertexBuffer, MemoryRequirement::HostVisible); deMemcpy(m_vertexBufferAlloc->getHostPtr(), dataOrNullPtr(vertices), static_cast(vertexBufferSize)); - flushMappedMemoryRange(vk, device, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(vk, device, *m_vertexBufferAlloc); } const TestParams m_params; @@ -1806,7 +1806,7 @@ public: DE_ASSERT(locations.size() == numDataEntries); std::copy(locations.begin(), locations.end(), pSampleData); - flushMappedMemoryRange(m_context.getDeviceInterface(), m_context.getDevice(), m_sampleDataBufferAlloc->getMemory(), m_sampleDataBufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(m_context.getDeviceInterface(), m_context.getDevice(), *m_sampleDataBufferAlloc); } drawSinglePass(VERTEX_INPUT_VEC4_VEC4); // sample locations are taken from the pixel grid @@ -2103,7 +2103,7 @@ public: m_vertexBufferAlloc = bindBuffer(vk, device, allocator, *m_vertexBuffer, MemoryRequirement::HostVisible); deMemcpy(m_vertexBufferAlloc->getHostPtr(), dataOrNullPtr(vertices), static_cast(vertexBufferSize)); - flushMappedMemoryRange(vk, device, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(vk, device, *m_vertexBufferAlloc); } // Multisample pixel grids - set up two sample patterns for two draw passes @@ -2339,7 +2339,7 @@ protected: endCommandBuffer(vk, *cmdBuffer); submitCommandsAndWait(vk, device, m_context.getUniversalQueue(), *cmdBuffer); - invalidateMappedMemoryRange(vk, device, m_colorBufferAlloc->getMemory(), m_colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *m_colorBufferAlloc); } //! Draw two shapes with distinct sample patterns, each in its own render pass @@ -2707,7 +2707,7 @@ protected: VK_CHECK(vk.waitForFences(device, 1u, &fence.get(), DE_TRUE, ~0ull)); } - invalidateMappedMemoryRange(vk, device, m_colorBufferAlloc->getMemory(), m_colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *m_colorBufferAlloc); } void recordFirstPassContents (const VkCommandBuffer cmdBuffer, @@ -2924,7 +2924,7 @@ protected: endCommandBuffer(vk, *cmdBuffer); submitCommandsAndWait(vk, device, m_context.getUniversalQueue(), *cmdBuffer); - invalidateMappedMemoryRange(vk, device, m_colorBufferAlloc->getMemory(), m_colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *m_colorBufferAlloc); } //! Draw two shapes within the same subpass of a renderpass @@ -3079,7 +3079,7 @@ protected: endCommandBuffer(vk, *cmdBuffer); submitCommandsAndWait(vk, device, m_context.getUniversalQueue(), *cmdBuffer); - invalidateMappedMemoryRange(vk, device, m_colorBufferAlloc->getMemory(), m_colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *m_colorBufferAlloc); } const TestParams m_params; diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleShaderBuiltInTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleShaderBuiltInTests.cpp index 937c490..68458d5 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleShaderBuiltInTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleShaderBuiltInTests.cpp @@ -648,7 +648,7 @@ const VkDescriptorSet* MSInstanceSampleMaskPattern::createMSPassDescSet (const I deMemcpy(m_buffer->getAllocation().getHostPtr(), &m_sampleMask, sizeof(VkSampleMask)); - flushMappedMemoryRange(deviceInterface, device, m_buffer->getAllocation().getMemory(), m_buffer->getAllocation().getOffset(), VK_WHOLE_SIZE); + flushAlloc(deviceInterface, device, m_buffer->getAllocation()); const VkDescriptorBufferInfo descBufferInfo = makeDescriptorBufferInfo(**m_buffer, 0u, sizeof(VkSampleMask)); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleTests.cpp index bc29969..31ce293 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleTests.cpp @@ -2719,7 +2719,7 @@ void MultisampleRenderer::initialize (Context& context, pDst += pVertices[i].size(); } } - flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferParams.size); + flushAlloc(vk, vkDevice, *m_vertexBufferAlloc); } // Create command pool diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelinePushConstantTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelinePushConstantTests.cpp index 00a2f5f..30c2f7d 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelinePushConstantTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelinePushConstantTests.cpp @@ -367,7 +367,7 @@ void PushConstantGraphicsTestInstance::init (void) const tcu::Vec4 value = tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f); deMemcpy(m_uniformBufferAlloc->getHostPtr(), &value, 16u); - flushMappedMemoryRange(vk, vkDevice, m_uniformBufferAlloc->getMemory(), m_uniformBufferAlloc->getOffset(), 16u); + invalidateAlloc(vk, vkDevice, *m_uniformBufferAlloc); // create and update descriptor set const VkDescriptorSetAllocateInfo allocInfo = @@ -525,7 +525,7 @@ void PushConstantGraphicsTestInstance::init (void) // Load vertices into vertex buffer deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA)); - flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferParams.size); + invalidateAlloc(vk, vkDevice, *m_vertexBufferAlloc); } // Create command pool @@ -1858,7 +1858,7 @@ tcu::TestStatus PushConstantComputeTestInstance::iterate (void) submitCommandsAndWait(vk, vkDevice, queue, m_cmdBuffer.get()); - invalidateMappedMemoryRange(vk, vkDevice, m_outBufferAlloc->getMemory(), m_outBufferAlloc->getOffset(), (size_t)(sizeof(tcu::Vec4) * 8)); + invalidateAlloc(vk, vkDevice, *m_outBufferAlloc); // verify result std::vector expectValue(8, tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f)); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelinePushDescriptorTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelinePushDescriptorTests.cpp index af06357..f1155a7 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelinePushDescriptorTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelinePushDescriptorTests.cpp @@ -392,7 +392,7 @@ void PushDescriptorBufferGraphicsTestInstance::init (void) VK_CHECK(m_vkd.bindBufferMemory(*m_device, **m_buffers[bufIdx], m_bufferAllocs[bufIdx]->getMemory(), m_bufferAllocs[bufIdx]->getOffset())); deMemcpy(m_bufferAllocs[bufIdx]->getHostPtr(), &testColors[bufIdx], 16u); - flushMappedMemoryRange(m_vkd, *m_device, m_bufferAllocs[bufIdx]->getMemory(), m_bufferAllocs[bufIdx]->getOffset(), 16u); + flushAlloc(m_vkd, *m_device, *m_bufferAllocs[bufIdx]); } } @@ -481,7 +481,7 @@ void PushDescriptorBufferGraphicsTestInstance::init (void) // Load vertices into vertex buffer deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA)); - flushMappedMemoryRange(m_vkd, *m_device, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferParams.size); + flushAlloc(m_vkd, *m_device, *m_vertexBufferAlloc); } // Create command pool @@ -775,7 +775,7 @@ void PushDescriptorBufferComputeTestInstance::init (void) VK_CHECK(m_vkd.bindBufferMemory(*m_device, **m_buffers[bufIdx], m_bufferAllocs[bufIdx]->getMemory(), m_bufferAllocs[bufIdx]->getOffset())); deMemcpy(m_bufferAllocs[bufIdx]->getHostPtr(), &testColors[bufIdx], 16u); - flushMappedMemoryRange(m_vkd, *m_device, m_bufferAllocs[bufIdx]->getMemory(), m_bufferAllocs[bufIdx]->getOffset(), 16u); + flushAlloc(m_vkd, *m_device, *m_bufferAllocs[bufIdx]); } } @@ -908,7 +908,7 @@ tcu::TestStatus PushDescriptorBufferComputeTestInstance::iterate (void) tcu::TestStatus PushDescriptorBufferComputeTestInstance::verifyOutput (void) { - invalidateMappedMemoryRange(m_vkd, *m_device, m_outputBufferAlloc->getMemory(), m_outputBufferAlloc->getOffset(), (size_t)32u); + invalidateAlloc(m_vkd, *m_device, *m_outputBufferAlloc); // Verify result if (deMemCmp((void*)testColors, m_outputBufferAlloc->getHostPtr(), (size_t)(16u * m_params.numCalls))) diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineRenderToImageTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineRenderToImageTests.cpp index af2a6ec..2b3c139 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineRenderToImageTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineRenderToImageTests.cpp @@ -979,7 +979,7 @@ tcu::TestStatus testWithSizeReduction (Context& context, const CaseDef& caseDef) { deMemset(colorBufferAlloc->getHostPtr(), 0, static_cast(colorBufferSize)); - flushMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(vk, device, *colorBufferAlloc); } const Unique vertexModule (createShaderModule (vk, device, context.getBinaryCollection().get("vert"), 0u)); @@ -1029,7 +1029,7 @@ tcu::TestStatus testWithSizeReduction (Context& context, const CaseDef& caseDef) vertexBufferAlloc = bindBuffer(vki, vk, physDevice, device, *vertexBuffer, MemoryRequirement::HostVisible, allocator, caseDef.allocationKind); deMemcpy(vertexBufferAlloc->getHostPtr(), &vertices[0], static_cast(vertexBufferSize)); - flushMappedMemoryRange(vk, device, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, device, *vertexBufferAlloc); } // Prepare color image upfront for rendering to individual slices. 3D slices aren't separate subresources, so they shouldn't be transitioned @@ -1198,7 +1198,7 @@ tcu::TestStatus testWithSizeReduction (Context& context, const CaseDef& caseDef) // Verify results { - invalidateMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *colorBufferAlloc); const tcu::TextureFormat format = mapVkFormat(caseDef.colorFormat); const int checkDepth = maxLayersOrDepth(checkSize); @@ -1405,7 +1405,7 @@ tcu::TestStatus testRenderToMipMaps (Context& context, const CaseDef caseDef) { deMemset(colorBufferAlloc->getHostPtr(), 0, static_cast(colorBufferSize)); - flushMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + flushAlloc(vk, device, *colorBufferAlloc); } const Unique vertexModule (createShaderModule (vk, device, context.getBinaryCollection().get("vert"), 0u)); @@ -1447,7 +1447,7 @@ tcu::TestStatus testRenderToMipMaps (Context& context, const CaseDef caseDef) vertexBufferAlloc = bindBuffer(vki, vk, physDevice, device, *vertexBuffer, MemoryRequirement::HostVisible, allocator, caseDef.allocationKind); deMemcpy(vertexBufferAlloc->getHostPtr(), &vertices[0], static_cast(vertexBufferSize)); - flushMappedMemoryRange(vk, device, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, device, *vertexBufferAlloc); } // Prepare images @@ -1601,7 +1601,7 @@ tcu::TestStatus testRenderToMipMaps (Context& context, const CaseDef caseDef) // Verify results (per mip level) { - invalidateMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), colorBufferAlloc->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *colorBufferAlloc); const tcu::TextureFormat format = mapVkFormat(caseDef.colorFormat); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineSpecConstantTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineSpecConstantTests.cpp index de4f7e7..0dedc7f 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineSpecConstantTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineSpecConstantTests.cpp @@ -524,7 +524,7 @@ tcu::TestStatus ComputeTestInstance::iterate (void) // Verify results const Allocation& resultAlloc = resultBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, resultAlloc.getMemory(), resultAlloc.getOffset(), m_ssboSize); + invalidateAlloc(vk, device, resultAlloc); if (verifyValues(m_context.getTestContext().getLog(), resultAlloc.getHostPtr(), m_expectedValues)) return tcu::TestStatus::pass("Success"); @@ -592,7 +592,7 @@ tcu::TestStatus GraphicsTestInstance::iterate (void) pVertices[1] = tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.0f); pVertices[2] = tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.0f); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), vertexBufferSizeBytes); + flushAlloc(vk, device, alloc); // No barrier needed, flushed memory is automatically visible } @@ -687,7 +687,7 @@ tcu::TestStatus GraphicsTestInstance::iterate (void) // Verify results const Allocation& resultAlloc = resultBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, resultAlloc.getMemory(), resultAlloc.getOffset(), m_ssboSize); + invalidateAlloc(vk, device, resultAlloc); if (verifyValues(m_context.getTestContext().getLog(), resultAlloc.getHostPtr(), m_expectedValues)) return tcu::TestStatus::pass("Success"); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineStencilExportTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineStencilExportTests.cpp index e33aa47..8707040 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineStencilExportTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineStencilExportTests.cpp @@ -503,7 +503,7 @@ tcu::TestStatus testStencilExportReplace (Context& context) // Zero color buffer. deMemset(colorBufferAlloc->getHostPtr(), 0, static_cast(colorBufferSize)); - flushMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), colorBufferAlloc->getOffset(), colorBufferSize); + flushAlloc(vk, device, *colorBufferAlloc); // Draw two subpasses: first write the stencil data, then use that data when writing color. // @@ -618,7 +618,7 @@ tcu::TestStatus testStencilExportReplace (Context& context) // Compare the resulting color buffer. { - invalidateMappedMemoryRange(vk, device, colorBufferAlloc->getMemory(), 0ull, colorBufferSize); + invalidateAlloc(vk, device, *colorBufferAlloc); const tcu::ConstPixelBufferAccess resultImage (mapVkFormat(colorFormat), renderSize.x(), renderSize.y(), 1u, colorBufferAlloc->getHostPtr()); tcu::TextureLevel referenceImage = generateReferenceImage(mapVkFormat(colorFormat), renderSize, 1 << 4, clearColor, Vec4(0, 0, 1, 1)); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineStencilTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineStencilTests.cpp index 060cc7d..d32d3d3 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineStencilTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineStencilTests.cpp @@ -581,17 +581,7 @@ StencilTestInstance::StencilTestInstance (Context& context, // Load vertices into vertex buffer deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA)); - - const VkMappedMemoryRange flushRange = - { - VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // VkStructureType sType; - DE_NULL, // const void* pNext; - m_vertexBufferAlloc->getMemory(), // VkDeviceMemory memory; - m_vertexBufferAlloc->getOffset(), // VkDeviceSize offset; - vertexBufferParams.size // VkDeviceSize size; - }; - - vk.flushMappedMemoryRanges(vkDevice, 1, &flushRange); + flushAlloc(vk, vkDevice, *m_vertexBufferAlloc); } // Create command pool diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineTimestampTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineTimestampTests.cpp index 874515b..94f2bab 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineTimestampTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineTimestampTests.cpp @@ -900,7 +900,7 @@ void BasicGraphicsTestInstance::buildVertexBuffer(void) m_vertices = createOverlappingQuads(); // Load vertices into vertex buffer deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA)); - flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), 1024u); + flushAlloc(vk, vkDevice, *m_vertexBufferAlloc); } } @@ -1286,7 +1286,7 @@ AdvGraphicsTestInstance::AdvGraphicsTestInstance(Context& context, }; // Load data into indirect draw buffer deMemcpy(m_indirectBufferAlloc->getHostPtr(), indirectCmds, m_draw_count * sizeof(VkDrawIndirectCommand)); - flushMappedMemoryRange(vk, vkDevice, m_indirectBufferAlloc->getMemory(), m_indirectBufferAlloc->getOffset(), 32u); + flushAlloc(vk, vkDevice, *m_indirectBufferAlloc); } @@ -1428,7 +1428,7 @@ BasicComputeTestInstance::BasicComputeTestInstance(Context& context pVec[ndx][component]= (float)(ndx * (component + 1u)); } } - flushMappedMemoryRange(vk, vkDevice, m_inputBufAlloc->getMemory(), m_inputBufAlloc->getOffset(), size); + flushAlloc(vk, vkDevice, *m_inputBufAlloc); m_outputBuf = createBufferAndBindMemory(size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, &m_outputBufAlloc); @@ -1637,7 +1637,7 @@ TransferTestInstance::TransferTestInstance(Context& context, // Init the source buffer memory char* pBuf = reinterpret_cast(m_srcBufferAlloc->getHostPtr()); memset(pBuf, 0xFF, sizeof(char)*(size_t)m_bufSize); - flushMappedMemoryRange(vk, vkDevice, m_srcBufferAlloc->getMemory(), m_srcBufferAlloc->getOffset(), m_bufSize); + flushAlloc(vk, vkDevice, *m_srcBufferAlloc); // Create dst buffer m_dstBuffer = createBufferAndBindMemory(m_bufSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, &m_dstBufferAlloc); diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineVertexInputTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineVertexInputTests.cpp index e4ac295..48ccc23 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineVertexInputTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineVertexInputTests.cpp @@ -1183,7 +1183,7 @@ VertexInputInstance::VertexInputInstance (Context& context, VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset())); writeVertexInputData((deUint8*)vertexBufferAlloc->getHostPtr(), bindingDescriptions[bindingNdx], bindingOffsets[bindingNdx], attributeDescriptions); - flushMappedMemoryRange(vk, vkDevice, vertexBufferAlloc->getMemory(), vertexBufferAlloc->getOffset(), vertexBufferParams.size); + flushAlloc(vk, vkDevice, *vertexBufferAlloc); m_vertexBuffers.push_back(vertexBuffer.disown()); m_vertexBufferAllocs.push_back(vertexBufferAlloc.release()); diff --git a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderExecutor.cpp b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderExecutor.cpp index 44872b0..cb17654 100644 --- a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderExecutor.cpp +++ b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderExecutor.cpp @@ -633,7 +633,7 @@ void FragmentOutExecutor::addAttribute (deUint32 bindingLocation, VkFormat forma VK_CHECK(vk.bindBufferMemory(vkDevice, *buffer, alloc->getMemory(), alloc->getOffset())); deMemcpy(alloc->getHostPtr(), dataPtr, (size_t)inputSize); - flushMappedMemoryRange(vk, vkDevice, alloc->getMemory(), alloc->getOffset(), inputSize); + flushAlloc(vk, vkDevice, *alloc); m_vertexBuffers.push_back(de::SharedPtr >(new Unique(buffer))); m_vertexBufferAllocs.push_back(AllocationSp(alloc.release())); @@ -1187,16 +1187,7 @@ void FragmentOutExecutor::execute (int numValues, const void* const* inputs, voi submitCommandsAndWait(vk, vkDevice, queue, copyCmdBuffer.get()); } - const VkMappedMemoryRange range = - { - VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // VkStructureType sType; - DE_NULL, // const void* pNext; - readImageBufferMemory->getMemory(), // VkDeviceMemory mem; - 0, // VkDeviceSize offset; - imageSizeBytes, // VkDeviceSize size; - }; - - VK_CHECK(vk.invalidateMappedMemoryRanges(vkDevice, 1u, &range)); + invalidateAlloc(vk, vkDevice, *readImageBufferMemory); tmpBuf.setStorage(readFormat, renderSize.x(), renderSize.y()); @@ -1589,7 +1580,7 @@ void BufferIoExecutor::uploadInputBuffer (const void* const* inputPtrs, int numV copyToBuffer(varType, layout, numValues, inputPtrs[inputNdx], m_inputAlloc->getHostPtr()); } - flushMappedMemoryRange(vk, vkDevice, m_inputAlloc->getMemory(), m_inputAlloc->getOffset(), inputBufferSize); + flushAlloc(vk, vkDevice, *m_inputAlloc); } void BufferIoExecutor::readOutputBuffer (void* const* outputPtrs, int numValues) @@ -1597,12 +1588,9 @@ void BufferIoExecutor::readOutputBuffer (void* const* outputPtrs, int numValues) const VkDevice vkDevice = m_context.getDevice(); const DeviceInterface& vk = m_context.getDeviceInterface(); - const deUint32 outputStride = getLayoutStride(m_outputLayout); - const int outputBufferSize = numValues * outputStride; - - DE_ASSERT(outputBufferSize > 0); // At least some outputs are required. + DE_ASSERT(numValues > 0); // At least some outputs are required. - invalidateMappedMemoryRange(vk, vkDevice, m_outputAlloc->getMemory(), m_outputAlloc->getOffset(), outputBufferSize); + invalidateAlloc(vk, vkDevice, *m_outputAlloc); DE_ASSERT(m_shaderSpec.outputs.size() == m_outputLayout.size()); for (size_t outputNdx = 0; outputNdx < m_shaderSpec.outputs.size(); ++outputNdx) diff --git a/external/vulkancts/modules/vulkan/shaderrender/vktShaderRender.cpp b/external/vulkancts/modules/vulkan/shaderrender/vktShaderRender.cpp index 7750c51..4dcd9ac 100644 --- a/external/vulkancts/modules/vulkan/shaderrender/vktShaderRender.cpp +++ b/external/vulkancts/modules/vulkan/shaderrender/vktShaderRender.cpp @@ -728,7 +728,7 @@ void ShaderRenderCaseInstance::setupUniformData (deUint32 bindingLocation, size_ VK_CHECK(vk.bindBufferMemory(vkDevice, *buffer, alloc->getMemory(), alloc->getOffset())); deMemcpy(alloc->getHostPtr(), dataPtr, size); - flushMappedMemoryRange(vk, vkDevice, alloc->getMemory(), alloc->getOffset(), size); + flushAlloc(vk, vkDevice, *alloc); de::MovePtr uniformInfo(new BufferUniform()); uniformInfo->type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; @@ -799,7 +799,7 @@ void ShaderRenderCaseInstance::addAttribute (deUint32 bindingLocation, VK_CHECK(vk.bindBufferMemory(vkDevice, *buffer, alloc->getMemory(), alloc->getOffset())); deMemcpy(alloc->getHostPtr(), dataPtr, (size_t)inputSize); - flushMappedMemoryRange(vk, vkDevice, alloc->getMemory(), alloc->getOffset(), inputSize); + flushAlloc(vk, vkDevice, *alloc); m_vertexBuffers.push_back(VkBufferSp(new vk::Unique(buffer))); m_vertexBufferAllocs.push_back(AllocationSp(alloc.release())); @@ -1047,7 +1047,7 @@ void ShaderRenderCaseInstance::uploadImage (const tcu::TextureFormat& texForma } } - flushMappedMemoryRange(vk, vkDevice, bufferAlloc->getMemory(), bufferAlloc->getOffset(), bufferSize); + flushAlloc(vk, vkDevice, *bufferAlloc); copyBufferToImage(vk, vkDevice, queue, queueFamilyIndex, *buffer, bufferSize, copyRegions, DE_NULL, aspectMask, mipLevels, arrayLayers, destImage); } @@ -2177,7 +2177,7 @@ void ShaderRenderCaseInstance::render (deUint32 numVertices, // Load vertice indices into buffer deMemcpy(indexBufferAlloc->getHostPtr(), indices, (size_t)indexBufferSize); - flushMappedMemoryRange(vk, vkDevice, indexBufferAlloc->getMemory(), indexBufferAlloc->getOffset(), indexBufferSize); + flushAlloc(vk, vkDevice, *indexBufferAlloc); } // Create command pool @@ -2351,7 +2351,7 @@ void ShaderRenderCaseInstance::render (deUint32 numVertices, submitCommandsAndWait(vk, vkDevice, queue, resultCmdBuffer.get()); - invalidateMappedMemoryRange(vk, vkDevice, readImageBufferMemory->getMemory(), readImageBufferMemory->getOffset(), imageSizeBytes); + invalidateAlloc(vk, vkDevice, *readImageBufferMemory); const tcu::ConstPixelBufferAccess resultAccess (resultFormat, m_renderSize.x(), m_renderSize.y(), 1, readImageBufferMemory->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp b/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp index 6c9ff52..e048386 100644 --- a/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp +++ b/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp @@ -1447,7 +1447,7 @@ TestStatus BuiltinFragCoordMsaaCaseInstance::iterate (void) submitCommandsAndWait(vk, device, queue, transferCmdBuffer.get()); - invalidateMappedMemoryRange(vk, device, sampleLocationBufferAllocation->getMemory(), sampleLocationBufferAllocation->getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, *sampleLocationBufferAllocation); } // Validate result diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferMemoryAliasing.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferMemoryAliasing.cpp old mode 100644 new mode 100755 index 7ff678a..58297b1 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferMemoryAliasing.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferMemoryAliasing.cpp @@ -395,7 +395,7 @@ tcu::TestStatus BufferSparseMemoryAliasingInstance::iterate (void) waitStageBits, 0, DE_NULL, m_useDeviceGroups, firstDeviceID); // Retrieve data from output buffer to host memory - invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), m_bufferSizeInBytes); + invalidateAlloc(deviceInterface, getDevice(), *outputBufferAlloc); const deUint8* outputData = static_cast(outputBufferAlloc->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseBinding.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseBinding.cpp old mode 100644 new mode 100755 index 79e2992..edd8b1b --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseBinding.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseBinding.cpp @@ -263,7 +263,7 @@ tcu::TestStatus BufferSparseBindingInstance::iterate (void) deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], m_bufferSize); - flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), m_bufferSize); + flushAlloc(deviceInterface, getDevice(), *inputBufferAlloc); { const VkBufferMemoryBarrier inputBufferBarrier @@ -325,7 +325,7 @@ tcu::TestStatus BufferSparseBindingInstance::iterate (void) waitStageBits, 0, DE_NULL, m_useDeviceGroups, firstDeviceID); // Retrieve data from output buffer to host memory - invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), m_bufferSize); + invalidateAlloc(deviceInterface, getDevice(), *outputBufferAlloc); const deUint8* outputData = static_cast(outputBufferAlloc->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseResidency.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseResidency.cpp old mode 100644 new mode 100755 index e778b79..05ef0e6 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseResidency.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferSparseResidency.cpp @@ -381,7 +381,7 @@ tcu::TestStatus BufferSparseResidencyInstance::iterate (void) waitStageBits, 0, DE_NULL, usingDeviceGroups(), firstDeviceID); // Retrieve data from output buffer to host memory - invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), m_bufferSize); + invalidateAlloc(deviceInterface, getDevice(), *outputBufferAlloc); const deUint8* outputData = static_cast(outputBufferAlloc->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp old mode 100644 new mode 100755 index 59c33da..d8c3b73 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp @@ -720,7 +720,7 @@ public: m_colorBufferAlloc = bindBuffer(vk, getDevice(), getAllocator(), *m_colorBuffer, MemoryRequirement::HostVisible); deMemset(m_colorBufferAlloc->getHostPtr(), 0, static_cast(m_colorBufferSize)); - flushMappedMemoryRange(vk, getDevice(), m_colorBufferAlloc->getMemory(), m_colorBufferAlloc->getOffset(), m_colorBufferSize); + flushAlloc(vk, getDevice(), *m_colorBufferAlloc); } protected: @@ -769,7 +769,7 @@ protected: bool isResultImageCorrect (void) const { - invalidateMappedMemoryRange(getDeviceInterface(), getDevice(), m_colorBufferAlloc->getMemory(), 0ull, m_colorBufferSize); + invalidateAlloc(getDeviceInterface(), getDevice(), *m_colorBufferAlloc); const tcu::ConstPixelBufferAccess resultImage (mapVkFormat(m_colorFormat), m_renderSize.x(), m_renderSize.y(), 1u, m_colorBufferAlloc->getHostPtr()); @@ -995,7 +995,7 @@ public: for (deUint32 i = 0; i < numBufferEntries; ++i) pData[i] = IVec4(3*i ^ 127, 0, 0, 0); - flushMappedMemoryRange(vk, getDevice(), stagingBufferAlloc->getMemory(), stagingBufferAlloc->getOffset(), stagingBufferSize); + flushAlloc(vk, getDevice(), *stagingBufferAlloc); const VkBufferCopy copyRegion = { @@ -1060,7 +1060,7 @@ public: m_vertexBufferAlloc = bindBuffer(vk, getDevice(), getAllocator(), *m_vertexBuffer, MemoryRequirement::HostVisible); deMemcpy(m_vertexBufferAlloc->getHostPtr(), &vertexData[0], vertexBufferSize); - flushMappedMemoryRange(vk, getDevice(), m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, getDevice(), *m_vertexBufferAlloc); } // Draw @@ -1263,7 +1263,7 @@ public: // Upload to the sparse buffer { - flushMappedMemoryRange(vk, getDevice(), m_stagingBufferAlloc->getMemory(), m_stagingBufferAlloc->getOffset(), m_stagingBufferSize); + flushAlloc(vk, getDevice(), *m_stagingBufferAlloc); VkDeviceSize firstChunkOffset = 0ull; VkDeviceSize secondChunkOffset = m_perDrawBufferOffset; @@ -1415,7 +1415,7 @@ public: generateGrid(m_vertexBufferAlloc->getHostPtr(), step, -1.0f, -1.0f, GRID_SIZE, GRID_SIZE); - flushMappedMemoryRange(vk, getDevice(), m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, getDevice(), *m_vertexBufferAlloc); } // Sparse index buffer @@ -1477,7 +1477,7 @@ public: { generateGrid(m_vertexBufferAlloc->getHostPtr(), 2.0f, -1.0f, -1.0f, 1, 1); - flushMappedMemoryRange(vk, getDevice(), m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferSize); + flushAlloc(vk, getDevice(), *m_vertexBufferAlloc); } // Indirect buffer diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageMemoryAliasing.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageMemoryAliasing.cpp old mode 100644 new mode 100755 index 6fd8ce4..dd1aec1 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageMemoryAliasing.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageMemoryAliasing.cpp @@ -454,7 +454,7 @@ tcu::TestStatus ImageSparseMemoryAliasingInstance::iterate (void) deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], imageSizeInBytes); - flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), imageSizeInBytes); + flushAlloc(deviceInterface, getDevice(), *inputBufferAlloc); { const VkBufferMemoryBarrier inputBufferBarrier = makeBufferMemoryBarrier @@ -623,7 +623,7 @@ tcu::TestStatus ImageSparseMemoryAliasingInstance::iterate (void) 0, DE_NULL, m_useDeviceGroups, firstDeviceID); // Retrieve data from buffer to host memory - invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), imageSizeInBytes); + invalidateAlloc(deviceInterface, getDevice(), *outputBufferAlloc); const deUint8* outputData = static_cast(outputBufferAlloc->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseBinding.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseBinding.cpp old mode 100644 new mode 100755 index 21cfae1..488dd12 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseBinding.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseBinding.cpp @@ -298,7 +298,7 @@ tcu::TestStatus ImageSparseBindingInstance::iterate (void) deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], imageSizeInBytes); - flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), imageSizeInBytes); + flushAlloc(deviceInterface, getDevice(), *inputBufferAlloc); { const VkBufferMemoryBarrier inputBufferBarrier = makeBufferMemoryBarrier @@ -374,7 +374,7 @@ tcu::TestStatus ImageSparseBindingInstance::iterate (void) 0, DE_NULL, m_useDeviceGroups, firstDeviceID); // Retrieve data from buffer to host memory - invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), imageSizeInBytes); + invalidateAlloc(deviceInterface, getDevice(), *outputBufferAlloc); const deUint8* outputData = static_cast(outputBufferAlloc->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseResidency.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseResidency.cpp old mode 100644 new mode 100755 index eccb9e0..450b7d4 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseResidency.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseResidency.cpp @@ -583,7 +583,7 @@ tcu::TestStatus ImageSparseResidencyInstance::iterate (void) 0, DE_NULL, m_useDeviceGroups, firstDeviceID); // Retrieve data from buffer to host memory - invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), imageSizeInBytes); + invalidateAlloc(deviceInterface, getDevice(), *outputBufferAlloc); const deUint8* outputData = static_cast(outputBufferAlloc->getHostPtr()); const tcu::ConstPixelBufferAccess pixelBuffer = tcu::ConstPixelBufferAccess(m_format, gridSize.x(), gridSize.y(), gridSize.z(), outputData); diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesMipmapSparseResidency.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesMipmapSparseResidency.cpp old mode 100644 new mode 100755 index 095a6c2..1df0017 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesMipmapSparseResidency.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesMipmapSparseResidency.cpp @@ -406,7 +406,7 @@ tcu::TestStatus MipmapSparseResidencyInstance::iterate (void) deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], imageSizeInBytes); - flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), imageSizeInBytes); + flushAlloc(deviceInterface, getDevice(), *inputBufferAlloc); { const VkBufferMemoryBarrier inputBufferBarrier = makeBufferMemoryBarrier @@ -482,7 +482,7 @@ tcu::TestStatus MipmapSparseResidencyInstance::iterate (void) 0, DE_NULL, m_useDeviceGroups, firstDeviceID); // Retrieve data from buffer to host memory - invalidateMappedMemoryRange(deviceInterface, getDevice(), outputBufferAlloc->getMemory(), outputBufferAlloc->getOffset(), imageSizeInBytes); + invalidateAlloc(deviceInterface, getDevice(), *outputBufferAlloc); const deUint8* outputData = static_cast(outputBufferAlloc->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesShaderIntrinsicsBase.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesShaderIntrinsicsBase.cpp old mode 100644 new mode 100755 index 271b3a4..a3a4528 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesShaderIntrinsicsBase.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesShaderIntrinsicsBase.cpp @@ -518,7 +518,7 @@ tcu::TestStatus SparseShaderIntrinsicsInstanceBase::iterate (void) } deMemcpy(inputBufferAlloc->getHostPtr(), &referenceData[0], imageSparseSizeInBytes); - flushMappedMemoryRange(deviceInterface, getDevice(), inputBufferAlloc->getMemory(), inputBufferAlloc->getOffset(), imageSparseSizeInBytes); + flushAlloc(deviceInterface, getDevice(), *inputBufferAlloc); { // Prepare input buffer for data transfer operation @@ -621,7 +621,7 @@ tcu::TestStatus SparseShaderIntrinsicsInstanceBase::iterate (void) deviceInterface.queueWaitIdle(sparseQueue.queueHandle); // Retrieve data from residency buffer to host memory - invalidateMappedMemoryRange(deviceInterface, getDevice(), bufferResidencyAlloc->getMemory(), bufferResidencyAlloc->getOffset(), imageResidencySizeInBytes); + invalidateAlloc(deviceInterface, getDevice(), *bufferResidencyAlloc); const deUint32* bufferResidencyData = static_cast(bufferResidencyAlloc->getHostPtr()); @@ -638,7 +638,7 @@ tcu::TestStatus SparseShaderIntrinsicsInstanceBase::iterate (void) } // Retrieve data from texels buffer to host memory - invalidateMappedMemoryRange(deviceInterface, getDevice(), bufferTexelsAlloc->getMemory(), bufferTexelsAlloc->getOffset(), imageSparseSizeInBytes); + invalidateAlloc(deviceInterface, getDevice(), *bufferTexelsAlloc); const deUint8* bufferTexelsData = static_cast(bufferTexelsAlloc->getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesShaderIntrinsicsSampled.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesShaderIntrinsicsSampled.cpp index 1abedc1..0e8bad4 100755 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesShaderIntrinsicsSampled.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesShaderIntrinsicsSampled.cpp @@ -555,7 +555,7 @@ void SparseShaderIntrinsicsInstanceSampledBase::recordCommands (const VkCommandB m_vertexBufferAlloc = bindBuffer(deviceInterface, getDevice(), getAllocator(), *m_vertexBuffer, MemoryRequirement::HostVisible); deMemcpy(m_vertexBufferAlloc->getHostPtr(), &vertexData[0], static_cast(vertexDataSizeInBytes)); - flushMappedMemoryRange(deviceInterface, getDevice(), m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexDataSizeInBytes); + flushAlloc(deviceInterface, getDevice(), *m_vertexBufferAlloc); // Create render pass const VkAttachmentDescription texelsAttachmentDescription = diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmComputeShaderCase.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmComputeShaderCase.cpp index 3401fbf..27cb3c6 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmComputeShaderCase.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmComputeShaderCase.cpp @@ -155,7 +155,7 @@ void setMemory (const DeviceInterface& vkdi, const VkDevice& device, Allocation* deMemcpy((deUint8*)hostPtr, data, numBytes); if (!coherent) - flushMappedMemoryRange(vkdi, device, destAlloc->getMemory(), destAlloc->getOffset(), numBytes); + flushAlloc(vkdi, device, *destAlloc); } void fillMemoryWithValue (const DeviceInterface& vkdi, const VkDevice& device, Allocation* destAlloc, size_t numBytes, deUint8 value, bool coherent = false) @@ -165,13 +165,13 @@ void fillMemoryWithValue (const DeviceInterface& vkdi, const VkDevice& device, A deMemset((deUint8*)hostPtr, value, numBytes); if (!coherent) - flushMappedMemoryRange(vkdi, device, destAlloc->getMemory(), destAlloc->getOffset(), numBytes); + flushAlloc(vkdi, device, *destAlloc); } -void invalidateMemory (const DeviceInterface& vkdi, const VkDevice& device, Allocation* srcAlloc, size_t numBytes, bool coherent = false) +void invalidateMemory (const DeviceInterface& vkdi, const VkDevice& device, Allocation* srcAlloc, bool coherent = false) { if (!coherent) - invalidateMappedMemoryRange(vkdi, device, srcAlloc->getMemory(), srcAlloc->getOffset(), numBytes); + invalidateAlloc(vkdi, device, *srcAlloc); } /*--------------------------------------------------------------------*//*! @@ -753,7 +753,7 @@ tcu::TestStatus SpvAsmComputeShaderInstance::iterate (void) // Invalidate output memory ranges before checking on host. for (size_t outputNdx = 0; outputNdx < m_shaderSpec.outputs.size(); ++outputNdx) { - invalidateMemory(vkdi, device, outputAllocs[outputNdx].get(), m_shaderSpec.outputs[outputNdx].getByteSize(), m_shaderSpec.coherentMemory); + invalidateMemory(vkdi, device, outputAllocs[outputNdx].get(), m_shaderSpec.coherentMemory); } // Check output. diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmCrossStageInterfaceTests.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmCrossStageInterfaceTests.cpp index 8673c54..75abdcd 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmCrossStageInterfaceTests.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmCrossStageInterfaceTests.cpp @@ -293,7 +293,7 @@ tcu::TestStatus CrossStageTestInstance::iterate (void) // Init host buffer data VK_CHECK(vk.bindBufferMemory(vkDevice, *vertexBuffer, allocationVertex->getMemory(), allocationVertex->getOffset())); deMemcpy(allocationVertex->getHostPtr(), m_data.data(), static_cast(vertexDataSize)); - flushMappedMemoryRange(vk, vkDevice, allocationVertex->getMemory(), allocationVertex->getOffset(), static_cast(vertexDataSize)); + flushAlloc(vk, vkDevice, *allocationVertex); Move renderPass = makeRenderPass (vk, vkDevice, m_colorFormat); Move frameBuffer = makeFramebuffer (vk, vkDevice, *renderPass, *colorAttachmentView, m_extent.width, m_extent.height); @@ -625,7 +625,7 @@ bool CrossStageTestInstance::checkImage (VkImage image, VkCommandBuffer cmdBuffe VK_CHECK(vk.bindBufferMemory(vkDevice, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset())); deMemset(bufferAlloc->getHostPtr(), 0, static_cast(pixelDataSize)); - flushMappedMemoryRange(vk, vkDevice, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize); + flushAlloc(vk, vkDevice, *bufferAlloc); } const VkBufferMemoryBarrier bufferBarrier = @@ -678,7 +678,7 @@ bool CrossStageTestInstance::checkImage (VkImage image, VkCommandBuffer cmdBuffe submitCommandsAndWait(vk, vkDevice, m_context.getUniversalQueue(), cmdBuffer); // Read buffer data - invalidateMappedMemoryRange(vk, vkDevice, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize); + invalidateAlloc(vk, vkDevice, *bufferAlloc); tcu::copy(dst, tcu::ConstPixelBufferAccess(dst.getFormat(), dst.getSize(), bufferAlloc->getHostPtr())); if (tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "Result", description.c_str(), referenceFrame.getLevel(0), dst, tcu::Vec4(0.05f), tcu::COMPARE_LOG_EVERYTHING)) diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmGraphicsShaderTestUtil.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmGraphicsShaderTestUtil.cpp index 42593bf..fcd3e58 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmGraphicsShaderTestUtil.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmGraphicsShaderTestUtil.cpp @@ -3690,18 +3690,9 @@ TestStatus runAndVerifyDefaultPipeline (Context& context, InstanceContext instan // Upload vertex data { - const VkMappedMemoryRange range = - { - VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // VkStructureType sType; - DE_NULL, // const void* pNext; - vertexBufferMemory->getMemory(), // VkDeviceMemory mem; - 0, // VkDeviceSize offset; - (VkDeviceSize)vertexDataSize, // VkDeviceSize size; - }; - void* vertexBufPtr = vertexBufferMemory->getHostPtr(); - + void* vertexBufPtr = vertexBufferMemory->getHostPtr(); deMemcpy(vertexBufPtr, &vertexData[0], vertexDataSize); - VK_CHECK(vk.flushMappedMemoryRanges(device, 1u, &range)); + flushAlloc(vk, device, *vertexBufferMemory); } if (needInterface) @@ -3750,19 +3741,8 @@ TestStatus runAndVerifyDefaultPipeline (Context& context, InstanceContext instan const tcu::ConstPixelBufferAccess pixelBuffer(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), renderSize.x(), renderSize.y(), 1, imagePtr); // Log image - { - const VkMappedMemoryRange range = - { - VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, // VkStructureType sType; - DE_NULL, // const void* pNext; - readImageBufferMemory->getMemory(), // VkDeviceMemory mem; - 0, // VkDeviceSize offset; - imageSizeBytes, // VkDeviceSize size; - }; - - VK_CHECK(vk.invalidateMappedMemoryRanges(device, 1u, &range)); - context.getTestContext().getLog() << TestLog::Image("Result", "Result", pixelBuffer); - } + invalidateAlloc(vk, device, *readImageBufferMemory); + context.getTestContext().getLog() << TestLog::Image("Result", "Result", pixelBuffer); if (needInterface) { diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp index c9f7af1..7746f2b 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp @@ -1448,8 +1448,7 @@ void initializeMemory(Context& context, const Allocation& alloc, subgroups::SSBO if (subgroups::SSBOData::InitializeNone != data.initializeType) { - flushMappedMemoryRange(context.getDeviceInterface(), - context.getDevice(), alloc.getMemory(), alloc.getOffset(), size); + flushAlloc(context.getDeviceInterface(), context.getDevice(), alloc); } } @@ -1647,7 +1646,7 @@ tcu::TestStatus vkt::subgroups::makeTessellationEvaluationFrameBufferTest( } deMemcpy(alloc.getHostPtr(), &data[0], data.size() * sizeof(tcu::Vec4)); - vk::flushMappedMemoryRange(context.getDeviceInterface(), context.getDevice(), alloc.getMemory(), alloc.getOffset(), vertexBufferSize); + flushAlloc(context.getDeviceInterface(), context.getDevice(), alloc); } for (deUint32 width = 1u; width < maxWidth; ++width) @@ -1723,7 +1722,7 @@ tcu::TestStatus vkt::subgroups::makeTessellationEvaluationFrameBufferTest( { const Allocation& allocResult = imageBufferResult.getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), context.getDevice(), allocResult.getMemory(), allocResult.getOffset(), imageResultSize); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), allocResult); std::vector datas; datas.push_back(allocResult.getHostPtr()); @@ -1863,7 +1862,7 @@ tcu::TestStatus vkt::subgroups::makeGeometryFrameBufferTest( } deMemcpy(alloc.getHostPtr(), &data[0], maxWidth * sizeof(tcu::Vec4)); - vk::flushMappedMemoryRange(context.getDeviceInterface(), context.getDevice(), alloc.getMemory(), alloc.getOffset(), vertexBufferSize); + flushAlloc(context.getDeviceInterface(), context.getDevice(), alloc); } for (deUint32 width = 1u; width < maxWidth; width++) @@ -1947,7 +1946,7 @@ tcu::TestStatus vkt::subgroups::makeGeometryFrameBufferTest( { const Allocation& allocResult = imageBufferResult.getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), context.getDevice(), allocResult.getMemory(), allocResult.getOffset(), imageResultSize); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), allocResult); std::vector datas; datas.push_back(allocResult.getHostPtr()); @@ -2159,7 +2158,6 @@ tcu::TestStatus vkt::subgroups::allStages( const Unique cmdBuffer (makeCommandBuffer(context, *cmdPool)); unsigned totalIterations = 0u; unsigned failedIterations = 0u; - const VkDeviceSize resultImageSizeInBytes = maxWidth * 1 * getFormatSizeInBytes(format); Image resultImage (context, maxWidth, 1, format, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT); const Unique framebuffer (makeFramebuffer(context, *renderPass, resultImage.getImageView(), maxWidth, 1)); const VkViewport viewport = makeViewport(maxWidth, 1u); @@ -2240,9 +2238,7 @@ tcu::TestStatus vkt::subgroups::allStages( if (!inputBuffers[ndx]->isImage()) { const Allocation& resultAlloc = inputBuffers[ndx]->getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), - context.getDevice(), resultAlloc.getMemory(), - resultAlloc.getOffset(), inputBuffers[ndx]->getAsBuffer()->getSize()); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), resultAlloc); // we always have our result data first datas.push_back(resultAlloc.getHostPtr()); } @@ -2253,9 +2249,7 @@ tcu::TestStatus vkt::subgroups::allStages( if ((stagesVector[ndx] & extraDatas[datasNdx].stages) && (!inputBuffers[index]->isImage())) { const Allocation& resultAlloc = inputBuffers[index]->getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), - context.getDevice(), resultAlloc.getMemory(), - resultAlloc.getOffset(), inputBuffers[index]->getAsBuffer()->getSize()); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), resultAlloc); // we always have our result data first datas.push_back(resultAlloc.getHostPtr()); } @@ -2268,9 +2262,7 @@ tcu::TestStatus vkt::subgroups::allStages( { std::vector datas; const Allocation& resultAlloc = imageBufferResult.getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), - context.getDevice(), resultAlloc.getMemory(), - resultAlloc.getOffset(), resultImageSizeInBytes); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), resultAlloc); // we always have our result data first datas.push_back(resultAlloc.getHostPtr()); @@ -2281,9 +2273,7 @@ tcu::TestStatus vkt::subgroups::allStages( if (VK_SHADER_STAGE_FRAGMENT_BIT & extraDatas[datasNdx].stages && (!inputBuffers[index]->isImage())) { const Allocation& alloc = inputBuffers[index]->getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), - context.getDevice(), alloc.getMemory(), - alloc.getOffset(), inputBuffers[index]->getAsBuffer()->getSize()); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), alloc); // we always have our result data first datas.push_back(alloc.getHostPtr()); } @@ -2439,7 +2429,7 @@ tcu::TestStatus vkt::subgroups::makeVertexFrameBufferTest(Context& context, vk:: } deMemcpy(alloc.getHostPtr(), &data[0], maxWidth * sizeof(tcu::Vec4)); - vk::flushMappedMemoryRange(context.getDeviceInterface(), context.getDevice(), alloc.getMemory(), alloc.getOffset(), vertexBufferSize); + flushAlloc(context.getDeviceInterface(), context.getDevice(), alloc); } for (deUint32 width = 1u; width < maxWidth; width++) @@ -2523,7 +2513,7 @@ tcu::TestStatus vkt::subgroups::makeVertexFrameBufferTest(Context& context, vk:: { const Allocation& allocResult = imageBufferResult.getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), context.getDevice(), allocResult.getMemory(), allocResult.getOffset(), imageResultSize); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), allocResult); std::vector datas; datas.push_back(allocResult.getHostPtr()); @@ -2739,9 +2729,7 @@ tcu::TestStatus vkt::subgroups::makeFragmentFrameBufferTest (Context& context, V std::vector datas; { const Allocation& resultAlloc = resultBuffer.getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), - context.getDevice(), resultAlloc.getMemory(), - resultAlloc.getOffset(), resultImageSizeInBytes); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), resultAlloc); // we always have our result data first datas.push_back(resultAlloc.getHostPtr()); @@ -2947,9 +2935,7 @@ tcu::TestStatus vkt::subgroups::makeComputeTest( { const Allocation& resultAlloc = resultBuffer.getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), - context.getDevice(), resultAlloc.getMemory(), - resultAlloc.getOffset(), resultBufferSizeInBytes); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), resultAlloc); // we always have our result data first datas.push_back(resultAlloc.getHostPtr()); @@ -2959,13 +2945,8 @@ tcu::TestStatus vkt::subgroups::makeComputeTest( { if (!inputBuffers[i]->isImage()) { - vk::VkDeviceSize size = - getFormatSizeInBytes(inputs[i].format) * - inputs[i].numElements; const Allocation& resultAlloc = inputBuffers[i]->getAllocation(); - invalidateMappedMemoryRange(context.getDeviceInterface(), - context.getDevice(), resultAlloc.getMemory(), - resultAlloc.getOffset(), size); + invalidateAlloc(context.getDeviceInterface(), context.getDevice(), resultAlloc); // we always have our result data first datas.push_back(resultAlloc.getHostPtr()); diff --git a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationInternallySynchronizedObjectsTests.cpp b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationInternallySynchronizedObjectsTests.cpp index c4c53e4..30a7f68 100644 --- a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationInternallySynchronizedObjectsTests.cpp +++ b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationInternallySynchronizedObjectsTests.cpp @@ -294,7 +294,7 @@ TestStatus executeComputePipeline (const Context& context, const VkPipeline& pip { const Allocation& alloc = resultBuffer.getAllocation(); deMemset(alloc.getHostPtr(), 0, BUFFER_SIZE); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), BUFFER_SIZE); + flushAlloc(vk, device, alloc); } // Start recording commands @@ -330,7 +330,7 @@ TestStatus executeComputePipeline (const Context& context, const VkPipeline& pip { const Allocation& resultAlloc = resultBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, resultAlloc.getMemory(), resultAlloc.getOffset(), BUFFER_SIZE); + invalidateAlloc(vk, device, resultAlloc); const deInt32* ptr = reinterpret_cast(resultAlloc.getHostPtr()); for (deInt32 ndx = 0; ndx < BUFFER_ELEMENT_COUNT; ++ndx) @@ -382,7 +382,7 @@ TestStatus executeGraphicPipeline (const Context& context, const VkPipeline& pip { const Allocation& alloc = resultBuffer.getAllocation(); deMemset(alloc.getHostPtr(), 0, BUFFER_SIZE); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), BUFFER_SIZE); + flushAlloc(vk, device, alloc); } // Start recording commands @@ -424,7 +424,7 @@ TestStatus executeGraphicPipeline (const Context& context, const VkPipeline& pip { const Allocation& resultAlloc = resultBuffer.getAllocation(); - invalidateMappedMemoryRange(vk, device, resultAlloc.getMemory(), resultAlloc.getOffset(), BUFFER_SIZE); + invalidateAlloc(vk, device, resultAlloc); const deInt32* ptr = reinterpret_cast(resultAlloc.getHostPtr()); for (deInt32 ndx = 0; ndx < BUFFER_ELEMENT_COUNT; ++ndx) diff --git a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationOperation.cpp b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationOperation.cpp index ba22420..1643461 100644 --- a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationOperation.cpp +++ b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationOperation.cpp @@ -118,7 +118,7 @@ public: const Allocation& alloc = m_vertexBuffer->getAllocation(); deMemcpy(alloc.getHostPtr(), &m_vertexData[0], static_cast(vertexDataSizeBytes)); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), vertexDataSizeBytes); + flushAlloc(vk, device, alloc); } } @@ -136,7 +136,7 @@ public: for (deUint32 i = 0; i < numIndices; ++i) pData[i] = i; - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), indexBufferSizeBytes); + flushAlloc(vk, device, alloc); } } } @@ -212,7 +212,7 @@ Data getHostBufferData (const OperationContext& context, const Buffer& hostBuffe static_cast(alloc.getHostPtr()), // const deUint8* data; }; - invalidateMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), size); + invalidateAlloc(vk, device, alloc); return data; } @@ -608,7 +608,7 @@ public: else fillPattern(alloc.getHostPtr(), m_resource.getBuffer().size); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), m_resource.getBuffer().size); + flushAlloc(vk, device, alloc); } void recordCommands (const VkCommandBuffer cmdBuffer) @@ -712,7 +712,7 @@ public: deMemset(alloc.getHostPtr(), 0, static_cast(m_bufferSize)); else fillPattern(alloc.getHostPtr(), m_bufferSize); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), m_bufferSize); + flushAlloc(vk, device, alloc); // Staging image m_image = de::MovePtr(new Image( @@ -1093,7 +1093,7 @@ public: pIndirectCommand->y = 1u; pIndirectCommand->z = 1u; - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), sizeof(VkDispatchIndirectCommand)); + flushAlloc(vk, device, alloc); } const Unique shaderModule(createShaderModule(vk, device, context.getBinaryCollection().get(shaderPrefix + "comp"), (VkShaderModuleCreateFlags)0)); @@ -1158,7 +1158,7 @@ public: deMemset(alloc.getHostPtr(), 0, static_cast(m_resource.getBuffer().size)); else fillPattern(alloc.getHostPtr(), m_resource.getBuffer().size); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), m_resource.getBuffer().size); + flushAlloc(vk, device, alloc); } // Prepare descriptors @@ -1293,7 +1293,7 @@ public: deMemset(alloc.getHostPtr(), 0, static_cast(m_hostBufferSizeBytes)); else fillPattern(alloc.getHostPtr(), m_hostBufferSizeBytes); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), m_hostBufferSizeBytes); + flushAlloc(vk, device, alloc); } // Image resources @@ -1780,7 +1780,7 @@ public: const Allocation& alloc = m_hostBuffer->getAllocation(); fillPattern(alloc.getHostPtr(), m_bufferSize); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), m_bufferSize); + flushAlloc(vk, device, alloc); } void recordCommands (const VkCommandBuffer cmdBuffer) @@ -1979,7 +1979,7 @@ public: const Allocation& alloc = m_hostBuffer->getAllocation(); fillPattern(alloc.getHostPtr(), m_resource.getBuffer().size); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), m_resource.getBuffer().size); + flushAlloc(vk, device, alloc); // Source data image m_image = de::MovePtr(new Image( @@ -2058,7 +2058,7 @@ public: const Allocation& alloc = m_hostBuffer->getAllocation(); deMemset(alloc.getHostPtr(), 0, static_cast(m_bufferSize)); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), m_bufferSize); + flushAlloc(vk, device, alloc); } void recordCommands (const VkCommandBuffer cmdBuffer) @@ -2287,7 +2287,7 @@ public: pIndirectCommand->firstVertex = 0u; pIndirectCommand->firstInstance = 0u; - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), sizeof(VkDrawIndirectCommand)); + flushAlloc(vk, device, alloc); } else if (m_drawCall == DRAW_CALL_DRAW_INDEXED_INDIRECT) { @@ -2303,7 +2303,7 @@ public: pIndirectCommand->vertexOffset = 0u; pIndirectCommand->firstInstance = 0u; - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), sizeof(VkDrawIndexedIndirectCommand)); + flushAlloc(vk, device, alloc); } // Resource image is the color attachment @@ -2830,7 +2830,7 @@ public: { const Allocation& alloc = m_hostBuffer->getAllocation(); deMemset(alloc.getHostPtr(), 0, static_cast(m_hostBufferSizeBytes)); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), static_cast(m_hostBufferSizeBytes)); + flushAlloc(vk, device, alloc); } // Prepare descriptors @@ -3132,7 +3132,7 @@ public: { const Allocation& alloc = m_outputBuffer->getAllocation(); deMemset(alloc.getHostPtr(), 0, static_cast(dataSizeBytes)); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), dataSizeBytes); + flushAlloc(vk, device, alloc); } m_descriptorSetLayout = DescriptorSetLayoutBuilder() diff --git a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationSmokeTests.cpp b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationSmokeTests.cpp index df47ea9..7c21160 100644 --- a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationSmokeTests.cpp +++ b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationSmokeTests.cpp @@ -184,17 +184,9 @@ void createVulkanBuffer (const DeviceInterface& vkd, VkDevice device, Allocator& if (bufferParameters.memory != DE_NULL) { VkMemoryBarrier barrier; - VkMappedMemoryRange range; - - deMemset(&range, 0xcd, sizeof(range)); - range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; - range.pNext = DE_NULL; - range.memory = buffer.allocation->getMemory(); - range.offset = buffer.allocation->getOffset(); - range.size = bufferParameters.size; deMemcpy(buffer.allocation->getHostPtr(), bufferParameters.memory, (size_t)bufferParameters.size); - VK_CHECK(vkd.flushMappedMemoryRanges(device, 1, &range)); + flushAlloc(vkd, device, *buffer.allocation); deMemset(&barrier, 0xcd, sizeof(barrier)); barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; @@ -990,7 +982,6 @@ tcu::TestStatus testFences (Context& context) VkResult fenceStatus; TestContext testContext (deviceInterface, device, queueFamilyIdx, context.getBinaryCollection(), context.getDefaultAllocator()); VkSubmitInfo submitInfo; - VkMappedMemoryRange range; void* resultImage; const tcu::Vec4 vertices[] = @@ -1069,12 +1060,7 @@ tcu::TestStatus testFences (Context& context) return tcu::TestStatus::fail("Fence in incorrect state"); } - range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; - range.pNext = DE_NULL; - range.memory = testContext.renderReadBuffer->getMemory(); - range.offset = 0; - range.size = testContext.renderSize; - VK_CHECK(deviceInterface.invalidateMappedMemoryRanges(device, 1, &range)); + invalidateAlloc(deviceInterface, device, *testContext.renderReadBuffer); resultImage = testContext.renderReadBuffer->getHostPtr(); log << TestLog::Image( "result", @@ -1111,7 +1097,6 @@ tcu::TestStatus testSemaphores (Context& context) TestContext testContext2 (deviceInterface, device.get(), queueFamilyIdx, context.getBinaryCollection(), allocator); Unique semaphore (createSemaphore(deviceInterface, *device)); VkSubmitInfo submitInfo[2]; - VkMappedMemoryRange range; void* resultImage; const VkPipelineStageFlags waitDstStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; @@ -1168,12 +1153,7 @@ tcu::TestStatus testSemaphores (Context& context) return tcu::TestStatus::fail("failed to wait for a set fence"); } - range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; - range.pNext = DE_NULL; - range.memory = testContext1.renderReadBuffer->getMemory(); - range.offset = 0; - range.size = testContext1.renderSize; - VK_CHECK(deviceInterface.invalidateMappedMemoryRanges(device.get(), 1, &range)); + invalidateAlloc(deviceInterface, device.get(), *testContext1.renderReadBuffer); resultImage = testContext1.renderReadBuffer->getHostPtr(); log << TestLog::Image( "result", @@ -1194,12 +1174,7 @@ tcu::TestStatus testSemaphores (Context& context) return tcu::TestStatus::fail("failed to wait for a set fence"); } - range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; - range.pNext = DE_NULL; - range.memory = testContext2.renderReadBuffer->getMemory(); - range.offset = 0; - range.size = testContext2.renderSize; - VK_CHECK(deviceInterface.invalidateMappedMemoryRanges(device.get(), 1, &range)); + invalidateAlloc(deviceInterface, device.get(), *testContext2.renderReadBuffer); resultImage = testContext2.renderReadBuffer->getHostPtr(); log << TestLog::Image( "result", @@ -1227,7 +1202,6 @@ tcu::TestStatus testEvents (Context& context) TestContext testContext (deviceInterface, device, queueFamilyIdx, context.getBinaryCollection(), allocator); Unique event (createEvent(deviceInterface, device)); VkSubmitInfo submitInfo; - VkMappedMemoryRange range; void* resultImage; const tcu::Vec4 vertices1[] = @@ -1285,12 +1259,7 @@ tcu::TestStatus testEvents (Context& context) return tcu::TestStatus::fail("failed to proceed after event set from host"); } - range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; - range.pNext = DE_NULL; - range.memory = testContext.renderReadBuffer->getMemory(); - range.offset = 0; - range.size = testContext.renderSize; - VK_CHECK(deviceInterface.invalidateMappedMemoryRanges(device, 1, &range)); + invalidateAlloc(deviceInterface, device, *testContext.renderReadBuffer); resultImage = testContext.renderReadBuffer->getHostPtr(); log << TestLog::Image( "result", diff --git a/external/vulkancts/modules/vulkan/texture/vktTextureFilteringExplicitLodTests.cpp b/external/vulkancts/modules/vulkan/texture/vktTextureFilteringExplicitLodTests.cpp index 495ec58..6dfbdc6 100644 --- a/external/vulkancts/modules/vulkan/texture/vktTextureFilteringExplicitLodTests.cpp +++ b/external/vulkancts/modules/vulkan/texture/vktTextureFilteringExplicitLodTests.cpp @@ -379,8 +379,6 @@ void initializeImage(Context& ctx, VkImage im, const ConstPixelBufferAccess* pba deMemcpy(bufCurPtr, pba[level].getDataPtr(), copySize); - flushMappedMemoryRange(vkd, dev, bufMem->getMemory(), bufMem->getOffset() + (bufCurPtr - bufMapPtr), copySize); - const VkImageSubresourceLayers curSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, @@ -404,6 +402,8 @@ void initializeImage(Context& ctx, VkImage im, const ConstPixelBufferAccess* pba bufCurPtr += copySize; } + flushAlloc(vkd, dev, *bufMem); + beginCommandBuffer(vkd, copyBuffer.get()); const VkImageSubresourceRange imMemBarSubRange = diff --git a/external/vulkancts/modules/vulkan/ubo/vktUniformBlockCase.cpp b/external/vulkancts/modules/vulkan/ubo/vktUniformBlockCase.cpp index f0dda16..270a258 100644 --- a/external/vulkancts/modules/vulkan/ubo/vktUniformBlockCase.cpp +++ b/external/vulkancts/modules/vulkan/ubo/vktUniformBlockCase.cpp @@ -1741,10 +1741,10 @@ tcu::TestStatus UniformBlockCaseInstance::iterate (void) // Upload attrbiutes data { deMemcpy(positionsAlloc->getHostPtr(), positions, sizeof(positions)); - flushMappedMemoryRange(vk, device, positionsAlloc->getMemory(), positionsAlloc->getOffset(), sizeof(positions)); + flushAlloc(vk, device, *positionsAlloc); deMemcpy(indicesAlloc->getHostPtr(), indices, sizeof(indices)); - flushMappedMemoryRange(vk, device, indicesAlloc->getMemory(), indicesAlloc->getOffset(), sizeof(indices)); + flushAlloc(vk, device, *indicesAlloc); } vk::Unique colorImage (createImage2D(m_context, @@ -1976,8 +1976,7 @@ tcu::TestStatus UniformBlockCaseInstance::iterate (void) { const tcu::TextureFormat textureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8); const tcu::ConstPixelBufferAccess imgAccess(textureFormat, RENDER_WIDTH, RENDER_HEIGHT, 1, readImageAlloc->getHostPtr()); - const vk::VkDeviceSize bufferSize = RENDER_WIDTH * RENDER_HEIGHT * 4; - invalidateMappedMemoryRange(vk, device, readImageAlloc->getMemory(), readImageAlloc->getOffset(), bufferSize); + invalidateAlloc(vk, device, *readImageAlloc); tcu::copy(surface.getAccess(), imgAccess); } @@ -2027,7 +2026,7 @@ vk::VkDescriptorBufferInfo UniformBlockCaseInstance::addUniformData (deUint32 si de::MovePtr alloc = allocateAndBindMemory(m_context, *buffer, vk::MemoryRequirement::HostVisible); deMemcpy(alloc->getHostPtr(), dataPtr, size); - flushMappedMemoryRange(vk, vkDevice, alloc->getMemory(), alloc->getOffset(), size); + flushAlloc(vk, vkDevice, *alloc); const VkDescriptorBufferInfo descriptor = { diff --git a/external/vulkancts/modules/vulkan/vktDrawUtil.cpp b/external/vulkancts/modules/vulkan/vktDrawUtil.cpp index 0eb186c..1ff5a57 100644 --- a/external/vulkancts/modules/vulkan/vktDrawUtil.cpp +++ b/external/vulkancts/modules/vulkan/vktDrawUtil.cpp @@ -374,7 +374,7 @@ VulkanDrawContext::VulkanDrawContext ( Context& context, { const Allocation& alloc = m_colorAttachmentBuffer->getAllocation(); deMemset(alloc.getHostPtr(), 0, (size_t)bitmapSize); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), bitmapSize); + flushAlloc(vk, device, alloc); } } @@ -386,7 +386,7 @@ VulkanDrawContext::VulkanDrawContext ( Context& context, const Allocation& alloc = m_vertexBuffer->getAllocation(); deMemcpy(alloc.getHostPtr(), &m_drawCallData.vertices[0], (size_t)bufferSize); - flushMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), bufferSize); + flushAlloc(vk, device, alloc); } // bind descriptor sets @@ -783,7 +783,7 @@ tcu::ConstPixelBufferAccess VulkanDrawContext::getColorPixels (void) const const VkDevice device = m_context.getDevice(); const Allocation& alloc = m_colorAttachmentBuffer->getAllocation(); - invalidateMappedMemoryRange(vk, device, alloc.getMemory(), alloc.getOffset(), VK_WHOLE_SIZE); + invalidateAlloc(vk, device, alloc); return tcu::ConstPixelBufferAccess(mapVkFormat(m_drawState.colorFormat), m_drawState.renderSize.x(), m_drawState.renderSize.y(), 1u, alloc.getHostPtr()); } diff --git a/external/vulkancts/modules/vulkan/vktShaderLibrary.cpp b/external/vulkancts/modules/vulkan/vktShaderLibrary.cpp index 504fb9d..1df4da9 100644 --- a/external/vulkancts/modules/vulkan/vktShaderLibrary.cpp +++ b/external/vulkancts/modules/vulkan/vktShaderLibrary.cpp @@ -1226,7 +1226,7 @@ void writeValuesToMem (Context& context, const vk::Allocation& dst, const ValueB copyToLayout(dst.getHostPtr(), layout, values, arrayNdx); // \note Buffers are not allocated with coherency / uncached requirement so we need to manually flush CPU write caches - flushMappedMemoryRange(context.getDeviceInterface(), context.getDevice(), dst.getMemory(), dst.getOffset(), (vk::VkDeviceSize)layout.size); + flushAlloc(context.getDeviceInterface(), context.getDevice(), dst); } class ShaderCaseInstance : public TestInstance @@ -1374,7 +1374,7 @@ ShaderCaseInstance::ShaderCaseInstance (Context& context, const ShaderCaseSpecif deMemcpy((deUint8*)m_posNdxMem->getHostPtr() + POSITIONS_OFFSET, &s_positions[0], sizeof(s_positions)); deMemcpy((deUint8*)m_posNdxMem->getHostPtr() + INDICES_OFFSET, &s_indices[0], sizeof(s_indices)); - flushMappedMemoryRange(m_context.getDeviceInterface(), context.getDevice(), m_posNdxMem->getMemory(), m_posNdxMem->getOffset(), sizeof(s_positions)+sizeof(s_indices)); + flushAlloc(m_context.getDeviceInterface(), context.getDevice(), *m_posNdxMem); } if (!m_spec.values.uniforms.empty()) -- 2.7.4