blob: 4ab951877137d9d82c109c9eba1da498098630a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include <vulkan/vulkan.h>
#include <spa/buffer/buffer.h>
#define MAX_BUFFERS 16
#define WORKGROUP_SIZE 32
struct pixel {
float r, g, b, a;
};
struct push_constants {
float time;
int frame;
int width;
int height;
};
struct vulkan_buffer {
struct spa_buffer *buf;
VkBuffer buffer;
VkDeviceMemory memory;
};
struct vulkan_state {
struct push_constants constants;
VkInstance instance;
VkPhysicalDevice physicalDevice;
VkDevice device;
VkPipeline pipeline;
VkPipelineLayout pipelineLayout;
VkShaderModule computeShaderModule;
VkCommandPool commandPool;
VkCommandBuffer commandBuffer;
VkQueue queue;
uint32_t queueFamilyIndex;
VkFence fence;
unsigned int prepared:1;
unsigned int busy:1;
VkDescriptorPool descriptorPool;
VkDescriptorSet descriptorSet;
VkDescriptorSetLayout descriptorSetLayout;
struct vulkan_buffer buffers[MAX_BUFFERS];
uint32_t n_buffers;
uint32_t bufferSize;
uint32_t buffer_id;
};
int spa_vulkan_prepare(struct vulkan_state *s);
int spa_vulkan_use_buffers(struct vulkan_state *s, uint32_t flags,
uint32_t n_buffers, struct spa_buffer **buffers);
int spa_vulkan_unprepare(struct vulkan_state *s);
int spa_vulkan_start(struct vulkan_state *s);
int spa_vulkan_stop(struct vulkan_state *s);
int spa_vulkan_ready(struct vulkan_state *s);
int spa_vulkan_process(struct vulkan_state *s, uint32_t buffer_id);
int spa_vulkan_cleanup(struct vulkan_state *s);
|