-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rendergraph: use opengl node and add shaders #14021
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2edbd96
use rendergraph in allshader/waveformwidget, derive allshader wavefor…
3f9a2b1
avoid rendering on images with 0 or negative width or height
cd9d060
added rendergraph shaders
efb9535
fixed double/float conversions
1fe2815
play nice with precompiled headers
31c99f6
chore(rendergraph): Port `generate_shaders_gl.pl` to Python
Holzhaus e315477
chore(rendergraph): Order `generated_shaders_gl.cmake` alphabetically
Holzhaus 78481fc
ci(pre-commit): Automatically update rendergraph shaders on changes
Holzhaus 182199f
remove generate_shaders_gl from precommit
4e16ade
moved generate_shaders_gl.py script to rendergraph/tools, updated readme
9104a3d
add missing pointer initialization
efae93e
fix(generate_shaders_gl): Replace new union expression with old syntax
Holzhaus 0d99bd6
moved script back, edited info, edited readme
931260c
removed all Q_UNUSED
6c21fcf
removed copy of generate_shaders_gl.py
a00d35c
added appendChildNode with templatized result as suggested by Nico, c…
0084dcf
comment
d7c0af5
comment
b6aa301
fix post rebase
2635bc2
remove needless convert and asNode
84f8966
only build shaders for added target
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# included from src/rendergraph/CMakeLists.txt | ||
|
||
set( | ||
shaders | ||
pattern.frag | ||
pattern.vert | ||
rgb.frag | ||
rgb.vert | ||
rgba.frag | ||
rgba.vert | ||
texture.frag | ||
texture.vert | ||
unicolor.frag | ||
unicolor.vert | ||
) | ||
|
||
if(TARGET rendergraph_sg) | ||
qt6_add_shaders(rendergraph_sg "shaders-qsb" | ||
BATCHABLE | ||
PRECOMPILE | ||
OPTIMIZED | ||
PREFIX | ||
/shaders/rendergraph | ||
FILES | ||
${shaders} | ||
) | ||
endif() | ||
|
||
if(TARGET rendergraph_gl) | ||
# USE_QSHADER_FOR_GL is set in src/rendergraph/CMakeLists.txt when Qt >= 6.6 | ||
if(USE_QSHADER_FOR_GL) | ||
# Add the .qsb shader bundles; rendergraph::MaterialShader will use | ||
# QShader to extract the GLSL shader from the bundle. | ||
message(STATUS "Adding qsb shaders to rendergraph_gl") | ||
qt6_add_shaders(rendergraph_gl "shaders-qsb" | ||
BATCHABLE | ||
PRECOMPILE | ||
OPTIMIZED | ||
PREFIX | ||
/shaders/rendergraph | ||
FILES | ||
${shaders} | ||
) | ||
else() | ||
# Use GLSL shaders extracted from the .qsb shader bundles using | ||
# generate_shaders_gl.pl | ||
message(STATUS "Adding gl shaders to rendergraph_gl") | ||
include(generated_shaders_gl.cmake) | ||
|
||
qt_add_resources(rendergraph_gl "shaders-gl" | ||
PREFIX | ||
/shaders/rendergraph | ||
FILES | ||
${generated_shaders_gl} | ||
) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# rendergraph shaders | ||
|
||
The CMakeLists.txt in this folder generates qsb shader bundles from spirv shaders, to | ||
be used by `rendergraph::MaterialShader`. | ||
|
||
## For use with QML / Qt scene graph | ||
|
||
The qsb files can be used directly through `QSGShader`. This includes the scenegraph | ||
implementation of rendergraph. | ||
|
||
## For use with OpenGL | ||
|
||
Depending on the Qt version, the opengl implementation of `rendergraph::MaterialShader` | ||
uses either the .qsb shader bundles directly, or the extracted GLSL shaders: | ||
|
||
### Qt >= 6.6 | ||
|
||
The GLSL shaders are extracted programmatically with `QShader` and then used with | ||
`QOpenGLShader`. | ||
|
||
### Qt < 6.6 | ||
|
||
The GLSL shader have to extracted from the qsb shader bundles to be used by `QOpenGLShader`. | ||
This can be done using the script `rg_generate_shaders_gl.py` in the mixxx/tools directory: | ||
|
||
```console | ||
$ ../../../tools/rg_generate_shaders_gl.py --cmake generated_shaders_gl.cmake *.vert *.frag | ||
``` | ||
|
||
To use this script, make sure that the qsb and spirv commands are in your path. qsb is part | ||
of Qt. spirv is part of the Vulkan SDK and can be downloaded from <https://vulkan.org> | ||
|
||
The script also generates the file `generated_shaders_gl.cmake` which sets a cmake | ||
variable containing a list of all GLSL shaders, used by the CMakeLists.txt in this folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
set( | ||
generated_shaders_gl | ||
pattern.frag.gl | ||
pattern.vert.gl | ||
rgb.frag.gl | ||
rgb.vert.gl | ||
rgba.frag.gl | ||
rgba.vert.gl | ||
texture.frag.gl | ||
texture.vert.gl | ||
unicolor.frag.gl | ||
unicolor.vert.gl | ||
) | ||
m0dB marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#version 440 | ||
|
||
layout(binding = 1) uniform sampler2D texture1; | ||
layout(location = 0) in vec2 vTexcoord; | ||
layout(location = 0) out vec4 fragColor; | ||
|
||
void main() { | ||
fragColor = texture(texture1, fract(vTexcoord)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#version 120 | ||
//// GENERATED - EDITS WILL BE OVERWRITTEN | ||
|
||
uniform sampler2D texture1; | ||
|
||
varying vec2 vTexcoord; | ||
|
||
void main() | ||
{ | ||
gl_FragData[0] = texture2D(texture1, fract(vTexcoord)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#version 440 | ||
|
||
layout(std140, binding = 0) uniform buf { | ||
mat4 matrix; | ||
} | ||
ubuf; | ||
|
||
layout(location = 0) in vec4 position; | ||
layout(location = 1) in vec2 texcoord; | ||
layout(location = 0) out vec2 vTexcoord; | ||
|
||
void main() { | ||
vTexcoord = texcoord; | ||
gl_Position = ubuf.matrix * position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#version 120 | ||
//// GENERATED - EDITS WILL BE OVERWRITTEN | ||
|
||
struct buf | ||
{ | ||
mat4 matrix; | ||
}; | ||
|
||
uniform buf ubuf; | ||
|
||
varying vec2 vTexcoord; | ||
attribute vec2 texcoord; | ||
attribute vec4 position; | ||
|
||
void main() | ||
{ | ||
vTexcoord = texcoord; | ||
gl_Position = ubuf.matrix * position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#version 440 | ||
|
||
layout(location = 0) in vec3 vColor; | ||
layout(location = 0) out vec4 fragColor; | ||
|
||
void main() { | ||
fragColor = vec4(vColor, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#version 120 | ||
//// GENERATED - EDITS WILL BE OVERWRITTEN | ||
|
||
varying vec3 vColor; | ||
|
||
void main() | ||
{ | ||
gl_FragData[0] = vec4(vColor, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#version 440 | ||
|
||
layout(std140, binding = 0) uniform buf { | ||
mat4 matrix; | ||
} | ||
ubuf; | ||
|
||
layout(location = 0) in vec4 position; | ||
layout(location = 1) in vec3 color; | ||
layout(location = 0) out vec3 vColor; | ||
|
||
void main() { | ||
vColor = color; | ||
gl_Position = ubuf.matrix * position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#version 120 | ||
//// GENERATED - EDITS WILL BE OVERWRITTEN | ||
|
||
struct buf | ||
{ | ||
mat4 matrix; | ||
}; | ||
|
||
uniform buf ubuf; | ||
|
||
varying vec3 vColor; | ||
attribute vec3 color; | ||
attribute vec4 position; | ||
|
||
void main() | ||
{ | ||
vColor = color; | ||
gl_Position = ubuf.matrix * position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#version 440 | ||
|
||
layout(location = 0) in vec4 vColor; | ||
layout(location = 0) out vec4 fragColor; | ||
|
||
void main() { | ||
fragColor = vec4(vColor.xyz * vColor.w, vColor.w); // premultiple alpha | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#version 120 | ||
//// GENERATED - EDITS WILL BE OVERWRITTEN | ||
|
||
varying vec4 vColor; | ||
|
||
void main() | ||
{ | ||
gl_FragData[0] = vec4(vColor.xyz * vColor.w, vColor.w); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#version 440 | ||
|
||
layout(std140, binding = 0) uniform buf { | ||
mat4 matrix; | ||
} | ||
ubuf; | ||
|
||
layout(location = 0) in vec4 position; | ||
layout(location = 1) in vec4 color; | ||
layout(location = 0) out vec4 vColor; | ||
|
||
void main() { | ||
vColor = color; | ||
gl_Position = ubuf.matrix * position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#version 120 | ||
//// GENERATED - EDITS WILL BE OVERWRITTEN | ||
|
||
struct buf | ||
{ | ||
mat4 matrix; | ||
}; | ||
|
||
uniform buf ubuf; | ||
|
||
varying vec4 vColor; | ||
attribute vec4 color; | ||
attribute vec4 position; | ||
|
||
void main() | ||
{ | ||
vColor = color; | ||
gl_Position = ubuf.matrix * position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#version 440 | ||
|
||
layout(binding = 1) uniform sampler2D texture1; | ||
layout(location = 0) in vec2 vTexcoord; | ||
layout(location = 0) out vec4 fragColor; | ||
|
||
void main() { | ||
fragColor = texture(texture1, vTexcoord); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#version 120 | ||
//// GENERATED - EDITS WILL BE OVERWRITTEN | ||
|
||
uniform sampler2D texture1; | ||
|
||
varying vec2 vTexcoord; | ||
|
||
void main() | ||
{ | ||
gl_FragData[0] = texture2D(texture1, vTexcoord); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#version 440 | ||
|
||
layout(std140, binding = 0) uniform buf { | ||
mat4 matrix; | ||
} | ||
ubuf; | ||
|
||
layout(location = 0) in vec4 position; | ||
layout(location = 1) in vec2 texcoord; | ||
layout(location = 0) out vec2 vTexcoord; | ||
|
||
void main() { | ||
vTexcoord = texcoord; | ||
gl_Position = ubuf.matrix * position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#version 120 | ||
//// GENERATED - EDITS WILL BE OVERWRITTEN | ||
|
||
struct buf | ||
{ | ||
mat4 matrix; | ||
}; | ||
|
||
uniform buf ubuf; | ||
|
||
varying vec2 vTexcoord; | ||
attribute vec2 texcoord; | ||
attribute vec4 position; | ||
|
||
void main() | ||
{ | ||
vTexcoord = texcoord; | ||
gl_Position = ubuf.matrix * position; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is the culprit that breaks it for me. WIthout
scenegraph
, the calls that reference the non-existingrendergraph_sg
target fail.Side note: Splitting the CMake code over multiple small
CMakeLists.txt
files that reference targets and variables defined elsewhere makes the control flow quite difficult to follow. Have you considered just using a singleCMakeLists.txt
inside therendergraph
directory?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, for now the calls that reference the non-existing rendergraph_sg target fail should be commented out. I will do that.
I obsoletely prefer splitting cmake over multiple files, one per target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please try again, @Holzhaus ? I added conditionals to only add the shaders for the targets that were added.
(It looks like this is a change in Qt, being more strict about this in more recent versions)