From 2144b4467573ebe95ff07af75ded35a7157c410a Mon Sep 17 00:00:00 2001 From: Ari Suonpaa Date: Tue, 23 Apr 2019 14:57:47 +0300 Subject: [PATCH] Make random number usage platform independent Generating multiple random numbers in argument list can happen in different order depending on implementation. This change makes these happen in the same order with all implementations. Affects: dEQP-VK.api.granularity.* dEQP-VK.draw.basic_draw.* dEQP-VK.protected_memory.* dEQP-VK.glsl.builtin.function.common.* dEQP-VK.glsl.builtin.function.pack_unpack.* dEQP-VK.glsl.texture_gather.* dEQP-VK.spirv_assembly.* dEQP-GLES3*.functional.shaders.builtin_functions.common.* Components: Vulkan, OpenGL, Framework (cherry picked from commit 0106f01209fe7abb7f4daf029318a1de17844c48) VK-GL-CTS issue: 1591 Change-Id: Iaaff9625fd331ed7184efd50b89fc835c701ac6f --- external/vulkancts/framework/vulkan/vkTypeUtil.hpp | 5 +++ .../modules/vulkan/api/vktApiGranularityTests.cpp | 27 ++++++++++---- .../modules/vulkan/draw/vktBasicDrawTests.cpp | 26 +++++++++----- .../vktProtectedMemAttachmentClearTests.cpp | 18 +++++----- .../vktProtectedMemAttachmentLoadTests.cpp | 18 +++++----- .../vktProtectedMemBlitImageTests.cpp | 18 +++++----- .../vktProtectedMemClearColorImageTests.cpp | 18 +++++----- .../vktProtectedMemCopyBufferToImageTests.cpp | 13 ++++--- .../vktProtectedMemCopyImageTests.cpp | 18 +++++----- .../vktProtectedMemCopyImageToBufferTests.cpp | 18 +++++----- .../vktProtectedMemFillUpdateCopyBufferTests.cpp | 38 +++++++++++--------- .../vktProtectedMemStorageBufferTests.cpp | 3 +- .../vktShaderCommonFunctionTests.cpp | 18 ++-------- .../vktShaderPackingFunctionTests.cpp | 41 +++++----------------- .../vktShaderRenderTextureGatherTests.cpp | 5 ++- .../vktSpvAsmGraphicsShaderTestUtil.hpp | 4 --- .../spirv_assembly/vktSpvAsmImageSamplerTests.cpp | 7 ++-- .../spirv_assembly/vktSpvAsmIndexingTests.cpp | 5 +-- .../spirv_assembly/vktSpvAsmInstructionTests.cpp | 5 +-- .../vktSpvAsmUboMatrixPaddingTests.cpp | 5 +-- .../vktSpvAsmVariablePointersTests.cpp | 2 +- framework/common/tcuVectorUtil.hpp | 27 ++++++++++++++ framework/delibs/decpp/deRandom.hpp | 5 +++ .../functional/es3fShaderCommonFunctionTests.cpp | 19 ++-------- .../functional/es31fShaderCommonFunctionTests.cpp | 19 ++-------- 25 files changed, 189 insertions(+), 193 deletions(-) diff --git a/external/vulkancts/framework/vulkan/vkTypeUtil.hpp b/external/vulkancts/framework/vulkan/vkTypeUtil.hpp index a3ccad4..b3ae6c0 100644 --- a/external/vulkancts/framework/vulkan/vkTypeUtil.hpp +++ b/external/vulkancts/framework/vulkan/vkTypeUtil.hpp @@ -41,6 +41,11 @@ inline VkClearValue makeClearValueColorF32 (float r, float g, float b, float a) return v; } +inline VkClearValue makeClearValueColorVec4 (tcu::Vec4 vec) +{ + return makeClearValueColorF32(vec.x(), vec.y(), vec.z(), vec.w()); +} + inline VkClearValue makeClearValueColorU32 (deUint32 r, deUint32 g, deUint32 b, deUint32 a) { VkClearValue v; diff --git a/external/vulkancts/modules/vulkan/api/vktApiGranularityTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiGranularityTests.cpp index 8d3ea4d..33f298c 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiGranularityTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiGranularityTests.cpp @@ -463,30 +463,43 @@ tcu::TestCaseGroup* createGranularityQueryTests (tcu::TestContext& testCtx) { std::vector attachments; - attachments.push_back(AttachmentInfo(format, rnd.getInt(1, maxDimension), rnd.getInt(1, maxDimension), 1)); + const int i0 = rnd.getInt(1, maxDimension); + const int i1 = rnd.getInt(1, maxDimension); + attachments.push_back(AttachmentInfo(format, i0, i1, 1)); single->addChild(new GranularityCase(testCtx, name.c_str(), description, attachments)); } { std::vector attachments; - deUint32 iterations = rnd.getInt(minIteration, maxIteration); + const deUint32 iterations = rnd.getInt(minIteration, maxIteration); + const int i0 = rnd.getInt(1, maxDimension); + const int i1 = rnd.getInt(1, maxDimension); for (deUint32 idx = 0; idx < iterations; ++idx) - attachments.push_back(AttachmentInfo(VkFormat(formatIdx), rnd.getInt(1, maxDimension), rnd.getInt(1, maxDimension), 1)); + attachments.push_back(AttachmentInfo(VkFormat(formatIdx), i0, i1, 1)); multi->addChild(new GranularityCase(testCtx, name.c_str(), description, attachments)); } { std::vector attachments; - deUint32 iterations = rnd.getInt(minIteration, maxIteration); - attachments.push_back(AttachmentInfo(VkFormat(formatIdx), rnd.getInt(1, maxDimension), rnd.getInt(1, maxDimension), 1)); + const deUint32 iterations = rnd.getInt(minIteration, maxIteration); + const int i0 = rnd.getInt(1, maxDimension); + const int i1 = rnd.getInt(1, maxDimension); + attachments.push_back(AttachmentInfo(VkFormat(formatIdx), i0, i1, 1)); for (deUint32 idx = 0; idx < iterations; ++idx) - attachments.push_back(AttachmentInfo(mandatoryFormats[rnd.getInt(0, DE_LENGTH_OF_ARRAY(mandatoryFormats) - 1)], rnd.getInt(1, maxDimension), rnd.getInt(1, maxDimension), 1)); + { + const int i2 = rnd.getInt(0, DE_LENGTH_OF_ARRAY(mandatoryFormats) - 1); + const int i3 = rnd.getInt(1, maxDimension); + const int i4 = rnd.getInt(1, maxDimension); + attachments.push_back(AttachmentInfo(mandatoryFormats[i2], i3, i4, 1)); + } random->addChild(new GranularityCase(testCtx, name.c_str(), description, attachments)); } { std::vector attachments; - attachments.push_back(AttachmentInfo(format, rnd.getInt(1, maxDimension), rnd.getInt(1, maxDimension), 1)); + const int i0 = rnd.getInt(1, maxDimension); + const int i1 = rnd.getInt(1, maxDimension); + attachments.push_back(AttachmentInfo(format, i0, i1, 1)); inRenderPass->addChild(new GranularityCase(testCtx, name.c_str(), description, attachments, true)); } } diff --git a/external/vulkancts/modules/vulkan/draw/vktBasicDrawTests.cpp b/external/vulkancts/modules/vulkan/draw/vktBasicDrawTests.cpp index 8cc14ba..fc2de92 100644 --- a/external/vulkancts/modules/vulkan/draw/vktBasicDrawTests.cpp +++ b/external/vulkancts/modules/vulkan/draw/vktBasicDrawTests.cpp @@ -38,6 +38,7 @@ #include "tcuRGBA.hpp" #include "tcuTextureUtil.hpp" #include "tcuImageCompare.hpp" +#include "tcuVectorUtil.hpp" #include "rrRenderer.hpp" @@ -631,9 +632,12 @@ void DrawTestInstance::generateDrawData (void) // Fill only the used indexes for (deUint32 vertexIdx = m_data.params.firstVertex; vertexIdx < vectorSize; ++vertexIdx) { + const float f0 = rnd.getFloat(-1.0f, 1.0f); + const float f1 = rnd.getFloat(-1.0f, 1.0f); + m_data.vertices[vertexIdx] = PositionColorVertex( - tcu::Vec4(rnd.getFloat(-1.0, 1.0), rnd.getFloat(-1.0, 1.0), 1.0, 1.0), // Coord - tcu::Vec4(rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0))); // Color + tcu::Vec4(f0, f1, 1.0f, 1.0f), // Coord + tcu::randomVec4(rnd)); // Color } } @@ -712,10 +716,12 @@ void DrawTestInstance::generateDrawData (void) std::vector::iterator vertexIt = m_data.vertices.begin() + m_data.params.vertexOffset + *indexIt; tcu::VecAccess positionAccess = vertexIt->position.xyzw(); - positionAccess = tcu::Vec4(rnd.getFloat(-1.0, 1.0), rnd.getFloat(-1.0, 1.0), 1.0, 1.0); + const float f0 = rnd.getFloat(-1.0f, 1.0f); + const float f1 = rnd.getFloat(-1.0f, 1.0f); + positionAccess = tcu::Vec4(f0, f1, 1.0f, 1.0f); tcu::VecAccess colorAccess = vertexIt->color.xyzw(); - colorAccess = tcu::Vec4(rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0)); + colorAccess = tcu::randomVec4(rnd); } } @@ -825,10 +831,12 @@ void DrawTestInstance::generateDrawData (void) std::vector::iterator vertexIt = vertexStart + idx; tcu::VecAccess positionAccess = vertexIt->position.xyzw(); - positionAccess = tcu::Vec4(rnd.getFloat(-1.0, 1.0), rnd.getFloat(-1.0, 1.0), 1.0, 1.0); + const float f0 = rnd.getFloat(-1.0f, 1.0f); + const float f1 = rnd.getFloat(-1.0f, 1.0f); + positionAccess = tcu::Vec4(f0, f1, 1.0f, 1.0f); tcu::VecAccess colorAccess = vertexIt->color.xyzw(); - colorAccess = tcu::Vec4(rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0)); + colorAccess = tcu::randomVec4(rnd); } } } @@ -976,10 +984,12 @@ void DrawTestInstance::generateDrawData (void) std::vector::iterator vertexIt = m_data.vertices.begin() + cmdIt->vertexOffset + m_data.indexes[idx]; tcu::VecAccess positionAccess = vertexIt->position.xyzw(); - positionAccess = tcu::Vec4(rnd.getFloat(-1.0, 1.0), rnd.getFloat(-1.0, 1.0), 1.0, 1.0); + const float f0 = rnd.getFloat(-1.0f, 1.0f); + const float f1 = rnd.getFloat(-1.0f, 1.0f); + positionAccess = tcu::Vec4(f0, f1, 1.0f, 1.0f); tcu::VecAccess colorAccess = vertexIt->color.xyzw(); - colorAccess = tcu::Vec4(rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0), rnd.getFloat(0.0, 1.0)); + colorAccess = tcu::randomVec4(rnd); } } } diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentClearTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentClearTests.cpp index fd0a0be..cb6eb6c 100644 --- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentClearTests.cpp +++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentClearTests.cpp @@ -27,6 +27,7 @@ #include "deRandom.hpp" #include "tcuTestLog.hpp" #include "tcuVector.hpp" +#include "tcuVectorUtil.hpp" #include "vkPrograms.hpp" #include "vktTestCase.hpp" @@ -356,19 +357,16 @@ tcu::TestCaseGroup* createAttachmentClearTests (tcu::TestContext& testCtx, CmdBu for (int ndx = 0; ndx < testCount; ++ndx) { const std::string name = "clear_" + de::toString(ndx + 1); - vk::VkClearValue clearValue = vk::makeClearValueColorF32( - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f)); + vk::VkClearValue clearValue = vk::makeClearValueColorVec4(tcu::randomVec4(rnd)); + const tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); + const tcu::Vec4 vec0 = tcu::randomVec4(rnd); + const tcu::Vec4 vec1 = tcu::randomVec4(rnd); + const tcu::Vec4 vec2 = tcu::randomVec4(rnd); + const tcu::Vec4 vec3 = tcu::randomVec4(rnd); - tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); ValidationData data = { - { tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)) }, + { vec0, vec1, vec2, vec3 }, { refValue, refValue, refValue, refValue } }; diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.cpp index 66ae052..cf3a45f 100644 --- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.cpp +++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.cpp @@ -27,6 +27,7 @@ #include "deRandom.hpp" #include "tcuTestLog.hpp" #include "tcuVector.hpp" +#include "tcuVectorUtil.hpp" #include "vkPrograms.hpp" #include "vktTestCase.hpp" @@ -300,18 +301,15 @@ tcu::TestCaseGroup* createAttachmentLoadTests (tcu::TestContext& testCtx) for (int ndx = 0; ndx < testCount; ++ndx) { const std::string name = "clear_" + de::toString(ndx + 1); - vk::VkClearValue clearValue = vk::makeClearValueColorF32( - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f)); + vk::VkClearValue clearValue = vk::makeClearValueColorVec4(tcu::randomVec4(rnd)); + const tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); + const tcu::Vec4 vec0 = tcu::randomVec4(rnd); + const tcu::Vec4 vec1 = tcu::randomVec4(rnd); + const tcu::Vec4 vec2 = tcu::randomVec4(rnd); + const tcu::Vec4 vec3 = tcu::randomVec4(rnd); - tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); ValidationData data = { - { tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)) }, + { vec0, vec1, vec2, vec3 }, { refValue, refValue, refValue, refValue } }; diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemBlitImageTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemBlitImageTests.cpp index b3091f8..1568031 100644 --- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemBlitImageTests.cpp +++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemBlitImageTests.cpp @@ -27,6 +27,7 @@ #include "deRandom.hpp" #include "tcuTestLog.hpp" #include "tcuVector.hpp" +#include "tcuVectorUtil.hpp" #include "vkPrograms.hpp" #include "vktTestCase.hpp" @@ -425,19 +426,16 @@ tcu::TestCaseGroup* createBlitImageTests (tcu::TestContext& testCtx, CmdBufferTy for (int ndx = 0; ndx < testCount; ++ndx) { const std::string name = "blit_" + de::toString(ndx + 1); - vk::VkClearValue clearValue = vk::makeClearValueColorF32( - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f)); + vk::VkClearValue clearValue = vk::makeClearValueColorVec4(tcu::randomVec4(rnd)); + const tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); + const tcu::Vec4 vec0 = tcu::randomVec4(rnd); + const tcu::Vec4 vec1 = tcu::randomVec4(rnd); + const tcu::Vec4 vec2 = tcu::randomVec4(rnd); + const tcu::Vec4 vec3 = tcu::randomVec4(rnd); - tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); ValidationData data = { - { tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)) }, + { vec0, vec1, vec2, vec3 }, { refValue, refValue, refValue, refValue } }; blitRandomTests->addChild(new BlitImageTestCase(testCtx, name.c_str(), clearValue.color, data, cmdBufferType)); diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemClearColorImageTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemClearColorImageTests.cpp index 86b8ba0..823a7b7 100644 --- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemClearColorImageTests.cpp +++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemClearColorImageTests.cpp @@ -27,6 +27,7 @@ #include "deRandom.hpp" #include "tcuTestLog.hpp" #include "tcuVector.hpp" +#include "tcuVectorUtil.hpp" #include "vkPrograms.hpp" #include "vktTestCase.hpp" @@ -318,19 +319,16 @@ tcu::TestCaseGroup* createClearColorImageTests (tcu::TestContext& testCtx, CmdBu for (int ndx = 0; ndx < testCount; ++ndx) { const std::string name = "clear_" + de::toString(ndx + 1); - vk::VkClearValue clearValue = vk::makeClearValueColorF32( - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f)); + vk::VkClearValue clearValue = vk::makeClearValueColorVec4(tcu::randomVec4(rnd)); + const tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); + const tcu::Vec4 vec0 = tcu::randomVec4(rnd); + const tcu::Vec4 vec1 = tcu::randomVec4(rnd); + const tcu::Vec4 vec2 = tcu::randomVec4(rnd); + const tcu::Vec4 vec3 = tcu::randomVec4(rnd); - tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); ValidationData data = { - { tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)) }, + { vec0, vec1, vec2, vec3 }, { refValue, refValue, refValue, refValue } }; clearRandomTests->addChild(new ClearColorImageTestCase(testCtx, name.c_str(), clearValue.color, data, cmdBufferType)); diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyBufferToImageTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyBufferToImageTests.cpp index 3c56960..c93db6d 100644 --- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyBufferToImageTests.cpp +++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyBufferToImageTests.cpp @@ -27,6 +27,7 @@ #include "deRandom.hpp" #include "tcuTestLog.hpp" #include "tcuVector.hpp" +#include "tcuVectorUtil.hpp" #include "vkPrograms.hpp" #include "vktTestCase.hpp" @@ -386,13 +387,15 @@ tcu::TestCaseGroup* createCopyBufferToImageTests (tcu::TestContext& testCtx, Cmd deUint32 uint; } fillValue = { rnd.getFloat(0.0, 1.0f) }; - tcu::Vec4 refValue (fillValue.flt); + const tcu::Vec4 refValue (fillValue.flt); + const tcu::Vec4 vec0 = tcu::randomVec4(rnd); + const tcu::Vec4 vec1 = tcu::randomVec4(rnd); + const tcu::Vec4 vec2 = tcu::randomVec4(rnd); + const tcu::Vec4 vec3 = tcu::randomVec4(rnd); + ValidationData data = { - { tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)) }, + { vec0, vec1, vec2, vec3 }, { refValue, refValue, refValue, refValue } }; copyRandomTests->addChild(new CopyBufferToImageTestCase(testCtx, name.c_str(), fillValue.uint, data, cmdBufferType)); diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyImageTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyImageTests.cpp index 769897c..85b4635 100644 --- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyImageTests.cpp +++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyImageTests.cpp @@ -27,6 +27,7 @@ #include "deRandom.hpp" #include "tcuTestLog.hpp" #include "tcuVector.hpp" +#include "tcuVectorUtil.hpp" #include "vkPrograms.hpp" #include "vktTestCase.hpp" @@ -423,19 +424,16 @@ tcu::TestCaseGroup* createCopyImageTests (tcu::TestContext& testCtx, CmdBufferTy for (int ndx = 0; ndx < testCount; ++ndx) { const std::string name = "copy_" + de::toString(ndx + 1); - vk::VkClearValue clearValue = vk::makeClearValueColorF32( - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f)); + vk::VkClearValue clearValue = vk::makeClearValueColorVec4(tcu::randomVec4(rnd)); + const tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); + const tcu::Vec4 vec0 = tcu::randomVec4(rnd); + const tcu::Vec4 vec1 = tcu::randomVec4(rnd); + const tcu::Vec4 vec2 = tcu::randomVec4(rnd); + const tcu::Vec4 vec3 = tcu::randomVec4(rnd); - tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); ValidationData data = { - { tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)), - tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)) }, + { vec0, vec1, vec2, vec3 }, { refValue, refValue, refValue, refValue } }; copyRandomTests->addChild(new CopyImageTestCase(testCtx, name.c_str(), clearValue.color, data, cmdBufferType)); diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyImageToBufferTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyImageToBufferTests.cpp index 2783273..4afde53 100644 --- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyImageToBufferTests.cpp +++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemCopyImageToBufferTests.cpp @@ -27,6 +27,7 @@ #include "deRandom.hpp" #include "tcuTestLog.hpp" #include "tcuVector.hpp" +#include "tcuVectorUtil.hpp" #include "vkPrograms.hpp" #include "vktTestCase.hpp" @@ -371,19 +372,16 @@ tcu::TestCaseGroup* createCopyImageToFloatBufferTests(tcu::TestContext& testCtx, for (int ndx = 0; ndx < testCount; ++ndx) { const std::string name = "copy_" + de::toString(ndx + 1); - vk::VkClearValue clearValue = vk::makeClearValueColorF32( - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f), - rnd.getFloat(0.0, 1.0f)); + vk::VkClearValue clearValue = vk::makeClearValueColorVec4(tcu::randomVec4(rnd)); + const tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); + const tcu::IVec4 vec0 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 vec1 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 vec2 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 vec3 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); - tcu::Vec4 refValue (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]); ValidationDataVec4 data = { - { tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)) }, + { vec0, vec1, vec2, vec3 }, { refValue, refValue, refValue, refValue } }; diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemFillUpdateCopyBufferTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemFillUpdateCopyBufferTests.cpp index fb8c89d..4616b04 100644 --- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemFillUpdateCopyBufferTests.cpp +++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemFillUpdateCopyBufferTests.cpp @@ -369,13 +369,15 @@ tcu::TestCaseGroup* createFillUpdateCopyBufferFloatTests (tcu::TestContext& test deUint32 uint; } fillValue = { rnd.getFloat(std::numeric_limits::min(), std::numeric_limits::max() - 1) }; - tcu::Vec4 refValue (fillValue.flt); + const tcu::Vec4 refValue (fillValue.flt); + const tcu::IVec4 vec0 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 vec1 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 vec2 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 vec3 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + ValidationDataVec4 data = { - { tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)) }, + { vec0, vec1, vec2, vec3 }, { refValue, refValue, refValue, refValue } }; @@ -478,13 +480,15 @@ tcu::TestCaseGroup* createFillUpdateCopyBufferIntegerTests (tcu::TestContext& te deUint32 uint; } fillValue = { rnd.getInt(std::numeric_limits::min(), std::numeric_limits::max() - 1) }; - tcu::IVec4 refValue (fillValue.integer); + const tcu::IVec4 refValue (fillValue.integer); + const tcu::IVec4 v0 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 v1 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 v2 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 v3 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + ValidationDataIVec4 data = { - { tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)) }, + { v0, v1, v2, v3 }, { refValue, refValue, refValue, refValue } }; @@ -579,14 +583,16 @@ tcu::TestCaseGroup* createFillUpdateCopyBufferUnsignedTests (tcu::TestContext& t for (int ndx = 0; ndx < testCount; ++ndx) { const std::string name = "test_" + de::toString(ndx + 1); - deUint32 fillValue = rnd.getUint32(); - tcu::UVec4 refValue (fillValue); + const deUint32 fillValue = rnd.getUint32(); + const tcu::UVec4 refValue (fillValue); + const tcu::IVec4 v0 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 v1 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 v2 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + const tcu::IVec4 v3 = tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)); + ValidationDataUVec4 data = { - { tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)), - tcu::IVec4(rnd.getInt(0, MAX_POSITION - 1)) }, + { v0, v1, v2, v3 }, { refValue, refValue, refValue, refValue } }; diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemStorageBufferTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemStorageBufferTests.cpp index 43bbdeb..a0b93e0 100644 --- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemStorageBufferTests.cpp +++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemStorageBufferTests.cpp @@ -694,7 +694,8 @@ tcu::TestCaseGroup* createRandomizedBufferTests (tcu::TestContext& testCtx, SSBO testData.resize(testCount); for (size_t ndx = 0; ndx < testCount; ++ndx) - testData[ndx].values = tcu::UVec4(rnd.getUint32(), rnd.getUint32(), rnd.getUint32(), rnd.getUint32()); + for (deUint32 compIdx = 0; compIdx < 4; ++compIdx) + testData[ndx].values[compIdx] = rnd.getUint32(); return createSpecifiedStorageBufferTests(testCtx, "random", testType, shaderType, testData.data(), testData.size()); } diff --git a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderCommonFunctionTests.cpp b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderCommonFunctionTests.cpp index 33a44de..0e72b78 100644 --- a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderCommonFunctionTests.cpp +++ b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderCommonFunctionTests.cpp @@ -31,6 +31,7 @@ #include "tcuFloat.hpp" #include "tcuInterval.hpp" #include "tcuFloatFormat.hpp" +#include "tcuVectorUtil.hpp" #include "deRandom.hpp" #include "deMath.h" #include "deString.h" @@ -74,25 +75,12 @@ private: tcu::Vector* m_array; }; -template T randomScalar (de::Random& rnd, T minValue, T maxValue); -template<> inline float randomScalar (de::Random& rnd, float minValue, float maxValue) { return rnd.getFloat(minValue, maxValue); } -template<> inline deInt32 randomScalar (de::Random& rnd, deInt32 minValue, deInt32 maxValue) { return rnd.getInt(minValue, maxValue); } - -template -inline tcu::Vector randomVector (de::Random& rnd, const tcu::Vector& minValue, const tcu::Vector& maxValue) -{ - tcu::Vector res; - for (int ndx = 0; ndx < Size; ndx++) - res[ndx] = randomScalar(rnd, minValue[ndx], maxValue[ndx]); - return res; -} - template static void fillRandomVectors (de::Random& rnd, const tcu::Vector& minValue, const tcu::Vector& maxValue, void* dst, int numValues, int offset = 0) { VecArrayAccess access(dst); for (int ndx = 0; ndx < numValues; ndx++) - access[offset + ndx] = randomVector(rnd, minValue, maxValue); + access[offset + ndx] = tcu::randomVector(rnd, minValue, maxValue); } template @@ -100,7 +88,7 @@ static void fillRandomScalars (de::Random& rnd, T minValue, T maxValue, void* ds { T* typedPtr = (T*)dst; for (int ndx = 0; ndx < numValues; ndx++) - typedPtr[offset + ndx] = randomScalar(rnd, minValue, maxValue); + typedPtr[offset + ndx] = de::randomScalar(rnd, minValue, maxValue); } inline int numBitsLostInOp (float input, float output) diff --git a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderPackingFunctionTests.cpp b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderPackingFunctionTests.cpp index 469369d..ad40f2e 100644 --- a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderPackingFunctionTests.cpp +++ b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderPackingFunctionTests.cpp @@ -28,6 +28,7 @@ #include "tcuTestLog.hpp" #include "tcuFormatUtil.hpp" #include "tcuFloat.hpp" +#include "tcuVectorUtil.hpp" #include "deRandom.hpp" #include "deMath.h" #include "deString.h" @@ -179,17 +180,13 @@ public: // Random values, mostly in range. for (int ndx = 0; ndx < 15; ndx++) { - const float x = rnd.getFloat()*2.5f - 1.25f; - const float y = rnd.getFloat()*2.5f - 1.25f; - inputs.push_back(tcu::Vec2(x, y)); + inputs.push_back(tcu::randomVector(rnd, tcu::Vec2(-1.25f), tcu::Vec2(1.25f))); } // Large random values. for (int ndx = 0; ndx < 80; ndx++) { - const float x = rnd.getFloat()*1e6f - 0.5e6f; - const float y = rnd.getFloat()*1e6f - 0.5e6f; - inputs.push_back(tcu::Vec2(x, y)); + inputs.push_back(tcu::randomVector(rnd, tcu::Vec2(-0.5e6f), tcu::Vec2(0.5e6f))); } outputs.resize(inputs.size()); @@ -402,17 +399,13 @@ public: // Random values, mostly in range. for (int ndx = 0; ndx < 15; ndx++) { - const float x = rnd.getFloat()*1.25f; - const float y = rnd.getFloat()*1.25f; - inputs.push_back(tcu::Vec2(x, y)); + inputs.push_back(tcu::randomVector(rnd, tcu::Vec2(0.0f), tcu::Vec2(1.25f))); } // Large random values. for (int ndx = 0; ndx < 80; ndx++) { - const float x = rnd.getFloat()*1e6f - 1e5f; - const float y = rnd.getFloat()*1e6f - 1e5f; - inputs.push_back(tcu::Vec2(x, y)); + inputs.push_back(tcu::randomVector(rnd, tcu::Vec2(-1e5f), tcu::Vec2(0.9e6f))); } outputs.resize(inputs.size()); @@ -949,21 +942,13 @@ public: // Random values, mostly in range. for (int ndx = 0; ndx < 15; ndx++) { - const float x = rnd.getFloat()*2.5f - 1.25f; - const float y = rnd.getFloat()*2.5f - 1.25f; - const float z = rnd.getFloat()*2.5f - 1.25f; - const float w = rnd.getFloat()*2.5f - 1.25f; - inputs.push_back(tcu::Vec4(x, y, z, w)); + inputs.push_back(tcu::randomVector(rnd, tcu::Vec4(-1.25f), tcu::Vec4(1.25f))); } // Large random values. for (int ndx = 0; ndx < 80; ndx++) { - const float x = rnd.getFloat()*1e6f - 0.5e6f; - const float y = rnd.getFloat()*1e6f - 0.5e6f; - const float z = rnd.getFloat()*1e6f - 0.5e6f; - const float w = rnd.getFloat()*1e6f - 0.5e6f; - inputs.push_back(tcu::Vec4(x, y, z, w)); + inputs.push_back(tcu::randomVector(rnd, tcu::Vec4(-0.5e6f), tcu::Vec4(0.5e6f))); } outputs.resize(inputs.size()); @@ -1192,21 +1177,13 @@ public: // Random values, mostly in range. for (int ndx = 0; ndx < 15; ndx++) { - const float x = rnd.getFloat()*1.25f - 0.125f; - const float y = rnd.getFloat()*1.25f - 0.125f; - const float z = rnd.getFloat()*1.25f - 0.125f; - const float w = rnd.getFloat()*1.25f - 0.125f; - inputs.push_back(tcu::Vec4(x, y, z, w)); + inputs.push_back(tcu::randomVector(rnd, tcu::Vec4(-0.125f), tcu::Vec4(1.125f))); } // Large random values. for (int ndx = 0; ndx < 80; ndx++) { - const float x = rnd.getFloat()*1e6f - 1e5f; - const float y = rnd.getFloat()*1e6f - 1e5f; - const float z = rnd.getFloat()*1e6f - 1e5f; - const float w = rnd.getFloat()*1e6f - 1e5f; - inputs.push_back(tcu::Vec4(x, y, z, w)); + inputs.push_back(tcu::randomVector(rnd, tcu::Vec4(-1e5f), tcu::Vec4(0.9e6f))); } outputs.resize(inputs.size()); diff --git a/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderTextureGatherTests.cpp b/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderTextureGatherTests.cpp index 7e4bd10..6f5d4d9 100644 --- a/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderTextureGatherTests.cpp +++ b/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderTextureGatherTests.cpp @@ -178,9 +178,8 @@ static void fillWithRandomColorTiles (const PixelBufferAccess& dst, const Vec4& const int yEnd = (row+1)*dst.getHeight()/numRows; const int xBegin = (col+0)*dst.getWidth()/numCols; const int xEnd = (col+1)*dst.getWidth()/numCols; - Vec4 color; - for (int i = 0; i < 4; i++) - color[i] = rnd.getFloat(minVal[i], maxVal[i]); + const Vec4 color = tcu::randomVector(rnd, minVal, maxVal); + tcu::clear(tcu::getSubregion(dst, xBegin, yBegin, slice, xEnd-xBegin, yEnd-yBegin, 1), color); } } diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmGraphicsShaderTestUtil.hpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmGraphicsShaderTestUtil.hpp index 3bf3933..e6d51a3 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmGraphicsShaderTestUtil.hpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmGraphicsShaderTestUtil.hpp @@ -325,10 +325,6 @@ const std::string numberToString (T number) return ss.str(); } -template T randomScalar (de::Random& rnd, T minValue, T maxValue); -template<> inline float randomScalar (de::Random& rnd, float minValue, float maxValue) { return rnd.getFloat(minValue, maxValue); } -template<> inline deInt32 randomScalar (de::Random& rnd, deInt32 minValue, deInt32 maxValue) { return rnd.getInt(minValue, maxValue); } - void getDefaultColors (tcu::RGBA (&colors)[4]); void getHalfColorsFullAlpha (tcu::RGBA (&colors)[4]); diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmImageSamplerTests.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmImageSamplerTests.cpp index c0a0d41..af3abb8 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmImageSamplerTests.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmImageSamplerTests.cpp @@ -28,6 +28,7 @@ #include "vkImageUtil.hpp" #include "tcuTextureUtil.hpp" +#include "tcuVectorUtil.hpp" namespace vkt { @@ -758,7 +759,7 @@ void addComputeImageSamplerTest (tcu::TestCaseGroup* group) inputData.reserve(numDataPoints); for (deUint32 numIdx = 0; numIdx < numDataPoints; ++numIdx) - inputData.push_back(tcu::Vec4(rnd.getFloat(), rnd.getFloat(), rnd.getFloat(), rnd.getFloat())); + inputData.push_back(tcu::randomVec4(rnd)); for (deUint32 opNdx = 0u; opNdx <= READOP_IMAGESAMPLE; opNdx++) { @@ -1050,7 +1051,7 @@ void addGraphicsImageSamplerTest (tcu::TestCaseGroup* group) vector inputData(numDataPoints); for (deUint32 numIdx = 0; numIdx < numDataPoints; ++numIdx) - inputData[numIdx] = tcu::Vec4(rnd.getFloat(), rnd.getFloat(), rnd.getFloat(), rnd.getFloat()); + inputData[numIdx] = tcu::randomVec4(rnd); for (deUint32 opNdx = 0u; opNdx <= READOP_IMAGESAMPLE; opNdx++) { @@ -1196,7 +1197,7 @@ void addGraphicsDepthPropertyTest (tcu::TestCaseGroup* group) inputDataVec4.reserve(numDataPoints); for (deUint32 numIdx = 0; numIdx < numDataPoints; ++numIdx) - inputDataVec4.push_back(Vec4(rnd.getFloat(), rnd.getFloat(), rnd.getFloat(), rnd.getFloat())); + inputDataVec4.push_back(tcu::randomVec4(rnd)); de::MovePtr testGroup (new tcu::TestCaseGroup(testCtx, "depth_property", "")); diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmIndexingTests.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmIndexingTests.cpp index c543d96..17ef9e5 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmIndexingTests.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmIndexingTests.cpp @@ -27,6 +27,7 @@ #include "vktSpvAsmGraphicsShaderTestUtil.hpp" #include "tcuStringTemplate.hpp" +#include "tcuVectorUtil.hpp" namespace vkt { @@ -81,7 +82,7 @@ void addComputeIndexingStructTests (tcu::TestCaseGroup* group) indexSelectorData.reserve(numItems); for (deUint32 numIdx = 0; numIdx < numItems; ++numIdx) - indexSelectorData.push_back(UVec4(rnd.getUint32() % 32, rnd.getUint32() % 32, rnd.getUint32() % 4, rnd.getUint32() % 4)); + indexSelectorData.push_back(tcu::randomVector(rnd, UVec4(0), UVec4(31, 31, 3, 3))); for (int chainOpIdx = 0; chainOpIdx < CHAIN_OP_LAST; ++chainOpIdx) { @@ -297,7 +298,7 @@ void addGraphicsIndexingStructTests (tcu::TestCaseGroup* group) indexSelectorData.reserve(numItems); for (deUint32 numIdx = 0; numIdx < numItems; ++numIdx) - indexSelectorData.push_back(UVec4(rnd.getUint32() % 32, rnd.getUint32() % 32, rnd.getUint32() % 4, rnd.getUint32() % 4)); + indexSelectorData.push_back(tcu::randomVector(rnd, UVec4(0), UVec4(31, 31, 3, 3))); getDefaultColors(defaultColors); diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp index 51ff4e8..152a08d 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp @@ -48,6 +48,7 @@ #include "deStringUtil.hpp" #include "deUniquePtr.hpp" #include "deMath.h" +#include "deRandom.hpp" #include "tcuStringTemplate.hpp" #include "vktSpvAsmCrossStageInterfaceTests.hpp" @@ -110,7 +111,7 @@ static void fillRandomScalars (de::Random& rnd, T minValue, T maxValue, void* ds { T* const typedPtr = (T*)dst; for (int ndx = 0; ndx < numValues; ndx++) - typedPtr[offset + ndx] = randomScalar(rnd, minValue, maxValue); + typedPtr[offset + ndx] = de::randomScalar(rnd, minValue, maxValue); } // Filter is a function that returns true if a value should pass, false otherwise. @@ -122,7 +123,7 @@ static void fillRandomScalars (de::Random& rnd, T minValue, T maxValue, void* ds for (int ndx = 0; ndx < numValues; ndx++) { do - value = randomScalar(rnd, minValue, maxValue); + value = de::randomScalar(rnd, minValue, maxValue); while (!filter(value)); typedPtr[offset + ndx] = value; diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmUboMatrixPaddingTests.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmUboMatrixPaddingTests.cpp index 1c333a5..b84b15a 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmUboMatrixPaddingTests.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmUboMatrixPaddingTests.cpp @@ -25,6 +25,7 @@ #include "vktSpvAsmComputeShaderCase.hpp" #include "vktSpvAsmComputeShaderTestUtil.hpp" #include "vktSpvAsmGraphicsShaderTestUtil.hpp" +#include "tcuVectorUtil.hpp" namespace vkt { @@ -130,7 +131,7 @@ void addComputeUboMatrixPaddingTest (tcu::TestCaseGroup* group) inputData.reserve(numElements); for (deUint32 numIdx = 0; numIdx < numElements; ++numIdx) - inputData.push_back(tcu::Vec4(rnd.getFloat(), rnd.getFloat(), rnd.getFloat(), rnd.getFloat())); + inputData.push_back(tcu::randomVec4(rnd)); spec.assembly = shaderSource; spec.numWorkGroups = IVec3(numElements, 1, 1); @@ -158,7 +159,7 @@ void addGraphicsUboMatrixPaddingTest (tcu::TestCaseGroup* group) vector inputData(numDataPoints); for (deUint32 numIdx = 0; numIdx < numDataPoints; ++numIdx) - inputData[numIdx] = tcu::Vec4(rnd.getFloat(), rnd.getFloat(), rnd.getFloat(), rnd.getFloat()); + inputData[numIdx] = tcu::randomVec4(rnd); resources.inputs.push_back(Resource(BufferSp(new Vec4Buffer(inputData)), VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER)); // Shader is expected to pass the input data by treating the input vec4 as mat2x2 diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmVariablePointersTests.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmVariablePointersTests.cpp index f17fe94..0bb8aed 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmVariablePointersTests.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmVariablePointersTests.cpp @@ -83,7 +83,7 @@ void fillRandomScalars (de::Random& rnd, T minValue, T maxValue, void* dst, int { T* const typedPtr = (T*)dst; for (int ndx = 0; ndx < numValues; ndx++) - typedPtr[offset + ndx] = randomScalar(rnd, minValue, maxValue); + typedPtr[offset + ndx] = de::randomScalar(rnd, minValue, maxValue); } // The following structure (outer_struct) is passed as a vector of 64 32-bit floats into some shaders. diff --git a/framework/common/tcuVectorUtil.hpp b/framework/common/tcuVectorUtil.hpp index 622bffa..0797463 100644 --- a/framework/common/tcuVectorUtil.hpp +++ b/framework/common/tcuVectorUtil.hpp @@ -25,6 +25,7 @@ #include "tcuDefs.hpp" #include "tcuVector.hpp" +#include "deRandom.hpp" #include "deMeta.hpp" #include "deMath.h" #include "deInt32.h" @@ -368,6 +369,32 @@ static inline Vector absDiff (const Vector& a, const Vector +inline tcu::Vector randomVector (de::Random& rnd, const tcu::Vector& minValue, const tcu::Vector& maxValue) +{ + tcu::Vector res; + + for (int ndx = 0; ndx < Size; ndx++) + res[ndx] = de::randomScalar(rnd, minValue[ndx], maxValue[ndx]); + + return res; +} + +inline Vector randomVec2 (de::Random& rnd) +{ + return randomVector(rnd, tcu::Vector(0.0f), tcu::Vector(1.0f)); +} + +inline Vector randomVec3 (de::Random& rnd) +{ + return randomVector(rnd, tcu::Vector(0.0f), tcu::Vector(1.0f)); +} + +inline Vector randomVec4 (de::Random& rnd) +{ + return randomVector(rnd, tcu::Vector(0.0f), tcu::Vector(1.0f)); +} + // Macros for component-wise ops. #define TCU_DECLARE_VECTOR_UNARY_FUNC(FUNC_NAME, OP_NAME) \ diff --git a/framework/delibs/decpp/deRandom.hpp b/framework/delibs/decpp/deRandom.hpp index a048622..4f6d15c 100644 --- a/framework/delibs/decpp/deRandom.hpp +++ b/framework/delibs/decpp/deRandom.hpp @@ -177,6 +177,11 @@ void Random::shuffle (Iterator first, Iterator last) } } +template T randomScalar (de::Random& rnd, T minValue, T maxValue); +template<> inline float randomScalar (de::Random& rnd, float minValue, float maxValue) { return rnd.getFloat(minValue, maxValue); } +template<> inline deInt32 randomScalar (de::Random& rnd, deInt32 minValue, deInt32 maxValue) { return rnd.getInt(minValue, maxValue); } +template<> inline deUint32 randomScalar (de::Random& rnd, deUint32 minValue, deUint32 maxValue) { return minValue + rnd.getUint32() % (maxValue - minValue + 1); } + } // de #endif // _DERANDOM_HPP diff --git a/modules/gles3/functional/es3fShaderCommonFunctionTests.cpp b/modules/gles3/functional/es3fShaderCommonFunctionTests.cpp index 237b754..edcf245 100644 --- a/modules/gles3/functional/es3fShaderCommonFunctionTests.cpp +++ b/modules/gles3/functional/es3fShaderCommonFunctionTests.cpp @@ -25,6 +25,7 @@ #include "glsShaderExecUtil.hpp" #include "tcuTestLog.hpp" #include "tcuFormatUtil.hpp" +#include "tcuVectorUtil.hpp" #include "tcuFloat.hpp" #include "deRandom.hpp" #include "deMath.h" @@ -65,26 +66,12 @@ private: tcu::Vector* m_array; }; -template T randomScalar (de::Random& rnd, T minValue, T maxValue); -template<> inline float randomScalar (de::Random& rnd, float minValue, float maxValue) { return rnd.getFloat(minValue, maxValue); } -template<> inline deInt32 randomScalar (de::Random& rnd, deInt32 minValue, deInt32 maxValue) { return rnd.getInt(minValue, maxValue); } -template<> inline deUint32 randomScalar (de::Random& rnd, deUint32 minValue, deUint32 maxValue) { return minValue + rnd.getUint32() % (maxValue - minValue + 1); } - -template -inline tcu::Vector randomVector (de::Random& rnd, const tcu::Vector& minValue, const tcu::Vector& maxValue) -{ - tcu::Vector res; - for (int ndx = 0; ndx < Size; ndx++) - res[ndx] = randomScalar(rnd, minValue[ndx], maxValue[ndx]); - return res; -} - template static void fillRandomVectors (de::Random& rnd, const tcu::Vector& minValue, const tcu::Vector& maxValue, void* dst, int numValues, int offset = 0) { VecArrayAccess access(dst); for (int ndx = 0; ndx < numValues; ndx++) - access[offset + ndx] = randomVector(rnd, minValue, maxValue); + access[offset + ndx] = tcu::randomVector(rnd, minValue, maxValue); } template @@ -92,7 +79,7 @@ static void fillRandomScalars (de::Random& rnd, T minValue, T maxValue, void* ds { T* typedPtr = (T*)dst; for (int ndx = 0; ndx < numValues; ndx++) - typedPtr[offset + ndx] = randomScalar(rnd, minValue, maxValue); + typedPtr[offset + ndx] = de::randomScalar(rnd, minValue, maxValue); } inline int numBitsLostInOp (float input, float output) diff --git a/modules/gles31/functional/es31fShaderCommonFunctionTests.cpp b/modules/gles31/functional/es31fShaderCommonFunctionTests.cpp index e7aae44..566e183 100644 --- a/modules/gles31/functional/es31fShaderCommonFunctionTests.cpp +++ b/modules/gles31/functional/es31fShaderCommonFunctionTests.cpp @@ -29,6 +29,7 @@ #include "tcuFloat.hpp" #include "tcuInterval.hpp" #include "tcuFloatFormat.hpp" +#include "tcuVectorUtil.hpp" #include "deRandom.hpp" #include "deMath.h" #include "deString.h" @@ -69,26 +70,12 @@ private: tcu::Vector* m_array; }; -template T randomScalar (de::Random& rnd, T minValue, T maxValue); -template<> inline float randomScalar (de::Random& rnd, float minValue, float maxValue) { return rnd.getFloat(minValue, maxValue); } -template<> inline deInt32 randomScalar (de::Random& rnd, deInt32 minValue, deInt32 maxValue) { return rnd.getInt(minValue, maxValue); } -template<> inline deUint32 randomScalar (de::Random& rnd, deUint32 minValue, deUint32 maxValue) { return minValue + rnd.getUint32() % (maxValue - minValue + 1); } - -template -inline tcu::Vector randomVector (de::Random& rnd, const tcu::Vector& minValue, const tcu::Vector& maxValue) -{ - tcu::Vector res; - for (int ndx = 0; ndx < Size; ndx++) - res[ndx] = randomScalar(rnd, minValue[ndx], maxValue[ndx]); - return res; -} - template static void fillRandomVectors (de::Random& rnd, const tcu::Vector& minValue, const tcu::Vector& maxValue, void* dst, int numValues, int offset = 0) { VecArrayAccess access(dst); for (int ndx = 0; ndx < numValues; ndx++) - access[offset + ndx] = randomVector(rnd, minValue, maxValue); + access[offset + ndx] = tcu::randomVector(rnd, minValue, maxValue); } template @@ -96,7 +83,7 @@ static void fillRandomScalars (de::Random& rnd, T minValue, T maxValue, void* ds { T* typedPtr = (T*)dst; for (int ndx = 0; ndx < numValues; ndx++) - typedPtr[offset + ndx] = randomScalar(rnd, minValue, maxValue); + typedPtr[offset + ndx] = de::randomScalar(rnd, minValue, maxValue); } inline int numBitsLostInOp (float input, float output) -- 2.7.4