}
// Create command pool and buffer
- {
- const VkCommandPoolCreateInfo cmdPoolParams =
- {
- VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, // VkCmdPoolCreateFlags flags;
- queueFamilyIndex, // deUint32 queueFamilyIndex;
- };
-
- cmdPool = createCommandPool(vk, device, &cmdPoolParams);
-
- const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
- {
- VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- *cmdPool, // VkCommandPool commandPool;
- VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level;
- 1u // deUint32 bufferCount;
- };
-
- cmdBuffer = allocateCommandBuffer(vk, device, &cmdBufferAllocateInfo);
- }
+ cmdPool = createCommandPool(vk, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex);
+ cmdBuffer = allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
// Create fence
- {
- const VkFenceCreateInfo fenceParams =
- {
- VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- 0u // VkFenceCreateFlags flags;
- };
-
- fence = createFence(vk, device, &fenceParams);
- }
+ fence = createFence(vk, device);
// Barriers for copying image to buffer
VK_CHECK(vk.waitForFences(device, 1, &fence.get(), 0, ~(0ull) /* infinity */));
// Read buffer data
- invalidateMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize);
+ invalidateMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), VK_WHOLE_SIZE);
tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), bufferAlloc->getHostPtr()));
return resultLevel;
} // anonymous
-void uploadTestTexture (const DeviceInterface& vk,
- VkDevice device,
- VkQueue queue,
- deUint32 queueFamilyIndex,
- Allocator& allocator,
- const TestTexture& srcTexture,
- VkImage destImage)
+void uploadTestTextureInternal (const DeviceInterface& vk,
+ VkDevice device,
+ VkQueue queue,
+ deUint32 queueFamilyIndex,
+ Allocator& allocator,
+ const TestTexture& srcTexture,
+ const TestTexture* srcStencilTexture,
+ tcu::TextureFormat format,
+ VkImage destImage)
{
deUint32 bufferSize;
Move<VkBuffer> buffer;
Move<VkCommandPool> cmdPool;
Move<VkCommandBuffer> cmdBuffer;
Move<VkFence> fence;
- const VkImageAspectFlags imageAspectFlags = getImageAspectFlags(srcTexture.getTextureFormat());
+ const VkImageAspectFlags imageAspectFlags = getImageAspectFlags(format);
+ deUint32 stencilOffset = 0u;
// Calculate buffer size
bufferSize = (srcTexture.isCompressed())? srcTexture.getCompressedSize(): srcTexture.getSize();
+ // Stencil-only texture should be provided if (and only if) the image has a combined DS format
+ DE_ASSERT((tcu::hasDepthComponent(format.order) && tcu::hasStencilComponent(format.order)) == (srcStencilTexture != DE_NULL));
+
+ if (srcStencilTexture != DE_NULL)
+ {
+ stencilOffset = static_cast<deUint32>(deAlign32(static_cast<deInt32>(bufferSize), 4));
+ bufferSize = stencilOffset + srcStencilTexture->getSize();
+ }
+
// Create source buffer
{
const VkBufferCreateInfo bufferParams =
}
// Create command pool and buffer
- {
- const VkCommandPoolCreateInfo cmdPoolParams =
- {
- VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, // VkCommandPoolCreateFlags flags;
- queueFamilyIndex, // deUint32 queueFamilyIndex;
- };
-
- cmdPool = createCommandPool(vk, device, &cmdPoolParams);
-
- const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
- {
- VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- *cmdPool, // VkCommandPool commandPool;
- VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level;
- 1u, // deUint32 bufferCount;
- };
-
- cmdBuffer = allocateCommandBuffer(vk, device, &cmdBufferAllocateInfo);
- }
+ cmdPool = createCommandPool(vk, device, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex);
+ cmdBuffer = allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
// Create fence
- {
- const VkFenceCreateInfo fenceParams =
- {
- VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- 0u // VkFenceCreateFlags flags;
- };
-
- fence = createFence(vk, device, &fenceParams);
- }
+ fence = createFence(vk, device);
// Barriers for copying buffer to image
const VkBufferMemoryBarrier preBufferBarrier =
(const VkCommandBufferInheritanceInfo*)DE_NULL,
};
- const std::vector<VkBufferImageCopy> copyRegions = srcTexture.getBufferCopyRegions();
+ std::vector<VkBufferImageCopy> copyRegions = srcTexture.getBufferCopyRegions();
// Write buffer data
srcTexture.write(reinterpret_cast<deUint8*>(bufferAlloc->getHostPtr()));
- flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), bufferSize);
+
+ if (srcStencilTexture != DE_NULL)
+ {
+ DE_ASSERT(stencilOffset != 0u);
+
+ srcStencilTexture->write(reinterpret_cast<deUint8*>(bufferAlloc->getHostPtr()) + stencilOffset);
+
+ std::vector<VkBufferImageCopy> stencilCopyRegions = srcStencilTexture->getBufferCopyRegions();
+ for (size_t regionIdx = 0; regionIdx < stencilCopyRegions.size(); regionIdx++)
+ {
+ VkBufferImageCopy region = stencilCopyRegions[regionIdx];
+ region.bufferOffset += stencilOffset;
+
+ copyRegions.push_back(region);
+ }
+ }
+
+ flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), VK_WHOLE_SIZE);
// Copy buffer to image
VK_CHECK(vk.beginCommandBuffer(*cmdBuffer, &cmdBufferBeginInfo));
VK_CHECK(vk.waitForFences(device, 1, &fence.get(), true, ~(0ull) /* infinity */));
}
+void uploadTestTexture (const DeviceInterface& vk,
+ VkDevice device,
+ VkQueue queue,
+ deUint32 queueFamilyIndex,
+ Allocator& allocator,
+ const TestTexture& srcTexture,
+ VkImage destImage)
+{
+ if (tcu::isCombinedDepthStencilType(srcTexture.getTextureFormat().type))
+ {
+ de::MovePtr<TestTexture> srcDepthTexture;
+ de::MovePtr<TestTexture> srcStencilTexture;
+
+ if (tcu::hasDepthComponent(srcTexture.getTextureFormat().order))
+ {
+ tcu::TextureFormat format;
+ switch (srcTexture.getTextureFormat().type) {
+ case tcu::TextureFormat::UNSIGNED_INT_16_8_8:
+ format = tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNORM_INT16);
+ break;
+ case tcu::TextureFormat::UNSIGNED_INT_24_8_REV:
+ format = tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::UNSIGNED_INT_24_8_REV);
+ break;
+ case tcu::TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV:
+ format = tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::FLOAT);
+ break;
+ default:
+ DE_ASSERT(0);
+ break;
+ }
+ srcDepthTexture = srcTexture.copy(format);
+ }
+
+ if (tcu::hasStencilComponent(srcTexture.getTextureFormat().order))
+ srcStencilTexture = srcTexture.copy(tcu::getEffectiveDepthStencilTextureFormat(srcTexture.getTextureFormat(), tcu::Sampler::MODE_STENCIL));
+
+ uploadTestTextureInternal(vk, device, queue, queueFamilyIndex, allocator, *srcDepthTexture, srcStencilTexture.get(), srcTexture.getTextureFormat(), destImage);
+ }
+ else
+ uploadTestTextureInternal(vk, device, queue, queueFamilyIndex, allocator, srcTexture, DE_NULL, srcTexture.getTextureFormat(), destImage);
+}
+
// Utilities for test textures
template<typename TcuTextureType>
}
}
+void TestTexture::copyToTexture (TestTexture& destTexture) const
+{
+ for (int levelNdx = 0; levelNdx < getNumLevels(); levelNdx++)
+ for (int layerNdx = 0; layerNdx < getArraySize(); layerNdx++)
+ tcu::copy(destTexture.getLevel(levelNdx, layerNdx), getLevel(levelNdx, layerNdx));
+}
+
void TestTexture::populateLevels (const std::vector<tcu::PixelBufferAccess>& levels)
{
for (size_t levelNdx = 0; levelNdx < levels.size(); levelNdx++)
return m_texture;
}
+de::MovePtr<TestTexture> TestTexture1D::copy(const tcu::TextureFormat format) const
+{
+ DE_ASSERT(!isCompressed());
+
+ de::MovePtr<TestTexture> texture (new TestTexture1D(format, m_texture.getWidth()));
+
+ copyToTexture(*texture);
+
+ return texture;
+}
+
// TestTexture1DArray
TestTexture1DArray::TestTexture1DArray (const tcu::TextureFormat& format, int width, int arraySize)
return m_texture.getNumLayers();
}
+de::MovePtr<TestTexture> TestTexture1DArray::copy(const tcu::TextureFormat format) const
+{
+ DE_ASSERT(!isCompressed());
+
+ de::MovePtr<TestTexture> texture (new TestTexture1DArray(format, m_texture.getWidth(), getArraySize()));
+
+ copyToTexture(*texture);
+
+ return texture;
+}
+
// TestTexture2D
TestTexture2D::TestTexture2D (const tcu::TextureFormat& format, int width, int height)
return m_texture;
}
+de::MovePtr<TestTexture> TestTexture2D::copy(const tcu::TextureFormat format) const
+{
+ DE_ASSERT(!isCompressed());
+
+ de::MovePtr<TestTexture> texture (new TestTexture2D(format, m_texture.getWidth(), m_texture.getHeight()));
+
+ copyToTexture(*texture);
+
+ return texture;
+}
+
// TestTexture2DArray
TestTexture2DArray::TestTexture2DArray (const tcu::TextureFormat& format, int width, int height, int arraySize)
return m_texture.getNumLayers();
}
+de::MovePtr<TestTexture> TestTexture2DArray::copy(const tcu::TextureFormat format) const
+{
+ DE_ASSERT(!isCompressed());
+
+ de::MovePtr<TestTexture> texture (new TestTexture2DArray(format, m_texture.getWidth(), m_texture.getHeight(), getArraySize()));
+
+ copyToTexture(*texture);
+
+ return texture;
+}
// TestTexture3D
return m_texture;
}
+de::MovePtr<TestTexture> TestTexture3D::copy(const tcu::TextureFormat format) const
+{
+ DE_ASSERT(!isCompressed());
+
+ de::MovePtr<TestTexture> texture (new TestTexture3D(format, m_texture.getWidth(), m_texture.getHeight(), m_texture.getDepth()));
+
+ copyToTexture(*texture);
+
+ return texture;
+}
+
// TestTextureCube
const static tcu::CubeFace tcuFaceMapping[tcu::CUBEFACE_LAST] =
return m_texture;
}
+de::MovePtr<TestTexture> TestTextureCube::copy(const tcu::TextureFormat format) const
+{
+ DE_ASSERT(!isCompressed());
+
+ de::MovePtr<TestTexture> texture (new TestTextureCube(format, m_texture.getSize()));
+
+ copyToTexture(*texture);
+
+ return texture;
+}
+
// TestTextureCubeArray
TestTextureCubeArray::TestTextureCubeArray (const tcu::TextureFormat& format, int size, int arraySize)
return m_texture;
}
+de::MovePtr<TestTexture> TestTextureCubeArray::copy(const tcu::TextureFormat format) const
+{
+ DE_ASSERT(!isCompressed());
+
+ de::MovePtr<TestTexture> texture (new TestTextureCubeArray(format, m_texture.getSize(), getArraySize()));
+
+ copyToTexture(*texture);
+
+ return texture;
+}
+
} // pipeline
} // vkt