1/*------------------------------------------------------------------------ 2 * Vulkan Conformance Tests 3 * ------------------------ 4 * 5 * Copyright (c) 2015 The Khronos Group Inc. 6 * Copyright (c) 2015 Intel Corporation 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 * 20 *//*! 21 * \file 22 * \brief Dynamic State Depth Stencil Tests 23 *//*--------------------------------------------------------------------*/ 24 25#include "vktDynamicStateDSTests.hpp" 26 27#include "vktTestCaseUtil.hpp" 28#include "vktDynamicStateTestCaseUtil.hpp" 29 30#include "tcuTestLog.hpp" 31#include "tcuResource.hpp" 32#include "tcuImageCompare.hpp" 33#include "tcuCommandLine.hpp" 34#include "tcuTextureUtil.hpp" 35#include "tcuRGBA.hpp" 36 37#include "vkRefUtil.hpp" 38#include "vkImageUtil.hpp" 39 40#include "vktDrawCreateInfoUtil.hpp" 41#include "vktDrawImageObjectUtil.hpp" 42#include "vktDrawBufferObjectUtil.hpp" 43#include "vkPrograms.hpp" 44 45namespace vkt 46{ 47namespace DynamicState 48{ 49 50using namespace Draw; 51 52namespace 53{ 54 55class DepthStencilBaseCase : public TestInstance 56{ 57public: 58 DepthStencilBaseCase (Context& context, const char* vertexShaderName, const char* fragmentShaderName) 59 : TestInstance (context) 60 , m_colorAttachmentFormat (vk::VK_FORMAT_R8G8B8A8_UNORM) 61 , m_topology (vk::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP) 62 , m_vk (context.getDeviceInterface()) 63 , m_vertexShaderName (vertexShaderName) 64 , m_fragmentShaderName (fragmentShaderName) 65 { 66 } 67 68protected: 69 70 enum 71 { 72 WIDTH = 128, 73 HEIGHT = 128 74 }; 75 76 vk::VkFormat m_colorAttachmentFormat; 77 vk::VkFormat m_depthStencilAttachmentFormat; 78 79 vk::VkPrimitiveTopology m_topology; 80 81 const vk::DeviceInterface& m_vk; 82 83 vk::Move<vk::VkPipeline> m_pipeline_1; 84 vk::Move<vk::VkPipeline> m_pipeline_2; 85 vk::Move<vk::VkPipelineLayout> m_pipelineLayout; 86 87 de::SharedPtr<Image> m_colorTargetImage; 88 vk::Move<vk::VkImageView> m_colorTargetView; 89 90 de::SharedPtr<Image> m_depthStencilImage; 91 vk::Move<vk::VkImageView> m_attachmentView; 92 93 PipelineCreateInfo::VertexInputState m_vertexInputState; 94 de::SharedPtr<Buffer> m_vertexBuffer; 95 96 vk::Move<vk::VkCommandPool> m_cmdPool; 97 vk::Move<vk::VkCommandBuffer> m_cmdBuffer; 98 99 vk::Move<vk::VkFramebuffer> m_framebuffer; 100 vk::Move<vk::VkRenderPass> m_renderPass; 101 102 const std::string m_vertexShaderName; 103 const std::string m_fragmentShaderName; 104 105 std::vector<PositionColorVertex> m_data; 106 107 PipelineCreateInfo::DepthStencilState m_depthStencilState_1; 108 PipelineCreateInfo::DepthStencilState m_depthStencilState_2; 109 110 void initialize (void) 111 { 112 const vk::VkDevice device = m_context.getDevice(); 113 114 vk::VkFormatProperties formatProperties; 115 // check for VK_FORMAT_D24_UNORM_S8_UINT support 116 m_context.getInstanceInterface().getPhysicalDeviceFormatProperties(m_context.getPhysicalDevice(), vk::VK_FORMAT_D24_UNORM_S8_UINT, &formatProperties); 117 if (formatProperties.optimalTilingFeatures & vk::VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) 118 { 119 m_depthStencilAttachmentFormat = vk::VK_FORMAT_D24_UNORM_S8_UINT; 120 } 121 else 122 { 123 // check for VK_FORMAT_D32_SFLOAT_S8_UINT support 124 m_context.getInstanceInterface().getPhysicalDeviceFormatProperties(m_context.getPhysicalDevice(), vk::VK_FORMAT_D32_SFLOAT_S8_UINT, &formatProperties); 125 if (formatProperties.optimalTilingFeatures & vk::VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) 126 { 127 m_depthStencilAttachmentFormat = vk::VK_FORMAT_D32_SFLOAT_S8_UINT; 128 } 129 else 130 throw tcu::NotSupportedError("No valid depth stencil attachment available"); 131 } 132 133 const PipelineLayoutCreateInfo pipelineLayoutCreateInfo; 134 m_pipelineLayout = vk::createPipelineLayout(m_vk, device, &pipelineLayoutCreateInfo); 135 136 const vk::Unique<vk::VkShaderModule> vs(createShaderModule(m_vk, device, m_context.getBinaryCollection().get(m_vertexShaderName), 0)); 137 const vk::Unique<vk::VkShaderModule> fs(createShaderModule(m_vk, device, m_context.getBinaryCollection().get(m_fragmentShaderName), 0)); 138 139 const vk::VkExtent3D imageExtent = { WIDTH, HEIGHT, 1 }; 140 const ImageCreateInfo targetImageCreateInfo(vk::VK_IMAGE_TYPE_2D, m_colorAttachmentFormat, imageExtent, 1, 1, vk::VK_SAMPLE_COUNT_1_BIT, 141 vk::VK_IMAGE_TILING_OPTIMAL, 142 vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | 143 vk::VK_IMAGE_USAGE_TRANSFER_SRC_BIT | 144 vk::VK_IMAGE_USAGE_TRANSFER_DST_BIT); 145 146 m_colorTargetImage = Image::createAndAlloc(m_vk, device, targetImageCreateInfo, m_context.getDefaultAllocator()); 147 148 const ImageCreateInfo depthStencilImageCreateInfo(vk::VK_IMAGE_TYPE_2D, m_depthStencilAttachmentFormat, imageExtent, 149 1, 1, vk::VK_SAMPLE_COUNT_1_BIT, vk::VK_IMAGE_TILING_OPTIMAL, 150 vk::VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | 151 vk::VK_IMAGE_USAGE_TRANSFER_DST_BIT); 152 153 m_depthStencilImage = Image::createAndAlloc(m_vk, device, depthStencilImageCreateInfo, m_context.getDefaultAllocator()); 154 155 const ImageViewCreateInfo colorTargetViewInfo(m_colorTargetImage->object(), vk::VK_IMAGE_VIEW_TYPE_2D, m_colorAttachmentFormat); 156 m_colorTargetView = vk::createImageView(m_vk, device, &colorTargetViewInfo); 157 158 const ImageViewCreateInfo attachmentViewInfo(m_depthStencilImage->object(), vk::VK_IMAGE_VIEW_TYPE_2D, m_depthStencilAttachmentFormat); 159 m_attachmentView = vk::createImageView(m_vk, device, &attachmentViewInfo); 160 161 RenderPassCreateInfo renderPassCreateInfo; 162 renderPassCreateInfo.addAttachment(AttachmentDescription(m_colorAttachmentFormat, 163 vk::VK_SAMPLE_COUNT_1_BIT, 164 vk::VK_ATTACHMENT_LOAD_OP_LOAD, 165 vk::VK_ATTACHMENT_STORE_OP_STORE, 166 vk::VK_ATTACHMENT_LOAD_OP_DONT_CARE, 167 vk::VK_ATTACHMENT_STORE_OP_STORE, 168 vk::VK_IMAGE_LAYOUT_GENERAL, 169 vk::VK_IMAGE_LAYOUT_GENERAL)); 170 171 renderPassCreateInfo.addAttachment(AttachmentDescription(m_depthStencilAttachmentFormat, 172 vk::VK_SAMPLE_COUNT_1_BIT, 173 vk::VK_ATTACHMENT_LOAD_OP_LOAD, 174 vk::VK_ATTACHMENT_STORE_OP_STORE, 175 vk::VK_ATTACHMENT_LOAD_OP_LOAD, 176 vk::VK_ATTACHMENT_STORE_OP_STORE, 177 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 178 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)); 179 180 const vk::VkAttachmentReference colorAttachmentReference = 181 { 182 0, 183 vk::VK_IMAGE_LAYOUT_GENERAL 184 }; 185 186 const vk::VkAttachmentReference depthAttachmentReference = 187 { 188 1, 189 vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL 190 }; 191 192 renderPassCreateInfo.addSubpass(SubpassDescription( 193 vk::VK_PIPELINE_BIND_POINT_GRAPHICS, 194 0, 195 0, 196 DE_NULL, 197 1, 198 &colorAttachmentReference, 199 DE_NULL, 200 depthAttachmentReference, 201 0, 202 DE_NULL)); 203 204 m_renderPass = vk::createRenderPass(m_vk, device, &renderPassCreateInfo); 205 206 const vk::VkVertexInputBindingDescription vertexInputBindingDescription = 207 { 208 0, 209 (deUint32)sizeof(tcu::Vec4) * 2, 210 vk::VK_VERTEX_INPUT_RATE_VERTEX, 211 }; 212 213 const vk::VkVertexInputAttributeDescription vertexInputAttributeDescriptions[2] = 214 { 215 { 216 0u, 217 0u, 218 vk::VK_FORMAT_R32G32B32A32_SFLOAT, 219 0u 220 }, 221 { 222 1u, 223 0u, 224 vk::VK_FORMAT_R32G32B32A32_SFLOAT, 225 (deUint32)(sizeof(float)* 4), 226 } 227 }; 228 229 m_vertexInputState = PipelineCreateInfo::VertexInputState( 230 1, 231 &vertexInputBindingDescription, 232 2, 233 vertexInputAttributeDescriptions); 234 235 const PipelineCreateInfo::ColorBlendState::Attachment vkCbAttachmentState; 236 237 PipelineCreateInfo pipelineCreateInfo_1(*m_pipelineLayout, *m_renderPass, 0, 0); 238 pipelineCreateInfo_1.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", vk::VK_SHADER_STAGE_VERTEX_BIT)); 239 pipelineCreateInfo_1.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", vk::VK_SHADER_STAGE_FRAGMENT_BIT)); 240 pipelineCreateInfo_1.addState(PipelineCreateInfo::VertexInputState(m_vertexInputState)); 241 pipelineCreateInfo_1.addState(PipelineCreateInfo::InputAssemblerState(m_topology)); 242 pipelineCreateInfo_1.addState(PipelineCreateInfo::ColorBlendState(1, &vkCbAttachmentState)); 243 pipelineCreateInfo_1.addState(PipelineCreateInfo::ViewportState(1)); 244 pipelineCreateInfo_1.addState(m_depthStencilState_1); 245 pipelineCreateInfo_1.addState(PipelineCreateInfo::RasterizerState()); 246 pipelineCreateInfo_1.addState(PipelineCreateInfo::MultiSampleState()); 247 pipelineCreateInfo_1.addState(PipelineCreateInfo::DynamicState()); 248 249 PipelineCreateInfo pipelineCreateInfo_2(*m_pipelineLayout, *m_renderPass, 0, 0); 250 pipelineCreateInfo_2.addShader(PipelineCreateInfo::PipelineShaderStage(*vs, "main", vk::VK_SHADER_STAGE_VERTEX_BIT)); 251 pipelineCreateInfo_2.addShader(PipelineCreateInfo::PipelineShaderStage(*fs, "main", vk::VK_SHADER_STAGE_FRAGMENT_BIT)); 252 pipelineCreateInfo_2.addState(PipelineCreateInfo::VertexInputState(m_vertexInputState)); 253 pipelineCreateInfo_2.addState(PipelineCreateInfo::InputAssemblerState(m_topology)); 254 pipelineCreateInfo_2.addState(PipelineCreateInfo::ColorBlendState(1, &vkCbAttachmentState)); 255 pipelineCreateInfo_2.addState(PipelineCreateInfo::ViewportState(1)); 256 pipelineCreateInfo_2.addState(m_depthStencilState_2); 257 pipelineCreateInfo_2.addState(PipelineCreateInfo::RasterizerState()); 258 pipelineCreateInfo_2.addState(PipelineCreateInfo::MultiSampleState()); 259 pipelineCreateInfo_2.addState(PipelineCreateInfo::DynamicState()); 260 261 m_pipeline_1 = vk::createGraphicsPipeline(m_vk, device, DE_NULL, &pipelineCreateInfo_1); 262 m_pipeline_2 = vk::createGraphicsPipeline(m_vk, device, DE_NULL, &pipelineCreateInfo_2); 263 264 std::vector<vk::VkImageView> attachments(2); 265 attachments[0] = *m_colorTargetView; 266 attachments[1] = *m_attachmentView; 267 268 const FramebufferCreateInfo framebufferCreateInfo(*m_renderPass, attachments, WIDTH, HEIGHT, 1); 269 270 m_framebuffer = vk::createFramebuffer(m_vk, device, &framebufferCreateInfo); 271 272 const vk::VkDeviceSize dataSize = m_data.size() * sizeof(PositionColorVertex); 273 m_vertexBuffer = Buffer::createAndAlloc(m_vk, device, BufferCreateInfo(dataSize, vk::VK_BUFFER_USAGE_VERTEX_BUFFER_BIT), 274 m_context.getDefaultAllocator(), vk::MemoryRequirement::HostVisible); 275 276 deUint8* ptr = reinterpret_cast<unsigned char *>(m_vertexBuffer->getBoundMemory().getHostPtr()); 277 deMemcpy(ptr, &m_data[0], (size_t)dataSize); 278 279 vk::flushMappedMemoryRange(m_vk, device, 280 m_vertexBuffer->getBoundMemory().getMemory(), 281 m_vertexBuffer->getBoundMemory().getOffset(), 282 dataSize); 283 284 const CmdPoolCreateInfo cmdPoolCreateInfo(m_context.getUniversalQueueFamilyIndex()); 285 m_cmdPool = vk::createCommandPool(m_vk, device, &cmdPoolCreateInfo); 286 287 const vk::VkCommandBufferAllocateInfo cmdBufferAllocateInfo = 288 { 289 vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType; 290 DE_NULL, // const void* pNext; 291 *m_cmdPool, // VkCommandPool commandPool; 292 vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level; 293 1u, // deUint32 bufferCount; 294 }; 295 m_cmdBuffer = vk::allocateCommandBuffer(m_vk, device, &cmdBufferAllocateInfo); 296 } 297 298 virtual tcu::TestStatus iterate (void) 299 { 300 DE_ASSERT(false); 301 return tcu::TestStatus::fail("Implement iterate() method!"); 302 } 303 304 void beginRenderPass (void) 305 { 306 const vk::VkClearColorValue clearColor = { { 0.0f, 0.0f, 0.0f, 1.0f } }; 307 beginRenderPassWithClearColor(clearColor); 308 } 309 310 void beginRenderPassWithClearColor (const vk::VkClearColorValue &clearColor) 311 { 312 const CmdBufferBeginInfo beginInfo; 313 m_vk.beginCommandBuffer(*m_cmdBuffer, &beginInfo); 314 315 initialTransitionColor2DImage(m_vk, *m_cmdBuffer, m_colorTargetImage->object(), vk::VK_IMAGE_LAYOUT_GENERAL); 316 initialTransitionDepthStencil2DImage(m_vk, *m_cmdBuffer, m_depthStencilImage->object(), vk::VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 0, vk::VK_ACCESS_TRANSFER_WRITE_BIT); 317 318 const ImageSubresourceRange subresourceRangeImage(vk::VK_IMAGE_ASPECT_COLOR_BIT); 319 m_vk.cmdClearColorImage(*m_cmdBuffer, m_colorTargetImage->object(), 320 vk::VK_IMAGE_LAYOUT_GENERAL, &clearColor, 1, &subresourceRangeImage); 321 322 const vk::VkClearDepthStencilValue depthStencilClearValue = { 0.0f, 0 }; 323 324 const ImageSubresourceRange subresourceRangeDepthStencil[2] = { vk::VK_IMAGE_ASPECT_DEPTH_BIT, vk::VK_IMAGE_ASPECT_STENCIL_BIT }; 325 m_vk.cmdClearDepthStencilImage(*m_cmdBuffer, m_depthStencilImage->object(), 326 vk::VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &depthStencilClearValue, 2, subresourceRangeDepthStencil); 327 328 vk::VkMemoryBarrier memBarrier; 329 memBarrier.sType = vk::VK_STRUCTURE_TYPE_MEMORY_BARRIER; 330 memBarrier.pNext = NULL; 331 memBarrier.srcAccessMask = vk::VK_ACCESS_TRANSFER_WRITE_BIT; 332 memBarrier.dstAccessMask = vk::VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | 333 vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; 334 335 m_vk.cmdPipelineBarrier(*m_cmdBuffer, vk::VK_PIPELINE_STAGE_TRANSFER_BIT, 336 vk::VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | 337 vk::VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | vk::VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, 338 0, 1, &memBarrier, 0, NULL, 0, NULL); 339 340 const vk::VkRect2D renderArea = { { 0, 0 }, { WIDTH, HEIGHT } }; 341 const RenderPassBeginInfo renderPassBegin(*m_renderPass, *m_framebuffer, renderArea); 342 343 transition2DImage(m_vk, *m_cmdBuffer, m_depthStencilImage->object(), vk::VK_IMAGE_ASPECT_DEPTH_BIT | vk::VK_IMAGE_ASPECT_STENCIL_BIT, vk::VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, vk::VK_ACCESS_TRANSFER_WRITE_BIT, vk::VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT); 344 345 m_vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBegin, vk::VK_SUBPASS_CONTENTS_INLINE); 346 } 347 348 void setDynamicViewportState (const deUint32 width, const deUint32 height) 349 { 350 vk::VkViewport viewport; 351 viewport.x = 0; 352 viewport.y = 0; 353 viewport.width = static_cast<float>(width); 354 viewport.height = static_cast<float>(height); 355 viewport.minDepth = 0.0f; 356 viewport.maxDepth = 1.0f; 357 358 m_vk.cmdSetViewport(*m_cmdBuffer, 0, 1, &viewport); 359 360 vk::VkRect2D scissor; 361 scissor.offset.x = 0; 362 scissor.offset.y = 0; 363 scissor.extent.width = width; 364 scissor.extent.height = height; 365 m_vk.cmdSetScissor(*m_cmdBuffer, 0, 1, &scissor); 366 } 367 368 void setDynamicViewportState(const deUint32 viewportCount, const vk::VkViewport* pViewports, const vk::VkRect2D* pScissors) 369 { 370 m_vk.cmdSetViewport(*m_cmdBuffer, 0, viewportCount, pViewports); 371 m_vk.cmdSetScissor(*m_cmdBuffer, 0, viewportCount, pScissors); 372 } 373 374 void setDynamicRasterizationState(const float lineWidth = 1.0f, 375 const float depthBiasConstantFactor = 0.0f, 376 const float depthBiasClamp = 0.0f, 377 const float depthBiasSlopeFactor = 0.0f) 378 { 379 m_vk.cmdSetLineWidth(*m_cmdBuffer, lineWidth); 380 m_vk.cmdSetDepthBias(*m_cmdBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor); 381 } 382 383 void setDynamicBlendState(const float const1 = 0.0f, const float const2 = 0.0f, 384 const float const3 = 0.0f, const float const4 = 0.0f) 385 { 386 float blendConstantsants[4] = { const1, const2, const3, const4 }; 387 m_vk.cmdSetBlendConstants(*m_cmdBuffer, blendConstantsants); 388 } 389 390 void setDynamicDepthStencilState(const float minDepthBounds = -1.0f, 391 const float maxDepthBounds = 1.0f, 392 const deUint32 stencilFrontCompareMask = 0xffffffffu, 393 const deUint32 stencilFrontWriteMask = 0xffffffffu, 394 const deUint32 stencilFrontReference = 0, 395 const deUint32 stencilBackCompareMask = 0xffffffffu, 396 const deUint32 stencilBackWriteMask = 0xffffffffu, 397 const deUint32 stencilBackReference = 0) 398 { 399 m_vk.cmdSetDepthBounds(*m_cmdBuffer, minDepthBounds, maxDepthBounds); 400 m_vk.cmdSetStencilCompareMask(*m_cmdBuffer, vk::VK_STENCIL_FACE_FRONT_BIT, stencilFrontCompareMask); 401 m_vk.cmdSetStencilWriteMask(*m_cmdBuffer, vk::VK_STENCIL_FACE_FRONT_BIT, stencilFrontWriteMask); 402 m_vk.cmdSetStencilReference(*m_cmdBuffer, vk::VK_STENCIL_FACE_FRONT_BIT, stencilFrontReference); 403 m_vk.cmdSetStencilCompareMask(*m_cmdBuffer, vk::VK_STENCIL_FACE_BACK_BIT, stencilBackCompareMask); 404 m_vk.cmdSetStencilWriteMask(*m_cmdBuffer, vk::VK_STENCIL_FACE_BACK_BIT, stencilBackWriteMask); 405 m_vk.cmdSetStencilReference(*m_cmdBuffer, vk::VK_STENCIL_FACE_BACK_BIT, stencilBackReference); 406 } 407}; 408 409class DepthBoundsParamTestInstance : public DepthStencilBaseCase 410{ 411public: 412 DepthBoundsParamTestInstance (Context &context, ShaderMap shaders) 413 : DepthStencilBaseCase (context, shaders[glu::SHADERTYPE_VERTEX], shaders[glu::SHADERTYPE_FRAGMENT]) 414 { 415 // Check if depth bounds test is supported 416 { 417 const vk::VkPhysicalDeviceFeatures& deviceFeatures = m_context.getDeviceFeatures(); 418 419 if (!deviceFeatures.depthBounds) 420 throw tcu::NotSupportedError("Depth bounds test is unsupported"); 421 } 422 423 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, 1.0f, 0.375f, 1.0f), tcu::RGBA::green().toVec())); 424 m_data.push_back(PositionColorVertex(tcu::Vec4(0.0f, 1.0f, 0.375f, 1.0f), tcu::RGBA::green().toVec())); 425 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, -1.0f, 0.375f, 1.0f), tcu::RGBA::green().toVec())); 426 m_data.push_back(PositionColorVertex(tcu::Vec4(0.0f, -1.0f, 0.375f, 1.0f), tcu::RGBA::green().toVec())); 427 428 m_data.push_back(PositionColorVertex(tcu::Vec4(0.0f, 1.0f, 0.625f, 1.0f), tcu::RGBA::green().toVec())); 429 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, 1.0f, 0.625f, 1.0f), tcu::RGBA::green().toVec())); 430 m_data.push_back(PositionColorVertex(tcu::Vec4(0.0f, -1.0f, 0.625f, 1.0f), tcu::RGBA::green().toVec())); 431 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, -1.0f, 0.625f, 1.0f), tcu::RGBA::green().toVec())); 432 433 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 434 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 435 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, -1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 436 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, -1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 437 438 m_depthStencilState_1 = PipelineCreateInfo::DepthStencilState( 439 VK_TRUE, VK_TRUE, vk::VK_COMPARE_OP_ALWAYS, VK_FALSE); 440 441 // enable depth bounds test 442 m_depthStencilState_2 = PipelineCreateInfo::DepthStencilState( 443 VK_FALSE, VK_FALSE, vk::VK_COMPARE_OP_NEVER, VK_TRUE); 444 445 DepthStencilBaseCase::initialize(); 446 } 447 448 virtual tcu::TestStatus iterate (void) 449 { 450 tcu::TestLog &log = m_context.getTestContext().getLog(); 451 const vk::VkQueue queue = m_context.getUniversalQueue(); 452 453 beginRenderPass(); 454 455 // set states here 456 setDynamicViewportState(WIDTH, HEIGHT); 457 setDynamicRasterizationState(); 458 setDynamicBlendState(); 459 setDynamicDepthStencilState(0.5f, 0.75f); 460 461 const vk::VkDeviceSize vertexBufferOffset = 0; 462 const vk::VkBuffer vertexBuffer = m_vertexBuffer->object(); 463 m_vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset); 464 465 m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline_1); 466 m_vk.cmdDraw(*m_cmdBuffer, 4, 1, 0, 0); 467 m_vk.cmdDraw(*m_cmdBuffer, 4, 1, 4, 0); 468 469 m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline_2); 470 m_vk.cmdDraw(*m_cmdBuffer, 4, 1, 8, 0); 471 472 m_vk.cmdEndRenderPass(*m_cmdBuffer); 473 m_vk.endCommandBuffer(*m_cmdBuffer); 474 475 vk::VkSubmitInfo submitInfo = 476 { 477 vk::VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType; 478 DE_NULL, // const void* pNext; 479 0, // deUint32 waitSemaphoreCount; 480 DE_NULL, // const VkSemaphore* pWaitSemaphores; 481 (const vk::VkPipelineStageFlags*)DE_NULL, 482 1, // deUint32 commandBufferCount; 483 &m_cmdBuffer.get(), // const VkCommandBuffer* pCommandBuffers; 484 0, // deUint32 signalSemaphoreCount; 485 DE_NULL // const VkSemaphore* pSignalSemaphores; 486 }; 487 m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL); 488 489 // validation 490 { 491 VK_CHECK(m_vk.queueWaitIdle(queue)); 492 493 tcu::Texture2D referenceFrame(vk::mapVkFormat(m_colorAttachmentFormat), (int)(0.5 + WIDTH), (int)(0.5 + HEIGHT)); 494 referenceFrame.allocLevel(0); 495 496 const deInt32 frameWidth = referenceFrame.getWidth(); 497 const deInt32 frameHeight = referenceFrame.getHeight(); 498 499 tcu::clear(referenceFrame.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f)); 500 501 for (int y = 0; y < frameHeight; y++) 502 { 503 const float yCoord = (float)(y / (0.5*frameHeight)) - 1.0f; 504 505 for (int x = 0; x < frameWidth; x++) 506 { 507 const float xCoord = (float)(x / (0.5*frameWidth)) - 1.0f; 508 509 if (xCoord >= 0.0f && xCoord <= 1.0f && yCoord >= -1.0f && yCoord <= 1.0f) 510 referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), x, y); 511 else 512 referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), x, y); 513 } 514 } 515 516 const vk::VkOffset3D zeroOffset = { 0, 0, 0 }; 517 const tcu::ConstPixelBufferAccess renderedFrame = m_colorTargetImage->readSurface(queue, m_context.getDefaultAllocator(), 518 vk::VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, vk::VK_IMAGE_ASPECT_COLOR_BIT); 519 520 if (!tcu::fuzzyCompare(log, "Result", "Image comparison result", 521 referenceFrame.getLevel(0), renderedFrame, 0.05f, 522 tcu::COMPARE_LOG_RESULT)) 523 { 524 return tcu::TestStatus(QP_TEST_RESULT_FAIL, "Image verification failed"); 525 } 526 527 return tcu::TestStatus(QP_TEST_RESULT_PASS, "Image verification passed"); 528 } 529 } 530}; 531 532class StencilParamsBasicTestInstance : public DepthStencilBaseCase 533{ 534protected: 535 deUint32 m_writeMask; 536 deUint32 m_readMask; 537 deUint32 m_expectedValue; 538 tcu::Vec4 m_expectedColor; 539 540public: 541 StencilParamsBasicTestInstance (Context& context, const char* vertexShaderName, const char* fragmentShaderName, 542 const deUint32 writeMask, const deUint32 readMask, 543 const deUint32 expectedValue, const tcu::Vec4 expectedColor) 544 : DepthStencilBaseCase (context, vertexShaderName, fragmentShaderName) 545 , m_expectedColor (1.0f, 1.0f, 1.0f, 1.0f) 546 { 547 m_writeMask = writeMask; 548 m_readMask = readMask; 549 m_expectedValue = expectedValue; 550 m_expectedColor = expectedColor; 551 552 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec())); 553 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec())); 554 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, -1.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec())); 555 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, -1.0f, 1.0f, 1.0f), tcu::RGBA::green().toVec())); 556 557 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 558 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 559 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, -1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 560 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, -1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 561 562 const PipelineCreateInfo::DepthStencilState::StencilOpState frontState_1 = 563 PipelineCreateInfo::DepthStencilState::StencilOpState( 564 vk::VK_STENCIL_OP_REPLACE, 565 vk::VK_STENCIL_OP_REPLACE, 566 vk::VK_STENCIL_OP_REPLACE, 567 vk::VK_COMPARE_OP_ALWAYS); 568 569 const PipelineCreateInfo::DepthStencilState::StencilOpState backState_1 = 570 PipelineCreateInfo::DepthStencilState::StencilOpState( 571 vk::VK_STENCIL_OP_REPLACE, 572 vk::VK_STENCIL_OP_REPLACE, 573 vk::VK_STENCIL_OP_REPLACE, 574 vk::VK_COMPARE_OP_ALWAYS); 575 576 const PipelineCreateInfo::DepthStencilState::StencilOpState frontState_2 = 577 PipelineCreateInfo::DepthStencilState::StencilOpState( 578 vk::VK_STENCIL_OP_REPLACE, 579 vk::VK_STENCIL_OP_REPLACE, 580 vk::VK_STENCIL_OP_REPLACE, 581 vk::VK_COMPARE_OP_EQUAL); 582 583 const PipelineCreateInfo::DepthStencilState::StencilOpState backState_2 = 584 PipelineCreateInfo::DepthStencilState::StencilOpState( 585 vk::VK_STENCIL_OP_REPLACE, 586 vk::VK_STENCIL_OP_REPLACE, 587 vk::VK_STENCIL_OP_REPLACE, 588 vk::VK_COMPARE_OP_EQUAL); 589 590 // enable stencil test 591 m_depthStencilState_1 = PipelineCreateInfo::DepthStencilState( 592 VK_FALSE, VK_FALSE, vk::VK_COMPARE_OP_NEVER, VK_FALSE, VK_TRUE, frontState_1, backState_1); 593 594 m_depthStencilState_2 = PipelineCreateInfo::DepthStencilState( 595 VK_FALSE, VK_FALSE, vk::VK_COMPARE_OP_NEVER, VK_FALSE, VK_TRUE, frontState_2, backState_2); 596 597 DepthStencilBaseCase::initialize(); 598 } 599 600 virtual tcu::TestStatus iterate (void) 601 { 602 tcu::TestLog &log = m_context.getTestContext().getLog(); 603 const vk::VkQueue queue = m_context.getUniversalQueue(); 604 605 beginRenderPass(); 606 607 // set states here 608 setDynamicViewportState(WIDTH, HEIGHT); 609 setDynamicRasterizationState(); 610 setDynamicBlendState(); 611 612 const vk::VkDeviceSize vertexBufferOffset = 0; 613 const vk::VkBuffer vertexBuffer = m_vertexBuffer->object(); 614 m_vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset); 615 616 m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline_1); 617 setDynamicDepthStencilState(-1.0f, 1.0f, 0xFF, m_writeMask, 0x0F, 0xFF, m_writeMask, 0x0F); 618 m_vk.cmdDraw(*m_cmdBuffer, 4, 1, 0, 0); 619 620 m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline_2); 621 setDynamicDepthStencilState(-1.0f, 1.0f, m_readMask, 0xFF, m_expectedValue, m_readMask, 0xFF, m_expectedValue); 622 m_vk.cmdDraw(*m_cmdBuffer, 4, 1, 4, 0); 623 624 m_vk.cmdEndRenderPass(*m_cmdBuffer); 625 m_vk.endCommandBuffer(*m_cmdBuffer); 626 627 vk::VkSubmitInfo submitInfo = 628 { 629 vk::VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType; 630 DE_NULL, // const void* pNext; 631 0, // deUint32 waitSemaphoreCount; 632 DE_NULL, // const VkSemaphore* pWaitSemaphores; 633 (const vk::VkPipelineStageFlags*)DE_NULL, 634 1, // deUint32 commandBufferCount; 635 &m_cmdBuffer.get(), // const VkCommandBuffer* pCommandBuffers; 636 0, // deUint32 signalSemaphoreCount; 637 DE_NULL // const VkSemaphore* pSignalSemaphores; 638 }; 639 m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL); 640 641 // validation 642 { 643 VK_CHECK(m_vk.queueWaitIdle(queue)); 644 645 tcu::Texture2D referenceFrame(vk::mapVkFormat(m_colorAttachmentFormat), (int)(0.5 + WIDTH), (int)(0.5 + HEIGHT)); 646 referenceFrame.allocLevel(0); 647 648 const deInt32 frameWidth = referenceFrame.getWidth(); 649 const deInt32 frameHeight = referenceFrame.getHeight(); 650 651 for (int y = 0; y < frameHeight; y++) 652 { 653 const float yCoord = (float)(y / (0.5*frameHeight)) - 1.0f; 654 655 for (int x = 0; x < frameWidth; x++) 656 { 657 const float xCoord = (float)(x / (0.5*frameWidth)) - 1.0f; 658 659 if (xCoord >= -1.0f && xCoord <= 1.0f && yCoord >= -1.0f && yCoord <= 1.0f) 660 referenceFrame.getLevel(0).setPixel(m_expectedColor, x, y); 661 } 662 } 663 664 const vk::VkOffset3D zeroOffset = { 0, 0, 0 }; 665 const tcu::ConstPixelBufferAccess renderedFrame = m_colorTargetImage->readSurface(queue, m_context.getDefaultAllocator(), 666 vk::VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, vk::VK_IMAGE_ASPECT_COLOR_BIT); 667 668 if (!tcu::fuzzyCompare(log, "Result", "Image comparison result", 669 referenceFrame.getLevel(0), renderedFrame, 0.05f, 670 tcu::COMPARE_LOG_RESULT)) 671 { 672 return tcu::TestStatus(QP_TEST_RESULT_FAIL, "Image verification failed"); 673 } 674 675 return tcu::TestStatus(QP_TEST_RESULT_PASS, "Image verification passed"); 676 } 677 } 678}; 679 680class StencilParamsBasicTestCase : public TestCase 681{ 682protected: 683 TestInstance* createInstance(Context& context) const 684 { 685 return new StencilParamsBasicTestInstance(context, "VertexFetch.vert", "VertexFetch.frag", 686 m_writeMask, m_readMask, m_expectedValue, m_expectedColor); 687 } 688 689 virtual void initPrograms(vk::SourceCollections& programCollection) const 690 { 691 programCollection.glslSources.add("VertexFetch.vert") << 692 glu::VertexSource(ShaderSourceProvider::getSource(m_testCtx.getArchive(), "vulkan/dynamic_state/VertexFetch.vert")); 693 694 programCollection.glslSources.add("VertexFetch.frag") << 695 glu::FragmentSource(ShaderSourceProvider::getSource(m_testCtx.getArchive(), "vulkan/dynamic_state/VertexFetch.frag")); 696 } 697 698 deUint32 m_writeMask; 699 deUint32 m_readMask; 700 deUint32 m_expectedValue; 701 tcu::Vec4 m_expectedColor; 702 703public: 704 StencilParamsBasicTestCase (tcu::TestContext& context, const char *name, const char *description, 705 const deUint32 writeMask, const deUint32 readMask, 706 const deUint32 expectedValue, const tcu::Vec4 expectedColor) 707 : TestCase (context, name, description) 708 , m_writeMask (writeMask) 709 , m_readMask (readMask) 710 , m_expectedValue (expectedValue) 711 , m_expectedColor (expectedColor) 712 { 713 } 714}; 715 716class StencilParamsAdvancedTestInstance : public DepthStencilBaseCase 717{ 718public: 719 StencilParamsAdvancedTestInstance (Context& context, ShaderMap shaders) 720 : DepthStencilBaseCase (context, shaders[glu::SHADERTYPE_VERTEX], shaders[glu::SHADERTYPE_FRAGMENT]) 721 { 722 m_data.push_back(PositionColorVertex(tcu::Vec4(-0.5f, 0.5f, 1.0f, 1.0f), tcu::RGBA::green().toVec())); 723 m_data.push_back(PositionColorVertex(tcu::Vec4(0.5f, 0.5f, 1.0f, 1.0f), tcu::RGBA::green().toVec())); 724 m_data.push_back(PositionColorVertex(tcu::Vec4(-0.5f, -0.5f, 1.0f, 1.0f), tcu::RGBA::green().toVec())); 725 m_data.push_back(PositionColorVertex(tcu::Vec4(0.5f, -0.5f, 1.0f, 1.0f), tcu::RGBA::green().toVec())); 726 727 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 728 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 729 m_data.push_back(PositionColorVertex(tcu::Vec4(-1.0f, -1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 730 m_data.push_back(PositionColorVertex(tcu::Vec4(1.0f, -1.0f, 1.0f, 1.0f), tcu::RGBA::blue().toVec())); 731 732 const PipelineCreateInfo::DepthStencilState::StencilOpState frontState_1 = 733 PipelineCreateInfo::DepthStencilState::StencilOpState( 734 vk::VK_STENCIL_OP_REPLACE, 735 vk::VK_STENCIL_OP_REPLACE, 736 vk::VK_STENCIL_OP_REPLACE, 737 vk::VK_COMPARE_OP_ALWAYS); 738 739 const PipelineCreateInfo::DepthStencilState::StencilOpState backState_1 = 740 PipelineCreateInfo::DepthStencilState::StencilOpState( 741 vk::VK_STENCIL_OP_REPLACE, 742 vk::VK_STENCIL_OP_REPLACE, 743 vk::VK_STENCIL_OP_REPLACE, 744 vk::VK_COMPARE_OP_ALWAYS); 745 746 const PipelineCreateInfo::DepthStencilState::StencilOpState frontState_2 = 747 PipelineCreateInfo::DepthStencilState::StencilOpState( 748 vk::VK_STENCIL_OP_REPLACE, 749 vk::VK_STENCIL_OP_REPLACE, 750 vk::VK_STENCIL_OP_REPLACE, 751 vk::VK_COMPARE_OP_NOT_EQUAL); 752 753 const PipelineCreateInfo::DepthStencilState::StencilOpState backState_2 = 754 PipelineCreateInfo::DepthStencilState::StencilOpState( 755 vk::VK_STENCIL_OP_REPLACE, 756 vk::VK_STENCIL_OP_REPLACE, 757 vk::VK_STENCIL_OP_REPLACE, 758 vk::VK_COMPARE_OP_NOT_EQUAL); 759 760 // enable stencil test 761 m_depthStencilState_1 = PipelineCreateInfo::DepthStencilState( 762 VK_FALSE, VK_FALSE, vk::VK_COMPARE_OP_NEVER, VK_FALSE, VK_TRUE, frontState_1, backState_1); 763 764 m_depthStencilState_2 = PipelineCreateInfo::DepthStencilState( 765 VK_FALSE, VK_FALSE, vk::VK_COMPARE_OP_NEVER, VK_FALSE, VK_TRUE, frontState_2, backState_2); 766 767 DepthStencilBaseCase::initialize(); 768 } 769 770 virtual tcu::TestStatus iterate (void) 771 { 772 tcu::TestLog &log = m_context.getTestContext().getLog(); 773 const vk::VkQueue queue = m_context.getUniversalQueue(); 774 775 beginRenderPass(); 776 777 // set states here 778 setDynamicViewportState(WIDTH, HEIGHT); 779 setDynamicRasterizationState(); 780 setDynamicBlendState(); 781 782 const vk::VkDeviceSize vertexBufferOffset = 0; 783 const vk::VkBuffer vertexBuffer = m_vertexBuffer->object(); 784 m_vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &vertexBuffer, &vertexBufferOffset); 785 786 m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline_1); 787 setDynamicDepthStencilState(-1.0f, 1.0f, 0xFF, 0x0E, 0x0F, 0xFF, 0x0E, 0x0F); 788 m_vk.cmdDraw(*m_cmdBuffer, 4, 1, 0, 0); 789 790 m_vk.cmdBindPipeline(*m_cmdBuffer, vk::VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipeline_2); 791 setDynamicDepthStencilState(-1.0f, 1.0f, 0xFF, 0xFF, 0x0E, 0xFF, 0xFF, 0x0E); 792 m_vk.cmdDraw(*m_cmdBuffer, 4, 1, 4, 0); 793 794 m_vk.cmdEndRenderPass(*m_cmdBuffer); 795 m_vk.endCommandBuffer(*m_cmdBuffer); 796 797 vk::VkSubmitInfo submitInfo = 798 { 799 vk::VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType; 800 DE_NULL, // const void* pNext; 801 0, // deUint32 waitSemaphoreCount; 802 DE_NULL, // const VkSemaphore* pWaitSemaphores; 803 (const vk::VkPipelineStageFlags*)DE_NULL, 804 1, // deUint32 commandBufferCount; 805 &m_cmdBuffer.get(), // const VkCommandBuffer* pCommandBuffers; 806 0, // deUint32 signalSemaphoreCount; 807 DE_NULL // const VkSemaphore* pSignalSemaphores; 808 }; 809 m_vk.queueSubmit(queue, 1, &submitInfo, DE_NULL); 810 811 // validation 812 { 813 VK_CHECK(m_vk.queueWaitIdle(queue)); 814 815 tcu::Texture2D referenceFrame(vk::mapVkFormat(m_colorAttachmentFormat), (int)(0.5 + WIDTH), (int)(0.5 + HEIGHT)); 816 referenceFrame.allocLevel(0); 817 818 const deInt32 frameWidth = referenceFrame.getWidth(); 819 const deInt32 frameHeight = referenceFrame.getHeight(); 820 821 for (int y = 0; y < frameHeight; y++) 822 { 823 const float yCoord = (float)(y / (0.5*frameHeight)) - 1.0f; 824 825 for (int x = 0; x < frameWidth; x++) 826 { 827 const float xCoord = (float)(x / (0.5*frameWidth)) - 1.0f; 828 829 if (xCoord >= -0.5f && xCoord <= 0.5f && yCoord >= -0.5f && yCoord <= 0.5f) 830 referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), x, y); 831 else 832 referenceFrame.getLevel(0).setPixel(tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), x, y); 833 } 834 } 835 836 const vk::VkOffset3D zeroOffset = { 0, 0, 0 }; 837 const tcu::ConstPixelBufferAccess renderedFrame = m_colorTargetImage->readSurface(queue, m_context.getDefaultAllocator(), 838 vk::VK_IMAGE_LAYOUT_GENERAL, zeroOffset, WIDTH, HEIGHT, vk::VK_IMAGE_ASPECT_COLOR_BIT); 839 840 if (!tcu::fuzzyCompare(log, "Result", "Image comparison result", 841 referenceFrame.getLevel(0), renderedFrame, 0.05f, 842 tcu::COMPARE_LOG_RESULT)) 843 { 844 return tcu::TestStatus(QP_TEST_RESULT_FAIL, "Image verification failed"); 845 } 846 847 return tcu::TestStatus(QP_TEST_RESULT_PASS, "Image verification passed"); 848 } 849 } 850}; 851 852} //anonymous 853 854DynamicStateDSTests::DynamicStateDSTests (tcu::TestContext& testCtx) 855 : TestCaseGroup (testCtx, "ds_state", "Tests for depth stencil state") 856{ 857 /* Left blank on purpose */ 858} 859 860DynamicStateDSTests::~DynamicStateDSTests () 861{ 862} 863 864void DynamicStateDSTests::init (void) 865{ 866 ShaderMap shaderPaths; 867 shaderPaths[glu::SHADERTYPE_VERTEX] = "vulkan/dynamic_state/VertexFetch.vert"; 868 shaderPaths[glu::SHADERTYPE_FRAGMENT] = "vulkan/dynamic_state/VertexFetch.frag"; 869 870 addChild(new InstanceFactory<DepthBoundsParamTestInstance>(m_testCtx, "depth_bounds", "Perform depth bounds test", shaderPaths)); 871 addChild(new StencilParamsBasicTestCase(m_testCtx, "stencil_params_basic_1", "Perform basic stencil test 1", 0x0D, 0x06, 0x05, tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f))); 872 addChild(new StencilParamsBasicTestCase(m_testCtx, "stencil_params_basic_2", "Perform basic stencil test 2", 0x06, 0x02, 0x05, tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f))); 873 addChild(new InstanceFactory<StencilParamsAdvancedTestInstance>(m_testCtx, "stencil_params_advanced", "Perform advanced stencil test", shaderPaths)); 874} 875 876} // DynamicState 877} // vkt 878