From 1462b52d6aca8ac3c7e2c90dd4bb70cb0dec8d3d Mon Sep 17 00:00:00 2001 From: Charlie Turner Date: Mon, 23 Jan 2023 22:30:54 +0000 Subject: [PATCH] Resolves invalid memory writes in primitives generated tests There were also a lot of claimed memory leaks by Valgrind, due to the use of naked new's in testGenerator. Those have been moved to the smart pointer classes that NULL the allocations after releasing. dEQP-VK.transform_feedback.primitives_generated* is Valgrind clean after this patch. Components: Vulkan Affects: dEQP-VK.transform_feedback.primitives_generated* VK-GL-CTS issue: 4247 Change-Id: Ie8383525e22da95ab65040c9671ce0adaba67ed5 --- .../vktPrimitivesGeneratedQueryTests.cpp | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/external/vulkancts/modules/vulkan/transform_feedback/vktPrimitivesGeneratedQueryTests.cpp b/external/vulkancts/modules/vulkan/transform_feedback/vktPrimitivesGeneratedQueryTests.cpp index fb3b07a..7ec792c 100644 --- a/external/vulkancts/modules/vulkan/transform_feedback/vktPrimitivesGeneratedQueryTests.cpp +++ b/external/vulkancts/modules/vulkan/transform_feedback/vktPrimitivesGeneratedQueryTests.cpp @@ -833,11 +833,11 @@ void PrimitivesGeneratedQueryTestInstance::fillVertexBuffer(tcu::Vec2* vertices, { if (prim % 2 == 0) { - vertices[3 + prim] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, 1.0f); + vertices[2 + prim] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, 1.0f); } else { - vertices[3 + prim] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, -1.0f); + vertices[2 + prim] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, -1.0f); } } break; @@ -943,13 +943,13 @@ void PrimitivesGeneratedQueryTestInstance::fillVertexBuffer(tcu::Vec2* vertices, { if (prim % 2 == 0) { - vertices[6 + prim + 0] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, 1.0f); - vertices[6 + prim + 1] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, 1.0f); + vertices[5 + prim + 0] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, 1.0f); + vertices[5 + prim + 1] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, 1.0f); } else { - vertices[6 + prim + 0] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, -1.0f); - vertices[6 + prim + 1] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, -1.0f); + vertices[5 + prim + 0] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, -1.0f); + vertices[5 + prim + 1] = tcu::Vec2(-1.0f + 2.0f * (float)prim * step, -1.0f); } } break; @@ -1302,23 +1302,23 @@ void testGenerator (tcu::TestCaseGroup* pgqGroup) for (const ReadType& read : readTypes) { - tcu::TestCaseGroup* const readGroup = new tcu::TestCaseGroup(testCtx, read.name, read.desc); + de::MovePtr readGroup(new tcu::TestCaseGroup(testCtx, read.name, read.desc)); for (const ResetType& reset : resetTypes) { - tcu::TestCaseGroup* const resetGroup = new tcu::TestCaseGroup(testCtx, reset.name, reset.desc); + de::MovePtr resetGroup(new tcu::TestCaseGroup(testCtx, reset.name, reset.desc)); for (const ResultTypes& result : resultTypes) { - tcu::TestCaseGroup* const resultGroup = new tcu::TestCaseGroup(testCtx, result.name, result.desc); + de::MovePtr resultGroup(new tcu::TestCaseGroup(testCtx, result.name, result.desc)); for (const Shader& shader : shaderStages) { - tcu::TestCaseGroup* const shaderGroup = new tcu::TestCaseGroup(testCtx, shader.name, shader.desc); + de::MovePtr shaderGroup(new tcu::TestCaseGroup(testCtx, shader.name, shader.desc)); for (const TransformFeedbackState& xfbState : transformFeedbackStates) { - tcu::TestCaseGroup* const xfbGroup = new tcu::TestCaseGroup(testCtx, xfbState.name, xfbState.desc); + de::MovePtr xfbGroup(new tcu::TestCaseGroup(testCtx, xfbState.name, xfbState.desc)); // Only test multiple result types with XFB enabled. if ((result.type == QUERY_RESULT_TYPE_PGQ_32_XFB_64 || result.type == QUERY_RESULT_TYPE_PGQ_64_XFB_32) && !xfbState.enable) @@ -1326,7 +1326,7 @@ void testGenerator (tcu::TestCaseGroup* pgqGroup) for (const RastCase& rastCase : rastCases) { - tcu::TestCaseGroup* const rastGroup = new tcu::TestCaseGroup(testCtx, rastCase.name, rastCase.desc); + de::MovePtr rastGroup(new tcu::TestCaseGroup(testCtx, rastCase.name, rastCase.desc)); // Skip uninteresting cases if ((rastCase.type > RAST_CASE_DISCARD) @@ -1339,7 +1339,7 @@ void testGenerator (tcu::TestCaseGroup* pgqGroup) for (const Topology& topology : topologies) { - tcu::TestCaseGroup* const topologyGroup = new tcu::TestCaseGroup(testCtx, topology.name, topology.desc); + de::MovePtr topologyGroup(new tcu::TestCaseGroup(testCtx, topology.name, topology.desc)); // Only test patch lists with tessellation shaders. if ((topology.type == VK_PRIMITIVE_TOPOLOGY_PATCH_LIST && shader.stage != SHADER_STAGE_TESSELLATION_EVALUATION) || @@ -1362,7 +1362,7 @@ void testGenerator (tcu::TestCaseGroup* pgqGroup) const std::string pgqDescStr = std::string("PGQ on ") + (pgqDefault ? "default " : "") + std::string("vertex stream ") + (pgqDefault ? "" : pgqStream.name); const std::string xfbDescStr = std::string("XFB on ") + (xfbDefault ? "default " : "") + std::string("vertex stream ") + (xfbDefault ? "" : xfbStream.name); const std::string streamGroupDesc = std::string("Tests for ") + pgqDescStr + (xfbState.enable ? (std::string(" and ") + xfbDescStr) : ""); - tcu::TestCaseGroup* const streamGroup = new tcu::TestCaseGroup(testCtx, streamGroupName.c_str(), streamGroupDesc.c_str()); + de::MovePtr streamGroup(new tcu::TestCaseGroup(testCtx, streamGroupName.c_str(), streamGroupDesc.c_str())); // Only test nondefault vertex streams with geometry shaders. if ((pgqStream.index != VERTEX_STREAM_DEFAULT || xfbStream.index != VERTEX_STREAM_DEFAULT) && shader.stage != SHADER_STAGE_GEOMETRY) @@ -1392,29 +1392,29 @@ void testGenerator (tcu::TestCaseGroup* pgqGroup) streamGroup->addChild(new PrimitivesGeneratedQueryTestCase(testCtx, cmdBufCase.name, cmdBufCase.desc, parameters)); } - topologyGroup->addChild(streamGroup); + topologyGroup->addChild(streamGroup.release()); } } - rastGroup->addChild(topologyGroup); + rastGroup->addChild(topologyGroup.release()); } - xfbGroup->addChild(rastGroup); + xfbGroup->addChild(rastGroup.release()); } - shaderGroup->addChild(xfbGroup); + shaderGroup->addChild(xfbGroup.release()); } - resultGroup->addChild(shaderGroup); + resultGroup->addChild(shaderGroup.release()); } - resetGroup->addChild(resultGroup); + resetGroup->addChild(resultGroup.release()); } - readGroup->addChild(resetGroup); + readGroup->addChild(resetGroup.release()); } - pgqGroup->addChild(readGroup); + pgqGroup->addChild(readGroup.release()); } } -- 2.7.4