2023-08-27 00:24:04 +02:00
|
|
|
/* Spa */
|
|
|
|
|
/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */
|
|
|
|
|
/* SPDX-License-Identifier: MIT */
|
|
|
|
|
|
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
|
|
|
|
|
|
#include <spa/buffer/buffer.h>
|
2023-02-21 16:29:17 +01:00
|
|
|
#include <spa/param/video/format.h>
|
2023-08-27 00:24:04 +02:00
|
|
|
#include <spa/node/node.h>
|
|
|
|
|
|
|
|
|
|
#include "vulkan-utils.h"
|
|
|
|
|
|
|
|
|
|
#define MAX_STREAMS 2
|
|
|
|
|
#define WORKGROUP_SIZE 32
|
|
|
|
|
|
|
|
|
|
struct pixel {
|
|
|
|
|
float r, g, b, a;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct push_constants {
|
|
|
|
|
float time;
|
|
|
|
|
int frame;
|
|
|
|
|
int width;
|
|
|
|
|
int height;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct vulkan_compute_state {
|
|
|
|
|
struct spa_log *log;
|
|
|
|
|
|
|
|
|
|
struct push_constants constants;
|
|
|
|
|
|
|
|
|
|
struct vulkan_base base;
|
|
|
|
|
|
|
|
|
|
VkPipeline pipeline;
|
|
|
|
|
VkPipelineLayout pipelineLayout;
|
|
|
|
|
const char *shaderName;
|
|
|
|
|
VkShaderModule computeShaderModule;
|
|
|
|
|
|
|
|
|
|
VkCommandPool commandPool;
|
|
|
|
|
VkCommandBuffer commandBuffer;
|
|
|
|
|
|
|
|
|
|
VkFence fence;
|
2023-08-13 03:13:31 +02:00
|
|
|
VkSemaphore pipelineSemaphore;
|
2023-08-27 00:24:04 +02:00
|
|
|
unsigned int initialized:1;
|
|
|
|
|
unsigned int prepared:1;
|
|
|
|
|
unsigned int started:1;
|
|
|
|
|
|
|
|
|
|
VkDescriptorPool descriptorPool;
|
|
|
|
|
VkDescriptorSetLayout descriptorSetLayout;
|
|
|
|
|
|
|
|
|
|
VkSampler sampler;
|
|
|
|
|
|
|
|
|
|
uint32_t n_streams;
|
|
|
|
|
VkDescriptorSet descriptorSet;
|
|
|
|
|
struct vulkan_stream streams[MAX_STREAMS];
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-28 13:48:54 +02:00
|
|
|
int spa_vulkan_compute_init_stream(struct vulkan_compute_state *s, struct vulkan_stream *stream, enum spa_direction,
|
2023-08-27 00:24:04 +02:00
|
|
|
struct spa_dict *props);
|
|
|
|
|
|
2023-08-28 13:48:54 +02:00
|
|
|
int spa_vulkan_compute_fixate_modifier(struct vulkan_compute_state *s, struct vulkan_stream *p, struct spa_video_info_dsp *dsp_info,
|
2023-08-10 02:59:36 +02:00
|
|
|
uint32_t modifierCount, uint64_t *modifiers, uint64_t *modifier);
|
2023-08-28 13:48:54 +02:00
|
|
|
int spa_vulkan_compute_prepare(struct vulkan_compute_state *s);
|
|
|
|
|
int spa_vulkan_compute_use_buffers(struct vulkan_compute_state *s, struct vulkan_stream *stream, uint32_t flags,
|
2023-02-21 16:29:17 +01:00
|
|
|
struct spa_video_info_dsp *dsp_info, uint32_t n_buffers, struct spa_buffer **buffers);
|
2023-08-28 13:48:54 +02:00
|
|
|
int spa_vulkan_compute_unprepare(struct vulkan_compute_state *s);
|
2023-08-27 00:24:04 +02:00
|
|
|
|
2023-08-28 13:48:54 +02:00
|
|
|
int spa_vulkan_compute_start(struct vulkan_compute_state *s);
|
|
|
|
|
int spa_vulkan_compute_stop(struct vulkan_compute_state *s);
|
|
|
|
|
int spa_vulkan_compute_ready(struct vulkan_compute_state *s);
|
|
|
|
|
int spa_vulkan_compute_process(struct vulkan_compute_state *s);
|
|
|
|
|
int spa_vulkan_compute_cleanup(struct vulkan_compute_state *s);
|
2023-08-27 00:24:04 +02:00
|
|
|
|
2023-08-28 13:48:54 +02:00
|
|
|
int spa_vulkan_compute_get_buffer_caps(struct vulkan_compute_state *s, enum spa_direction direction);
|
|
|
|
|
struct vulkan_modifier_info *spa_vulkan_compute_get_modifier_info(struct vulkan_compute_state *s,
|
2023-08-04 00:26:20 +02:00
|
|
|
struct spa_video_info_dsp *dsp_info);
|
2023-08-12 02:50:34 +02:00
|
|
|
|
2023-08-28 13:48:54 +02:00
|
|
|
int spa_vulkan_compute_init(struct vulkan_compute_state *s);
|
|
|
|
|
void spa_vulkan_compute_deinit(struct vulkan_compute_state *s);
|