GPU: Print shader source on compilation error #116470

Merged
Miguel Pozo merged 3 commits from pragma37/blender:pull-gpu-better-shader-log into main 2024-02-26 17:30:25 +01:00
Member

Add a define (DEBUG_LOG_SHADER_SRC_ON_ERROR ) in gpu_shader_private.h
to print the full source code of shaders that fail to compile.

Add a define (DEBUG_LOG_SHADER_SRC_ON_ERROR ) in `gpu_shader_private.h` to print the full source code of shaders that fail to compile.
Miguel Pozo added the
Module
EEVEE & Viewport
label 2023-12-22 17:45:53 +01:00
Miguel Pozo added 1 commit 2023-12-22 17:46:05 +01:00
Miguel Pozo requested review from Jeroen Bakker 2024-01-08 18:40:07 +01:00
Miguel Pozo requested review from Clément Foucault 2024-01-08 18:40:07 +01:00
Author
Member

I did this when looking into #115226.
Not sure if you guys think it's a good idea or if you would prefer to enable the option in some other way.
Printing the whole source code can be slow, but at the same time, if you're debugging and there's a shader compilation error, that's probably what you are looking for in the first place.

I did this when looking into #115226. Not sure if you guys think it's a good idea or if you would prefer to enable the option in some other way. Printing the whole source code can be slow, but at the same time, if you're debugging and there's a shader compilation error, that's probably what you are looking for in the first place.

I wouldn't do this. This is uneeded 95% of the time.
But you have a point that it is useful if you want to diff two shaders.
Usually you want to compare two part of the code not the whole shader.

This is not readable (and slow) in the console so I would suggest to write the shader code to a file instead. About keeping it behing G_DEBUG_GPU, I'm not sure. I would say it is preferable to have a #define option instead.

I wouldn't do this. This is uneeded 95% of the time. But you have a point that it is useful if you want to diff two shaders. Usually you want to compare two part of the code not the whole shader. This is not readable (and slow) in the console so I would suggest to write the shader code to a file instead. About keeping it behing `G_DEBUG_GPU`, I'm not sure. I would say it is preferable to have a `#define` option instead.
Member

+1 for using a define. I normally just add a print statement in the logger..

+1 for using a define. I normally just add a print statement in the logger..
Author
Member

This is uneeded 95% of the time.

Yes, but that 95% of the time it's not going to print anything, that's why I thought just enabling it in GPU debug mode might be ok.
But a define would be ok too.

Usually you want to compare two part of the code not the whole shader.

I think, ideally, you want to see only the generated code, and keep the require statements as-is without inlining them. That would probably be the best solution, but it's not trivial to implement.

so I would suggest to write the shader code to a file instead.

Sounds good to me. Something like a shader_compiler_error.log in the Blender root directory?

I normally just add a print statement in the logger..

The issue is this doesn't work for linking errors, because the source is no longer available.

> This is uneeded 95% of the time. Yes, but that 95% of the time it's not going to print anything, that's why I thought just enabling it in GPU debug mode might be ok. But a define would be ok too. > Usually you want to compare two part of the code not the whole shader. I think, ideally, you want to see only the generated code, and keep the `require` statements as-is without inlining them. That would probably be the best solution, but it's not trivial to implement. > so I would suggest to write the shader code to a file instead. Sounds good to me. Something like a `shader_compiler_error.log` in the Blender root directory? > I normally just add a print statement in the logger.. The issue is this doesn't work for linking errors, because the source is no longer available.

Yes, but that 95% of the time it's not going to print anything

If you mean the shader logger is not working on some platform we should improve and fix it.

I think, ideally, you want to see only the generated code, and keep the require statements as-is without inlining them. That would probably be the best solution, but it's not trivial to implement.

I'm not sure what you mean by that. Do you mean you want the name of the required files + the generated code?

Something like a shader_compiler_error.log in the Blender root directory?

I would use current working directory. It's easier to find.

The issue is this doesn't work for linking errors

That unfortunate yes. I'm not sure what we can do about this.

> Yes, but that 95% of the time it's not going to print anything If you mean the shader logger is not working on some platform we should improve and fix it. > I think, ideally, you want to see only the generated code, and keep the require statements as-is without inlining them. That would probably be the best solution, but it's not trivial to implement. I'm not sure what you mean by that. Do you mean you want the name of the required files + the generated code? > Something like a shader_compiler_error.log in the Blender root directory? I would use current working directory. It's easier to find. > The issue is this doesn't work for linking errors That unfortunate yes. I'm not sure what we can do about this.
Clément Foucault requested changes 2024-02-25 17:27:15 +01:00
Dismissed
Clément Foucault left a comment
Member

Just requesting review for updating the state of the PR. We decided to hide this option behind a preprocessor define option.

Just requesting review for updating the state of the PR. We decided to hide this option behind a preprocessor define option.
Miguel Pozo added 2 commits 2024-02-26 13:34:09 +01:00
Clément Foucault approved these changes 2024-02-26 14:03:29 +01:00
Miguel Pozo merged commit c713fbc2d3 into main 2024-02-26 17:30:25 +01:00
Miguel Pozo deleted branch pull-gpu-better-shader-log 2024-02-26 17:30:27 +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
3 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#116470
No description provided.