Handle odd type for textureGather component.
This commit is contained in:
parent
585fc6f3cb
commit
165dbff228
@ -0,0 +1,29 @@
|
||||
Texture2D<float4> uSamp : register(t0);
|
||||
SamplerState _uSamp_sampler : register(s0);
|
||||
|
||||
static float4 FragColor;
|
||||
static float2 vUV;
|
||||
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
float2 vUV : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float4 FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
FragColor = uSamp.GatherGreen(_uSamp_sampler, vUV);
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
vUV = stage_input.vUV;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
return stage_output;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 vUV [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> uSamp [[texture(0)]], sampler uSampSmplr [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.FragColor = uSamp.gather(uSampSmplr, in.vUV, int2(0), component::y);
|
||||
return out;
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
#version 450
|
||||
|
||||
layout(binding = 0) uniform sampler2D uSamp;
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
layout(location = 0) in vec2 vUV;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = textureGather(uSamp, vUV, int(1u));
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos Glslang Reference Front End; 10
|
||||
; Bound: 22
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %FragColor %vUV
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %FragColor "FragColor"
|
||||
OpName %uSamp "uSamp"
|
||||
OpName %vUV "vUV"
|
||||
OpDecorate %FragColor Location 0
|
||||
OpDecorate %uSamp DescriptorSet 0
|
||||
OpDecorate %uSamp Binding 0
|
||||
OpDecorate %vUV Location 0
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%FragColor = OpVariable %_ptr_Output_v4float Output
|
||||
%10 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||
%11 = OpTypeSampledImage %10
|
||||
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
||||
%uSamp = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||
%v2float = OpTypeVector %float 2
|
||||
%_ptr_Input_v2float = OpTypePointer Input %v2float
|
||||
%vUV = OpVariable %_ptr_Input_v2float Input
|
||||
%int = OpTypeInt 32 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
%14 = OpLoad %11 %uSamp
|
||||
%18 = OpLoad %v2float %vUV
|
||||
%21 = OpImageGather %v4float %14 %18 %int_1
|
||||
OpStore %FragColor %21
|
||||
OpReturn
|
||||
OpFunctionEnd
|
@ -0,0 +1,42 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos Glslang Reference Front End; 10
|
||||
; Bound: 22
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %FragColor %vUV
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %FragColor "FragColor"
|
||||
OpName %uSamp "uSamp"
|
||||
OpName %vUV "vUV"
|
||||
OpDecorate %FragColor Location 0
|
||||
OpDecorate %uSamp DescriptorSet 0
|
||||
OpDecorate %uSamp Binding 0
|
||||
OpDecorate %vUV Location 0
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%FragColor = OpVariable %_ptr_Output_v4float Output
|
||||
%10 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||
%11 = OpTypeSampledImage %10
|
||||
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
||||
%uSamp = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||
%v2float = OpTypeVector %float 2
|
||||
%_ptr_Input_v2float = OpTypePointer Input %v2float
|
||||
%vUV = OpVariable %_ptr_Input_v2float Input
|
||||
%int = OpTypeInt 32 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
%14 = OpLoad %11 %uSamp
|
||||
%18 = OpLoad %v2float %vUV
|
||||
%21 = OpImageGather %v4float %14 %18 %int_1
|
||||
OpStore %FragColor %21
|
||||
OpReturn
|
||||
OpFunctionEnd
|
42
shaders-no-opt/frag/texture-gather-uint-component.asm.frag
Normal file
42
shaders-no-opt/frag/texture-gather-uint-component.asm.frag
Normal file
@ -0,0 +1,42 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos Glslang Reference Front End; 10
|
||||
; Bound: 22
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %FragColor %vUV
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %FragColor "FragColor"
|
||||
OpName %uSamp "uSamp"
|
||||
OpName %vUV "vUV"
|
||||
OpDecorate %FragColor Location 0
|
||||
OpDecorate %uSamp DescriptorSet 0
|
||||
OpDecorate %uSamp Binding 0
|
||||
OpDecorate %vUV Location 0
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%FragColor = OpVariable %_ptr_Output_v4float Output
|
||||
%10 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||
%11 = OpTypeSampledImage %10
|
||||
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
||||
%uSamp = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||
%v2float = OpTypeVector %float 2
|
||||
%_ptr_Input_v2float = OpTypePointer Input %v2float
|
||||
%vUV = OpVariable %_ptr_Input_v2float Input
|
||||
%int = OpTypeInt 32 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
%14 = OpLoad %11 %uSamp
|
||||
%18 = OpLoad %v2float %vUV
|
||||
%21 = OpImageGather %v4float %14 %18 %int_1
|
||||
OpStore %FragColor %21
|
||||
OpReturn
|
||||
OpFunctionEnd
|
@ -7108,7 +7108,11 @@ string CompilerGLSL::to_function_args(const TextureFunctionArguments &args, bool
|
||||
{
|
||||
forward = forward && should_forward(args.component);
|
||||
farg_str += ", ";
|
||||
farg_str += to_expression(args.component);
|
||||
auto &component_type = expression_type(args.component);
|
||||
if (component_type.basetype == SPIRType::Int)
|
||||
farg_str += to_expression(args.component);
|
||||
else
|
||||
farg_str += join("int(", to_expression(args.component), ")");
|
||||
}
|
||||
|
||||
*p_forward = forward;
|
||||
|
Loading…
Reference in New Issue
Block a user