Compiler MSL default gather offset when component specified.

This commit is contained in:
Bill Hollings 2018-04-30 16:30:29 -04:00
parent 8f07df016b
commit 57213cb7ca
4 changed files with 49 additions and 6 deletions

View File

@ -0,0 +1,17 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(texture2d<float> uT [[texture(0)]], sampler uTSmplr [[sampler(0)]])
{
main0_out out = {};
out.FragColor = uT.gather(uTSmplr, float2(0.5), int2(0), component::w);
return out;
}

View File

@ -0,0 +1,17 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(texture2d<float> uT [[texture(0)]], sampler uTSmplr [[sampler(0)]])
{
main0_out out = {};
out.FragColor = uT.gather(uTSmplr, float2(0.5), int2(0), component::w);
return out;
}

View File

@ -0,0 +1,9 @@
#version 450
layout(binding = 0) uniform sampler2D uT;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = textureGather(uT, vec2(0.5), 3);
}

View File

@ -2658,21 +2658,17 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
{
switch (imgtype.image.dim)
{
case Dim1D:
if (coord_type.vecsize > 1)
offset_expr = enclose_expression(offset_expr) + ".x";
farg_str += ", " + offset_expr;
break;
case Dim2D:
if (coord_type.vecsize > 2)
offset_expr = enclose_expression(offset_expr) + ".xy";
farg_str += ", " + offset_expr;
break;
case Dim3D:
if (coord_type.vecsize > 3)
offset_expr = enclose_expression(offset_expr) + ".xyz";
farg_str += ", " + offset_expr;
break;
@ -2683,6 +2679,10 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
if (comp)
{
// If 2D has gather component, ensure it also has an offset arg
if (imgtype.image.dim == Dim2D && offset_expr.empty())
farg_str += ", int2(0)";
forward = forward && should_forward(comp);
farg_str += ", " + to_component_argument(comp);
}