#include "vkQueryUtil.hpp"
#include "vkTypeUtil.hpp"
+#include "tcuTestLog.hpp"
+
#include "deUniquePtr.hpp"
#include "deSharedPtr.hpp"
#include "deMath.h"
m_pipelineLayout = makePipelineLayout (vk, device, m_descriptorSetLayout);
m_pipeline = makeGraphicsPipeline (vk, device, *m_pipelineLayout, *m_renderPass, m_renderSize, m_topology, DE_LENGTH_OF_ARRAY(pShaderStages), pShaderStages);
m_cmdPool = makeCommandPool (vk, device, queueFamilyIndex);
- m_cmdBuffer = makeCommandBuffer (vk, device, *m_cmdPool);
+ m_cmdBuffer = allocateCommandBuffer (vk, device, *m_cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
}
void draw (const DeviceInterface& vk,
DE_NULL, // const VkSemaphore* pSignalSemaphores;
};
- const Unique<VkFence> fence(makeFence(vk, device));
+ const Unique<VkFence> fence(createFence(vk, device));
VK_CHECK(vk.queueBindSparse(sparseQueue, 1u, &bindInfo, *fence));
VK_CHECK(vk.waitForFences(device, 1u, &fence.get(), VK_TRUE, ~0ull));
, m_aliased ((flags & TEST_FLAG_ALIASED) != 0)
, m_residency ((flags & TEST_FLAG_RESIDENCY) != 0)
, m_nonResidentStrict ((flags & TEST_FLAG_NON_RESIDENT_STRICT) != 0)
- , m_deviceProperties (getPhysicalDeviceProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice()))
, m_renderSize (RENDER_SIZE, RENDER_SIZE)
, m_colorFormat (VK_FORMAT_R8G8B8A8_UNORM)
, m_colorBufferSize (m_renderSize.x() * m_renderSize.y() * tcu::getPixelSize(mapVkFormat(m_colorFormat)))
{
- const DeviceInterface& vk = m_context.getDeviceInterface();
const VkPhysicalDeviceFeatures features = getPhysicalDeviceFeatures(m_context.getInstanceInterface(), m_context.getPhysicalDevice());
if (!features.sparseBinding)
if (m_aliased && !features.sparseResidencyAliased)
TCU_THROW(NotSupportedError, "Missing feature: sparseResidencyAliased");
- if (m_nonResidentStrict && !m_deviceProperties.sparseProperties.residencyNonResidentStrict)
+ if (m_nonResidentStrict && !m_context.getDeviceProperties().sparseProperties.residencyNonResidentStrict)
TCU_THROW(NotSupportedError, "Missing sparse property: residencyNonResidentStrict");
{
createDeviceSupportingQueues(requirements);
}
+ const DeviceInterface& vk = getDeviceInterface();
m_sparseQueue = getQueue(VK_QUEUE_SPARSE_BINDING_BIT, 0u);
m_universalQueue = getQueue(VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT, 0u);
Renderer::SpecializationMap specMap = Renderer::SpecializationMap())
{
const UniquePtr<Renderer> renderer(new Renderer(
- m_context.getDeviceInterface(), getDevice(), getAllocator(), m_universalQueue.queueFamilyIndex, descriptorSetLayout,
+ getDeviceInterface(), getDevice(), getAllocator(), m_universalQueue.queueFamilyIndex, descriptorSetLayout,
m_context.getBinaryCollection(), "vert", "frag", *m_colorBuffer, m_renderSize, m_colorFormat, Vec4(1.0f, 0.0f, 0.0f, 1.0f), topology, specMap));
- renderer->draw(m_context.getDeviceInterface(), getDevice(), m_universalQueue.queueHandle, *this);
+ renderer->draw(getDeviceInterface(), getDevice(), m_universalQueue.queueHandle, *this);
}
tcu::TestStatus verifyDrawResult (void) const
{
- invalidateMappedMemoryRange(m_context.getDeviceInterface(), getDevice(), m_colorBufferAlloc->getMemory(), 0ull, m_colorBufferSize);
+ invalidateMappedMemoryRange(getDeviceInterface(), getDevice(), m_colorBufferAlloc->getMemory(), 0ull, m_colorBufferSize);
const tcu::ConstPixelBufferAccess resultImage (mapVkFormat(m_colorFormat), m_renderSize.x(), m_renderSize.y(), 1u, m_colorBufferAlloc->getHostPtr());
const bool m_aliased;
const bool m_residency;
const bool m_nonResidentStrict;
- const VkPhysicalDeviceProperties m_deviceProperties;
Queue m_sparseQueue;
Queue m_universalQueue;
void rendererDraw (const VkPipelineLayout pipelineLayout, const VkCommandBuffer cmdBuffer) const
{
- const DeviceInterface& vk = m_context.getDeviceInterface();
+ const DeviceInterface& vk = getDeviceInterface();
const VkDeviceSize vertexOffset = 0ull;
vk.cmdBindVertexBuffers (cmdBuffer, 0u, 1u, &m_vertexBuffer.get(), &vertexOffset);
tcu::TestStatus iterate (void)
{
- const DeviceInterface& vk = m_context.getDeviceInterface();
+ const DeviceInterface& vk = getDeviceInterface();
MovePtr<SparseAllocation> sparseAllocation;
Move<VkBuffer> sparseBuffer;
Move<VkBuffer> sparseBufferAliased;
.addMemoryBind()
.build(vk, getDevice(), getAllocator(), referenceBufferCreateInfo, minChunkSize));
- if (minAllocation->resourceSize > m_deviceProperties.limits.maxUniformBufferRange)
- return tcu::TestStatus::fail("The smallest sparse UBO size exceeds maxUniformBufferRange limit");
-
- numMaxChunks = static_cast<deUint32>(m_deviceProperties.limits.maxUniformBufferRange / minAllocation->resourceSize);
+ numMaxChunks = deMaxu32(static_cast<deUint32>(m_context.getDeviceProperties().limits.maxUniformBufferRange / minAllocation->resourceSize), 1u);
}
if (numMaxChunks < 4)
builder.addAliasedMemoryBind(0u, 0u);
sparseAllocation = builder.build(vk, getDevice(), getAllocator(), referenceBufferCreateInfo, minChunkSize);
- DE_ASSERT(sparseAllocation->resourceSize <= m_deviceProperties.limits.maxUniformBufferRange);
+ DE_ASSERT(sparseAllocation->resourceSize <= m_context.getDeviceProperties().limits.maxUniformBufferRange);
}
// Create the buffer
stagingBufferSize, // VkDeviceSize size;
};
- const Unique<VkCommandPool> cmdPool (makeCommandPool (vk, getDevice(), m_universalQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> cmdBuffer (makeCommandBuffer (vk, getDevice(), *cmdPool));
+ const Unique<VkCommandPool> cmdPool (makeCommandPool(vk, getDevice(), m_universalQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, getDevice(), *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
beginCommandBuffer (vk, *cmdBuffer);
vk.cmdCopyBuffer (*cmdBuffer, *stagingBuffer, *sparseBuffer, 1u, ©Region);
}
}
+ // Make sure that we don't try to access a larger range than is allowed. This only applies to a single chunk case.
+ const deUint32 maxBufferRange = deMinu32(static_cast<deUint32>(sparseAllocation->resourceSize), m_context.getDeviceProperties().limits.maxUniformBufferRange);
+
// Descriptor sets
{
m_descriptorSetLayout = DescriptorSetLayoutBuilder()
m_descriptorSet = makeDescriptorSet(vk, getDevice(), *m_descriptorPool, *m_descriptorSetLayout);
const VkBuffer buffer = (m_aliased ? *sparseBufferAliased : *sparseBuffer);
- const VkDescriptorBufferInfo sparseBufferInfo = makeDescriptorBufferInfo(buffer, 0ull, sparseAllocation->resourceSize);
+ const VkDescriptorBufferInfo sparseBufferInfo = makeDescriptorBufferInfo(buffer, 0ull, maxBufferRange);
DescriptorSetUpdateBuilder()
.writeSingle(*m_descriptorSet, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &sparseBufferInfo)
{
std::vector<deInt32> specializationData;
{
- const deUint32 numBufferEntries = static_cast<deUint32>(sparseAllocation->resourceSize / sizeof(IVec4));
+ const deUint32 numBufferEntries = maxBufferRange / static_cast<deUint32>(sizeof(IVec4));
const deUint32 numEntriesPerChunk = numBufferEntries / sparseAllocation->numResourceChunks;
specializationData.push_back(numBufferEntries);
DrawGridTestInstance (Context& context, const TestFlags flags, const VkBufferUsageFlags usage, const VkDeviceSize minChunkSize)
: SparseBufferTestInstance (context, flags)
{
- const DeviceInterface& vk = m_context.getDeviceInterface();
+ const DeviceInterface& vk = getDeviceInterface();
VkBufferCreateInfo referenceBufferCreateInfo = getSparseBufferCreateInfo(usage);
{
{
initializeBuffers();
- const DeviceInterface& vk = m_context.getDeviceInterface();
+ const DeviceInterface& vk = getDeviceInterface();
// Upload to the sparse buffer
{
},
};
- const Unique<VkCommandPool> cmdPool (makeCommandPool (vk, getDevice(), m_universalQueue.queueFamilyIndex));
- const Unique<VkCommandBuffer> cmdBuffer (makeCommandBuffer (vk, getDevice(), *cmdPool));
+ const Unique<VkCommandPool> cmdPool (makeCommandPool(vk, getDevice(), m_universalQueue.queueFamilyIndex));
+ const Unique<VkCommandBuffer> cmdBuffer (allocateCommandBuffer(vk, getDevice(), *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY));
beginCommandBuffer (vk, *cmdBuffer);
vk.cmdCopyBuffer (*cmdBuffer, *m_stagingBuffer, *m_sparseBuffer, DE_LENGTH_OF_ARRAY(copyRegions), copyRegions);
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << "Drawing a grid of triangles backed by a sparse vertex buffer. There should be no red pixels visible." << tcu::TestLog::EndMessage;
- const DeviceInterface& vk = m_context.getDeviceInterface();
+ const DeviceInterface& vk = getDeviceInterface();
const deUint32 vertexCount = 6 * (GRID_SIZE * GRID_SIZE) / 2;
VkDeviceSize vertexOffset = 0ull;
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << "Drawing a grid of triangles from a sparse index buffer. There should be no red pixels visible." << tcu::TestLog::EndMessage;
- const DeviceInterface& vk = m_context.getDeviceInterface();
+ const DeviceInterface& vk = getDeviceInterface();
const VkDeviceSize vertexOffset = 0ull;
VkDeviceSize indexOffset = 0ull;
void initializeBuffers (void)
{
// Vertex buffer
- const DeviceInterface& vk = m_context.getDeviceInterface();
+ const DeviceInterface& vk = getDeviceInterface();
const VkDeviceSize vertexBufferSize = 2 * m_halfVertexCount * sizeof(Vec4);
m_vertexBuffer = makeBuffer(vk, getDevice(), makeBufferCreateInfo(vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT));
m_vertexBufferAlloc = bindBuffer(vk, getDevice(), getAllocator(), *m_vertexBuffer, MemoryRequirement::HostVisible);
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << "Drawing two triangles covering the whole viewport. There should be no red pixels visible." << tcu::TestLog::EndMessage;
- const DeviceInterface& vk = m_context.getDeviceInterface();
+ const DeviceInterface& vk = getDeviceInterface();
const VkDeviceSize vertexOffset = 0ull;
VkDeviceSize indirectOffset = 0ull;
void initializeBuffers (void)
{
// Vertex buffer
- const DeviceInterface& vk = m_context.getDeviceInterface();
+ const DeviceInterface& vk = getDeviceInterface();
const VkDeviceSize vertexBufferSize = 2 * 3 * sizeof(Vec4);
m_vertexBuffer = makeBuffer(vk, getDevice(), makeBufferCreateInfo(vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT));
m_vertexBufferAlloc = bindBuffer(vk, getDevice(), getAllocator(), *m_vertexBuffer, MemoryRequirement::HostVisible);