From 393912cd7758e7b05e82cd0e6ce337e9d560de2a Mon Sep 17 00:00:00 2001 From: Carl Ritson Date: Thu, 14 Mar 2019 16:25:30 +0000 Subject: [PATCH] Fix memory initialisation in subgroups tests Subgroup tests expand memory allocations to accommodate std140 layout shaders; however, the extra memory is not initialised. This changes initialisation to be based on the actually allocated buffer size and adds additional verification to catch uninitialised memory. Affects: dEQP-VK.subgroups.* Components: Vulkan VK-GL-CTS Issue: 1639 Change-Id: I0dfc0abb9bcbe63b5d1d5ad43e6fee99389fdfa2 --- .../subgroups/vktSubgroupsArithmeticTests.cpp | 3 + .../subgroups/vktSubgroupsBallotBroadcastTests.cpp | 3 + .../vulkan/subgroups/vktSubgroupsBallotTests.cpp | 3 + .../vulkan/subgroups/vktSubgroupsBasicTests.cpp | 77 +++++++++++++++++++--- .../subgroups/vktSubgroupsClusteredTests.cpp | 3 + .../subgroups/vktSubgroupsPartitionedTests.cpp | 3 + .../vulkan/subgroups/vktSubgroupsQuadTests.cpp | 3 + .../vulkan/subgroups/vktSubgroupsShuffleTests.cpp | 6 ++ .../vulkan/subgroups/vktSubgroupsTestsUtils.cpp | 35 ++++++---- .../vulkan/subgroups/vktSubgroupsTestsUtils.hpp | 8 +++ .../vulkan/subgroups/vktSubgroupsVoteTests.cpp | 3 + 11 files changed, 126 insertions(+), 21 deletions(-) diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsArithmeticTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsArithmeticTests.cpp index b3555f7..6b946c4 100755 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsArithmeticTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsArithmeticTests.cpp @@ -898,6 +898,7 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd140; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; @@ -944,6 +945,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) } subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; @@ -976,6 +978,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; inputData.binding = 4u; diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotBroadcastTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotBroadcastTests.cpp index 2ba32f9..43a732f 100755 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotBroadcastTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotBroadcastTests.cpp @@ -504,6 +504,7 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData[1]; inputData[0].format = caseDef.format; + inputData[0].layout = subgroups::SSBOData::LayoutStd140; inputData[0].numElements = subgroups::maxSupportedSubgroupSize(); inputData[0].initializeType = subgroups::SSBOData::InitializeNonZero; @@ -540,6 +541,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) } subgroups::SSBOData inputData[1]; inputData[0].format = caseDef.format; + inputData[0].layout = subgroups::SSBOData::LayoutStd430; inputData[0].numElements = subgroups::maxSupportedSubgroupSize(); inputData[0].initializeType = subgroups::SSBOData::InitializeNonZero; @@ -572,6 +574,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; inputData.binding = 4u; diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotTests.cpp index afccff8..d5a22d0 100755 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotTests.cpp @@ -968,6 +968,7 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData[1]; inputData[0].format = VK_FORMAT_R32_UINT; + inputData[0].layout = subgroups::SSBOData::LayoutStd140; inputData[0].numElements = subgroups::maxSupportedSubgroupSize(); inputData[0].initializeType = subgroups::SSBOData::InitializeNonZero; @@ -996,6 +997,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) } subgroups::SSBOData inputData[1]; inputData[0].format = VK_FORMAT_R32_UINT; + inputData[0].layout = subgroups::SSBOData::LayoutStd430; inputData[0].numElements = subgroups::maxSupportedSubgroupSize(); inputData[0].initializeType = subgroups::SSBOData::InitializeNonZero; @@ -1028,6 +1030,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = VK_FORMAT_R32_UINT; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; inputData.binding = 4u; diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBasicTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBasicTests.cpp index d626a17..a46692e 100755 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBasicTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBasicTests.cpp @@ -39,8 +39,8 @@ static const deUint32 ELECTED_VALUE = 42u; static const deUint32 UNELECTED_VALUE = 13u; static const vk::VkDeviceSize SHADER_BUFFER_SIZE = 4096ull; // min(maxUniformBufferRange, maxImageDimension1D) -static bool checkFragmentSubgroupBarriersNoSSBO(std::vector datas, - deUint32 width, deUint32 height, deUint32) +static bool _checkFragmentSubgroupBarriersNoSSBO(std::vector datas, + deUint32 width, deUint32 height, bool withImage) { const float* const resultData = reinterpret_cast(datas[0]); @@ -49,7 +49,11 @@ static bool checkFragmentSubgroupBarriersNoSSBO(std::vector datas, for (deUint32 y = 0u; y < height; ++y) { const deUint32 ndx = (x * height + y) * 4u; - if (1.0f == resultData[ndx +2]) + if (!withImage && 0.0f == resultData[ndx]) + { + return false; + } + else if (1.0f == resultData[ndx +2]) { if(resultData[ndx] != resultData[ndx +1]) { @@ -66,6 +70,18 @@ static bool checkFragmentSubgroupBarriersNoSSBO(std::vector datas, return true; } +static bool checkFragmentSubgroupBarriersNoSSBO(std::vector datas, + deUint32 width, deUint32 height, deUint32) +{ + return _checkFragmentSubgroupBarriersNoSSBO(datas, width, height, false); +} + +static bool checkFragmentSubgroupBarriersWithImageNoSSBO(std::vector datas, + deUint32 width, deUint32 height, deUint32) +{ + return _checkFragmentSubgroupBarriersNoSSBO(datas, width, height, true); +} + static bool checkVertexPipelineStagesSubgroupElectNoSSBO(std::vector datas, deUint32 width, deUint32) { @@ -143,15 +159,19 @@ static bool checkVertexPipelineStagesSubgroupBarriers(std::vector d return true; } -static bool checkVertexPipelineStagesSubgroupBarriersNoSSBO(std::vector datas, - deUint32 width, deUint32) +static bool _checkVertexPipelineStagesSubgroupBarriersNoSSBO(std::vector datas, + deUint32 width, bool withImage) { const float* const resultData = reinterpret_cast(datas[0]); for (deUint32 x = 0u; x < width; ++x) { const deUint32 ndx = x*4u; - if (1.0f == resultData[ndx +2]) + if (!withImage && 0.0f == resultData[ndx]) + { + return false; + } + else if (1.0f == resultData[ndx +2]) { if(resultData[ndx] != resultData[ndx +1]) return false; @@ -164,6 +184,18 @@ static bool checkVertexPipelineStagesSubgroupBarriersNoSSBO(std::vector datas, + deUint32 width, deUint32) +{ + return _checkVertexPipelineStagesSubgroupBarriersNoSSBO(datas, width, false); +} + +static bool checkVertexPipelineStagesSubgroupBarriersWithImageNoSSBO(std::vector datas, + deUint32 width, deUint32) +{ + return _checkVertexPipelineStagesSubgroupBarriersNoSSBO(datas, width, true); +} + static bool checkTessellationEvaluationSubgroupBarriersNoSSBO(std::vector datas, deUint32 width, deUint32) { @@ -1926,16 +1958,19 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) std::vector inputDatas (inputDatasCount); inputDatas[0].format = VK_FORMAT_R32_UINT; + inputDatas[0].layout = subgroups::SSBOData::LayoutStd140; inputDatas[0].numElements = SHADER_BUFFER_SIZE/4ull; inputDatas[0].initializeType = subgroups::SSBOData::InitializeNonZero; inputDatas[1].format = VK_FORMAT_R32_UINT; + inputDatas[1].layout = subgroups::SSBOData::LayoutStd140; inputDatas[1].numElements = 1ull; inputDatas[1].initializeType = subgroups::SSBOData::InitializeNonZero; if(OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType ) { inputDatas[2].format = VK_FORMAT_R32_UINT; + inputDatas[2].layout = subgroups::SSBOData::LayoutPacked; inputDatas[2].numElements = SHADER_BUFFER_SIZE; inputDatas[2].initializeType = subgroups::SSBOData::InitializeNone; inputDatas[2].isImage = true; @@ -1946,18 +1981,30 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) if (OPTYPE_ELECT == caseDef.opType) return subgroups::makeVertexFrameBufferTest(context, VK_FORMAT_R32G32_SFLOAT, DE_NULL, 0u, checkVertexPipelineStagesSubgroupElectNoSSBO); else - return subgroups::makeVertexFrameBufferTest(context, VK_FORMAT_R32G32B32A32_SFLOAT, &inputDatas[0], inputDatasCount, checkVertexPipelineStagesSubgroupBarriersNoSSBO); + return subgroups::makeVertexFrameBufferTest(context, VK_FORMAT_R32G32B32A32_SFLOAT, &inputDatas[0], inputDatasCount, + (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType) ? + checkVertexPipelineStagesSubgroupBarriersWithImageNoSSBO : + checkVertexPipelineStagesSubgroupBarriersNoSSBO + ); } else if (VK_SHADER_STAGE_FRAGMENT_BIT == caseDef.shaderStage) { - return subgroups::makeFragmentFrameBufferTest(context, VK_FORMAT_R32G32B32A32_SFLOAT, &inputDatas[0], inputDatasCount, checkFragmentSubgroupBarriersNoSSBO); + return subgroups::makeFragmentFrameBufferTest(context, VK_FORMAT_R32G32B32A32_SFLOAT, &inputDatas[0], inputDatasCount, + (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType) ? + checkFragmentSubgroupBarriersWithImageNoSSBO : + checkFragmentSubgroupBarriersNoSSBO + ); } else if (VK_SHADER_STAGE_GEOMETRY_BIT == caseDef.shaderStage) { if (OPTYPE_ELECT == caseDef.opType) return subgroups::makeGeometryFrameBufferTest(context, VK_FORMAT_R32G32_SFLOAT, DE_NULL, 0u, checkVertexPipelineStagesSubgroupElectNoSSBO); else - return subgroups::makeGeometryFrameBufferTest(context, VK_FORMAT_R32G32B32A32_SFLOAT, &inputDatas[0], inputDatasCount, checkVertexPipelineStagesSubgroupBarriersNoSSBO); + return subgroups::makeGeometryFrameBufferTest(context, VK_FORMAT_R32G32B32A32_SFLOAT, &inputDatas[0], inputDatasCount, + (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType) ? + checkVertexPipelineStagesSubgroupBarriersWithImageNoSSBO : + checkVertexPipelineStagesSubgroupBarriersNoSSBO + ); } if (OPTYPE_ELECT == caseDef.opType) @@ -2004,14 +2051,17 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) const deUint32 inputDatasCount = 3; subgroups::SSBOData inputDatas[inputDatasCount]; inputDatas[0].format = VK_FORMAT_R32_UINT; + inputDatas[0].layout = subgroups::SSBOData::LayoutStd430; inputDatas[0].numElements = SHADER_BUFFER_SIZE; inputDatas[0].initializeType = subgroups::SSBOData::InitializeNone; inputDatas[1].format = VK_FORMAT_R32_UINT; + inputDatas[1].layout = subgroups::SSBOData::LayoutStd430; inputDatas[1].numElements = 1; inputDatas[1].initializeType = subgroups::SSBOData::InitializeNonZero; inputDatas[2].format = VK_FORMAT_R32_UINT; + inputDatas[2].layout = subgroups::SSBOData::LayoutPacked; inputDatas[2].numElements = SHADER_BUFFER_SIZE; inputDatas[2].initializeType = subgroups::SSBOData::InitializeNone; inputDatas[2].isImage = true; @@ -2055,30 +2105,35 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData[inputCount]; inputData[0].format = VK_FORMAT_R32_UINT; + inputData[0].layout = subgroups::SSBOData::LayoutStd430; inputData[0].numElements = 1; inputData[0].initializeType = subgroups::SSBOData::InitializeZero; inputData[0].binding = 4u; inputData[0].stages = VK_SHADER_STAGE_VERTEX_BIT; inputData[1].format = VK_FORMAT_R32_UINT; + inputData[1].layout = subgroups::SSBOData::LayoutStd430; inputData[1].numElements = 1; inputData[1].initializeType = subgroups::SSBOData::InitializeZero; inputData[1].binding = 5u; inputData[1].stages = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; inputData[2].format = VK_FORMAT_R32_UINT; + inputData[2].layout = subgroups::SSBOData::LayoutStd430; inputData[2].numElements = 1; inputData[2].initializeType = subgroups::SSBOData::InitializeZero; inputData[2].binding = 6u; inputData[2].stages = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; inputData[3].format = VK_FORMAT_R32_UINT; + inputData[3].layout = subgroups::SSBOData::LayoutStd430; inputData[3].numElements = 1; inputData[3].initializeType = subgroups::SSBOData::InitializeZero; inputData[3].binding = 7u; inputData[3].stages = VK_SHADER_STAGE_GEOMETRY_BIT; inputData[4].format = VK_FORMAT_R32_UINT; + inputData[4].layout = subgroups::SSBOData::LayoutStd430; inputData[4].numElements = 1; inputData[4].initializeType = subgroups::SSBOData::InitializeZero; inputData[4].binding = 8u; @@ -2104,24 +2159,28 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) { const deUint32 index = ndx*4; inputDatas[index].format = VK_FORMAT_R32_UINT; + inputDatas[index].layout = subgroups::SSBOData::LayoutStd430; inputDatas[index].numElements = SHADER_BUFFER_SIZE; inputDatas[index].initializeType = subgroups::SSBOData::InitializeNonZero; inputDatas[index].binding = index + 4u; inputDatas[index].stages = stagesBits[ndx]; inputDatas[index + 1].format = VK_FORMAT_R32_UINT; + inputDatas[index + 1].layout = subgroups::SSBOData::LayoutStd430; inputDatas[index + 1].numElements = 1; inputDatas[index + 1].initializeType = subgroups::SSBOData::InitializeZero; inputDatas[index + 1].binding = index + 5u; inputDatas[index + 1].stages = stagesBits[ndx]; inputDatas[index + 2].format = VK_FORMAT_R32_UINT; + inputDatas[index + 2].layout = subgroups::SSBOData::LayoutStd430; inputDatas[index + 2].numElements = 1; inputDatas[index + 2].initializeType = subgroups::SSBOData::InitializeNonZero; inputDatas[index + 2].binding = index + 6u; inputDatas[index + 2].stages = stagesBits[ndx]; inputDatas[index + 3].format = VK_FORMAT_R32_UINT; + inputDatas[index + 3].layout = subgroups::SSBOData::LayoutStd430; inputDatas[index + 3].numElements = SHADER_BUFFER_SIZE; inputDatas[index + 3].initializeType = subgroups::SSBOData::InitializeNone; inputDatas[index + 3].isImage = true; diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsClusteredTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsClusteredTests.cpp index 8520b41..8ac2af1 100755 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsClusteredTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsClusteredTests.cpp @@ -773,6 +773,7 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd140; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; @@ -801,6 +802,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) } subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; @@ -833,6 +835,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; inputData.binding = 4u; diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsPartitionedTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsPartitionedTests.cpp index c1a658a..34579a7 100755 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsPartitionedTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsPartitionedTests.cpp @@ -835,6 +835,7 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd140; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; @@ -881,6 +882,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) } subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; @@ -913,6 +915,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; inputData.binding = 4u; diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsQuadTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsQuadTests.cpp index 3cca837..2009f60 100755 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsQuadTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsQuadTests.cpp @@ -648,6 +648,7 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd140; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero;; @@ -677,6 +678,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) } subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; @@ -709,6 +711,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = subgroups::SSBOData::InitializeNonZero; inputData.binding = 4u; diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShuffleTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShuffleTests.cpp index 0721854..900f655 100755 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShuffleTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsShuffleTests.cpp @@ -693,10 +693,12 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData[2]; inputData[0].format = caseDef.format; + inputData[0].layout = subgroups::SSBOData::LayoutStd140; inputData[0].numElements = subgroups::maxSupportedSubgroupSize(); inputData[0].initializeType = subgroups::SSBOData::InitializeNonZero; inputData[1].format = VK_FORMAT_R32_UINT; + inputData[1].layout = subgroups::SSBOData::LayoutStd140; inputData[1].numElements = inputData[0].numElements; inputData[1].initializeType = subgroups::SSBOData::InitializeNonZero; @@ -748,10 +750,12 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) } subgroups::SSBOData inputData[2]; inputData[0].format = caseDef.format; + inputData[0].layout = subgroups::SSBOData::LayoutStd430; inputData[0].numElements = subgroups::maxSupportedSubgroupSize(); inputData[0].initializeType = subgroups::SSBOData::InitializeNonZero; inputData[1].format = VK_FORMAT_R32_UINT; + inputData[1].layout = subgroups::SSBOData::LayoutStd430; inputData[1].numElements = inputData[0].numElements; inputData[1].initializeType = subgroups::SSBOData::InitializeNonZero; @@ -785,12 +789,14 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData[2]; inputData[0].format = caseDef.format; + inputData[0].layout = subgroups::SSBOData::LayoutStd430; inputData[0].numElements = subgroups::maxSupportedSubgroupSize(); inputData[0].initializeType = subgroups::SSBOData::InitializeNonZero; inputData[0].binding = 4u; inputData[0].stages = stages; inputData[1].format = VK_FORMAT_R32_UINT; + inputData[1].layout = subgroups::SSBOData::LayoutStd430; inputData[1].numElements = inputData[0].numElements; inputData[1].initializeType = subgroups::SSBOData::InitializeNonZero; inputData[1].binding = 5u; diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp index f67f006..b99f345 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp @@ -87,6 +87,17 @@ deUint32 getFormatSizeInBytes(const VkFormat format) } } +deUint32 getElementSizeInBytes( + const VkFormat format, + const subgroups::SSBOData::InputDataLayoutType layout) +{ + deUint32 bytes = getFormatSizeInBytes(format); + if (layout == subgroups::SSBOData::LayoutStd140) + return bytes < 16 ? 16 : bytes; + else + return bytes; +} + Move makePipelineLayout( Context& context, const VkDescriptorSetLayout descriptorSetLayout) { @@ -425,7 +436,7 @@ struct Buffer : public BufferOrImage VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, DE_NULL, 0u, - sizeInBytes, + m_sizeInBytes, m_usage, VK_SHARING_MODE_EXCLUSIVE, 0u, @@ -435,7 +446,6 @@ struct Buffer : public BufferOrImage context.getDevice(), &bufferCreateInfo); vk::VkMemoryRequirements req = getBufferMemoryRequirements( context.getDeviceInterface(), context.getDevice(), *m_buffer); - req.size *= 4; m_allocation = context.getDefaultAllocator().allocate( req, MemoryRequirement::HostVisible); VK_CHECK(context.getDeviceInterface().bindBufferMemory( @@ -1377,7 +1387,8 @@ void vkt::subgroups::addGeometryShadersFromTemplate (const std::string& spirvTem void initializeMemory(Context& context, const Allocation& alloc, subgroups::SSBOData& data) { const vk::VkFormat format = data.format; - const vk::VkDeviceSize size = getFormatSizeInBytes(format) * data.numElements; + const vk::VkDeviceSize size = data.numElements * + (data.isImage ? getFormatSizeInBytes(format) : getElementSizeInBytes(format, data.layout)); if (subgroups::SSBOData::InitializeNonZero == data.initializeType) { de::Random rnd(context.getTestContext().getCommandLine().getBaseSeed()); @@ -1568,7 +1579,7 @@ tcu::TestStatus vkt::subgroups::makeTessellationEvaluationFrameBufferTest( } else { - vk::VkDeviceSize size = getFormatSizeInBytes(extraData[i].format) * extraData[i].numElements; + vk::VkDeviceSize size = getElementSizeInBytes(extraData[i].format, extraData[i].layout) * extraData[i].numElements; inputBuffers[i] = de::SharedPtr(new Buffer(context, size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)); } const Allocation& alloc = inputBuffers[i]->getAllocation(); @@ -1786,7 +1797,7 @@ tcu::TestStatus vkt::subgroups::makeGeometryFrameBufferTest( } else { - vk::VkDeviceSize size = getFormatSizeInBytes(extraData[i].format) * extraData[i].numElements; + vk::VkDeviceSize size = getElementSizeInBytes(extraData[i].format, extraData[i].layout) * extraData[i].numElements; inputBuffers[i] = de::SharedPtr(new Buffer(context, size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)); } const Allocation& alloc = inputBuffers[i]->getAllocation(); @@ -2048,7 +2059,7 @@ tcu::TestStatus vkt::subgroups::allStages( for (deUint32 ndx = 0u; ndx < stagesCount; ++ndx) { const VkDeviceSize shaderSize = (stagesVector[ndx] == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) ? maxWidth * 2 : maxWidth; - const VkDeviceSize size = getFormatSizeInBytes(format) * shaderSize; + const VkDeviceSize size = getElementSizeInBytes(format, SSBOData::LayoutStd430) * shaderSize; inputBuffers[ndx] = de::SharedPtr(new Buffer(context, size)); layoutBuilder.addIndexedBinding(inputBuffers[ndx]->getType(), 1, stagesVector[ndx], getResultBinding(stagesVector[ndx]), DE_NULL); @@ -2063,7 +2074,7 @@ tcu::TestStatus vkt::subgroups::allStages( } else { - const vk::VkDeviceSize size = getFormatSizeInBytes(extraDatas[datasNdx].format) * extraDatas[datasNdx].numElements; + const vk::VkDeviceSize size = getElementSizeInBytes(extraDatas[datasNdx].format, extraDatas[datasNdx].layout) * extraDatas[datasNdx].numElements; inputBuffers[ndx] = de::SharedPtr(new Buffer(context, size)); } @@ -2344,7 +2355,7 @@ tcu::TestStatus vkt::subgroups::makeVertexFrameBufferTest(Context& context, vk:: } else { - vk::VkDeviceSize size = getFormatSizeInBytes(extraData[i].format) * extraData[i].numElements; + vk::VkDeviceSize size = getElementSizeInBytes(extraData[i].format, extraData[i].layout) * extraData[i].numElements; inputBuffers[i] = de::SharedPtr(new Buffer(context, size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)); } const Allocation& alloc = inputBuffers[i]->getAllocation(); @@ -2566,7 +2577,7 @@ tcu::TestStatus vkt::subgroups::makeFragmentFrameBufferTest (Context& context, V else { vk::VkDeviceSize size = - getFormatSizeInBytes(extraDatas[i].format) * extraDatas[i].numElements; + getElementSizeInBytes(extraDatas[i].format, extraDatas[i].layout) * extraDatas[i].numElements; inputBuffers[i] = de::SharedPtr(new Buffer(context, size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)); } @@ -2795,7 +2806,7 @@ tcu::TestStatus vkt::subgroups::makeComputeTest( else { vk::VkDeviceSize size = - getFormatSizeInBytes(inputs[i].format) * inputs[i].numElements; + getElementSizeInBytes(inputs[i].format, inputs[i].layout) * inputs[i].numElements; inputBuffers[i] = de::SharedPtr(new Buffer(context, size)); } @@ -2864,7 +2875,7 @@ tcu::TestStatus vkt::subgroups::makeComputeTest( else { vk::VkDeviceSize size = - getFormatSizeInBytes(inputs[i].format) * inputs[i].numElements; + getElementSizeInBytes(inputs[i].format, inputs[i].layout) * inputs[i].numElements; VkDescriptorBufferInfo info = makeDescriptorBufferInfo(inputBuffers[i]->getAsBuffer()->getBuffer(), 0ull, size); @@ -2960,7 +2971,7 @@ tcu::TestStatus vkt::subgroups::makeComputeTest( if (!inputBuffers[i]->isImage()) { vk::VkDeviceSize size = - getFormatSizeInBytes(inputs[i].format) * + getElementSizeInBytes(inputs[i].format, inputs[i].layout) * inputs[i].numElements; const Allocation& resultAlloc = inputBuffers[i]->getAllocation(); invalidateMappedMemoryRange(context.getDeviceInterface(), diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp index 87aca75..7f28039 100644 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp @@ -58,6 +58,7 @@ struct SSBOData { SSBOData() : initializeType (InitializeNone), + layout (LayoutStd140), format (vk::VK_FORMAT_UNDEFINED), numElements (0), isImage (false), @@ -72,6 +73,13 @@ struct SSBOData InitializeZero, } initializeType; + enum InputDataLayoutType + { + LayoutStd140 = 0, + LayoutStd430, + LayoutPacked + } layout; + vk::VkFormat format; vk::VkDeviceSize numElements; bool isImage; diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp index c8ced10..f85f9c1 100755 --- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp +++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp @@ -738,6 +738,7 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd140; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = OPTYPE_ALLEQUAL == caseDef.opType ? subgroups::SSBOData::InitializeZero : subgroups::SSBOData::InitializeNonZero; @@ -770,6 +771,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = OPTYPE_ALLEQUAL == caseDef.opType ? subgroups::SSBOData::InitializeZero : subgroups::SSBOData::InitializeNonZero; @@ -803,6 +805,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef) subgroups::SSBOData inputData; inputData.format = caseDef.format; + inputData.layout = subgroups::SSBOData::LayoutStd430; inputData.numElements = subgroups::maxSupportedSubgroupSize(); inputData.initializeType = OPTYPE_ALLEQUAL == caseDef.opType ? subgroups::SSBOData::InitializeZero : subgroups::SSBOData::InitializeNonZero; inputData.binding = 4u; -- 2.7.4