Need to make sure the fetch expression is uint.

This commit is contained in:
Hans-Kristian Arntzen 2018-08-07 16:02:17 +02:00
parent eee290a029
commit 981d7c1d85
3 changed files with 14 additions and 6 deletions

View File

@ -12,8 +12,8 @@ fragment main0_out main0(texture2d<float> uTexture [[texture(0)]], sampler uText
{
main0_out out = {};
int2 _22 = int2(gl_FragCoord.xy);
out.FragColor = uTexture.read(uint2(_22) + int2(1), 0);
out.FragColor += uTexture.read(uint2(_22) + int2(-1, 1), 0);
out.FragColor = uTexture.read(uint2(_22) + uint2(int2(1)), 0);
out.FragColor += uTexture.read(uint2(_22) + uint2(int2(-1, 1)), 0);
return out;
}

View File

@ -11,8 +11,8 @@ struct main0_out
fragment main0_out main0(texture2d<float> uTexture [[texture(0)]], sampler uTextureSmplr [[sampler(0)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
out.FragColor = uTexture.read(uint2(int2(gl_FragCoord.xy)) + int2(1), 0);
out.FragColor += uTexture.read(uint2(int2(gl_FragCoord.xy)) + int2(-1, 1), 0);
out.FragColor = uTexture.read(uint2(int2(gl_FragCoord.xy)) + uint2(int2(1)), 0);
out.FragColor += uTexture.read(uint2(int2(gl_FragCoord.xy)) + uint2(int2(-1, 1)), 0);
return out;
}

View File

@ -2556,13 +2556,21 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
{
// Fetch offsets must be applied directly to the coordinate.
forward = forward && should_forward(offset);
tex_coords += " + " + to_enclosed_expression(offset);
auto &type = expression_type(offset);
if (type.basetype != SPIRType::UInt)
tex_coords += " + " + bitcast_expression(SPIRType::UInt, offset);
else
tex_coords += " + " + to_enclosed_expression(offset);
}
else if (is_fetch && coffset)
{
// Fetch offsets must be applied directly to the coordinate.
forward = forward && should_forward(coffset);
tex_coords += " + " + to_enclosed_expression(coffset);
auto &type = expression_type(coffset);
if (type.basetype != SPIRType::UInt)
tex_coords += " + " + bitcast_expression(SPIRType::UInt, coffset);
else
tex_coords += " + " + to_enclosed_expression(coffset);
}
// If projection, use alt coord as divisor