1 #ifndef _VKTDYNAMICSTATEBASECLASS_HPP 2 #define _VKTDYNAMICSTATEBASECLASS_HPP 3 /*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2015 The Khronos Group Inc. 8 * Copyright (c) 2015 Intel Corporation 9 * 10 * Licensed under the Apache License, Version 2.0 (the "License"); 11 * you may not use this file except in compliance with the License. 12 * You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, software 17 * distributed under the License is distributed on an "AS IS" BASIS, 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 * See the License for the specific language governing permissions and 20 * limitations under the License. 21 * 22 *//*! 23 * \file 24 * \brief Dynamic State Tests - Base Class 25 *//*--------------------------------------------------------------------*/ 26 27 #include "tcuDefs.hpp" 28 #include "vktTestCase.hpp" 29 30 #include "vktDynamicStateTestCaseUtil.hpp" 31 #include "vktDrawImageObjectUtil.hpp" 32 #include "vktDrawBufferObjectUtil.hpp" 33 #include "vktDrawCreateInfoUtil.hpp" 34 #include "vkPipelineConstructionUtil.hpp" 35 36 namespace vkt 37 { 38 namespace DynamicState 39 { 40 41 class DynamicStateBaseClass : public TestInstance 42 { 43 public: 44 DynamicStateBaseClass (Context& context, 45 vk::PipelineConstructionType pipelineConstructionType, 46 const char* vertexShaderName, 47 const char* fragmentShaderName, 48 const char* meshShaderName = nullptr); 49 50 protected: 51 void initialize (void); 52 53 virtual void initRenderPass (const vk::VkDevice device); 54 virtual void initFramebuffer (const vk::VkDevice device); 55 virtual void initPipeline (const vk::VkDevice device); 56 57 virtual tcu::TestStatus iterate (void); 58 59 void beginRenderPass (void); 60 61 void beginRenderPassWithClearColor (const vk::VkClearColorValue& clearColor, 62 const bool skipBeginCmdBuffer = false); 63 64 void setDynamicViewportState (const deUint32 width, 65 const deUint32 height); 66 67 void setDynamicViewportState (deUint32 viewportCount, 68 const vk::VkViewport* pViewports, 69 const vk::VkRect2D* pScissors); 70 71 void setDynamicRasterizationState (const float lineWidth = 1.0f, 72 const float depthBiasConstantFactor = 0.0f, 73 const float depthBiasClamp = 0.0f, 74 const float depthBiasSlopeFactor = 0.0f); 75 76 void setDynamicBlendState (const float const1 = 0.0f, const float const2 = 0.0f, 77 const float const3 = 0.0f, const float const4 = 0.0f); 78 79 void setDynamicDepthStencilState (const float minDepthBounds = 0.0f, 80 const float maxDepthBounds = 1.0f, 81 const deUint32 stencilFrontCompareMask = 0xffffffffu, 82 const deUint32 stencilFrontWriteMask = 0xffffffffu, 83 const deUint32 stencilFrontReference = 0, 84 const deUint32 stencilBackCompareMask = 0xffffffffu, 85 const deUint32 stencilBackWriteMask = 0xffffffffu, 86 const deUint32 stencilBackReference = 0); 87 88 #ifndef CTS_USES_VULKANSC 89 void pushVertexOffset (const uint32_t vertexOffset, 90 const vk::VkPipelineLayout pipelineLayout, 91 const vk::VkShaderStageFlags stageFlags = vk::VK_SHADER_STAGE_MESH_BIT_EXT); 92 #endif // CTS_USES_VULKANSC 93 94 enum 95 { 96 WIDTH = 128, 97 HEIGHT = 128 98 }; 99 100 vk::VkFormat m_colorAttachmentFormat; 101 102 vk::VkPrimitiveTopology m_topology; 103 104 const vk::DeviceInterface& m_vk; 105 106 vk::Move<vk::VkDescriptorPool> m_descriptorPool; 107 vk::Move<vk::VkDescriptorSetLayout> m_meshSetLayout; 108 vk::Move<vk::VkDescriptorSetLayout> m_otherSetLayout; 109 vk::Move<vk::VkPipelineLayout> m_pipelineLayout; 110 vk::Move<vk::VkDescriptorSet> m_descriptorSet; 111 vk::GraphicsPipelineWrapper m_pipeline; 112 113 de::SharedPtr<Draw::Image> m_colorTargetImage; 114 vk::Move<vk::VkImageView> m_colorTargetView; 115 116 Draw::PipelineCreateInfo::VertexInputState m_vertexInputState; 117 de::SharedPtr<Draw::Buffer> m_vertexBuffer; 118 119 vk::Move<vk::VkCommandPool> m_cmdPool; 120 vk::Move<vk::VkCommandBuffer> m_cmdBuffer; 121 122 vk::Move<vk::VkFramebuffer> m_framebuffer; 123 vk::Move<vk::VkRenderPass> m_renderPass; 124 125 const std::string m_vertexShaderName; 126 const std::string m_fragmentShaderName; 127 const std::string m_meshShaderName; 128 std::vector<PositionColorVertex> m_data; 129 bool m_isMesh; 130 131 Draw::PipelineCreateInfo::ColorBlendState::Attachment m_attachmentState; 132 }; 133 134 } // DynamicState 135 } // vkt 136 137 #endif // _VKTDYNAMICSTATEBASECLASS_HPP 138