#ifndef _VKTROBUSTNESSUTIL_HPP #define _VKTROBUSTNESSUTIL_HPP /*------------------------------------------------------------------------ * Vulkan Conformance Tests * ------------------------ * * Copyright (c) 2016 The Khronos Group Inc. * Copyright (c) 2016 Imagination Technologies Ltd. * * 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 Robustness Utilities *//*--------------------------------------------------------------------*/ #include "tcuDefs.hpp" #include "vkDefs.hpp" #include "vkRefUtil.hpp" #include "vktTestCase.hpp" #include "vkMemUtil.hpp" #include "deUniquePtr.hpp" #include "tcuVectorUtil.hpp" namespace vkt { namespace robustness { vk::Move createRobustBufferAccessDevice (Context& context, const vk::VkPhysicalDeviceFeatures2* enabledFeatures2 = DE_NULL); bool areEqual (float a, float b); bool isValueZero (const void* valuePtr, size_t valueSize); bool isValueWithinBuffer (const void* buffer, vk::VkDeviceSize bufferSize, const void* valuePtr, size_t valueSizeInBytes); bool isValueWithinBufferOrZero (const void* buffer, vk::VkDeviceSize bufferSize, const void* valuePtr, size_t valueSizeInBytes); bool verifyOutOfBoundsVec4 (const void* vecPtr, vk::VkFormat bufferFormat); void populateBufferWithTestValues (void* buffer, vk::VkDeviceSize size, vk::VkFormat format); void logValue (std::ostringstream& logMsg, const void* valuePtr, vk::VkFormat valueFormat, size_t valueSize); class TestEnvironment { public: TestEnvironment (Context& context, const vk::DeviceInterface& vk, vk::VkDevice device, vk::VkDescriptorSetLayout descriptorSetLayout, vk::VkDescriptorSet descriptorSet); virtual ~TestEnvironment (void) {} virtual vk::VkCommandBuffer getCommandBuffer (void); protected: Context& m_context; vk::VkDevice m_device; vk::VkDescriptorSetLayout m_descriptorSetLayout; vk::VkDescriptorSet m_descriptorSet; vk::Move m_commandPool; vk::Move m_commandBuffer; }; class GraphicsEnvironment: public TestEnvironment { public: typedef std::vector VertexBindings; typedef std::vector VertexAttributes; struct DrawConfig { std::vector vertexBuffers; deUint32 vertexCount; deUint32 instanceCount; vk::VkBuffer indexBuffer; deUint32 indexCount; }; GraphicsEnvironment (Context& context, const vk::DeviceInterface& vk, vk::VkDevice device, vk::VkDescriptorSetLayout descriptorSetLayout, vk::VkDescriptorSet descriptorSet, const VertexBindings& vertexBindings, const VertexAttributes& vertexAttributes, const DrawConfig& drawConfig, bool testPipelineRobustness = false); virtual ~GraphicsEnvironment (void) {} private: const tcu::UVec2 m_renderSize; const vk::VkFormat m_colorFormat; vk::Move m_colorImage; de::MovePtr m_colorImageAlloc; vk::Move m_colorAttachmentView; vk::Move m_renderPass; vk::Move m_framebuffer; vk::Move m_vertexShaderModule; vk::Move m_fragmentShaderModule; vk::Move m_vertexBuffer; de::MovePtr m_vertexBufferAlloc; vk::Move m_pipelineLayout; vk::Move m_graphicsPipeline; }; class ComputeEnvironment: public TestEnvironment { public: ComputeEnvironment (Context& context, const vk::DeviceInterface& vk, vk::VkDevice device, vk::VkDescriptorSetLayout descriptorSetLayout, vk::VkDescriptorSet descriptorSet, bool testPipelineRobustness = false); virtual ~ComputeEnvironment (void) {} private: vk::Move m_computeShaderModule; vk::Move m_pipelineLayout; vk::Move m_computePipeline; }; } // robustness } // vkt #endif // _VKTROBUSTNESSUTIL_HPP