From 1382a58780e515d2e6379dfd9dbd6fb835982800 Mon Sep 17 00:00:00 2001 From: Juha Heiskanen Date: Tue, 29 Mar 2022 12:02:53 +0300 Subject: [PATCH] Fix dEQP-VK.image.sample_texture.* tests write out-of-bounds bug Compute shader writing to the view is now made by using block size instead of pixel count. Components: Vulkan VK-GL-CTS Issue: 3442 Affects: dEQP-VK.image.sample_texture.* Change-Id: Ie351fb1d2730c5377c8110453bc34629c20b5d82 --- .../image/vktImageSampleCompressedTextureTests.cpp | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/external/vulkancts/modules/vulkan/image/vktImageSampleCompressedTextureTests.cpp b/external/vulkancts/modules/vulkan/image/vktImageSampleCompressedTextureTests.cpp index a43b9d7..d5a7dea 100644 --- a/external/vulkancts/modules/vulkan/image/vktImageSampleCompressedTextureTests.cpp +++ b/external/vulkancts/modules/vulkan/image/vktImageSampleCompressedTextureTests.cpp @@ -2,7 +2,7 @@ * Vulkan Conformance Tests * ------------------------ * - * Copyright (c) 2021 Google LLC. + * Copyright (c) 2021-2022 Google LLC. * * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,6 +32,7 @@ #include "deUniquePtr.hpp" #include "deStringUtil.hpp" +#include "tcuCompressedTexture.hpp" #include "tcuVectorType.hpp" #include "tcuTextureUtil.hpp" #include "tcuImageCompare.hpp" @@ -700,15 +701,20 @@ void SampleDrawnTextureTest::checkSupport(Context& context) const void SampleDrawnTextureTest::initPrograms (SourceCollections& programCollection) const { // Pure red, green, and blue compressed with the BC1 and BC3 algorithms. - std::string bc1_red = "uvec4(4160813056u, 0u, 4160813056u, 0u);\n"; - std::string bc1_blue = "uvec4(2031647, 0u, 2031647, 0u);\n"; - std::string bc3_red = "uvec4(4294967295u, 4294967295u, 4160813056u, 0u);\n"; - std::string bc3_blue = "uvec4(4294967295u, 4294967295u, 2031647, 0u);\n"; + std::string bc1_red = "uvec4(4160813056u, 0u, 4160813056u, 0u);\n"; + std::string bc1_blue = "uvec4(2031647, 0u, 2031647, 0u);\n"; + std::string bc3_red = "uvec4(4294967295u, 4294967295u, 4160813056u, 0u);\n"; + std::string bc3_blue = "uvec4(4294967295u, 4294967295u, 2031647, 0u);\n"; - std::string red = (m_imageFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK) ? bc1_red : bc3_red; - std::string blue = (m_imageFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK) ? bc1_blue : bc3_blue; + std::string red = (m_imageFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK) ? bc1_red : bc3_red; + std::string blue = (m_imageFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK) ? bc1_blue : bc3_blue; - std::ostringstream computeSrc; + tcu::CompressedTexFormat compressedFormat (mapVkCompressedFormat(m_imageFormat)); + IVec3 blockSize = tcu::getBlockPixelSize(compressedFormat); + + DE_ASSERT(blockSize.z() == 1); + + std::ostringstream computeSrc; // Generate the compute shader. computeSrc << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"; @@ -735,13 +741,13 @@ void SampleDrawnTextureTest::initPrograms (SourceCollections& programCollection) } computeSrc - << " for (int x = 0; x < " << WIDTH << "; x++)\n" - << " for (int y = 0; y < " << HEIGHT << "; y++)\n" + << " for (int x = 0; x < " << WIDTH / blockSize.x() << "; x++)\n" + << " for (int y = 0; y < " << HEIGHT / blockSize.y() << "; y++)\n" << " imageStore(img, ivec2(x, y), color);\n" << "}\n"; // Generate the vertex shader. - std::ostringstream vertexSrc; + std::ostringstream vertexSrc; vertexSrc << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n" << "layout(location = 0) in highp vec4 a_position;\n" @@ -753,7 +759,7 @@ void SampleDrawnTextureTest::initPrograms (SourceCollections& programCollection) << "}\n"; // Generate the fragment shader. - std::ostringstream fragmentSrc; + std::ostringstream fragmentSrc; fragmentSrc << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n" << "layout(location = 0) out vec4 outColor;\n" -- 2.7.4