From: Nicolas Capens Date: Wed, 19 Jun 2019 21:33:02 +0000 (-0400) Subject: Fix rounding when casting to integer X-Git-Tag: upstream/1.3.5~2010 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e81b11867f3a423c69838b2078ab39b12d3952d0;p=platform%2Fupstream%2FVK-GL-CTS.git Fix rounding when casting to integer Normalized values that were sampled from textures and have been scaled by their maximum magnitude will be close to their unnormalized integer value but may be slightly less. Subsequent casting to integer (with rounding towards zero) may therefore result in a value one-off from the original. Use round-to-nearest to ensure the correct integer value is produced. Fixes: #151 VK-GL-CTS public issue: 151 VK-GL-CTS issue: 1853 Affects: dEQP-VK.memory.pipeline_barrier.all.* Components: Vulkan Change-Id: I435d41145c83957db15c74ea394e89faf142c2a3 --- diff --git a/external/vulkancts/modules/vulkan/memory/vktMemoryPipelineBarrierTests.cpp b/external/vulkancts/modules/vulkan/memory/vktMemoryPipelineBarrierTests.cpp index a1a8d0f..8ea44e9 100644 --- a/external/vulkancts/modules/vulkan/memory/vktMemoryPipelineBarrierTests.cpp +++ b/external/vulkancts/modules/vulkan/memory/vktMemoryPipelineBarrierTests.cpp @@ -7011,10 +7011,10 @@ void RenderFragmentStorageImage::verify (VerifyRenderPassContext& context, size_ const UVec2 pos = UVec2(value.z() * 256u + (value.x() ^ value.z()), value.w() * 256u + (value.y() ^ value.w())); const Vec4 floatValue = context.getReferenceImage().getAccess().getPixel(pos.x() % size.x(), pos.y() % size.y()); - value = UVec4((deUint32)(floatValue.x() * 255.0f), - (deUint32)(floatValue.y() * 255.0f), - (deUint32)(floatValue.z() * 255.0f), - (deUint32)(floatValue.w() * 255.0f)); + value = UVec4((deUint32)round(floatValue.x() * 255.0f), + (deUint32)round(floatValue.y() * 255.0f), + (deUint32)round(floatValue.z() * 255.0f), + (deUint32)round(floatValue.w() * 255.0f)); } context.getReferenceTarget().getAccess().setPixel(value.asFloat() / Vec4(255.0f), x, y); @@ -7219,10 +7219,10 @@ void RenderFragmentSampledImage::verify (VerifyRenderPassContext& context, size_ const UVec2 pos = UVec2(value.z() * 256u + (value.x() ^ value.z()), value.w() * 256u + (value.y() ^ value.w())); const Vec4 floatValue = context.getReferenceImage().getAccess().getPixel(pos.x() % size.x(), pos.y() % size.y()); - value = UVec4((deUint32)(floatValue.x() * 255.0f), - (deUint32)(floatValue.y() * 255.0f), - (deUint32)(floatValue.z() * 255.0f), - (deUint32)(floatValue.w() * 255.0f)); + value = UVec4((deUint32)round(floatValue.x() * 255.0f), + (deUint32)round(floatValue.y() * 255.0f), + (deUint32)round(floatValue.z() * 255.0f), + (deUint32)round(floatValue.w() * 255.0f)); } @@ -9932,7 +9932,7 @@ struct AddPrograms "\tfor (uint i = 0u; i < valuesPerPixel; i++)\n" "\t{\n" "\t\thighp vec4 floatValue = imageLoad(u_image, ivec2(int((value.z * 256u + (value.x ^ value.z)) % size.x), int((value.w * 256u + (value.y ^ value.w)) % size.y)));\n" - "\t\tvalue = uvec4(uint(floatValue.x * 255.0), uint(floatValue.y * 255.0), uint(floatValue.z * 255.0), uint(floatValue.w * 255.0));\n" + "\t\tvalue = uvec4(uint(round(floatValue.x * 255.0)), uint(round(floatValue.y * 255.0)), uint(round(floatValue.z * 255.0)), uint(round(floatValue.w * 255.0)));\n" "\t}\n" "\to_color = vec4(value) / vec4(255.0);\n" "}\n"; @@ -9983,7 +9983,7 @@ struct AddPrograms "\tfor (uint i = 0u; i < valuesPerPixel; i++)\n" "\t{\n" "\t\thighp vec4 floatValue = texelFetch(u_sampler, ivec2(int((value.z * 256u + (value.x ^ value.z)) % size.x), int((value.w * 256u + (value.y ^ value.w)) % size.y)), 0);\n" - "\t\tvalue = uvec4(uint(floatValue.x * 255.0), uint(floatValue.y * 255.0), uint(floatValue.z * 255.0), uint(floatValue.w * 255.0));\n" + "\t\tvalue = uvec4(uint(round(floatValue.x * 255.0)), uint(round(floatValue.y * 255.0)), uint(round(floatValue.z * 255.0)), uint(round(floatValue.w * 255.0)));\n" "\t}\n" "\to_color = vec4(value) / vec4(255.0);\n" "}\n";