Commit 9a23dc6a authored by Erik Faye-Lund 's avatar Erik Faye-Lund

zink: do not use both depth and stencil aspects for sampler-views

parent 217143d3
...@@ -226,6 +226,19 @@ component_mapping(enum pipe_swizzle swizzle) ...@@ -226,6 +226,19 @@ component_mapping(enum pipe_swizzle swizzle)
} }
} }
static VkImageAspectFlags
sampler_aspect_from_format(enum pipe_format fmt)
{
if (util_format_is_depth_or_stencil(fmt)) {
const struct util_format_description *desc = util_format_description(fmt);
if (util_format_has_depth(desc))
return VK_IMAGE_ASPECT_DEPTH_BIT;
assert(util_format_has_stencil(desc));
return VK_IMAGE_ASPECT_STENCIL_BIT;
} else
return VK_IMAGE_ASPECT_COLOR_BIT;
}
static struct pipe_sampler_view * static struct pipe_sampler_view *
zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres, zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
const struct pipe_sampler_view *state) const struct pipe_sampler_view *state)
...@@ -249,7 +262,8 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres, ...@@ -249,7 +262,8 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
ivci.components.g = component_mapping(state->swizzle_g); ivci.components.g = component_mapping(state->swizzle_g);
ivci.components.b = component_mapping(state->swizzle_b); ivci.components.b = component_mapping(state->swizzle_b);
ivci.components.a = component_mapping(state->swizzle_a); ivci.components.a = component_mapping(state->swizzle_a);
ivci.subresourceRange.aspectMask = zink_aspect_from_format(state->format);
ivci.subresourceRange.aspectMask = sampler_aspect_from_format(state->format);
ivci.subresourceRange.baseMipLevel = state->u.tex.first_level; ivci.subresourceRange.baseMipLevel = state->u.tex.first_level;
ivci.subresourceRange.baseArrayLayer = state->u.tex.first_layer; ivci.subresourceRange.baseArrayLayer = state->u.tex.first_layer;
ivci.subresourceRange.levelCount = state->u.tex.last_level - state->u.tex.first_level + 1; ivci.subresourceRange.levelCount = state->u.tex.last_level - state->u.tex.first_level + 1;
......
...@@ -68,8 +68,8 @@ get_memory_type_index(struct zink_screen *screen, ...@@ -68,8 +68,8 @@ get_memory_type_index(struct zink_screen *screen,
return 0; return 0;
} }
VkImageAspectFlags static VkImageAspectFlags
zink_aspect_from_format(enum pipe_format fmt) aspect_from_format(enum pipe_format fmt)
{ {
if (util_format_is_depth_or_stencil(fmt)) { if (util_format_is_depth_or_stencil(fmt)) {
VkImageAspectFlags aspect = 0; VkImageAspectFlags aspect = 0;
...@@ -224,7 +224,7 @@ zink_resource_create(struct pipe_screen *pscreen, ...@@ -224,7 +224,7 @@ zink_resource_create(struct pipe_screen *pscreen,
} }
res->optimial_tiling = ici.tiling != VK_IMAGE_TILING_LINEAR; res->optimial_tiling = ici.tiling != VK_IMAGE_TILING_LINEAR;
res->aspect = zink_aspect_from_format(templ->format); res->aspect = aspect_from_format(templ->format);
vkGetImageMemoryRequirements(screen->dev, res->image, &reqs); vkGetImageMemoryRequirements(screen->dev, res->image, &reqs);
if (templ->usage == PIPE_USAGE_STAGING || (screen->winsys && (templ->bind & (PIPE_BIND_SCANOUT|PIPE_BIND_DISPLAY_TARGET|PIPE_BIND_SHARED)))) if (templ->usage == PIPE_USAGE_STAGING || (screen->winsys && (templ->bind & (PIPE_BIND_SCANOUT|PIPE_BIND_DISPLAY_TARGET|PIPE_BIND_SHARED))))
......
...@@ -62,9 +62,6 @@ zink_resource(struct pipe_resource *r) ...@@ -62,9 +62,6 @@ zink_resource(struct pipe_resource *r)
return (struct zink_resource *)r; return (struct zink_resource *)r;
} }
VkImageAspectFlags
zink_aspect_from_format(enum pipe_format fmt);
void void
zink_screen_resource_init(struct pipe_screen *pscreen); zink_screen_resource_init(struct pipe_screen *pscreen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment