1 #ifndef _VKTDRAWUTIL_HPP
2 #define _VKTDRAWUTIL_HPP
3 /*-------------------------------------------------------------------------
7 * Copyright (c) 2016 The Khronos Group Inc.
8 * Copyright (c) 2016 Google Inc.
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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 * \brief Utility for generating simple work
25 *//*--------------------------------------------------------------------*/
29 #include "deUniquePtr.hpp"
30 #include "vkBufferWithMemory.hpp"
31 #include "vkImageWithMemory.hpp"
32 #include "vkImageUtil.hpp"
33 #include "vkPrograms.hpp"
34 #include "vktTestCase.hpp"
44 RENDER_SIZE_LARGE = 128,
45 NUM_RENDER_PIXELS = RENDER_SIZE * RENDER_SIZE,
46 NUM_PATCH_CONTROL_POINTS = 3,
47 MAX_NUM_SHADER_MODULES = 5,
48 MAX_CLIP_DISTANCES = 8,
49 MAX_CULL_DISTANCES = 8,
50 MAX_COMBINED_CLIP_AND_CULL_DISTANCES = 8,
55 vk::VkShaderStageFlagBits stage;
56 const vk::ProgramBinary* binary;
58 Shader (const vk::VkShaderStageFlagBits stage_, const vk::ProgramBinary& binary_)
64 //! Sets up a graphics pipeline and enables simple draw calls to predefined attachments.
65 //! Clip volume uses wc = 1.0, which gives clip coord ranges: x = [-1, 1], y = [-1, 1], z = [0, 1]
66 //! Clip coords (-1,-1) map to viewport coords (0, 0).
70 DrawContext (Context& context,
71 const std::vector<Shader>& shaders,
72 const std::vector<tcu::Vec4>& vertices,
73 const vk::VkPrimitiveTopology primitiveTopology,
74 const deUint32 renderSize = static_cast<deUint32>(RENDER_SIZE),
75 const bool depthClampEnable = false,
76 const bool blendEnable = false,
77 const float lineWidth = 1.0f);
80 tcu::ConstPixelBufferAccess getColorPixels (void) const;
84 const vk::VkFormat m_colorFormat;
85 const vk::VkFormat m_depthFormat;
86 const vk::VkImageSubresourceRange m_colorSubresourceRange;
87 const vk::VkImageSubresourceRange m_depthSubresourceRange;
88 const tcu::UVec2 m_renderSize;
89 const vk::VkExtent3D m_imageExtent;
90 const vk::VkPrimitiveTopology m_primitiveTopology;
91 const bool m_depthClampEnable;
92 const bool m_blendEnable;
93 const deUint32 m_numVertices;
94 const float m_lineWidth;
95 const deUint32 m_numPatchControlPoints;
96 de::MovePtr<vk::BufferWithMemory> m_vertexBuffer;
97 de::MovePtr<vk::ImageWithMemory> m_colorImage;
98 de::MovePtr<vk::ImageWithMemory> m_depthImage;
99 de::MovePtr<vk::BufferWithMemory> m_colorAttachmentBuffer;
100 vk::refdetails::Move<vk::VkImageView> m_colorImageView;
101 vk::refdetails::Move<vk::VkImageView> m_depthImageView;
102 vk::refdetails::Move<vk::VkRenderPass> m_renderPass;
103 vk::refdetails::Move<vk::VkFramebuffer> m_framebuffer;
104 vk::refdetails::Move<vk::VkPipelineLayout> m_pipelineLayout;
105 vk::refdetails::Move<vk::VkPipeline> m_pipeline;
106 vk::refdetails::Move<vk::VkCommandPool> m_cmdPool;
107 vk::refdetails::Move<vk::VkCommandBuffer> m_cmdBuffer;
108 vk::refdetails::Move<vk::VkShaderModule> m_shaderModules[MAX_NUM_SHADER_MODULES];
110 DrawContext (const DrawContext&); // "deleted"
111 DrawContext& operator= (const DrawContext&); // "deleted"
113 std::string getPrimitiveTopologyShortName (const vk::VkPrimitiveTopology topology);
118 #endif // _VKTDRAWUTIL_HPP