Fix GatherDref on GLSL.

This commit is contained in:
Hans-Kristian Arntzen 2018-04-30 12:45:23 +02:00
parent 6b478c928d
commit 47081f810a
7 changed files with 96 additions and 2 deletions

View File

@ -0,0 +1,22 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_in
{
float3 vUV [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uT [[texture(0)]], sampler uTSmplr [[sampler(0)]])
{
main0_out out = {};
out.FragColor = uT.gather_compare(uTSmplr, in.vUV.xy, in.vUV.z);
return out;
}

View File

@ -0,0 +1,14 @@
#version 310 es
precision mediump float;
precision highp int;
layout(binding = 0) uniform mediump sampler2DShadow uT;
layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec3 vUV;
void main()
{
FragColor = textureGather(uT, vUV.xy, vUV.z);
}

View File

@ -0,0 +1,22 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_in
{
float3 vUV [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uT [[texture(0)]], sampler uTSmplr [[sampler(0)]])
{
main0_out out = {};
out.FragColor = uT.gather_compare(uTSmplr, in.vUV.xy, in.vUV.z);
return out;
}

View File

@ -0,0 +1,14 @@
#version 310 es
precision mediump float;
precision highp int;
layout(binding = 0) uniform mediump sampler2DShadow uT;
layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec3 vUV;
void main()
{
FragColor = textureGather(uT, vUV.xy, vUV.z);
}

View File

@ -0,0 +1,11 @@
#version 310 es
precision mediump float;
layout(binding = 0) uniform mediump sampler2DShadow uT;
layout(location = 0) in vec3 vUV;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = textureGather(uT, vUV.xy, vUV.z);
}

View File

@ -0,0 +1,11 @@
#version 310 es
precision mediump float;
layout(binding = 0) uniform mediump sampler2DShadow uT;
layout(location = 0) in vec3 vUV;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = textureGather(uT, vUV.xy, vUV.z);
}

View File

@ -3940,7 +3940,7 @@ std::string CompilerGLSL::convert_separate_image_to_combined(uint32_t id)
}
// Returns the function args for a texture sampling function for the specified image and sampling characteristics.
string CompilerGLSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool, bool is_proj,
string CompilerGLSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj,
uint32_t coord, uint32_t coord_components, uint32_t dref, uint32_t grad_x,
uint32_t grad_y, uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias,
uint32_t comp, uint32_t sample, bool *p_forward)
@ -3998,7 +3998,7 @@ string CompilerGLSL::to_function_args(uint32_t img, const SPIRType &imgtype, boo
forward = forward && should_forward(dref);
// SPIR-V splits dref and coordinate.
if (coord_components == 4) // GLSL also splits the arguments in two.
if (is_gather || coord_components == 4) // GLSL also splits the arguments in two. Same for textureGather.
{
farg_str += ", ";
farg_str += to_expression(coord);