Bug Ambient Occlusion +Texture not working. Apple M1 GPU Rendering #94050

Closed
opened 2021-12-14 09:57:15 +01:00 by Gerrit · 12 comments

GPU.png

{F12739017}System Information
Operating system: 'macOS-12.0.1-arm64-arm-64bit'
Graphics card: Apple M1 8 Core GPU '4.1 Metal - 76.1' / 8 Core CPU. 16GB

Blender Version
Broken:
version: 3.1.0 Alpha, branch: master, commit date: 2021-12-14 00:16, hash: c1f5d8d023, type: release
build date: 2021-12-14, 00:59:09

Ambient Occlusion is not working together with texture input. Resulting in black Material (GPU Rendering!)

CPU Rendering is fine.

Exact steps for others to reproduce the error
Switch to GPU Rendering. Add Ambient Occlusion Shader with texture to shader node.

![GPU.png](https://archive.blender.org/developer/F12739018/GPU.png) {[F12739017](https://archive.blender.org/developer/F12739017/CPU.png)}**System Information** Operating system: 'macOS-12.0.1-arm64-arm-64bit' Graphics card: Apple M1 8 Core GPU '4.1 Metal - 76.1' / 8 Core CPU. 16GB **Blender Version** Broken: version: 3.1.0 Alpha, branch: master, commit date: 2021-12-14 00:16, hash: c1f5d8d023c6, type: release build date: 2021-12-14, 00:59:09 Ambient Occlusion is not working together with texture input. Resulting in black Material (GPU Rendering!) CPU Rendering is fine. **Exact steps for others to reproduce the error** Switch to GPU Rendering. Add Ambient Occlusion Shader with texture to shader node.
Author

Added subscriber: @Khameir

Added subscriber: @Khameir
Gerrit changed title from Ambient Occlusion +Texture not working. Apple M1 GPU Rendering to Bug Ambient Occlusion +Texture not working. Apple M1 GPU Rendering 2021-12-14 10:02:39 +01:00

Added subscribers: @Michael-Jones, @brecht

Added subscribers: @Michael-Jones, @brecht

CC @michael_jones.

CC @michael_jones.

I found a workaround after some experimentation:

diff --git a/intern/cycles/kernel/device/gpu/kernel.h b/intern/cycles/kernel/device/gpu/kernel.h
index b50f492e8c7..0c93d3fcf77 100644
--- a/intern/cycles/kernel/device/gpu/kernel.h
+++ b/intern/cycles/kernel/device/gpu/kernel.h
@@ -243,6 +243,10 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
   }
 }
 
+#ifdef __KERNEL_METAL_APPLE__
+constant int __dummy_constant [[function_constant(0)]];
+#endif
+
 ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
     ccl_gpu_kernel_signature(integrator_shade_surface_raytrace,
                              ccl_global const int *path_index_array,
@@ -253,7 +257,14 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS)
 
   if (global_index < work_size) {
     const int state = (path_index_array) ? path_index_array[global_index] : global_index;
-    ccl_gpu_kernel_call(integrator_shade_surface_raytrace(NULL, state, render_buffer));
+
+    KernelGlobals kg = NULL;
+#ifdef __KERNEL_METAL_APPLE__
+    /* T94050: Bug Ambient Occlusion +Texture not working. Apple M1 GPU Rendering */
+    /* Workaround: Dummy offset should not affect result, but somehow fixes bug! */
+    kg +=__dummy_constant;
+#endif
+    ccl_gpu_kernel_call(integrator_shade_surface_raytrace(kg, state, render_buffer));
   }
 }
 
I found a workaround after some experimentation: ``` diff --git a/intern/cycles/kernel/device/gpu/kernel.h b/intern/cycles/kernel/device/gpu/kernel.h index b50f492e8c7..0c93d3fcf77 100644 --- a/intern/cycles/kernel/device/gpu/kernel.h +++ b/intern/cycles/kernel/device/gpu/kernel.h @@ -243,6 +243,10 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) } } +#ifdef __KERNEL_METAL_APPLE__ +constant int __dummy_constant [[function_constant(0)]]; +#endif + ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) ccl_gpu_kernel_signature(integrator_shade_surface_raytrace, ccl_global const int *path_index_array, @@ -253,7 +257,14 @@ ccl_gpu_kernel(GPU_KERNEL_BLOCK_NUM_THREADS, GPU_KERNEL_MAX_REGISTERS) if (global_index < work_size) { const int state = (path_index_array) ? path_index_array[global_index] : global_index; - ccl_gpu_kernel_call(integrator_shade_surface_raytrace(NULL, state, render_buffer)); + + KernelGlobals kg = NULL; +#ifdef __KERNEL_METAL_APPLE__ + /* T94050: Bug Ambient Occlusion +Texture not working. Apple M1 GPU Rendering */ + /* Workaround: Dummy offset should not affect result, but somehow fixes bug! */ + kg +=__dummy_constant; +#endif + ccl_gpu_kernel_call(integrator_shade_surface_raytrace(kg, state, render_buffer)); } } ```

The workaround makes very little sense to me at present, but is being investigated further.

The workaround makes very little sense to me at present, but is being investigated further.

It's fine with me to commit that workaround if it takes a while for the proper fix to come.

It's fine with me to commit that workaround if it takes a while for the proper fix to come.

Added subscriber: @Staars

Added subscriber: @Staars

BTW, in my tests this fixes #94570 and #94527 too.

BTW, in my tests this fixes #94570 and #94527 too.

This issue was referenced by blender/cycles@125decca34

This issue was referenced by blender/cycles@125decca343a93008777de21c6f27458f11598b8

This issue was referenced by 0cf2fafd81

This issue was referenced by 0cf2fafd81442518927a594e422ad2b26b54527a

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Brecht Van Lommel self-assigned this 2022-01-13 10:51:37 +01:00

I committed the workaround for now.

I committed the workaround for now.
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
5 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#94050
No description provided.