[Mesa-dev] [PATCH 07/16] radv: Implement VK_KHR_maintenance3.
Samuel Pitoiset
samuel.pitoiset at gmail.com
Wed Mar 7 18:35:46 UTC 2018
On 03/07/2018 07:32 PM, Bas Nieuwenhuizen wrote:
> On Wed, Mar 7, 2018 at 7:19 PM, Samuel Pitoiset
> <samuel.pitoiset at gmail.com> wrote:
>>
>>
>> On 03/07/2018 03:47 PM, Bas Nieuwenhuizen wrote:
>>>
>>> Reviewed-by: Dave Airlie <airlied at redhat.com>
>>> ---
>>> src/amd/vulkan/radv_descriptor_set.c | 82
>>> ++++++++++++++++++++++++++++++++++--
>>> src/amd/vulkan/radv_device.c | 10 +++++
>>> src/amd/vulkan/radv_extensions.py | 1 +
>>> 3 files changed, 89 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/src/amd/vulkan/radv_descriptor_set.c
>>> b/src/amd/vulkan/radv_descriptor_set.c
>>> index 38b8dc78e1..265028df2b 100644
>>> --- a/src/amd/vulkan/radv_descriptor_set.c
>>> +++ b/src/amd/vulkan/radv_descriptor_set.c
>>> @@ -31,6 +31,20 @@
>>> #include "radv_private.h"
>>> #include "sid.h"
>>> +
>>> +static bool has_equal_immutable_samplers(const VkSampler *samplers,
>>> uint32_t count)
>>> +{
>>> + if (!samplers)
>>> + return false;
>>> + for(uint32_t i = 1; i < count; ++i) {
>>> + if (memcmp(radv_sampler_from_handle(samplers[0])->state,
>>> + radv_sampler_from_handle(samplers[i])->state,
>>> 16)) {
>>> + return false;
>>> + }
>>> + }
>>> + return true;
>>> +}
>>> +
>>> VkResult radv_CreateDescriptorSetLayout(
>>> VkDevice _device,
>>> const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
>>> @@ -132,15 +146,13 @@ VkResult radv_CreateDescriptorSetLayout(
>>> if (binding->pImmutableSamplers) {
>>> set_layout->binding[b].immutable_samplers_offset =
>>> samplers_offset;
>>> - set_layout->binding[b].immutable_samplers_equal =
>>> true;
>>> + set_layout->binding[b].immutable_samplers_equal =
>>> +
>>> has_equal_immutable_samplers(binding->pImmutableSamplers,
>>> binding->descriptorCount);
>>> set_layout->has_immutable_samplers = true;
>>> for (uint32_t i = 0; i < binding->descriptorCount;
>>> i++)
>>> memcpy(samplers + 4 * i,
>>> &radv_sampler_from_handle(binding->pImmutableSamplers[i])->state, 16);
>>> - for (uint32_t i = 1; i < binding->descriptorCount;
>>> i++)
>>> - if (memcmp(samplers + 4 * i, samplers, 16)
>>> != 0)
>>> -
>>> set_layout->binding[b].immutable_samplers_equal = false;
>>> /* Don't reserve space for the samplers if they're
>>> not accessed. */
>>> if
>>> (set_layout->binding[b].immutable_samplers_equal) {
>>> @@ -182,6 +194,68 @@ void radv_DestroyDescriptorSetLayout(
>>> vk_free2(&device->alloc, pAllocator, set_layout);
>>> }
>>> +void radv_GetDescriptorSetLayoutSupport(VkDevice device,
>>> + const
>>> VkDescriptorSetLayoutCreateInfo* pCreateInfo,
>>> + VkDescriptorSetLayoutSupport*
>>> pSupport)
>>> +{
>>> + bool supported = true;
>>> + uint64_t size = 0;
>>> + for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) {
>>> + const VkDescriptorSetLayoutBinding *binding =
>>> &pCreateInfo->pBindings[i];
>>> +
>>> + if (binding->descriptorCount == 0)
>>> + continue;
>>> +
>>> + uint64_t descriptor_size = 0;
>>> + uint64_t descriptor_alignment = 1;
>>> + switch (binding->descriptorType) {
>>> + 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:
>>> + if
>>> (!has_equal_immutable_samplers(binding->pImmutableSamplers,
>>> binding->descriptorCount)) {
>>> + descriptor_size = 64;
>>> + } else {
>>> + descriptor_size = 96;
>>> + }
>>> + descriptor_alignment = 32;
>>
>>
>> Missing break?
>
> So much for the tests ...
Yes...
The rest looks good to me, nice work!
>
> Fixed locally.
>
>>
>>
>>> + case VK_DESCRIPTOR_TYPE_SAMPLER:
>>> + if
>>> (!has_equal_immutable_samplers(binding->pImmutableSamplers,
>>> binding->descriptorCount)) {
>>> + descriptor_size = 16;
>>> + descriptor_alignment = 16;
>>> + }
>>> + break;
>>> + default:
>>> + unreachable("unknown descriptor type\n");
>>> + break;
>>> + }
>>> +
>>> + if (size && !align_u64(size, descriptor_alignment)) {
>>> + supported = false;
>>> + }
>>> + size = align_u64(size, descriptor_alignment);
>>> + if (descriptor_size && (UINT64_MAX - size) /
>>> descriptor_size < binding->descriptorCount) {
>>> + supported = false;
>>> + }
>>> + size += binding->descriptorCount * descriptor_size;
>>> + }
>>> +
>>> + pSupport->supported = supported;
>>> +}
>>> +
>>> /*
>>> * Pipeline layouts. These have nothing to do with the pipeline. They
>>> are
>>> * just muttiple descriptor set layouts pasted together
>>> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
>>> index 00bb70612e..593cfc9a36 100644
>>> --- a/src/amd/vulkan/radv_device.c
>>> +++ b/src/amd/vulkan/radv_device.c
>>> @@ -875,6 +875,16 @@ void radv_GetPhysicalDeviceProperties2(
>>> properties->quadOperationsInAllStages = false;
>>> break;
>>> }
>>> + case
>>> VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES: {
>>> + VkPhysicalDeviceMaintenance3Properties *properties
>>> =
>>> + (VkPhysicalDeviceMaintenance3Properties*)ext;
>>> + /* Make sure evrything is addressable by a signed
>>> 32-bit int, and our
>>> + * largest descriptors are 96 bytes. */
>>> + properties->maxPerSetDescriptors = (1ull << 31) /
>>> 96;
>>> + /* Our buffer size fields allow only this much */
>>> + properties->maxMemoryAllocationSize =
>>> 0xFFFFFFFFull;
>>> + break;
>>> + }
>>> default:
>>> break;
>>> }
>>> diff --git a/src/amd/vulkan/radv_extensions.py
>>> b/src/amd/vulkan/radv_extensions.py
>>> index 6fa553e589..3b4f75bff6 100644
>>> --- a/src/amd/vulkan/radv_extensions.py
>>> +++ b/src/amd/vulkan/radv_extensions.py
>>> @@ -70,6 +70,7 @@ EXTENSIONS = [
>>> Extension('VK_KHR_incremental_present', 1, True),
>>> Extension('VK_KHR_maintenance1', 1, True),
>>> Extension('VK_KHR_maintenance2', 1, True),
>>> + Extension('VK_KHR_maintenance3', 1, True),
>>> Extension('VK_KHR_push_descriptor', 1, True),
>>> Extension('VK_KHR_relaxed_block_layout', 1, True),
>>> Extension('VK_KHR_sampler_mirror_clamp_to_edge', 1, True),
>>>
>>
More information about the mesa-dev
mailing list