Fix T103412: Resolve selection outline rendering with Metal backend on AMD.
AMD GPUs do not appear to produce consistent results with other GPUs when using textureGather in the Metal backend. Disabling for now to ensure correct function of outline rendering. This may require an additional sub-pixel offset in the texture sampling calls, to achieve correct behaviour. Authored by Apple: Michael Parkin-White Ref T103412 Ref T96261 Reviewed By: fclem Maniphest Tasks: T103412, T96261 Differential Revision: https://developer.blender.org/D16934
This commit is contained in:
parent
48b82a6ea3
commit
cd2926fb05
Notes:
blender-bot
2023-02-14 09:48:25 +01:00
Referenced by issue #103412, 3.5 Metal Backend Selected- Object selected Outline Missing Referenced by issue #96261, Metal Viewport
|
@ -254,7 +254,11 @@ void main()
|
|||
edge_case += int(has_edge_neg_y) * YNEG;
|
||||
|
||||
if (edge_case == ALL || edge_case == NONE) {
|
||||
/* NOTE(Metal): Discards are not explicit returns in Metal. We should also return to avoid
|
||||
* erroneous derivatives which can manifest during texture sampling in
|
||||
* non-uniform-control-flow. */
|
||||
discard;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!doAntiAliasing) {
|
||||
|
|
|
@ -358,6 +358,9 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
|
|||
supportsFamily:MTLGPUFamilyMacCatalyst1];
|
||||
MTLBackend::capabilities.supports_family_mac_catalyst2 = [device
|
||||
supportsFamily:MTLGPUFamilyMacCatalyst2];
|
||||
/* NOTE(Metal): Texture gather is supported on AMD, but results are non consistent
|
||||
* with Apple Silicon GPUs. Disabling for now to avoid erroneous rendering. */
|
||||
MTLBackend::capabilities.supports_texture_gather = [device hasUnifiedMemory];
|
||||
|
||||
/* Common Global Capabilities. */
|
||||
GCaps.max_texture_size = ([device supportsFamily:MTLGPUFamilyApple3] ||
|
||||
|
|
|
@ -36,6 +36,7 @@ struct MTLCapabilities {
|
|||
bool supports_memory_barriers = false;
|
||||
bool supports_sampler_border_color = false;
|
||||
bool supports_argument_buffers_tier2 = false;
|
||||
bool supports_texture_gather = false;
|
||||
|
||||
/* GPU Family */
|
||||
bool supports_family_mac1 = false;
|
||||
|
|
|
@ -569,10 +569,16 @@ bool MTLShader::generate_msl_from_glsl(const shader::ShaderCreateInfo *info)
|
|||
/* Concatenate msl_shader_defines to provide functionality mapping
|
||||
* from GLSL to MSL. Also include additional GPU defines for
|
||||
* optional high-level feature support. */
|
||||
const std::string msl_defines_string =
|
||||
std::string msl_defines_string =
|
||||
"#define GPU_ARB_texture_cube_map_array 1\n\
|
||||
#define GPU_ARB_shader_draw_parameters 1\n\
|
||||
#define GPU_ARB_texture_gather 1\n";
|
||||
#define GPU_ARB_shader_draw_parameters 1\n";
|
||||
|
||||
/* NOTE(Metal): textureGather appears to not function correctly on non-Apple-silicon GPUs.
|
||||
* Manifests as selection outlines not showing up (T103412). Disable texture gather if
|
||||
* not suitable for use. */
|
||||
if (MTLBackend::get_capabilities().supports_texture_gather) {
|
||||
msl_defines_string += "#define GPU_ARB_texture_gather 1\n";
|
||||
}
|
||||
|
||||
shd_builder_->glsl_vertex_source_ = msl_defines_string + shd_builder_->glsl_vertex_source_;
|
||||
if (!msl_iface.uses_transform_feedback) {
|
||||
|
|
Loading…
Reference in New Issue