#ifndef _VKTSPVASMCOMPUTESHADERTESTUTIL_HPP #define _VKTSPVASMCOMPUTESHADERTESTUTIL_HPP /*------------------------------------------------------------------------- * Vulkan Conformance Tests * ------------------------ * * Copyright (c) 2015 Google 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 Compute Shader Based Test Case Utility Structs/Functions *//*--------------------------------------------------------------------*/ #include "deDefs.h" #include "deSharedPtr.hpp" #include "tcuTestLog.hpp" #include "tcuVector.hpp" #include "vkMemUtil.hpp" #include #include using namespace vk; namespace vkt { namespace SpirVAssembly { typedef de::MovePtr AllocationMp; typedef de::SharedPtr AllocationSp; /*--------------------------------------------------------------------*//*! * \brief Abstract class for an input/output storage buffer object *//*--------------------------------------------------------------------*/ class BufferInterface { public: virtual ~BufferInterface (void) {} virtual size_t getNumBytes (void) const = 0; virtual const void* data (void) const = 0; }; typedef de::SharedPtr BufferSp; /*--------------------------------------------------------------------*//*! * \brief Concrete class for an input/output storage buffer object *//*--------------------------------------------------------------------*/ template class Buffer : public BufferInterface { public: Buffer (const std::vector& elements) : m_elements(elements) {} size_t getNumBytes (void) const { return m_elements.size() * sizeof(E); } const void* data (void) const { return &m_elements.front(); } private: std::vector m_elements; }; DE_STATIC_ASSERT(sizeof(tcu::Vec4) == 4 * sizeof(float)); typedef Buffer Float32Buffer; typedef Buffer Int32Buffer; typedef Buffer Vec4Buffer; /*--------------------------------------------------------------------*//*! * \brief Specification for a compute shader. * * This struct bundles SPIR-V assembly code, input and expected output * together. *//*--------------------------------------------------------------------*/ struct ComputeShaderSpec { std::string assembly; std::string entryPoint; std::vector inputs; std::vector outputs; tcu::IVec3 numWorkGroups; std::vector specConstants; // If null, a default verification will be performed by comparing the memory pointed to by outputAllocations // and the contents of expectedOutputs. Otherwise the function pointed to by verifyIO will be called. // If true is returned, then the test case is assumed to have passed, if false is returned, then the test // case is assumed to have failed. bool (*verifyIO)(const std::vector& inputs, const std::vector& outputAllocations, const std::vector& expectedOutputs, tcu::TestLog& log); ComputeShaderSpec() : entryPoint ("main") , verifyIO (DE_NULL) {} }; } // SpirVAssembly } // vkt #endif // _VKTSPVASMCOMPUTESHADERTESTUTIL_HPP