Skip to content
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 #13599

Draft
wants to merge 59 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
280fcf7
using rendergraph for allshader waveforms, with rendergraph::Geometry…
Aug 23, 2024
d3a69bb
waveformrenderbeat with rendergraph, various fixes, use same shaders …
Aug 27, 2024
c2fffea
preroll/postroll using rendergraph
Aug 30, 2024
4ad583c
node iterator, fixed examples
Aug 30, 2024
1dc16a5
fix teardown order
Aug 30, 2024
8014163
mark range with dynamic nodes
Aug 31, 2024
9a01213
make linked list handling part of rendergraph::Node
Aug 31, 2024
9eb2938
towards digits renderer as node
Aug 31, 2024
1e4d04b
draw playpos with rendergraph
Aug 31, 2024
058f5ec
reuse materialshaders
Aug 31, 2024
8032b38
keep track of material that modified the shader uniforms, fix scenegraph
Aug 31, 2024
3dcf907
digitsrenderer with rendergraph
Aug 31, 2024
507a465
draw marks with rendergraph
Aug 31, 2024
a0df59e
removed pimpl from rendergraph opengl
Sep 1, 2024
18fa2c4
removed pimpl from rendergraph scenegraph
Sep 18, 2024
1967817
cleanup and moved common rendergraph files to common/rendergraph
Sep 18, 2024
88013d4
remove nodebase, use encapsulation for scenegraph Node
Sep 19, 2024
b8bcb19
reorganized the code, with a public common API that is derived from t…
Sep 19, 2024
319ffb0
Update src/rendergraph/common/rendergraph/material/patternmaterial.h
m0dB Sep 22, 2024
390dd0e
Update src/rendergraph/common/rendergraph/material/rgbamaterial.cpp
m0dB Sep 22, 2024
afdc0ed
Update res/shaders/rendergraph/unicolor.frag
m0dB Sep 22, 2024
dff3a31
Update src/rendergraph/opengl/backend/shadercache.h
m0dB Sep 22, 2024
c713d6a
Update src/rendergraph/common/rendergraph/attribute.h
m0dB Sep 22, 2024
6ebc9d5
removed accidental commit
Sep 22, 2024
2a4a7d1
removed backend:: namespace, minor changes based on reviews
Sep 22, 2024
c5444fc
added comment to explain return value of remove node functions
Sep 22, 2024
ec3f816
use a generic Material::compare
Sep 22, 2024
86e5f09
added some DEBUG_ASSERTs and some vector.reserve calls
Sep 22, 2024
bc32a9c
use string literal
Sep 22, 2024
eeae3ea
use qshader to load qsb files for opengl Qt >= 6.6
Sep 22, 2024
0a691ad
avoid adding entire src dir to include paths
Sep 22, 2024
9c607c1
updated READMEs
Sep 22, 2024
2f8e548
improved/added asserts
Sep 23, 2024
c6cdb34
moved opengl node as baseclass for waveform renderers to derived clas…
Sep 23, 2024
92cd753
fix typo
Sep 23, 2024
8e5128f
moved rendergraph::OpenGLNode to derived
Sep 23, 2024
07d1f6a
moved vertexupdaters
Sep 23, 2024
b24e9ba
ported waveformrendererrgb to rendergraph, hurray!
Sep 23, 2024
b817d6c
removed class Attribute and use BaseGeometry::Attribute to reduce del…
Sep 24, 2024
0e870dd
comment
Sep 24, 2024
941f0cc
put rendergraph_sg and rendergraph_gl in different namespaces
Sep 25, 2024
1f10725
remove generated file
Sep 27, 2024
ca5f780
also use rendergraph::Engine in scenegraph to initialize and resize n…
Sep 27, 2024
bf7ed15
wip
Oct 6, 2024
1e57aae
let matrix be handled by qt scenegraph or by the opengl engine, remov…
Oct 19, 2024
8011f61
remove treenode
Oct 20, 2024
6b2442d
add nodeinterface for unique_ptr ownership methods
Oct 20, 2024
1a38137
reduce delta with feat/qml-scrolling-waveform-with-sg-and-rendergraph
Oct 20, 2024
cf17f15
reduce delta with feat/qml-scrolling-waveform-with-sg-and-rendergraph
Oct 20, 2024
5220b39
reduced delta with feat/qml-scrolling-waveform-with-sg-and-rendergraph
Oct 20, 2024
b8f2268
some cleanup
Oct 20, 2024
3c76b1b
merge changes from acolombier, clear and set owned by parent flag, mo…
Nov 1, 2024
2de8ded
missing file
Nov 1, 2024
d12d463
typo
Nov 2, 2024
c2d6c44
various cleanup, acting on review
Nov 2, 2024
8b25d13
improved attributeset from niko
Nov 2, 2024
a57b823
cleanup and comments
Nov 2, 2024
c7a3c7a
use std::erase
Nov 2, 2024
f409455
reduce delta with qml-rendergraph-fixes
Nov 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,6 @@ if(QOPENGL)
src/shaders/vinylqualityshader.cpp
src/util/opengltexture2d.cpp
src/waveform/renderers/allshader/digitsrenderer.cpp
src/waveform/renderers/allshader/matrixforwidgetgeometry.cpp
src/waveform/renderers/allshader/waveformrenderbackground.cpp
src/waveform/renderers/allshader/waveformrenderbeat.cpp
src/waveform/renderers/allshader/waveformrenderer.cpp
Expand Down Expand Up @@ -3810,6 +3809,12 @@ if(VINYLCONTROL)
target_link_libraries(mixxx-lib PRIVATE mixxx-xwax)
endif()

# rendergraph
add_subdirectory(src/rendergraph/opengl)
add_subdirectory(res/shaders/rendergraph)
target_link_libraries(mixxx-lib PUBLIC rendergraph_gl)
target_compile_definitions(mixxx-lib PRIVATE rendergraph=rendergraph_gl)

# WavPack audio file support
find_package(wavpack)
default_option(WAVPACK "WavPack audio file support" "wavpack_FOUND")
Expand Down
4 changes: 4 additions & 0 deletions res/mixxx.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,9 @@
<file>shaders/passthrough.vert</file>
<file>shaders/rgbsignal.frag</file>
<file>shaders/stackedsignal.frag</file>
<file>shaders/rendergraph/endoftrack.frag.gl</file>
<file>shaders/rendergraph/endoftrack.vert.gl</file>
<file>shaders/rendergraph/texture.frag.gl</file>
<file>shaders/rendergraph/texture.vert.gl</file>
</qresource>
</RCC>
47 changes: 47 additions & 0 deletions res/shaders/rendergraph/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
set(shaders
endoftrack.frag
endoftrack.vert
pattern.frag
pattern.vert
rgb.frag
rgb.vert
rgba.frag
rgba.vert
texture.frag
texture.vert
unicolor.frag
unicolor.vert
)

qt6_add_shaders(rendergraph_sg "shaders-qsb"
BATCHABLE
PRECOMPILE
OPTIMIZED
PREFIX
/shaders/rendergraph
FILES
${shaders}
)

if(USE_QSHADER_FOR_GL)
message(STATUS "Adding qsb shaders to rendergraph_gl")
qt6_add_shaders(rendergraph_gl "shaders-qsb"
BATCHABLE
PRECOMPILE
OPTIMIZED
PREFIX
/shaders/rendergraph
FILES
${shaders}
)
else()
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()
10 changes: 10 additions & 0 deletions res/shaders/rendergraph/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The CMakeLists.txt in this folder generates qsb shader bundles from the spirv shaders.

The qsb files can be used by QML / Qt scene graph QSGShader. Since Qt >= 6.6 we can load the qsb files and extract the glsl shaders
programmatically with QShader and use the with QOpenGLShader. For Qt < 6.6 the files have to generated manually with the script:

generate_shaders_gl.pl

(Make sure qsb and spirv commands are in your path. E.g:
export PATH=$PATH:~/VulkanSDK/1.3.283.0/macOS/bin:~/Qt/6.7.2/macos/bin
)
17 changes: 17 additions & 0 deletions res/shaders/rendergraph/endoftrack.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#version 440

layout(location = 0) in float vGradient;
layout(location = 0) out vec4 fragColor;

layout(std140, binding = 0) uniform buf {
vec4 color;
}
ubuf;

void main() {
float minAlpha = 0.5 * ubuf.color.w;
float maxAlpha = 0.83 * ubuf.color.w;
float alpha = mix(minAlpha, maxAlpha, max(0.0, vGradient));
// premultiple alpha
fragColor = vec4(ubuf.color.xyz * alpha, alpha);
}
19 changes: 19 additions & 0 deletions res/shaders/rendergraph/endoftrack.frag.gl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#version 120
//// GENERATED - EDITS WILL BE OVERWRITTEN

struct buf
{
vec4 color;
};

uniform buf ubuf;

varying float vGradient;

void main()
{
float minAlpha = 0.5 * ubuf.color.w;
float maxAlpha = 0.829999983310699462890625 * ubuf.color.w;
float alpha = mix(minAlpha, maxAlpha, max(0.0, vGradient));
gl_FragData[0] = vec4(ubuf.color.xyz * alpha, alpha);
}
10 changes: 10 additions & 0 deletions res/shaders/rendergraph/endoftrack.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#version 440

layout(location = 0) in vec4 position;
layout(location = 1) in float gradient;
layout(location = 0) out float vGradient;

void main() {
vGradient = gradient;
gl_Position = position;
}
12 changes: 12 additions & 0 deletions res/shaders/rendergraph/endoftrack.vert.gl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#version 120
//// GENERATED - EDITS WILL BE OVERWRITTEN

varying float vGradient;
attribute float gradient;
attribute vec4 position;

void main()
{
vGradient = gradient;
gl_Position = position;
}
68 changes: 68 additions & 0 deletions res/shaders/rendergraph/generate_shaders_gl.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/perl

my @files = (glob("*.vert"),glob("*.frag"));

open(GENERATED,">generated_shaders_gl.cmake");
print(GENERATED "set(generated_shaders_gl\n");
for $file (@files)
{
system("qsb","--glsl","120",$file,"-o","/tmp/$$-$file.qsb");
open(INFILE,"qsb --dump /tmp/$$-$file.qsb|");
open(OUTFILE,">$file.gl");
$ok = 0;
$comment_added = 0;
print "Generating $file.gl from $file\n";
while (<INFILE>)
{
if ($in_shader_block == 2)
{
if (m/^\*\*/)
{
$in_shader_block = 0;
$ok = 1;
}
else
{
if (!$comment_added)
{
if (!m/^#/)
{
print(OUTFILE "//// GENERATED - EDITS WILL BE OVERWRITTEN\n");
$comment_added = 1;
}
}
print OUTFILE "$_";
}
}
elsif ($in_shader_block == 1)
{
chomp($_);
if ($_ eq "Contents:")
{
$in_shader_block = 2;
}
}
else
{
chomp($_);
if ($_ eq "Shader 1: GLSL 120 [Standard]")
{
$in_shader_block = 1;
}
}
}
close INFILE;
close OUTFILE;
if($ok)
{
print(GENERATED " $file.gl\n");
}
else
{
print STDERR "Failed to generated $file.gl";
unlink("$file.gl")
}
unlink("/tmp/$$-$file.qsb");
}
print(GENERATED ")\n");
close GENERATED;
14 changes: 14 additions & 0 deletions res/shaders/rendergraph/generated_shaders_gl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set(generated_shaders_gl
endoftrack.vert.gl
pattern.vert.gl
rgb.vert.gl
rgba.vert.gl
texture.vert.gl
unicolor.vert.gl
endoftrack.frag.gl
pattern.frag.gl
rgb.frag.gl
rgba.frag.gl
texture.frag.gl
unicolor.frag.gl
)
9 changes: 9 additions & 0 deletions res/shaders/rendergraph/pattern.frag
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));
}
11 changes: 11 additions & 0 deletions res/shaders/rendergraph/pattern.frag.gl
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));
}
15 changes: 15 additions & 0 deletions res/shaders/rendergraph/pattern.vert
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;
}
19 changes: 19 additions & 0 deletions res/shaders/rendergraph/pattern.vert.gl
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;
}
8 changes: 8 additions & 0 deletions res/shaders/rendergraph/rgb.frag
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);
}
9 changes: 9 additions & 0 deletions res/shaders/rendergraph/rgb.frag.gl
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);
}
15 changes: 15 additions & 0 deletions res/shaders/rendergraph/rgb.vert
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;
}
19 changes: 19 additions & 0 deletions res/shaders/rendergraph/rgb.vert.gl
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;
}
8 changes: 8 additions & 0 deletions res/shaders/rendergraph/rgba.frag
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
}
9 changes: 9 additions & 0 deletions res/shaders/rendergraph/rgba.frag.gl
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);
}
15 changes: 15 additions & 0 deletions res/shaders/rendergraph/rgba.vert
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;
}
Loading
Loading