Fix #104266: Metal AMD refractions #105967

Merged
Member

Workaround for compiler issue on AMD
platforms resulting in the erroneous
discarding of valid rays in fragment
raytracing.

Authored by Apple: Michael Parkin-White

Workaround for compiler issue on AMD platforms resulting in the erroneous discarding of valid rays in fragment raytracing. Authored by Apple: Michael Parkin-White
Jason Fielder requested review from Jeroen Bakker 2023-03-21 18:54:53 +01:00
Jason Fielder requested review from Clément Foucault 2023-03-21 18:54:54 +01:00
Hans Goudey changed title from Fix #104266: Metal AMD refractions. to Fix #104266: Metal AMD refractions 2023-03-21 19:21:04 +01:00
Clément Foucault approved these changes 2023-03-21 20:48:06 +01:00
Clément Foucault left a comment
Member

Nice find! I'm just adding suggestion to make the code clearer, but the patch is good.

Nice find! I'm just adding suggestion to make the code clearer, but the patch is good.
@ -127,2 +127,4 @@
float lod_fac = saturate(fast_sqrt(params.roughness) * 2.0 - 0.4);
#if defined(GPU_METAL) && defined(GPU_ATI)
bool hit_valid = true;

Suggest: Name it hit_failsafe and move it near bool hit = false;.

Suggest: Name it `hit_failsafe` and move it near `bool hit = false;`.
@ -146,0 +150,4 @@
#if defined(GPU_METAL) && defined(GPU_ATI)
/* NOTE(Metal): Invalidate all future hits using immediate test to avoid side-effects from
* non-uniform control flow. This must only be used to invalidate while hit is false. */
bool raytrace_fail_check =

I would replace it by bool hit_valid = !(discard_backface && prev_delta < 0.0) && (depth_sample != 1.0);
This at least doesn't confuse the reader as of why it is different from the same check at the bottom.

Also !hit operation at the end is always true at this point here so I removed it from the suggestion.

About the comment itself I don't see how this avoid non uniform control flow. So maybe note that this is to avoid a compiler bug.

I would also be tempted to make a METAL_REFRACTION_WORKAROUND define for these #if directive. This would make it clear all these checks are related to the same workaround.

I would replace it by `bool hit_valid = !(discard_backface && prev_delta < 0.0) && (depth_sample != 1.0);` This at least doesn't confuse the reader as of why it is different from the same check at the bottom. Also `!hit` operation at the end is always true at this point here so I removed it from the suggestion. About the comment itself I don't see how this avoid non uniform control flow. So maybe note that this is to avoid a compiler bug. I would also be tempted to make a `METAL_REFRACTION_WORKAROUND` define for these `#if` directive. This would make it clear all these checks are related to the same workaround.
Clément Foucault approved these changes 2023-03-22 09:51:27 +01:00
Clément Foucault force-pushed Fix_104266_MetalAMDRefraction_2 from e5d92615ad to 84e6cbb51e 2023-03-22 09:52:10 +01:00 Compare
Clément Foucault merged commit f73d1ddce4 into blender-v3.5-release 2023-03-22 09:57:40 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#105967
No description provided.