mirror of
https://github.com/KhronosGroup/SPIRV-Cross.git
synced 2024-11-13 23:50:08 +00:00
MSL: only fix up gl_FragCoord if really necessary.
This commit is contained in:
parent
f6ca617825
commit
1b9296e1a5
@ -197,10 +197,9 @@ struct main0_out
|
||||
float4 out_var_SV_Target0 [[color(0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d<float> ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]])
|
||||
fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d<float> ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]])
|
||||
{
|
||||
main0_out out = {};
|
||||
gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5;
|
||||
float4 _67 = _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData;
|
||||
float _68 = _67.w;
|
||||
float4 _82 = _Globals.ScreenToShadowMatrix * float4((fma(gl_FragCoord.xy, View.View_BufferSizeAndInvSize.zw, -View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_68), _68, 1.0);
|
||||
|
@ -197,10 +197,9 @@ struct main0_out
|
||||
float4 out_var_SV_Target0 [[color(0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d<float> ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]])
|
||||
fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d<float> ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]])
|
||||
{
|
||||
main0_out out = {};
|
||||
gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5;
|
||||
float4 _67 = _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData;
|
||||
float _68 = _67.w;
|
||||
float4 _82 = _Globals.ScreenToShadowMatrix * float4((fma(gl_FragCoord.xy, View.View_BufferSizeAndInvSize.zw, -View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_68), _68, 1.0);
|
||||
|
@ -197,10 +197,9 @@ struct main0_out
|
||||
float4 out_var_SV_Target0 [[color(0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d<float> ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]])
|
||||
fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d<float> ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]])
|
||||
{
|
||||
main0_out out = {};
|
||||
gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5;
|
||||
float4 _67 = _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData;
|
||||
float _68 = _67.w;
|
||||
float4 _82 = _Globals.ScreenToShadowMatrix * float4((((gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw) - View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_68), _68, 1.0);
|
||||
|
@ -197,10 +197,9 @@ struct main0_out
|
||||
float4 out_var_SV_Target0 [[color(0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d<float> ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]])
|
||||
fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d<float> ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]])
|
||||
{
|
||||
main0_out out = {};
|
||||
gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5;
|
||||
float4 _67 = _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData;
|
||||
float _68 = _67.w;
|
||||
float4 _82 = _Globals.ScreenToShadowMatrix * float4((((gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw) - View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_68), _68, 1.0);
|
||||
|
@ -4426,6 +4426,7 @@ void Compiler::analyze_image_and_sampler_usage()
|
||||
|
||||
comparison_ids = std::move(handler.comparison_ids);
|
||||
need_subpass_input = handler.need_subpass_input;
|
||||
need_subpass_input_ms = handler.need_subpass_input_ms;
|
||||
|
||||
// Forward information from separate images and samplers into combined image samplers.
|
||||
for (auto &combined : combined_image_samplers)
|
||||
@ -4592,7 +4593,11 @@ bool Compiler::CombinedImageSamplerUsageHandler::handle(Op opcode, const uint32_
|
||||
// If we load an image, we're going to use it and there is little harm in declaring an unused gl_FragCoord.
|
||||
auto &type = compiler.get<SPIRType>(args[0]);
|
||||
if (type.image.dim == DimSubpassData)
|
||||
{
|
||||
need_subpass_input = true;
|
||||
if (type.image.ms)
|
||||
need_subpass_input_ms = true;
|
||||
}
|
||||
|
||||
// If we load a SampledImage and it will be used with Dref, propagate the state up.
|
||||
if (dref_combined_samplers.count(args[1]) != 0)
|
||||
|
@ -930,6 +930,7 @@ protected:
|
||||
// Similar is implemented for images, as well as if subpass inputs are needed.
|
||||
std::unordered_set<uint32_t> comparison_ids;
|
||||
bool need_subpass_input = false;
|
||||
bool need_subpass_input_ms = false;
|
||||
|
||||
// In certain backends, we will need to use a dummy sampler to be able to emit code.
|
||||
// GLSL does not support texelFetch on texture2D objects, but SPIR-V does,
|
||||
@ -969,6 +970,7 @@ protected:
|
||||
|
||||
void add_hierarchy_to_comparison_ids(uint32_t ids);
|
||||
bool need_subpass_input = false;
|
||||
bool need_subpass_input_ms = false;
|
||||
void add_dependency(uint32_t dst, uint32_t src);
|
||||
};
|
||||
|
||||
|
@ -1532,7 +1532,7 @@ void CompilerMSL::preprocess_op_codes()
|
||||
// that function would add gl_FragCoord.
|
||||
if (preproc.needs_sample_id || msl_options.force_sample_rate_shading ||
|
||||
(is_sample_rate() && (active_input_builtins.get(BuiltInFragCoord) ||
|
||||
(need_subpass_input && !msl_options.use_framebuffer_fetch_subpasses))))
|
||||
(need_subpass_input_ms && !msl_options.use_framebuffer_fetch_subpasses))))
|
||||
needs_sample_id = true;
|
||||
|
||||
if (is_intersection_query())
|
||||
@ -12036,7 +12036,7 @@ bool CompilerMSL::is_sample_rate() const
|
||||
return get_execution_model() == ExecutionModelFragment &&
|
||||
(msl_options.force_sample_rate_shading ||
|
||||
std::find(caps.begin(), caps.end(), CapabilitySampleRateShading) != caps.end() ||
|
||||
(msl_options.use_framebuffer_fetch_subpasses && need_subpass_input));
|
||||
(msl_options.use_framebuffer_fetch_subpasses && need_subpass_input_ms));
|
||||
}
|
||||
|
||||
bool CompilerMSL::is_intersection_query() const
|
||||
|
Loading…
Reference in New Issue
Block a user