Fix ClearOpsBufferStorageTestCase on ppc64le
authorLiam Middlebrook <lmiddlebrook@nvidia.com>
Wed, 17 Jan 2018 05:17:38 +0000 (21:17 -0800)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Tue, 6 Feb 2018 09:10:02 +0000 (04:10 -0500)
The check for the modified ClearOpsBufferStorageTestCase output currently checks
if the value present in the mapped buffer from GL is equivalent to the
calculated value under the following scheme:

    (data_rgba8 & (0xFF << (n_current_byte * 8))) >> (n_current_byte * 8)

The C++ Working Draft Standard N4140 [1] Section 5.8
states the following:

    The behavior is undefined if the right operand is negative or greater than
    or equal to the length in bits of the promoted left operand.

Similar language is also stated in the C Working Draft Standard N1256 [2]

    If the value of the right operand is negative or is greater than or equal to
    the width of the promoted left operand, the behavior is undefined.

This change removes the undefined behavior that is being used to set
`expected_value`.

Additionally this change makes the literal 0xFF into 0xFFu since all of the
other components surrounding it are unsigned.

References:

[1] https://timsong-cpp.github.io/cppwp/n4140/draft.pdf
[2] http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf

Components: OpenGL
VK-GL-CTS issue: 955
Change-Id: I8f1a25b184379c966355e6d0dec81b1416049279
Reviewed-By: pdaniell
external/openglcts/modules/gl/gl4cSparseBufferTests.cpp

index e67f508..8859d75 100644 (file)
@@ -1775,8 +1775,9 @@ bool ClearOpsBufferStorageTestCase::execute(glw::GLuint sparse_bo_storage_flags)
                                 (n_current_byte < modified_region_start_offset + modified_region_size) && result_local;
                                 ++n_current_byte)
                        {
+                               const unsigned char component_offset = n_current_byte % 4;
                                const unsigned char expected_value =
-                                       static_cast<unsigned char>((data_rgba8 & (0xFF << (n_current_byte * 8))) >> (n_current_byte * 8));
+                                       static_cast<unsigned char>((data_rgba8 & (0xFFu << (component_offset * 8))) >> (component_offset * 8));
                                const unsigned char found_value = result_data[n_current_byte];
 
                                if (expected_value != found_value)