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);
[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
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;
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) {
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;
}
VkFormat
-zink_get_format(enum pipe_format format);
+zink_get_format(struct zink_screen *screen, enum pipe_format format);
#endif
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)
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;
}