summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/zink/zink_context.c2
-rw-r--r--src/gallium/drivers/zink/zink_resource.c2
-rw-r--r--src/gallium/drivers/zink/zink_screen.c34
-rw-r--r--src/gallium/drivers/zink/zink_screen.h6
-rw-r--r--src/gallium/drivers/zink/zink_state.c4
-rw-r--r--src/gallium/drivers/zink/zink_surface.c2
6 files changed, 42 insertions, 8 deletions
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 74f94ee988d..2c253b575e5 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -257,7 +257,7 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
ivci.image = res->image;
ivci.viewType = image_view_type(state->target);
- ivci.format = zink_get_format(state->format);
+ ivci.format = zink_get_format(screen, state->format);
ivci.components.r = component_mapping(state->swizzle_r);
ivci.components.g = component_mapping(state->swizzle_g);
ivci.components.b = component_mapping(state->swizzle_b);
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index fe4097e9f0c..dccbe827f63 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -133,7 +133,7 @@ resource_create(struct pipe_screen *pscreen,
vkGetBufferMemoryRequirements(screen->dev, res->buffer, &reqs);
flags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
} else {
- res->format = zink_get_format(templ->format);
+ res->format = zink_get_format(screen, templ->format);
VkImageCreateInfo ici = {};
ici.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 667f242091c..a75389257af 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -569,10 +569,33 @@ static const VkFormat formats[PIPE_FORMAT_COUNT] = {
[PIPE_FORMAT_BPTC_RGB_UFLOAT] = VK_FORMAT_BC6H_UFLOAT_BLOCK,
};
+static bool
+is_depth_format_supported(struct zink_screen *screen, VkFormat format)
+{
+ VkFormatProperties props;
+ vkGetPhysicalDeviceFormatProperties(screen->pdev, format, &props);
+ return (props.linearTilingFeatures | props.optimalTilingFeatures) &
+ VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
+}
+
VkFormat
-zink_get_format(enum pipe_format format)
+zink_get_format(struct zink_screen *screen, enum pipe_format format)
{
- return formats[format];
+ VkFormat ret = formats[format];
+
+ if (ret == VK_FORMAT_X8_D24_UNORM_PACK32 &&
+ !screen->have_X8_D24_UNORM_PACK32) {
+ assert(is_depth_format_supported(screen, VK_FORMAT_D32_SFLOAT));
+ return VK_FORMAT_D32_SFLOAT;
+ }
+
+ if (ret == VK_FORMAT_D24_UNORM_S8_UINT &&
+ !screen->have_D24_UNORM_S8_UINT) {
+ assert(is_depth_format_supported(screen, VK_FORMAT_D32_SFLOAT_S8_UINT));
+ return VK_FORMAT_D32_SFLOAT_S8_UINT;
+ }
+
+ return ret;
}
static VkSampleCountFlagBits
@@ -605,7 +628,7 @@ zink_is_format_supported(struct pipe_screen *pscreen,
return screen->props.limits.framebufferNoAttachmentsSampleCounts &
vk_sample_count_flags(sample_count);
- VkFormat vkformat = formats[format];
+ VkFormat vkformat = zink_get_format(screen, format);
if (vkformat == VK_FORMAT_UNDEFINED)
return FALSE;
@@ -830,6 +853,11 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
vkGetPhysicalDeviceFeatures(screen->pdev, &screen->feats);
vkGetPhysicalDeviceMemoryProperties(screen->pdev, &screen->mem_props);
+ screen->have_X8_D24_UNORM_PACK32 = is_depth_format_supported(screen,
+ VK_FORMAT_X8_D24_UNORM_PACK32);
+ screen->have_D24_UNORM_S8_UINT = is_depth_format_supported(screen,
+ VK_FORMAT_D24_UNORM_S8_UINT);
+
uint32_t num_extensions = 0;
if (vkEnumerateDeviceExtensionProperties(screen->pdev, NULL,
&num_extensions, NULL) == VK_SUCCESS && num_extensions > 0) {
diff --git a/src/gallium/drivers/zink/zink_screen.h b/src/gallium/drivers/zink/zink_screen.h
index 38ade554ccc..0b0ee210abb 100644
--- a/src/gallium/drivers/zink/zink_screen.h
+++ b/src/gallium/drivers/zink/zink_screen.h
@@ -48,8 +48,12 @@ struct zink_screen {
VkPhysicalDeviceProperties props;
VkPhysicalDeviceFeatures feats;
VkPhysicalDeviceMemoryProperties mem_props;
+
bool have_KHR_maintenance1;
+ bool have_X8_D24_UNORM_PACK32;
+ bool have_D24_UNORM_S8_UINT;
+
uint32_t gfx_queue;
VkDevice dev;
@@ -63,6 +67,6 @@ zink_screen(struct pipe_screen *pipe)
}
VkFormat
-zink_get_format(enum pipe_format format);
+zink_get_format(struct zink_screen *screen, enum pipe_format format);
#endif
diff --git a/src/gallium/drivers/zink/zink_state.c b/src/gallium/drivers/zink/zink_state.c
index 07da1be2bf8..dba85ef43e8 100644
--- a/src/gallium/drivers/zink/zink_state.c
+++ b/src/gallium/drivers/zink/zink_state.c
@@ -35,6 +35,7 @@ zink_create_vertex_elements_state(struct pipe_context *pctx,
unsigned num_elements,
const struct pipe_vertex_element *elements)
{
+ struct zink_screen *screen = zink_screen(pctx->screen);
unsigned int i;
struct zink_vertex_elements_state *ves = CALLOC_STRUCT(zink_vertex_elements_state);
if (!ves)
@@ -62,7 +63,8 @@ zink_create_vertex_elements_state(struct pipe_context *pctx,
ves->hw_state.attribs[i].binding = binding;
ves->hw_state.attribs[i].location = i; // TODO: unsure
- ves->hw_state.attribs[i].format = zink_get_format(elem->src_format);
+ ves->hw_state.attribs[i].format = zink_get_format(screen,
+ elem->src_format);
assert(ves->hw_state.attribs[i].format != VK_FORMAT_UNDEFINED);
ves->hw_state.attribs[i].offset = elem->src_offset;
}
diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c
index 0b480643b1b..3c1fc4e7216 100644
--- a/src/gallium/drivers/zink/zink_surface.c
+++ b/src/gallium/drivers/zink/zink_surface.c
@@ -93,7 +93,7 @@ zink_create_surface(struct pipe_context *pctx,
unreachable("unsupported target");
}
- ivci.format = zink_get_format(templ->format);
+ ivci.format = zink_get_format(screen, templ->format);
// TODO: format swizzles
ivci.components.r = VK_COMPONENT_SWIZZLE_R;