From 74813d58fa4e5b69132bb684f44084d2bf4e3a41 Mon Sep 17 00:00:00 2001 From: Mikko Tiusanen Date: Mon, 19 Oct 2020 18:03:50 +0300 Subject: [PATCH] Add tests for oob access in unexecuted shader paths Added tests for non-robust out of bounds buffer access in unexecuted shader code paths. New tests: dEQP-VK.robustness.non_robust_buffer_access.* Components: Vulkan VK-GL-CTS issue: 2171 Change-Id: I43ec27225ed949964d1d9783745326ff7a4dd528 --- AndroidGen.mk | 1 + android/cts/master/vk-master-2020-03-01.txt | 2 + android/cts/master/vk-master.txt | 2 + .../unexecuted_oob_overflow.amber | 105 +++++++++++++++++++++ .../unexecuted_oob_underflow.amber | 105 +++++++++++++++++++++ .../modules/vulkan/robustness/CMakeLists.txt | 3 +- .../robustness/vktNonRobustBufferAccessTests.cpp | 57 +++++++++++ .../robustness/vktNonRobustBufferAccessTests.hpp | 41 ++++++++ .../vulkan/robustness/vktRobustnessTests.cpp | 2 + external/vulkancts/mustpass/master/vk-default.txt | 2 + 10 files changed, 319 insertions(+), 1 deletion(-) create mode 100644 external/vulkancts/data/vulkan/amber/non_robust_buffer_access/unexecuted_oob_overflow.amber create mode 100644 external/vulkancts/data/vulkan/amber/non_robust_buffer_access/unexecuted_oob_underflow.amber create mode 100644 external/vulkancts/modules/vulkan/robustness/vktNonRobustBufferAccessTests.cpp create mode 100644 external/vulkancts/modules/vulkan/robustness/vktNonRobustBufferAccessTests.hpp diff --git a/AndroidGen.mk b/AndroidGen.mk index d0dab8c..ab3d6b2 100644 --- a/AndroidGen.mk +++ b/AndroidGen.mk @@ -285,6 +285,7 @@ LOCAL_SRC_FILES := \ external/vulkancts/modules/vulkan/renderpass/vktRenderPassUnusedAttachmentSparseFillingTests.cpp \ external/vulkancts/modules/vulkan/renderpass/vktRenderPassUnusedAttachmentTests.cpp \ external/vulkancts/modules/vulkan/renderpass/vktRenderPassUnusedClearAttachmentTests.cpp \ + external/vulkancts/modules/vulkan/robustness/vktNonRobustBufferAccessTests.cpp \ external/vulkancts/modules/vulkan/robustness/vktRobustBufferAccessWithVariablePointersTests.cpp \ external/vulkancts/modules/vulkan/robustness/vktRobustnessBufferAccessTests.cpp \ external/vulkancts/modules/vulkan/robustness/vktRobustnessExtsTests.cpp \ diff --git a/android/cts/master/vk-master-2020-03-01.txt b/android/cts/master/vk-master-2020-03-01.txt index d17b8f5..b89026e 100644 --- a/android/cts/master/vk-master-2020-03-01.txt +++ b/android/cts/master/vk-master-2020-03-01.txt @@ -274317,6 +274317,8 @@ dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.stor dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d_array.frag dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d_array.vert dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d_array.rgen +dEQP-VK.robustness.non_robust_buffer_access.unexecuted_oob_underflow +dEQP-VK.robustness.non_robust_buffer_access.unexecuted_oob_overflow dEQP-VK.multiview.non_precise_queries.15 dEQP-VK.multiview.non_precise_queries.8 dEQP-VK.multiview.non_precise_queries.1_2_4_8 diff --git a/android/cts/master/vk-master.txt b/android/cts/master/vk-master.txt index 44051a4..1a8568d 100644 --- a/android/cts/master/vk-master.txt +++ b/android/cts/master/vk-master.txt @@ -647448,6 +647448,8 @@ dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.stor dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d_array.frag dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d_array.vert dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d_array.rgen +dEQP-VK.robustness.non_robust_buffer_access.unexecuted_oob_underflow +dEQP-VK.robustness.non_robust_buffer_access.unexecuted_oob_overflow dEQP-VK.multiview.masks.15 dEQP-VK.multiview.masks.8 dEQP-VK.multiview.masks.1_2_4_8 diff --git a/external/vulkancts/data/vulkan/amber/non_robust_buffer_access/unexecuted_oob_overflow.amber b/external/vulkancts/data/vulkan/amber/non_robust_buffer_access/unexecuted_oob_overflow.amber new file mode 100644 index 0000000..8ed89cc --- /dev/null +++ b/external/vulkancts/data/vulkan/amber/non_robust_buffer_access/unexecuted_oob_overflow.amber @@ -0,0 +1,105 @@ +#!amber +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Overview of the test: +# data_out array composed of values read from two input arrays of half +# it's size, executed in 4 work groups, result equal to: +# data_out[2 * i ] = data_in0[i] +# data_out[2 * i + 1] = data_in1[i] +# +# data_in2 is used for condition and condition_index increment to avoid +# optimizing away the loop: +# data_in2 = (cond0, inc0, cond1, inc1, ... condN, incN) +# +# Each iteration of the for-loop uses alternating (if-else) path while +# still always accessing and modifying the same index value (but +# swapping between used index variables), equivalent to: +# if (i % 2 == 0) +# data_out[base + index_out--] = data_in0[base + index_in ] +# else +# data_out[base + index_out--] = data_in1[base + index_in--] +# +# The unexecuted if-else path accesses out of bounds or overlapping +# with valid result indices. +SHADER compute test_overflow GLSL +#version 430 + +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +layout(set = 0, binding = 0) readonly buffer In0 { int data_in0[512]; }; +layout(set = 0, binding = 1) readonly buffer In1 { int data_in1[512]; }; +layout(set = 0, binding = 2) readonly buffer In2 { int data_in2[8]; }; +layout(set = 0, binding = 3) writeonly buffer Out0 { int data_out0[1024]; }; + +void main() +{ + uint base_index_in = 128 * gl_WorkGroupID.x; + uint base_index_out = 256 * gl_WorkGroupID.x; + int index_in0 = 127; + int index_in1 = 383; + int index_out0 = 255; + int index_out1 = 383; + int condition_index = 0; + for(int i = 0; i < 256; ++i) + { + if (data_in2[condition_index] == 0) + { + data_out0[base_index_out + index_out0] = data_in1[base_index_in + index_in0]; + --index_out0; + --index_in1; + } + else + { + data_out0[base_index_out + index_out1] = data_in0[base_index_in + index_in1]; + --index_out1; + --index_in1; + } + condition_index += data_in2[condition_index + 1]; + int temp0 = index_in0; + index_in0 = index_in1; + index_in1 = temp0; + int temp1 = index_out0; + index_out0 = index_out1; + index_out1 = temp1; + } +} +END + +BUFFER data_in0 DATA_TYPE int32 SIZE 512 SERIES_FROM 0 INC_BY 2 +BUFFER data_in1 DATA_TYPE int32 SIZE 512 SERIES_FROM 1 INC_BY 2 +BUFFER data_in2 DATA_TYPE int32 DATA + 0 + 2 + 1 + 2 + 0 + 2 + 1 + -6 +END +BUFFER data_out DATA_TYPE int32 SIZE 1024 FILL -1 + +BUFFER expected DATA_TYPE int32 SIZE 1024 SERIES_FROM 0 INC_BY 1 + +PIPELINE compute pipeline + ATTACH test_overflow + BIND BUFFER data_in0 AS storage DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER data_in1 AS storage DESCRIPTOR_SET 0 BINDING 1 + BIND BUFFER data_in2 AS storage DESCRIPTOR_SET 0 BINDING 2 + BIND BUFFER data_out AS storage DESCRIPTOR_SET 0 BINDING 3 +END + +RUN pipeline 4 1 1 + +EXPECT data_out EQ_BUFFER expected diff --git a/external/vulkancts/data/vulkan/amber/non_robust_buffer_access/unexecuted_oob_underflow.amber b/external/vulkancts/data/vulkan/amber/non_robust_buffer_access/unexecuted_oob_underflow.amber new file mode 100644 index 0000000..dc82127 --- /dev/null +++ b/external/vulkancts/data/vulkan/amber/non_robust_buffer_access/unexecuted_oob_underflow.amber @@ -0,0 +1,105 @@ +#!amber +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Overview of the test: +# data_out array composed of values read from two input arrays of half +# it's size, executed in 4 work groups, result equal to: +# data_out[2 * i ] = data_in0[i] +# data_out[2 * i + 1] = data_in1[i] +# +# data_in2 is used for condition and condition_index increment to avoid +# optimizing away the loop: +# data_in2 = (cond0, inc0, cond1, inc1, ... condN, incN) +# +# Each iteration of the for-loop uses alternating (if-else) path while +# still always accessing and modifying the same index value (but +# swapping between used index variables), equivalent to: +# if (i % 2 == 0) +# data_out[base + index_out++] = data_in0[base + index_in ] +# else +# data_out[base + index_out++] = data_in1[base + index_in++] +# +# The unexecuted if-else path accesses out of bounds or overlapping +# with valid result indices. +SHADER compute test_underflow GLSL +#version 430 + +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +layout(set = 0, binding = 0) readonly buffer In0 { int data_in0[512]; }; +layout(set = 0, binding = 1) readonly buffer In1 { int data_in1[512]; }; +layout(set = 0, binding = 2) readonly buffer In2 { int data_in2[8]; }; +layout(set = 0, binding = 3) writeonly buffer Out0 { int data_out0[1024]; }; + +void main() +{ + uint base_index_in = 128 * gl_WorkGroupID.x; + uint base_index_out = 256 * gl_WorkGroupID.x; + int index_in0 = 0; + int index_in1 = -128; + int index_out0 = 0; + int index_out1 = -128; + int condition_index = 0; + for(int i = 0; i < 256; ++i) + { + if (data_in2[condition_index] == 0) + { + data_out0[base_index_out + index_out0] = data_in0[base_index_in + index_in0]; + ++index_out0; + ++index_in1; + } + else + { + data_out0[base_index_out + index_out1] = data_in1[base_index_in + index_in1]; + ++index_out1; + ++index_in1; + } + condition_index += data_in2[condition_index + 1]; + int temp0 = index_in0; + index_in0 = index_in1; + index_in1 = temp0; + int temp1 = index_out0; + index_out0 = index_out1; + index_out1 = temp1; + } +} +END + +BUFFER data_in0 DATA_TYPE int32 SIZE 512 SERIES_FROM 0 INC_BY 2 +BUFFER data_in1 DATA_TYPE int32 SIZE 512 SERIES_FROM 1 INC_BY 2 +BUFFER data_in2 DATA_TYPE int32 DATA + 0 + 2 + 1 + 2 + 0 + 2 + 1 + -6 +END +BUFFER data_out DATA_TYPE int32 SIZE 1024 FILL -1 + +BUFFER expected DATA_TYPE int32 SIZE 1024 SERIES_FROM 0 INC_BY 1 + +PIPELINE compute pipeline + ATTACH test_underflow + BIND BUFFER data_in0 AS storage DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER data_in1 AS storage DESCRIPTOR_SET 0 BINDING 1 + BIND BUFFER data_in2 AS storage DESCRIPTOR_SET 0 BINDING 2 + BIND BUFFER data_out AS storage DESCRIPTOR_SET 0 BINDING 3 +END + +RUN pipeline 4 1 1 + +EXPECT data_out EQ_BUFFER expected diff --git a/external/vulkancts/modules/vulkan/robustness/CMakeLists.txt b/external/vulkancts/modules/vulkan/robustness/CMakeLists.txt index 5d44374..9eded85 100644 --- a/external/vulkancts/modules/vulkan/robustness/CMakeLists.txt +++ b/external/vulkancts/modules/vulkan/robustness/CMakeLists.txt @@ -15,6 +15,8 @@ set(DEQP_VK_ROBUSTNESS_SRCS vktRobustnessUtil.hpp vktRobustnessVertexAccessTests.cpp vktRobustnessVertexAccessTests.hpp + vktNonRobustBufferAccessTests.hpp + vktNonRobustBufferAccessTests.cpp ) set(DEQP_VK_ROBUSTNESS_LIBS @@ -26,4 +28,3 @@ PCH(DEQP_VK_ROBUSTNESS_SRCS ../pch.cpp) add_library(deqp-vk-robustness STATIC ${DEQP_VK_ROBUSTNESS_SRCS}) target_link_libraries(deqp-vk-robustness ${DEQP_VK_ROBUSTNESS_LIBS}) - diff --git a/external/vulkancts/modules/vulkan/robustness/vktNonRobustBufferAccessTests.cpp b/external/vulkancts/modules/vulkan/robustness/vktNonRobustBufferAccessTests.cpp new file mode 100644 index 0000000..f748fb6 --- /dev/null +++ b/external/vulkancts/modules/vulkan/robustness/vktNonRobustBufferAccessTests.cpp @@ -0,0 +1,57 @@ +/*------------------------------------------------------------------------ + * Vulkan Conformance Tests + * ------------------------ + * + * Copyright (c) 2019 Google LLC + * Copyright (c) 2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *//*! + * \file + * \brief Tests for non robust oob buffer access in unexecuted shder code + * paths. + *//*--------------------------------------------------------------------*/ + +#include "vktNonRobustBufferAccessTests.hpp" +#include "amber/vktAmberTestCase.hpp" + +#include +#include +#include + +namespace vkt +{ +namespace robustness +{ +using namespace cts_amber; + +tcu::TestCaseGroup* createNonRobustBufferAccessTests (tcu::TestContext& testCtx) +{ + static const std::string kGroupName = "non_robust_buffer_access"; + static const std::vector> nonRobustBufferAccessTests = + { + { "unexecuted_oob_underflow", "Test for correct handling of buffer access index underflow in unexecuted shader code paths" }, + { "unexecuted_oob_overflow", "Test for correct handling of buffer access index overflow in unexecuted shader code paths" } + }; + + de::MovePtr group{new tcu::TestCaseGroup{testCtx, kGroupName.c_str(), "Non-robust buffer access test group"}}; + for (const auto& test : nonRobustBufferAccessTests) + { + group->addChild(createAmberTestCase(testCtx, test.first.c_str(), test.second.c_str(), kGroupName.c_str(), test.first + ".amber")); + } + return group.release(); +} + +} // cts_amber +} // vkt diff --git a/external/vulkancts/modules/vulkan/robustness/vktNonRobustBufferAccessTests.hpp b/external/vulkancts/modules/vulkan/robustness/vktNonRobustBufferAccessTests.hpp new file mode 100644 index 0000000..712553e --- /dev/null +++ b/external/vulkancts/modules/vulkan/robustness/vktNonRobustBufferAccessTests.hpp @@ -0,0 +1,41 @@ +#ifndef _VKTNONROBUSTBUFFERACCESSTESTS_HPP +#define _VKTNONROBUSTBUFFERACCESSTESTS_HPP +/*------------------------------------------------------------------------ + * Vulkan Conformance Tests + * ------------------------ + * + * Copyright (c) 2019 Google LLC + * Copyright (c) 2019 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *//*! + * \file + * \brief Tests for non robust oob buffer access in unexecuted shder code + * paths. + *//*--------------------------------------------------------------------*/ + +#include "tcuDefs.hpp" +#include "tcuTestCase.hpp" + +namespace vkt +{ +namespace robustness +{ + +tcu::TestCaseGroup* createNonRobustBufferAccessTests (tcu::TestContext&); + +} // cts_amber +} // vkt + +#endif // _VKTNONROBUSTBUFFERACCESSTESTS_HPP diff --git a/external/vulkancts/modules/vulkan/robustness/vktRobustnessTests.cpp b/external/vulkancts/modules/vulkan/robustness/vktRobustnessTests.cpp index fd841a6..325eb1d 100644 --- a/external/vulkancts/modules/vulkan/robustness/vktRobustnessTests.cpp +++ b/external/vulkancts/modules/vulkan/robustness/vktRobustnessTests.cpp @@ -27,6 +27,7 @@ #include "vktRobustnessBufferAccessTests.hpp" #include "vktRobustnessVertexAccessTests.hpp" #include "vktRobustBufferAccessWithVariablePointersTests.hpp" +#include "vktNonRobustBufferAccessTests.hpp" #include "vktTestGroupUtil.hpp" namespace vkt @@ -76,6 +77,7 @@ tcu::TestCaseGroup* createTests (tcu::TestContext& testCtx) robustnessTests->addChild(createRobustness2Tests(testCtx)); robustnessTests->addChild(createImageRobustnessTests(testCtx)); + robustnessTests->addChild(createNonRobustBufferAccessTests(testCtx)); return robustnessTests.release(); } diff --git a/external/vulkancts/mustpass/master/vk-default.txt b/external/vulkancts/mustpass/master/vk-default.txt index 7d2b6d4..b59daed 100644 --- a/external/vulkancts/mustpass/master/vk-default.txt +++ b/external/vulkancts/mustpass/master/vk-default.txt @@ -649782,6 +649782,8 @@ dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.stor dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d_array.frag dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d_array.vert dEQP-VK.robustness.image_robustness.push.notemplate.rgba32f.unroll.volatile.storage_image.fmt_qual.img.samples_4.2d_array.rgen +dEQP-VK.robustness.non_robust_buffer_access.unexecuted_oob_underflow +dEQP-VK.robustness.non_robust_buffer_access.unexecuted_oob_overflow dEQP-VK.multiview.masks.15 dEQP-VK.multiview.masks.8 dEQP-VK.multiview.masks.1_2_4_8 -- 2.7.4