beginCommandBuffer(vkd, *commandBuffer);
+ // Transition stencil aspects to the final layout directly.
+ if (isDepthStencilFormat(m_format))
+ {
+ const VkImageSubresourceRange imageSubresourceRange =
+ {
+ VK_IMAGE_ASPECT_STENCIL_BIT, // VkImageAspectFlags aspectMask
+ 0u, // uint32_t baseMipLevel
+ 1u, // uint32_t levelCount
+ 0u, // uint32_t baseArrayLayer
+ 1u // uint32_t layerCount
+ };
+
+ VkImageMemoryBarrier barrier =
+ {
+ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType
+ DE_NULL, // const void* pNext
+ 0u, // VkAccessFlags srcAccessMask
+ VK_ACCESS_TRANSFER_READ_BIT, // VkAccessFlags dstAccessMask
+ VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout
+ VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL, // VkImageLayout newLayout
+ VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex
+ VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex
+ DE_NULL, // VkImage image
+ imageSubresourceRange // VkImageSubresourceRange subresourceRange
+ };
+
+ for (deUint32 attachmentNdx = 0; attachmentNdx < attachmentCount; ++attachmentNdx)
+ {
+ barrier.image = **m_images[attachmentNdx];
+ vkd.cmdPipelineBarrier(*commandBuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0u, 0u, DE_NULL, 0u, DE_NULL, 1u, &barrier);
+ }
+ }
+
// Begin render pass
{
VkRect2D renderArea =
dst.glslSources.add("vert") << glu::VertexSource(
"#version 450\n"
"layout(location = 0) in highp vec4 position;\n"
+ "out gl_PerVertex {\n"
+ " vec4 gl_Position;\n"
+ "};\n"
"void main (void)\n"
"{\n"
" gl_Position = position;\n"
VkDeviceSize nonCoherentAtomSize)
{
// Expand the range to flush to account for the nonCoherentAtomSize
- VkDeviceSize roundedOffset = (VkDeviceSize)deAlignSize(deUint32(memory.getOffset()), deUint32(nonCoherentAtomSize));
- VkDeviceSize roundedSize = (VkDeviceSize)deAlignSize(deUint32(memory.getOffset() + size - roundedOffset), deUint32(nonCoherentAtomSize));
+ const VkDeviceSize roundedOffset = de::roundDown(memory.getOffset(), nonCoherentAtomSize);
+ const VkDeviceSize roundedSize = de::roundUp(memory.getOffset() - roundedOffset + static_cast<VkDeviceSize>(size), nonCoherentAtomSize);
const VkMappedMemoryRange range =
{
m_pipelineLayout = createPipelineLayout(vk, device, &pipelineLayoutParams);
m_pipeline = createSubpassPipeline(vk, device, renderPass, *m_vertexShaderModule, *m_fragmentShaderModule, *m_pipelineLayout, m_renderInfo);
- m_vertexBuffer = createBuffer(vk, device, 0u, (VkDeviceSize)renderQuad.getVertexDataSize(), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_SHARING_MODE_EXCLUSIVE, 1u, &queueFamilyIndex);
+ // Round up the vertex buffer size to honor nonCoherentAtomSize.
+ const auto properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
+ const auto vertexBufferSize = de::roundUp(static_cast<VkDeviceSize>(renderQuad.getVertexDataSize()), properties.limits.nonCoherentAtomSize);
+
+ m_vertexBuffer = createBuffer(vk, device, 0u, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_SHARING_MODE_EXCLUSIVE, 1u, &queueFamilyIndex);
m_vertexBufferMemory = allocateBuffer(vki, vk, physDevice, device, *m_vertexBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
bindBufferMemory(vk, device, *m_vertexBuffer, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset());
- const vk::VkPhysicalDeviceProperties properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
- uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer(), properties.limits.nonCoherentAtomSize);
+ uploadBufferData(vk, device, *m_vertexBufferMemory, static_cast<size_t>(vertexBufferSize), renderQuad.getVertexPointer(), properties.limits.nonCoherentAtomSize);
if (renderInfo.getInputAttachmentCount() > 0)
{
//! Return T with high n bits reset
template<typename T> inline T leftZeroMask (T n) { return T(~leftSetMask(n)); }
+//! Round x up to a multiple of y.
+template<typename T> inline T roundUp (T x, T y) { DE_ASSERT(y != T(0)); const T mod = x % y; return x + ((mod == T(0)) ? T(0) : (y - mod)); }
+
+//! Round x down to a multiple of y.
+template<typename T> inline T roundDown (T x, T y) { DE_ASSERT(y != T(0)); return (x / y) * y; }
+
//! Helper for DE_CHECK() macros.
void throwRuntimeError (const char* message, const char* expr, const char* file, int line);