mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-08 06:20:19 +01:00
zink: wrap all access to format_props and modifier_props
no functional changes Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31413>
This commit is contained in:
parent
086791ade8
commit
8ce4951bf7
6 changed files with 44 additions and 29 deletions
|
|
@ -971,7 +971,7 @@ create_bvci(struct zink_context *ctx, struct zink_resource *res, enum pipe_forma
|
|||
memset(&bvci, 0, sizeof(bvci));
|
||||
bvci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
|
||||
bvci.pNext = NULL;
|
||||
if (screen->format_props[format].bufferFeatures & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT)
|
||||
if (zink_get_format_props(screen, format)->bufferFeatures & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT)
|
||||
bvci.buffer = res->obj->storage_buffer ? res->obj->storage_buffer : res->obj->buffer;
|
||||
else
|
||||
bvci.buffer = res->obj->buffer;
|
||||
|
|
|
|||
|
|
@ -549,7 +549,7 @@ get_image_usage(struct zink_screen *screen, VkImageCreateInfo *ici, const struct
|
|||
*mod = DRM_FORMAT_MOD_INVALID;
|
||||
if (modifiers_count) {
|
||||
bool have_linear = false;
|
||||
const struct zink_modifier_props *prop = &screen->modifier_props[templ->format];
|
||||
const struct zink_modifier_props *prop = zink_get_modifier_props(screen, templ->format);
|
||||
assert(tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT);
|
||||
bool found = false;
|
||||
uint64_t good_mod = 0;
|
||||
|
|
@ -595,8 +595,8 @@ get_image_usage(struct zink_screen *screen, VkImageCreateInfo *ici, const struct
|
|||
}
|
||||
}
|
||||
} else {
|
||||
struct zink_format_props props = screen->format_props[templ->format];
|
||||
VkFormatFeatureFlags2 feats = tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures;
|
||||
const struct zink_format_props *props = zink_get_format_props(screen, templ->format);
|
||||
VkFormatFeatureFlags2 feats = tiling == VK_IMAGE_TILING_LINEAR ? props->linearTilingFeatures : props->optimalTilingFeatures;
|
||||
if (feats & VK_FORMAT_FEATURE_2_DISJOINT_BIT && util_format_get_num_planes(templ->format))
|
||||
ici->flags |= VK_IMAGE_CREATE_DISJOINT_BIT;
|
||||
if (ici->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT)
|
||||
|
|
@ -837,10 +837,10 @@ get_format_feature_flags(VkImageCreateInfo ici, struct zink_screen *screen, cons
|
|||
VkFormatFeatureFlags feats = 0;
|
||||
switch (ici.tiling) {
|
||||
case VK_IMAGE_TILING_LINEAR:
|
||||
feats = screen->format_props[templ->format].linearTilingFeatures;
|
||||
feats = zink_get_format_props(screen, templ->format)->linearTilingFeatures;
|
||||
break;
|
||||
case VK_IMAGE_TILING_OPTIMAL:
|
||||
feats = screen->format_props[templ->format].optimalTilingFeatures;
|
||||
feats = zink_get_format_props(screen, templ->format)->optimalTilingFeatures;
|
||||
break;
|
||||
case VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT:
|
||||
feats = VK_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM;
|
||||
|
|
|
|||
|
|
@ -1495,42 +1495,42 @@ zink_is_format_supported(struct pipe_screen *pscreen,
|
|||
return false;
|
||||
}
|
||||
|
||||
struct zink_format_props props = screen->format_props[format];
|
||||
const struct zink_format_props *props = zink_get_format_props(screen, format);
|
||||
|
||||
if (target == PIPE_BUFFER) {
|
||||
if (bind & PIPE_BIND_VERTEX_BUFFER) {
|
||||
if (!(props.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT)) {
|
||||
if (!(props->bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT)) {
|
||||
enum pipe_format new_format = zink_decompose_vertex_format(format);
|
||||
if (!new_format)
|
||||
return false;
|
||||
if (!(screen->format_props[new_format].bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT))
|
||||
if (!(zink_get_format_props(screen, new_format)->bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bind & PIPE_BIND_SAMPLER_VIEW &&
|
||||
!(props.bufferFeatures & VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT))
|
||||
!(props->bufferFeatures & VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT))
|
||||
return false;
|
||||
|
||||
if (bind & PIPE_BIND_SHADER_IMAGE &&
|
||||
!(props.bufferFeatures & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT))
|
||||
!(props->bufferFeatures & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT))
|
||||
return false;
|
||||
} else {
|
||||
/* all other targets are texture-targets */
|
||||
if (bind & PIPE_BIND_RENDER_TARGET &&
|
||||
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
|
||||
!(props->optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
|
||||
return false;
|
||||
|
||||
if (bind & PIPE_BIND_BLENDABLE &&
|
||||
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT))
|
||||
!(props->optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT))
|
||||
return false;
|
||||
|
||||
if (bind & PIPE_BIND_SAMPLER_VIEW &&
|
||||
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
|
||||
!(props->optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
|
||||
return false;
|
||||
|
||||
if (bind & PIPE_BIND_SAMPLER_REDUCTION_MINMAX &&
|
||||
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT))
|
||||
!(props->optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT))
|
||||
return false;
|
||||
|
||||
if ((bind & PIPE_BIND_SAMPLER_VIEW) || (bind & PIPE_BIND_RENDER_TARGET)) {
|
||||
|
|
@ -1542,11 +1542,11 @@ zink_is_format_supported(struct pipe_screen *pscreen,
|
|||
}
|
||||
|
||||
if (bind & PIPE_BIND_DEPTH_STENCIL &&
|
||||
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
|
||||
!(props->optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
|
||||
return false;
|
||||
|
||||
if (bind & PIPE_BIND_SHADER_IMAGE &&
|
||||
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT))
|
||||
!(props->optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2641,12 +2641,13 @@ static void
|
|||
zink_query_dmabuf_modifiers(struct pipe_screen *pscreen, enum pipe_format format, int max, uint64_t *modifiers, unsigned int *external_only, int *count)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(pscreen);
|
||||
*count = screen->modifier_props[format].drmFormatModifierCount;
|
||||
const struct zink_modifier_props *props = zink_get_modifier_props(screen, format);
|
||||
*count = props->drmFormatModifierCount;
|
||||
for (int i = 0; i < MIN2(max, *count); i++) {
|
||||
if (external_only)
|
||||
external_only[i] = 0;
|
||||
|
||||
modifiers[i] = screen->modifier_props[format].pDrmFormatModifierProperties[i].drmFormatModifier;
|
||||
modifiers[i] = props->pDrmFormatModifierProperties[i].drmFormatModifier;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2654,8 +2655,9 @@ static bool
|
|||
zink_is_dmabuf_modifier_supported(struct pipe_screen *pscreen, uint64_t modifier, enum pipe_format format, bool *external_only)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(pscreen);
|
||||
for (unsigned i = 0; i < screen->modifier_props[format].drmFormatModifierCount; i++)
|
||||
if (screen->modifier_props[format].pDrmFormatModifierProperties[i].drmFormatModifier == modifier)
|
||||
const struct zink_modifier_props *props = zink_get_modifier_props(screen, format);
|
||||
for (unsigned i = 0; i < props->drmFormatModifierCount; i++)
|
||||
if (props->pDrmFormatModifierProperties[i].drmFormatModifier == modifier)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2664,9 +2666,10 @@ static unsigned
|
|||
zink_get_dmabuf_modifier_planes(struct pipe_screen *pscreen, uint64_t modifier, enum pipe_format format)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(pscreen);
|
||||
for (unsigned i = 0; i < screen->modifier_props[format].drmFormatModifierCount; i++)
|
||||
if (screen->modifier_props[format].pDrmFormatModifierProperties[i].drmFormatModifier == modifier)
|
||||
return screen->modifier_props[format].pDrmFormatModifierProperties[i].drmFormatModifierPlaneCount;
|
||||
const struct zink_modifier_props *props = zink_get_modifier_props(screen, format);
|
||||
for (unsigned i = 0; i < props->drmFormatModifierCount; i++)
|
||||
if (props->pDrmFormatModifierProperties[i].drmFormatModifier == modifier)
|
||||
return props->pDrmFormatModifierProperties[i].drmFormatModifierPlaneCount;
|
||||
return util_format_get_num_planes(format);
|
||||
}
|
||||
|
||||
|
|
@ -2732,7 +2735,7 @@ zink_get_sparse_texture_virtual_page_size(struct pipe_screen *pscreen,
|
|||
VkImageUsageFlags use_flags = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
|
||||
VK_IMAGE_USAGE_STORAGE_BIT;
|
||||
use_flags |= is_zs ? VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
VkImageUsageFlags flags = screen->format_props[pformat].optimalTilingFeatures & use_flags;
|
||||
VkImageUsageFlags flags = zink_get_format_props(screen, pformat)->optimalTilingFeatures & use_flags;
|
||||
VkSparseImageFormatProperties props[4]; //planar?
|
||||
unsigned prop_count = ARRAY_SIZE(props);
|
||||
VKSCR(GetPhysicalDeviceSparseImageFormatProperties)(screen->pdev, format, type,
|
||||
|
|
|
|||
|
|
@ -151,6 +151,18 @@ zink_screen_export_dmabuf_semaphore(struct zink_screen *screen, struct zink_reso
|
|||
bool
|
||||
zink_screen_import_dmabuf_semaphore(struct zink_screen *screen, struct zink_resource *res, VkSemaphore sem);
|
||||
|
||||
static inline const struct zink_modifier_props *
|
||||
zink_get_modifier_props(struct zink_screen *screen, enum pipe_format pformat)
|
||||
{
|
||||
return &screen->modifier_props[pformat];
|
||||
}
|
||||
|
||||
static inline const struct zink_format_props *
|
||||
zink_get_format_props(struct zink_screen *screen, enum pipe_format pformat)
|
||||
{
|
||||
return &screen->format_props[pformat];
|
||||
}
|
||||
|
||||
VkFormat
|
||||
zink_get_format(struct zink_screen *screen, enum pipe_format format);
|
||||
|
||||
|
|
|
|||
|
|
@ -77,13 +77,13 @@ zink_create_vertex_elements_state(struct pipe_context *pctx,
|
|||
ves->divisor[binding] = MIN2(elem->instance_divisor, screen->info.vdiv_props.maxVertexAttribDivisor);
|
||||
|
||||
VkFormat format;
|
||||
if (screen->format_props[elem->src_format].bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT)
|
||||
if (zink_get_format_props(screen, elem->src_format)->bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT)
|
||||
format = zink_get_format(screen, elem->src_format);
|
||||
else {
|
||||
enum pipe_format new_format = zink_decompose_vertex_format(elem->src_format);
|
||||
assert(new_format);
|
||||
num_decomposed++;
|
||||
assert(screen->format_props[new_format].bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT);
|
||||
assert(zink_get_format_props(screen, new_format)->bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT);
|
||||
if (util_format_get_blocksize(new_format) == 4)
|
||||
size32 |= BITFIELD_BIT(i);
|
||||
else if (util_format_get_blocksize(new_format) == 2)
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ static void
|
|||
apply_view_usage_for_format(struct zink_screen *screen, struct zink_resource *res, struct zink_surface *surface, enum pipe_format format, VkImageViewCreateInfo *ivci)
|
||||
{
|
||||
VkFormatFeatureFlags feats = res->linear ?
|
||||
screen->format_props[format].linearTilingFeatures :
|
||||
screen->format_props[format].optimalTilingFeatures;
|
||||
zink_get_format_props(screen, format)->linearTilingFeatures :
|
||||
zink_get_format_props(screen, format)->optimalTilingFeatures;
|
||||
VkImageUsageFlags attachment = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
|
||||
surface->usage_info.usage = res->obj->vkusage & ~attachment;
|
||||
if (res->obj->modifier_aspect) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue