Commit a972758d by Nicolas Capens Committed by Nicolas Capens

Work around Subzero constant folding limitation.

The Subzero JIT only supports constants in the second operand of arithmetic operations, not the first. It assumes constant folding already took place (true for NaCl which takes LLVM IR as input). Reactor has constant folding as part of the static C++ compilation, but the Optimizer may substitute the first operand for a constant (i.e. constant propagation). Addressing it in the Optimizer by not performing the substitution is not trivial because we'd have to check each use. And it would cost run-time performance. Ideally we'd have a pass for legalization/optimization which performs constant folding. For now, avoid hitting 'unreachable' code in Subzero by multiplying constants at the Reactor level. Fixes regression caused by https://swiftshader-review.googlesource.com/22910 Bug chromium:904265 Bug swiftshader:14 Change-Id: Ifdc72ac997ad5d71c1f7006259f54f3d715cb613 Reviewed-on: https://swiftshader-review.googlesource.com/c/22930Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 79d0e565
...@@ -1255,8 +1255,8 @@ namespace sw ...@@ -1255,8 +1255,8 @@ namespace sw
void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1) void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
{ {
bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID); bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID);
Int index = uniformSampler ? src1.index : As<Int>(Float(fetchRegister(src1).x.x)); Int offset = uniformSampler ? src1.index * sizeof(Texture) : As<Int>(Float(fetchRegister(src1).x.x)) * sizeof(Texture);
Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + index * sizeof(Texture); Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + offset;
dst = SamplerCore::textureSize(texture, lod); dst = SamplerCore::textureSize(texture, lod);
} }
......
...@@ -1525,8 +1525,8 @@ namespace sw ...@@ -1525,8 +1525,8 @@ namespace sw
void VertexProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1) void VertexProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
{ {
bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID); bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID);
Int index = uniformSampler ? src1.index : As<Int>(Float(fetchRegister(src1).x.x)); Int offset = uniformSampler ? src1.index * sizeof(Texture) : As<Int>(Float(fetchRegister(src1).x.x)) * sizeof(Texture);
Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + index * sizeof(Texture); Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + offset;
dst = SamplerCore::textureSize(texture, lod); dst = SamplerCore::textureSize(texture, lod);
} }
......
...@@ -1280,8 +1280,8 @@ namespace sw ...@@ -1280,8 +1280,8 @@ namespace sw
void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1) void PixelProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
{ {
bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID); bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID);
Int index = uniformSampler ? src1.index : As<Int>(Float(fetchRegister(src1).x.x)); Int offset = uniformSampler ? src1.index * sizeof(Texture) : As<Int>(Float(fetchRegister(src1).x.x)) * sizeof(Texture);
Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + index * sizeof(Texture); Pointer<Byte> texture = data + OFFSET(DrawData, mipmap) + offset;
dst = SamplerCore::textureSize(texture, lod); dst = SamplerCore::textureSize(texture, lod);
} }
......
...@@ -1609,8 +1609,8 @@ namespace sw ...@@ -1609,8 +1609,8 @@ namespace sw
void VertexProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1) void VertexProgram::TEXSIZE(Vector4f &dst, Float4 &lod, const Src &src1)
{ {
bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID); bool uniformSampler = (src1.type == Shader::PARAMETER_SAMPLER && src1.rel.type == Shader::PARAMETER_VOID);
Int index = uniformSampler ? src1.index : As<Int>(Float(fetchRegister(src1).x.x)); Int offset = uniformSampler ? src1.index * sizeof(Texture) : As<Int>(Float(fetchRegister(src1).x.x)) * sizeof(Texture);
Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + index * sizeof(Texture); Pointer<Byte> texture = data + OFFSET(DrawData, mipmap[TEXTURE_IMAGE_UNITS]) + offset;
dst = SamplerCore::textureSize(texture, lod); dst = SamplerCore::textureSize(texture, lod);
} }
......
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