blob: c975813a8883450130b4be238795b223d554512b [file] [log] [blame]
#ifndef _VKTCLIPPINGUTIL_HPP
#define _VKTCLIPPINGUTIL_HPP
/*------------------------------------------------------------------------
* Vulkan Conformance Tests
* ------------------------
*
* Copyright (c) 2016 The Khronos Group Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*//*!
* \file
* \brief Clipping tests utilities
*//*--------------------------------------------------------------------*/
#include "vkDefs.hpp"
#include "vkQueryUtil.hpp"
#include "vkMemUtil.hpp"
#include "vkRefUtil.hpp"
#include "vkPrograms.hpp"
#include "tcuVector.hpp"
namespace vkt
{
namespace clipping
{
class Buffer
{
public:
Buffer (const vk::DeviceInterface& vk,
const vk::VkDevice device,
vk::Allocator& allocator,
const vk::VkBufferCreateInfo& bufferCreateInfo,
const vk::MemoryRequirement memoryRequirement)
: m_buffer (createBuffer(vk, device, &bufferCreateInfo))
, m_allocation (allocator.allocate(getBufferMemoryRequirements(vk, device, *m_buffer), memoryRequirement))
{
VK_CHECK(vk.bindBufferMemory(device, *m_buffer, m_allocation->getMemory(), m_allocation->getOffset()));
}
const vk::VkBuffer& get (void) const { return *m_buffer; }
const vk::VkBuffer& operator* (void) const { return get(); }
vk::Allocation& getAllocation (void) const { return *m_allocation; }
private:
const vk::Unique<vk::VkBuffer> m_buffer;
const de::UniquePtr<vk::Allocation> m_allocation;
// "deleted"
Buffer (const Buffer&);
Buffer& operator= (const Buffer&);
};
class Image
{
public:
Image (const vk::DeviceInterface& vk,
const vk::VkDevice device,
vk::Allocator& allocator,
const vk::VkImageCreateInfo& imageCreateInfo,
const vk::MemoryRequirement memoryRequirement)
: m_image (createImage(vk, device, &imageCreateInfo))
, m_allocation (allocator.allocate(getImageMemoryRequirements(vk, device, *m_image), memoryRequirement))
{
VK_CHECK(vk.bindImageMemory(device, *m_image, m_allocation->getMemory(), m_allocation->getOffset()));
}
const vk::VkImage& get (void) const { return *m_image; }
const vk::VkImage& operator* (void) const { return get(); }
vk::Allocation& getAllocation (void) const { return *m_allocation; }
private:
const vk::Unique<vk::VkImage> m_image;
const de::UniquePtr<vk::Allocation> m_allocation;
// "deleted"
Image (const Image&);
Image& operator= (const Image&);
};
enum FeatureFlagBits
{
FEATURE_TESSELLATION_SHADER = 1u << 0,
FEATURE_GEOMETRY_SHADER = 1u << 1,
FEATURE_SHADER_FLOAT_64 = 1u << 2,
FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS = 1u << 3,
FEATURE_FRAGMENT_STORES_AND_ATOMICS = 1u << 4,
FEATURE_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE = 1u << 5,
FEATURE_DEPTH_CLAMP = 1u << 6,
FEATURE_LARGE_POINTS = 1u << 7,
FEATURE_WIDE_LINES = 1u << 8,
FEATURE_SHADER_CLIP_DISTANCE = 1u << 9,
FEATURE_SHADER_CULL_DISTANCE = 1u << 10,
};
typedef deUint32 FeatureFlags;
vk::VkBufferCreateInfo makeBufferCreateInfo (const vk::VkDeviceSize bufferSize, const vk::VkBufferUsageFlags usage);
vk::Move<vk::VkCommandPool> makeCommandPool (const vk::DeviceInterface& vk, const vk::VkDevice device, const deUint32 queueFamilyIndex);
vk::Move<vk::VkCommandBuffer> makeCommandBuffer (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkCommandPool commandPool);
vk::Move<vk::VkDescriptorSet> makeDescriptorSet (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkDescriptorPool descriptorPool, const vk::VkDescriptorSetLayout setLayout);
vk::Move<vk::VkPipelineLayout> makePipelineLayout (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkDescriptorSetLayout descriptorSetLayout);
vk::Move<vk::VkPipelineLayout> makePipelineLayoutWithoutDescriptors (const vk::DeviceInterface& vk, const vk::VkDevice device);
vk::Move<vk::VkImageView> makeImageView (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkImage image, const vk::VkImageViewType viewType, const vk::VkFormat format, const vk::VkImageSubresourceRange subresourceRange);
vk::VkBufferImageCopy makeBufferImageCopy (const vk::VkImageSubresourceLayers subresourceLayers, const vk::VkExtent3D extent);
vk::VkBufferMemoryBarrier makeBufferMemoryBarrier (const vk::VkAccessFlags srcAccessMask, const vk::VkAccessFlags dstAccessMask, const vk::VkBuffer buffer, const vk::VkDeviceSize offset, const vk::VkDeviceSize bufferSizeBytes);
vk::VkImageMemoryBarrier makeImageMemoryBarrier (const vk::VkAccessFlags srcAccessMask, const vk::VkAccessFlags dstAccessMask, const vk::VkImageLayout oldLayout, const vk::VkImageLayout newLayout, const vk::VkImage image, const vk::VkImageSubresourceRange subresourceRange);
void beginCommandBuffer (const vk::DeviceInterface& vk, const vk::VkCommandBuffer commandBuffer);
void endCommandBuffer (const vk::DeviceInterface& vk, const vk::VkCommandBuffer commandBuffer);
void submitCommandsAndWait (const vk::DeviceInterface& vk, const vk::VkDevice device, const vk::VkQueue queue, const vk::VkCommandBuffer commandBuffer);
void requireFeatures (const vk::InstanceInterface& vki, const vk::VkPhysicalDevice physDevice, const FeatureFlags flags);
std::string getPrimitiveTopologyShortName (const vk::VkPrimitiveTopology topology);
} // clipping
} // vkt
#endif // _VKTCLIPPINGUTIL_HPP