mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
vulkan: use image sampler
This commit is contained in:
parent
b02ebec954
commit
d40e6aeedd
2 changed files with 24 additions and 4 deletions
|
|
@ -248,7 +248,7 @@ static int createDescriptors(struct vulkan_state *s)
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
VkDescriptorPoolSize descriptorPoolSize = {
|
VkDescriptorPoolSize descriptorPoolSize = {
|
||||||
.type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||||
.descriptorCount = s->n_streams,
|
.descriptorCount = s->n_streams,
|
||||||
};
|
};
|
||||||
const VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = {
|
const VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = {
|
||||||
|
|
@ -266,7 +266,7 @@ static int createDescriptors(struct vulkan_state *s)
|
||||||
for (i = 0; i < s->n_streams; i++) {
|
for (i = 0; i < s->n_streams; i++) {
|
||||||
descriptorSetLayoutBinding[i] = (VkDescriptorSetLayoutBinding) {
|
descriptorSetLayoutBinding[i] = (VkDescriptorSetLayoutBinding) {
|
||||||
.binding = i,
|
.binding = i,
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT
|
||||||
};
|
};
|
||||||
|
|
@ -291,7 +291,23 @@ static int createDescriptors(struct vulkan_state *s)
|
||||||
&descriptorSetAllocateInfo,
|
&descriptorSetAllocateInfo,
|
||||||
&s->descriptorSet));
|
&s->descriptorSet));
|
||||||
|
|
||||||
|
const VkSamplerCreateInfo samplerInfo = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
||||||
|
.magFilter = VK_FILTER_LINEAR,
|
||||||
|
.minFilter = VK_FILTER_LINEAR,
|
||||||
|
.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR,
|
||||||
|
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
|
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
|
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
|
.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK,
|
||||||
|
.unnormalizedCoordinates = VK_FALSE,
|
||||||
|
.compareEnable = VK_FALSE,
|
||||||
|
.compareOp = VK_COMPARE_OP_ALWAYS,
|
||||||
|
.mipLodBias = 0.0f,
|
||||||
|
.minLod = 0,
|
||||||
|
.maxLod = 5,
|
||||||
|
};
|
||||||
|
VK_CHECK_RESULT(vkCreateSampler(s->device, &samplerInfo, NULL, &s->sampler));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -314,6 +330,7 @@ static int updateDescriptors(struct vulkan_state *s)
|
||||||
p->pending_buffer_id = SPA_ID_INVALID;
|
p->pending_buffer_id = SPA_ID_INVALID;
|
||||||
|
|
||||||
descriptorImageInfo[i] = (VkDescriptorImageInfo) {
|
descriptorImageInfo[i] = (VkDescriptorImageInfo) {
|
||||||
|
.sampler = s->sampler,
|
||||||
.imageView = p->buffers[p->current_buffer_id].view,
|
.imageView = p->buffers[p->current_buffer_id].view,
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
};
|
};
|
||||||
|
|
@ -322,7 +339,7 @@ static int updateDescriptors(struct vulkan_state *s)
|
||||||
.dstSet = s->descriptorSet,
|
.dstSet = s->descriptorSet,
|
||||||
.dstBinding = i,
|
.dstBinding = i,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||||
.pImageInfo = &descriptorImageInfo[i],
|
.pImageInfo = &descriptorImageInfo[i],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -629,6 +646,7 @@ int spa_vulkan_unprepare(struct vulkan_state *s)
|
||||||
{
|
{
|
||||||
if (s->prepared) {
|
if (s->prepared) {
|
||||||
vkDestroyShaderModule(s->device, s->computeShaderModule, NULL);
|
vkDestroyShaderModule(s->device, s->computeShaderModule, NULL);
|
||||||
|
vkDestroySampler(s->device, s->sampler, NULL);
|
||||||
vkDestroyDescriptorPool(s->device, s->descriptorPool, NULL);
|
vkDestroyDescriptorPool(s->device, s->descriptorPool, NULL);
|
||||||
vkDestroyDescriptorSetLayout(s->device, s->descriptorSetLayout, NULL);
|
vkDestroyDescriptorSetLayout(s->device, s->descriptorSetLayout, NULL);
|
||||||
vkDestroyPipelineLayout(s->device, s->pipelineLayout, NULL);
|
vkDestroyPipelineLayout(s->device, s->pipelineLayout, NULL);
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,8 @@ struct vulkan_state {
|
||||||
VkDescriptorPool descriptorPool;
|
VkDescriptorPool descriptorPool;
|
||||||
VkDescriptorSetLayout descriptorSetLayout;
|
VkDescriptorSetLayout descriptorSetLayout;
|
||||||
|
|
||||||
|
VkSampler sampler;
|
||||||
|
|
||||||
uint32_t n_streams;
|
uint32_t n_streams;
|
||||||
VkDescriptorSet descriptorSet;
|
VkDescriptorSet descriptorSet;
|
||||||
struct vulkan_stream streams[MAX_STREAMS];
|
struct vulkan_stream streams[MAX_STREAMS];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue