2018-08-08 23:23:57 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2016 Red Hat.
|
|
|
|
* Copyright © 2016 Bas Nieuwenhuizen
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
2019-01-09 22:16:01 +00:00
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2018-08-08 23:23:57 +01:00
|
|
|
*/
|
2019-01-09 22:16:01 +00:00
|
|
|
#include "tu_private.h"
|
|
|
|
|
2018-08-08 23:23:57 +01:00
|
|
|
#include <assert.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "util/mesa-sha1.h"
|
|
|
|
#include "vk_util.h"
|
|
|
|
|
|
|
|
static int
|
|
|
|
binding_compare(const void *av, const void *bv)
|
|
|
|
{
|
|
|
|
const VkDescriptorSetLayoutBinding *a =
|
2019-01-09 22:16:01 +00:00
|
|
|
(const VkDescriptorSetLayoutBinding *) av;
|
2018-08-08 23:23:57 +01:00
|
|
|
const VkDescriptorSetLayoutBinding *b =
|
2019-01-09 22:16:01 +00:00
|
|
|
(const VkDescriptorSetLayoutBinding *) bv;
|
2018-08-08 23:23:57 +01:00
|
|
|
|
|
|
|
return (a->binding < b->binding) ? -1 : (a->binding > b->binding) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VkDescriptorSetLayoutBinding *
|
|
|
|
create_sorted_bindings(const VkDescriptorSetLayoutBinding *bindings,
|
|
|
|
unsigned count)
|
|
|
|
{
|
|
|
|
VkDescriptorSetLayoutBinding *sorted_bindings =
|
2019-01-09 22:16:01 +00:00
|
|
|
malloc(count * sizeof(VkDescriptorSetLayoutBinding));
|
2018-08-08 23:23:57 +01:00
|
|
|
if (!sorted_bindings)
|
|
|
|
return NULL;
|
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
memcpy(sorted_bindings, bindings,
|
|
|
|
count * sizeof(VkDescriptorSetLayoutBinding));
|
2018-08-08 23:23:57 +01:00
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
qsort(sorted_bindings, count, sizeof(VkDescriptorSetLayoutBinding),
|
2018-08-08 23:23:57 +01:00
|
|
|
binding_compare);
|
|
|
|
|
|
|
|
return sorted_bindings;
|
|
|
|
}
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
tu_CreateDescriptorSetLayout(
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDevice _device,
|
|
|
|
const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
|
|
|
|
const VkAllocationCallbacks *pAllocator,
|
|
|
|
VkDescriptorSetLayout *pSetLayout)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
|
|
|
struct tu_descriptor_set_layout *set_layout;
|
|
|
|
|
|
|
|
assert(pCreateInfo->sType ==
|
|
|
|
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO);
|
|
|
|
const VkDescriptorSetLayoutBindingFlagsCreateInfoEXT *variable_flags =
|
2019-01-09 22:16:01 +00:00
|
|
|
vk_find_struct_const(
|
|
|
|
pCreateInfo->pNext,
|
|
|
|
DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT);
|
2018-08-08 23:23:57 +01:00
|
|
|
|
|
|
|
uint32_t max_binding = 0;
|
|
|
|
uint32_t immutable_sampler_count = 0;
|
|
|
|
for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) {
|
|
|
|
max_binding = MAX2(max_binding, pCreateInfo->pBindings[j].binding);
|
|
|
|
if (pCreateInfo->pBindings[j].pImmutableSamplers)
|
|
|
|
immutable_sampler_count += pCreateInfo->pBindings[j].descriptorCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t samplers_offset =
|
2019-01-09 22:16:01 +00:00
|
|
|
sizeof(struct tu_descriptor_set_layout) +
|
|
|
|
(max_binding + 1) * sizeof(set_layout->binding[0]);
|
2018-08-08 23:23:57 +01:00
|
|
|
size_t size =
|
2019-01-09 22:16:01 +00:00
|
|
|
samplers_offset + immutable_sampler_count * 4 * sizeof(uint32_t);
|
2018-08-08 23:23:57 +01:00
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
set_layout = vk_alloc2(&device->alloc, pAllocator, size, 8,
|
|
|
|
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
2018-08-08 23:23:57 +01:00
|
|
|
if (!set_layout)
|
|
|
|
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
|
|
|
|
|
|
|
set_layout->flags = pCreateInfo->flags;
|
|
|
|
|
|
|
|
/* We just allocate all the samplers at the end of the struct */
|
2019-01-09 22:16:01 +00:00
|
|
|
uint32_t *samplers = (uint32_t *) &set_layout->binding[max_binding + 1];
|
2018-11-12 22:42:36 +00:00
|
|
|
(void) samplers; /* TODO: Use me */
|
2018-08-08 23:23:57 +01:00
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
VkDescriptorSetLayoutBinding *bindings = create_sorted_bindings(
|
|
|
|
pCreateInfo->pBindings, pCreateInfo->bindingCount);
|
2018-08-08 23:23:57 +01:00
|
|
|
if (!bindings) {
|
|
|
|
vk_free2(&device->alloc, pAllocator, set_layout);
|
|
|
|
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
set_layout->binding_count = max_binding + 1;
|
|
|
|
set_layout->shader_stages = 0;
|
|
|
|
set_layout->dynamic_shader_stages = 0;
|
|
|
|
set_layout->has_immutable_samplers = false;
|
|
|
|
set_layout->size = 0;
|
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
memset(set_layout->binding, 0,
|
|
|
|
size - sizeof(struct tu_descriptor_set_layout));
|
2018-08-08 23:23:57 +01:00
|
|
|
|
|
|
|
uint32_t buffer_count = 0;
|
|
|
|
uint32_t dynamic_offset_count = 0;
|
|
|
|
|
|
|
|
for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) {
|
|
|
|
const VkDescriptorSetLayoutBinding *binding = bindings + j;
|
|
|
|
uint32_t b = binding->binding;
|
|
|
|
uint32_t alignment;
|
|
|
|
unsigned binding_buffer_count = 0;
|
|
|
|
|
|
|
|
switch (binding->descriptorType) {
|
2019-01-09 22:16:01 +00:00
|
|
|
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
|
|
|
assert(!(pCreateInfo->flags &
|
|
|
|
VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR));
|
|
|
|
set_layout->binding[b].dynamic_offset_count = 1;
|
|
|
|
set_layout->dynamic_shader_stages |= binding->stageFlags;
|
|
|
|
set_layout->binding[b].size = 0;
|
|
|
|
binding_buffer_count = 1;
|
|
|
|
alignment = 1;
|
|
|
|
break;
|
|
|
|
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
|
|
|
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
|
|
|
set_layout->binding[b].size = 16;
|
|
|
|
binding_buffer_count = 1;
|
|
|
|
alignment = 16;
|
|
|
|
break;
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
|
|
|
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
|
|
|
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
|
|
|
/* main descriptor + fmask descriptor */
|
|
|
|
set_layout->binding[b].size = 64;
|
|
|
|
binding_buffer_count = 1;
|
|
|
|
alignment = 32;
|
|
|
|
break;
|
|
|
|
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
|
|
|
/* main descriptor + fmask descriptor + sampler */
|
|
|
|
set_layout->binding[b].size = 96;
|
|
|
|
binding_buffer_count = 1;
|
|
|
|
alignment = 32;
|
|
|
|
break;
|
|
|
|
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
|
|
|
set_layout->binding[b].size = 16;
|
|
|
|
alignment = 16;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unreachable("unknown descriptor type\n");
|
|
|
|
break;
|
2018-08-08 23:23:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
set_layout->size = align(set_layout->size, alignment);
|
|
|
|
set_layout->binding[b].type = binding->descriptorType;
|
|
|
|
set_layout->binding[b].array_size = binding->descriptorCount;
|
|
|
|
set_layout->binding[b].offset = set_layout->size;
|
|
|
|
set_layout->binding[b].buffer_offset = buffer_count;
|
|
|
|
set_layout->binding[b].dynamic_offset_offset = dynamic_offset_count;
|
|
|
|
|
|
|
|
if (variable_flags && binding->binding < variable_flags->bindingCount &&
|
|
|
|
(variable_flags->pBindingFlags[binding->binding] &
|
|
|
|
VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT)) {
|
2019-01-09 22:16:01 +00:00
|
|
|
assert(!binding->pImmutableSamplers); /* Terribly ill defined how
|
|
|
|
many samplers are valid */
|
2018-08-08 23:23:57 +01:00
|
|
|
assert(binding->binding == max_binding);
|
|
|
|
|
|
|
|
set_layout->has_variable_descriptors = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (binding->pImmutableSamplers) {
|
|
|
|
set_layout->binding[b].immutable_samplers_offset = samplers_offset;
|
|
|
|
set_layout->has_immutable_samplers = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_layout->size +=
|
2019-01-09 22:16:01 +00:00
|
|
|
binding->descriptorCount * set_layout->binding[b].size;
|
2018-08-08 23:23:57 +01:00
|
|
|
buffer_count += binding->descriptorCount * binding_buffer_count;
|
2019-01-09 22:16:01 +00:00
|
|
|
dynamic_offset_count += binding->descriptorCount *
|
|
|
|
set_layout->binding[b].dynamic_offset_count;
|
2018-08-08 23:23:57 +01:00
|
|
|
set_layout->shader_stages |= binding->stageFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(bindings);
|
|
|
|
|
|
|
|
set_layout->buffer_count = buffer_count;
|
|
|
|
set_layout->dynamic_offset_count = dynamic_offset_count;
|
|
|
|
|
|
|
|
*pSetLayout = tu_descriptor_set_layout_to_handle(set_layout);
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_DestroyDescriptorSetLayout(VkDevice _device,
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDescriptorSetLayout _set_layout,
|
|
|
|
const VkAllocationCallbacks *pAllocator)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
|
|
|
TU_FROM_HANDLE(tu_descriptor_set_layout, set_layout, _set_layout);
|
|
|
|
|
|
|
|
if (!set_layout)
|
|
|
|
return;
|
|
|
|
|
|
|
|
vk_free2(&device->alloc, pAllocator, set_layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_GetDescriptorSetLayoutSupport(
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDevice device,
|
|
|
|
const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
|
|
|
|
VkDescriptorSetLayoutSupport *pSupport)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
2019-01-09 22:16:01 +00:00
|
|
|
VkDescriptorSetLayoutBinding *bindings = create_sorted_bindings(
|
|
|
|
pCreateInfo->pBindings, pCreateInfo->bindingCount);
|
2018-08-08 23:23:57 +01:00
|
|
|
if (!bindings) {
|
|
|
|
pSupport->supported = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const VkDescriptorSetLayoutBindingFlagsCreateInfoEXT *variable_flags =
|
2019-01-09 22:16:01 +00:00
|
|
|
vk_find_struct_const(
|
|
|
|
pCreateInfo->pNext,
|
|
|
|
DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT);
|
2018-08-08 23:23:57 +01:00
|
|
|
VkDescriptorSetVariableDescriptorCountLayoutSupportEXT *variable_count =
|
2019-01-09 22:16:01 +00:00
|
|
|
vk_find_struct(
|
|
|
|
(void *) pCreateInfo->pNext,
|
|
|
|
DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT_EXT);
|
2018-08-08 23:23:57 +01:00
|
|
|
if (variable_count) {
|
|
|
|
variable_count->maxVariableDescriptorCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool supported = true;
|
|
|
|
uint64_t size = 0;
|
|
|
|
for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) {
|
|
|
|
const VkDescriptorSetLayoutBinding *binding = bindings + i;
|
|
|
|
|
|
|
|
uint64_t descriptor_size = 0;
|
|
|
|
uint64_t descriptor_alignment = 1;
|
|
|
|
switch (binding->descriptorType) {
|
2019-01-09 22:16:01 +00:00
|
|
|
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
|
|
|
break;
|
|
|
|
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
|
|
|
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
|
|
|
descriptor_size = 16;
|
|
|
|
descriptor_alignment = 16;
|
|
|
|
break;
|
|
|
|
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
|
|
|
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
|
|
|
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
|
|
|
descriptor_size = 64;
|
|
|
|
descriptor_alignment = 32;
|
|
|
|
break;
|
|
|
|
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
|
|
|
descriptor_size = 96;
|
|
|
|
descriptor_alignment = 32;
|
|
|
|
break;
|
|
|
|
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
|
|
|
descriptor_size = 16;
|
|
|
|
descriptor_alignment = 16;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unreachable("unknown descriptor type\n");
|
|
|
|
break;
|
2018-08-08 23:23:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (size && !align_u64(size, descriptor_alignment)) {
|
|
|
|
supported = false;
|
|
|
|
}
|
|
|
|
size = align_u64(size, descriptor_alignment);
|
|
|
|
|
|
|
|
uint64_t max_count = UINT64_MAX;
|
|
|
|
if (descriptor_size)
|
|
|
|
max_count = (UINT64_MAX - size) / descriptor_size;
|
|
|
|
|
|
|
|
if (max_count < binding->descriptorCount) {
|
|
|
|
supported = false;
|
|
|
|
}
|
|
|
|
if (variable_flags && binding->binding < variable_flags->bindingCount &&
|
|
|
|
variable_count &&
|
|
|
|
(variable_flags->pBindingFlags[binding->binding] &
|
|
|
|
VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT)) {
|
|
|
|
variable_count->maxVariableDescriptorCount =
|
2019-01-09 22:16:01 +00:00
|
|
|
MIN2(UINT32_MAX, max_count);
|
2018-08-08 23:23:57 +01:00
|
|
|
}
|
|
|
|
size += binding->descriptorCount * descriptor_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(bindings);
|
|
|
|
|
|
|
|
pSupport->supported = supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pipeline layouts. These have nothing to do with the pipeline. They are
|
|
|
|
* just multiple descriptor set layouts pasted together.
|
|
|
|
*/
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
tu_CreatePipelineLayout(VkDevice _device,
|
2018-11-05 06:42:55 +00:00
|
|
|
const VkPipelineLayoutCreateInfo *pCreateInfo,
|
|
|
|
const VkAllocationCallbacks *pAllocator,
|
|
|
|
VkPipelineLayout *pPipelineLayout)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
|
|
|
struct tu_pipeline_layout *layout;
|
|
|
|
struct mesa_sha1 ctx;
|
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
assert(pCreateInfo->sType ==
|
|
|
|
VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO);
|
2018-08-08 23:23:57 +01:00
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
layout = vk_alloc2(&device->alloc, pAllocator, sizeof(*layout), 8,
|
2018-08-08 23:23:57 +01:00
|
|
|
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
|
|
|
if (layout == NULL)
|
|
|
|
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
|
|
|
|
|
|
|
layout->num_sets = pCreateInfo->setLayoutCount;
|
|
|
|
|
|
|
|
unsigned dynamic_offset_count = 0;
|
|
|
|
|
|
|
|
_mesa_sha1_init(&ctx);
|
|
|
|
for (uint32_t set = 0; set < pCreateInfo->setLayoutCount; set++) {
|
2019-01-09 22:16:01 +00:00
|
|
|
TU_FROM_HANDLE(tu_descriptor_set_layout, set_layout,
|
|
|
|
pCreateInfo->pSetLayouts[set]);
|
2018-08-08 23:23:57 +01:00
|
|
|
layout->set[set].layout = set_layout;
|
|
|
|
|
|
|
|
layout->set[set].dynamic_offset_start = dynamic_offset_count;
|
|
|
|
for (uint32_t b = 0; b < set_layout->binding_count; b++) {
|
|
|
|
dynamic_offset_count += set_layout->binding[b].array_size *
|
|
|
|
set_layout->binding[b].dynamic_offset_count;
|
|
|
|
if (set_layout->binding[b].immutable_samplers_offset)
|
|
|
|
_mesa_sha1_update(
|
2019-01-09 22:16:01 +00:00
|
|
|
&ctx,
|
|
|
|
tu_immutable_samplers(set_layout, set_layout->binding + b),
|
|
|
|
set_layout->binding[b].array_size * 4 * sizeof(uint32_t));
|
2018-08-08 23:23:57 +01:00
|
|
|
}
|
2019-01-09 22:16:01 +00:00
|
|
|
_mesa_sha1_update(
|
|
|
|
&ctx, set_layout->binding,
|
|
|
|
sizeof(set_layout->binding[0]) * set_layout->binding_count);
|
2018-08-08 23:23:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
layout->dynamic_offset_count = dynamic_offset_count;
|
|
|
|
layout->push_constant_size = 0;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < pCreateInfo->pushConstantRangeCount; ++i) {
|
|
|
|
const VkPushConstantRange *range = pCreateInfo->pPushConstantRanges + i;
|
|
|
|
layout->push_constant_size =
|
2019-01-09 22:16:01 +00:00
|
|
|
MAX2(layout->push_constant_size, range->offset + range->size);
|
2018-08-08 23:23:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
layout->push_constant_size = align(layout->push_constant_size, 16);
|
2019-01-09 22:16:01 +00:00
|
|
|
_mesa_sha1_update(&ctx, &layout->push_constant_size,
|
|
|
|
sizeof(layout->push_constant_size));
|
2018-08-08 23:23:57 +01:00
|
|
|
_mesa_sha1_final(&ctx, layout->sha1);
|
|
|
|
*pPipelineLayout = tu_pipeline_layout_to_handle(layout);
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_DestroyPipelineLayout(VkDevice _device,
|
2018-11-05 06:42:55 +00:00
|
|
|
VkPipelineLayout _pipelineLayout,
|
|
|
|
const VkAllocationCallbacks *pAllocator)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
|
|
|
TU_FROM_HANDLE(tu_pipeline_layout, pipeline_layout, _pipelineLayout);
|
|
|
|
|
|
|
|
if (!pipeline_layout)
|
|
|
|
return;
|
|
|
|
vk_free2(&device->alloc, pAllocator, pipeline_layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define EMPTY 1
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
tu_CreateDescriptorPool(VkDevice _device,
|
2018-11-05 06:42:55 +00:00
|
|
|
const VkDescriptorPoolCreateInfo *pCreateInfo,
|
|
|
|
const VkAllocationCallbacks *pAllocator,
|
|
|
|
VkDescriptorPool *pDescriptorPool)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
2018-11-12 22:42:36 +00:00
|
|
|
tu_use_args(device);
|
|
|
|
tu_stub();
|
2018-08-08 23:23:57 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_DestroyDescriptorPool(VkDevice _device,
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDescriptorPool _pool,
|
|
|
|
const VkAllocationCallbacks *pAllocator)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
tu_ResetDescriptorPool(VkDevice _device,
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDescriptorPool descriptorPool,
|
|
|
|
VkDescriptorPoolResetFlags flags)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
|
|
|
TU_FROM_HANDLE(tu_descriptor_pool, pool, descriptorPool);
|
|
|
|
|
2018-11-12 22:42:36 +00:00
|
|
|
tu_use_args(device, pool);
|
|
|
|
tu_stub();
|
2018-08-08 23:23:57 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
tu_AllocateDescriptorSets(VkDevice _device,
|
2018-11-05 06:42:55 +00:00
|
|
|
const VkDescriptorSetAllocateInfo *pAllocateInfo,
|
|
|
|
VkDescriptorSet *pDescriptorSets)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
|
|
|
TU_FROM_HANDLE(tu_descriptor_pool, pool, pAllocateInfo->descriptorPool);
|
|
|
|
|
2018-11-12 22:42:36 +00:00
|
|
|
tu_use_args(device, pool);
|
|
|
|
tu_stub();
|
2018-08-08 23:23:57 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
tu_FreeDescriptorSets(VkDevice _device,
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDescriptorPool descriptorPool,
|
|
|
|
uint32_t count,
|
|
|
|
const VkDescriptorSet *pDescriptorSets)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
|
|
|
TU_FROM_HANDLE(tu_descriptor_pool, pool, descriptorPool);
|
|
|
|
|
2018-11-12 22:42:36 +00:00
|
|
|
tu_use_args(device, pool);
|
|
|
|
tu_stub();
|
2018-08-08 23:23:57 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_update_descriptor_sets(struct tu_device *device,
|
2018-11-05 06:42:55 +00:00
|
|
|
struct tu_cmd_buffer *cmd_buffer,
|
|
|
|
VkDescriptorSet dstSetOverride,
|
|
|
|
uint32_t descriptorWriteCount,
|
|
|
|
const VkWriteDescriptorSet *pDescriptorWrites,
|
|
|
|
uint32_t descriptorCopyCount,
|
|
|
|
const VkCopyDescriptorSet *pDescriptorCopies)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_UpdateDescriptorSets(VkDevice _device,
|
2018-11-05 06:42:55 +00:00
|
|
|
uint32_t descriptorWriteCount,
|
|
|
|
const VkWriteDescriptorSet *pDescriptorWrites,
|
|
|
|
uint32_t descriptorCopyCount,
|
|
|
|
const VkCopyDescriptorSet *pDescriptorCopies)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
tu_update_descriptor_sets(device, NULL, VK_NULL_HANDLE,
|
|
|
|
descriptorWriteCount, pDescriptorWrites,
|
|
|
|
descriptorCopyCount, pDescriptorCopies);
|
2018-08-08 23:23:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
tu_CreateDescriptorUpdateTemplate(
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDevice _device,
|
|
|
|
const VkDescriptorUpdateTemplateCreateInfoKHR *pCreateInfo,
|
|
|
|
const VkAllocationCallbacks *pAllocator,
|
|
|
|
VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
2019-01-09 22:16:01 +00:00
|
|
|
TU_FROM_HANDLE(tu_descriptor_set_layout, set_layout,
|
|
|
|
pCreateInfo->descriptorSetLayout);
|
2018-08-08 23:23:57 +01:00
|
|
|
const uint32_t entry_count = pCreateInfo->descriptorUpdateEntryCount;
|
|
|
|
const size_t size =
|
2019-01-09 22:16:01 +00:00
|
|
|
sizeof(struct tu_descriptor_update_template) +
|
|
|
|
sizeof(struct tu_descriptor_update_template_entry) * entry_count;
|
2018-08-08 23:23:57 +01:00
|
|
|
struct tu_descriptor_update_template *templ;
|
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
templ = vk_alloc2(&device->alloc, pAllocator, size, 8,
|
|
|
|
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
2018-08-08 23:23:57 +01:00
|
|
|
if (!templ)
|
|
|
|
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
*pDescriptorUpdateTemplate =
|
|
|
|
tu_descriptor_update_template_to_handle(templ);
|
2018-11-12 22:42:36 +00:00
|
|
|
|
|
|
|
tu_use_args(set_layout);
|
|
|
|
tu_stub();
|
2018-08-08 23:23:57 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_DestroyDescriptorUpdateTemplate(
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDevice _device,
|
|
|
|
VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
|
|
|
|
const VkAllocationCallbacks *pAllocator)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
2019-01-09 22:16:01 +00:00
|
|
|
TU_FROM_HANDLE(tu_descriptor_update_template, templ,
|
|
|
|
descriptorUpdateTemplate);
|
2018-08-08 23:23:57 +01:00
|
|
|
|
|
|
|
if (!templ)
|
|
|
|
return;
|
|
|
|
|
|
|
|
vk_free2(&device->alloc, pAllocator, templ);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_update_descriptor_set_with_template(
|
2018-11-05 06:42:55 +00:00
|
|
|
struct tu_device *device,
|
|
|
|
struct tu_cmd_buffer *cmd_buffer,
|
|
|
|
struct tu_descriptor_set *set,
|
|
|
|
VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
|
|
|
|
const void *pData)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
2019-01-09 22:16:01 +00:00
|
|
|
TU_FROM_HANDLE(tu_descriptor_update_template, templ,
|
|
|
|
descriptorUpdateTemplate);
|
2018-11-12 22:42:36 +00:00
|
|
|
tu_use_args(templ);
|
2018-08-08 23:23:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_UpdateDescriptorSetWithTemplate(
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDevice _device,
|
|
|
|
VkDescriptorSet descriptorSet,
|
|
|
|
VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
|
|
|
|
const void *pData)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
TU_FROM_HANDLE(tu_device, device, _device);
|
|
|
|
TU_FROM_HANDLE(tu_descriptor_set, set, descriptorSet);
|
|
|
|
|
2019-01-09 22:16:01 +00:00
|
|
|
tu_update_descriptor_set_with_template(device, NULL, set,
|
|
|
|
descriptorUpdateTemplate, pData);
|
2018-08-08 23:23:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VkResult
|
|
|
|
tu_CreateSamplerYcbcrConversion(
|
2018-11-05 06:42:55 +00:00
|
|
|
VkDevice device,
|
|
|
|
const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
|
|
|
|
const VkAllocationCallbacks *pAllocator,
|
|
|
|
VkSamplerYcbcrConversion *pYcbcrConversion)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
*pYcbcrConversion = VK_NULL_HANDLE;
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tu_DestroySamplerYcbcrConversion(VkDevice device,
|
2018-11-05 06:42:55 +00:00
|
|
|
VkSamplerYcbcrConversion ycbcrConversion,
|
|
|
|
const VkAllocationCallbacks *pAllocator)
|
2018-08-08 23:23:57 +01:00
|
|
|
{
|
|
|
|
/* Do nothing. */
|
|
|
|
}
|