Commit 19a0081c by Nicolas Capens Committed by Nicolas Capens

Fix cubemap sampling at (0, 0, 0) division by zero

Whichever direction was chosen as the 'major' one, a division by zero occurred when trying to project to its corresponding face. Prevent it by ensuring 'M' is greater than zero. Bug: b/132981873 Test: dEQP-VK.glsl.opaque_type_indexing.sampler.const_literal.compute.samplercube Change-Id: I71c25be4d8e17409cc9bf32a2f6180db9a948d34 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31729 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 8d548b6c
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "Vulkan/VkSampler.hpp" #include "Vulkan/VkSampler.hpp"
#include "Vulkan/VkDebug.hpp" #include "Vulkan/VkDebug.hpp"
#include <limits>
namespace namespace
{ {
void applySwizzle(VkComponentSwizzle swizzle, sw::Float4& f, const sw::Vector4f& c, bool integer) void applySwizzle(VkComponentSwizzle swizzle, sw::Float4& f, const sw::Vector4f& c, bool integer)
...@@ -1126,7 +1128,7 @@ namespace sw ...@@ -1126,7 +1128,7 @@ namespace sw
face[3] = (face[0] >> 12) & 0x7; face[3] = (face[0] >> 12) & 0x7;
face[0] &= 0x7; face[0] &= 0x7;
M = Max(Max(absX, absY), absZ); M = Max(Max(absX, absY), Max(absZ, Float4(std::numeric_limits<float>::min())));
// U = xMajor ? (neg ^ -z) : ((zMajor & neg) ^ x) // U = xMajor ? (neg ^ -z) : ((zMajor & neg) ^ x)
U = As<Float4>((xMajor & (n ^ As<Int4>(-z))) | (~xMajor & ((zMajor & n) ^ As<Int4>(x)))); U = As<Float4>((xMajor & (n ^ As<Int4>(-z))) | (~xMajor & ((zMajor & n) ^ As<Int4>(x))));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment