Skip to content

vulkanshaderspv: SPIRV based filter

This MR is an initial implementation of a GStreamer plugin that does video filtering with SPIRV shaders using Vulkan (gstvulkan), akin to glshader of the OpenGL ones (gstopengl).

Regarding shaders there are some features that are the same from glshader like uniforms for width, height plus time and RGBA image input plus output.

The vulkanshaderspv filter has properties for both vertex and fragment SPIRV binaries (vertex + fragment) with corresponding path locations (vertex-location + fragment-location) plus a period option that sets time in intervals of one second (period).

Here's a demo showcasing the plugin using the accompaning fragment shader (launched via gst-launch-1.0 videotestsrc num-buffers=300 ! vulkanupload ! vulkancolorconvert ! vulkanshaderspv fragment-location="waved.f.spv" ! vulkandownload ! videoconvert ! vp9enc ! queue ! webmmux ! filesink location=test.webm).

#version 450 core

#define PI 3.1415926538

layout(location = 0) in vec2 inTexCoord;

layout(set = 0, binding = 0) uniform ShaderFilter {
  float time;
  float width;
  float height;
};
layout(set = 0, binding = 1) uniform sampler2D inTexture;

layout(location = 0) out vec4 outColor;

void main()
{
  vec2 waved = (inTexCoord + vec2 (0.03125, 0.03125)) * 0.9;
  outColor = texture (inTexture, vec2 (waved.x + 16.0 * sin (10.0 * waved.y + 2.0 * PI * time) / width, waved.y));
}

Merge request reports