mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
vulkan: add vulkan compute source
Add a source that runs a compute shader and exports the GPU buffer as a DmaBuf to the clients.
This commit is contained in:
parent
edbd9eb077
commit
9799b0e679
12 changed files with 1759 additions and 0 deletions
57
spa/plugins/vulkan/shaders/main.comp
Normal file
57
spa/plugins/vulkan/shaders/main.comp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
#define WORKGROUP_SIZE 32
|
||||
layout (local_size_x = WORKGROUP_SIZE, local_size_y = WORKGROUP_SIZE, local_size_z = 1 ) in;
|
||||
|
||||
struct Pixel{
|
||||
vec4 value;
|
||||
};
|
||||
|
||||
layout(std140, binding = 0) buffer buf
|
||||
{
|
||||
Pixel imageData[];
|
||||
};
|
||||
|
||||
layout( push_constant ) uniform Constants {
|
||||
float time;
|
||||
int frame;
|
||||
int width;
|
||||
int height;
|
||||
} PushConstant;
|
||||
|
||||
float iTime;
|
||||
int iFrame;
|
||||
vec3 iResolution;
|
||||
vec4 iMouse;
|
||||
|
||||
void mainImage( out vec4 fragColor, in vec2 fragCoord );
|
||||
|
||||
void main()
|
||||
{
|
||||
iTime = PushConstant.time;
|
||||
iFrame = PushConstant.frame;
|
||||
iResolution = vec3(float(PushConstant.width), float(PushConstant.height), 0.0);
|
||||
iMouse = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec2 coord = vec2(float(gl_GlobalInvocationID.x),
|
||||
iResolution.y - float(gl_GlobalInvocationID.y));
|
||||
vec4 outColor;
|
||||
|
||||
if(coord.x >= iResolution.x || coord.y >= iResolution.y)
|
||||
return;
|
||||
|
||||
mainImage(outColor, coord);
|
||||
|
||||
imageData[PushConstant.width * gl_GlobalInvocationID.y +
|
||||
gl_GlobalInvocationID.x].value = outColor;
|
||||
}
|
||||
|
||||
//#include "plasma-globe.comp"
|
||||
#include "mandelbrot-distance.comp"
|
||||
//#include "ring-twister.comp"
|
||||
//#include "gears.comp"
|
||||
//#include "protean-clouds.comp"
|
||||
//#include "flame.comp"
|
||||
//#include "shader.comp"
|
||||
//#include "raymarching-primitives.comp"
|
||||
//#include "3d-primitives.comp"
|
||||
Loading…
Add table
Add a link
Reference in a new issue