mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 18:28:12 +02:00
nvk: Add an nvk_get_format helper
This makes the array size internal to nvk_format.c so we don't have to keep it in sync when we add extra elements. Also, there's no reason why we need to be hand-rolling that loop all the time. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
parent
ec6d56d4ce
commit
3516136d7a
5 changed files with 44 additions and 46 deletions
|
|
@ -20,7 +20,7 @@
|
|||
* TODO: O formats
|
||||
*/
|
||||
|
||||
struct nvk_format nvk_formats[NVK_FORMATS] = {
|
||||
struct nvk_format nvk_formats[] = {
|
||||
{
|
||||
.vk_format = VK_FORMAT_R8_UNORM,
|
||||
.hw_format = 0x0,
|
||||
|
|
@ -166,6 +166,17 @@ struct nvk_format nvk_formats[NVK_FORMATS] = {
|
|||
},
|
||||
};
|
||||
|
||||
const struct nvk_format *
|
||||
nvk_get_format(VkFormat vk_format)
|
||||
{
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(nvk_formats); i++) {
|
||||
if (nvk_formats[i].vk_format == vk_format)
|
||||
return &nvk_formats[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#include "gallium/drivers/nouveau/nv50/g80_defs.xml.h"
|
||||
#include "gallium/drivers/nouveau/nv50/g80_texture.xml.h"
|
||||
#include "gallium/drivers/nouveau/nvc0/gm107_texture.xml.h"
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ struct nvk_format {
|
|||
bool supports_2d_blit:1;
|
||||
};
|
||||
|
||||
#define NVK_FORMATS 28
|
||||
extern struct nvk_format nvk_formats[NVK_FORMATS];
|
||||
const struct nvk_format *nvk_get_format(VkFormat vk_format);
|
||||
|
||||
struct nvk_tic_format {
|
||||
unsigned comp_sizes:8;
|
||||
|
|
|
|||
|
|
@ -98,14 +98,7 @@ static VkResult nvk_image_init(struct nvk_device *device,
|
|||
|
||||
vk_image_init(&device->vk, &image->vk, pCreateInfo);
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(nvk_formats); i++) {
|
||||
struct nvk_format *format = &nvk_formats[i];
|
||||
|
||||
if (format->vk_format != pCreateInfo->format)
|
||||
continue;
|
||||
|
||||
image->format = format;
|
||||
}
|
||||
image->format = nvk_get_format(pCreateInfo->format);
|
||||
assert(image->format);
|
||||
|
||||
for (uint32_t l = 0; l < pCreateInfo->mipLevels; l++) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ struct nvk_image {
|
|||
|
||||
VkDeviceSize min_size;
|
||||
|
||||
struct nvk_format *format;
|
||||
const struct nvk_format *format;
|
||||
struct nvk_image_level level[NVK_MAX_MIP_LEVELS];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -465,44 +465,39 @@ nvk_GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
|
|||
if (base_info->usage & ~(VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT))
|
||||
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(nvk_formats); i++) {
|
||||
struct nvk_format *format = &nvk_formats[i];
|
||||
const struct nvk_format *format = nvk_get_format(base_info->format);
|
||||
if (format == NULL)
|
||||
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
|
||||
if (format->vk_format != base_info->format)
|
||||
continue;
|
||||
if (base_info->type == VK_IMAGE_TYPE_1D)
|
||||
base_props->imageFormatProperties.maxExtent = (VkExtent3D){32768, 1, 1};
|
||||
else if (base_info->type == VK_IMAGE_TYPE_2D)
|
||||
base_props->imageFormatProperties.maxExtent = (VkExtent3D){32768, 32768, 1};
|
||||
else
|
||||
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
|
||||
if (base_info->type == VK_IMAGE_TYPE_1D)
|
||||
base_props->imageFormatProperties.maxExtent = (VkExtent3D){32768, 1, 1};
|
||||
else if (base_info->type == VK_IMAGE_TYPE_2D)
|
||||
base_props->imageFormatProperties.maxExtent = (VkExtent3D){32768, 32768, 1};
|
||||
else
|
||||
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
base_props->imageFormatProperties.maxMipLevels = NVK_MAX_MIP_LEVELS;
|
||||
base_props->imageFormatProperties.maxArrayLayers = 2048;
|
||||
base_props->imageFormatProperties.sampleCounts = 0;
|
||||
base_props->imageFormatProperties.maxResourceSize = 0xffffffff; // TODO proper value
|
||||
|
||||
base_props->imageFormatProperties.maxMipLevels = NVK_MAX_MIP_LEVELS;
|
||||
base_props->imageFormatProperties.maxArrayLayers = 2048;
|
||||
base_props->imageFormatProperties.sampleCounts = 0;
|
||||
base_props->imageFormatProperties.maxResourceSize = 0xffffffff; // TODO proper value
|
||||
|
||||
vk_foreach_struct(s, base_props->pNext) {
|
||||
switch (s->sType) {
|
||||
default:
|
||||
nvk_debug_ignored_stype(s->sType);
|
||||
break;
|
||||
}
|
||||
vk_foreach_struct(s, base_props->pNext) {
|
||||
switch (s->sType) {
|
||||
default:
|
||||
nvk_debug_ignored_stype(s->sType);
|
||||
break;
|
||||
}
|
||||
|
||||
vk_foreach_struct(ext, base_info->pNext)
|
||||
{
|
||||
/* Use unsigned since some cases are not in the VkStructureType enum. */
|
||||
switch ((unsigned)ext->sType) {
|
||||
default:
|
||||
nvk_debug_ignored_stype(ext->sType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
vk_foreach_struct(ext, base_info->pNext)
|
||||
{
|
||||
/* Use unsigned since some cases are not in the VkStructureType enum. */
|
||||
switch ((unsigned)ext->sType) {
|
||||
default:
|
||||
nvk_debug_ignored_stype(ext->sType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue