Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2022-09-15 12:44:38 +0300
committerGitHub <noreply@github.com>2022-09-15 12:44:38 +0300
commit6d3518e23849326415129d275d2df40fe3fc6b64 (patch)
treed3544f607dab96822ce473add2c8d4699d64fc68
parent7afbbb624aab20d745f1938db4a23f1c347110b9 (diff)
parent1b9296e1a5e9049de56e7d70103796bb74d56d63 (diff)
Merge pull request #2018 from atyuwen/master
MSL: only fix up gl_FragCoord if really necessary.
-rw-r--r--reference/opt/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag3
-rw-r--r--reference/opt/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag3
-rw-r--r--reference/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag3
-rw-r--r--reference/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag3
-rw-r--r--spirv_cross.cpp5
-rw-r--r--spirv_cross.hpp2
-rw-r--r--spirv_msl.cpp4
7 files changed, 13 insertions, 10 deletions
diff --git a/reference/opt/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag b/reference/opt/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag
index e17515f2..6a7f419a 100644
--- a/reference/opt/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag
+++ b/reference/opt/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag
@@ -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);
diff --git a/reference/opt/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag b/reference/opt/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag
index e17515f2..6a7f419a 100644
--- a/reference/opt/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag
+++ b/reference/opt/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag
@@ -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);
diff --git a/reference/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag b/reference/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag
index 5017be6c..d7a1993d 100644
--- a/reference/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag
+++ b/reference/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag
@@ -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);
diff --git a/reference/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag b/reference/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag
index 5017be6c..d7a1993d 100644
--- a/reference/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag
+++ b/reference/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag
@@ -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);
diff --git a/spirv_cross.cpp b/spirv_cross.cpp
index 599a3232..3f30ee93 100644
--- a/spirv_cross.cpp
+++ b/spirv_cross.cpp
@@ -4439,6 +4439,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)
@@ -4605,7 +4606,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)
diff --git a/spirv_cross.hpp b/spirv_cross.hpp
index 783af1e2..f1c347dd 100644
--- a/spirv_cross.hpp
+++ b/spirv_cross.hpp
@@ -931,6 +931,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,
@@ -970,6 +971,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);
};
diff --git a/spirv_msl.cpp b/spirv_msl.cpp
index 60b35021..9610bfa8 100644
--- a/spirv_msl.cpp
+++ b/spirv_msl.cpp
@@ -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())
@@ -12071,7 +12071,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