Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,10 @@ if(QML)
target_link_libraries(mixxx-qml-lib PUBLIC mixxx-proto)
target_link_libraries(mixxx-qml-libplugin PUBLIC mixxx-proto)

# Rendergraph
add_subdirectory(src/rendergraph/scenegraph)
target_link_libraries(mixxx-qml-lib PUBLIC rendergraph_sg)

target_precompile_headers(mixxx-qml-lib PUBLIC
${MIXXX_COMMON_PRECOMPILED_HEADER}
)
Expand All @@ -2764,6 +2768,7 @@ if(QML)
res/qml/Mixxx/Controls/WaveformOverviewHotcueMarker.qml
res/qml/Mixxx/Controls/WaveformOverviewMarker.qml
res/qml/Mixxx/Controls/WaveformOverview.qml
res/qml/Mixxx/Controls/WaveformDisplay.qml
)
target_link_libraries(mixxx-qml-lib PRIVATE mixxx-qml-mixxxcontrolsplugin)

Expand All @@ -2786,6 +2791,8 @@ if(QML)
src/qml/qmlvisibleeffectsmodel.cpp
src/qml/qmlchainpresetmodel.cpp
src/qml/qmlwaveformoverview.cpp
src/qml/qmlwaveformdisplay.cpp
src/waveform/renderers/waveformdisplayrange.cpp
# The following sources need to be in this target to get QML_ELEMENT properly interpreted
src/control/controlmodel.cpp
src/control/controlsortfiltermodel.cpp
Expand Down Expand Up @@ -3804,6 +3811,11 @@ 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)

# 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>
7 changes: 7 additions & 0 deletions res/qml/Mixxx/Controls/WaveformDisplay.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Mixxx 1.0 as Mixxx

Mixxx.WaveformDisplay {
id: root

player: Mixxx.PlayerManager.getPlayer(root.group)
}
16 changes: 16 additions & 0 deletions res/qml/WaveformDisplay.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import "." as Skin
import Mixxx 1.0 as Mixxx
import Mixxx.Controls 1.0 as MixxxControls
import QtQuick 2.12
import "Theme"

Item {
id: root

required property string group

MixxxControls.WaveformDisplay {
anchors.fill: parent
group: root.group
}
}
33 changes: 33 additions & 0 deletions res/shaders/rendergraph/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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-sg"
BATCHABLE
PRECOMPILE
OPTIMIZED
PREFIX
/shaders/rendergraph
FILES
${shaders}
)

include(generated_shaders_gl.cmake)

qt_add_resources(rendergraph_gl "shaders-gl"
PREFIX
/shaders/rendergraph
FILES
${generated_shaders_gl}
)
9 changes: 9 additions & 0 deletions res/shaders/rendergraph/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Generate the GLSL shaders from the spirv shaders by running

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
)

Since Qt 6.6 we should be able to access this programmatically with QShader, but for now I do it manually
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);
}
Loading