2018-08-31 16:50:20 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Collabora Ltd.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
|
|
|
* license, and/or sell copies of the Software, and to permit persons to whom
|
|
|
|
* the Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZINK_SCREEN_H
|
|
|
|
#define ZINK_SCREEN_H
|
|
|
|
|
2020-09-26 14:49:49 +08:00
|
|
|
#include "zink_device_info.h"
|
2020-11-27 01:32:39 +08:00
|
|
|
#include "zink_instance.h"
|
2020-09-26 14:49:49 +08:00
|
|
|
|
2018-08-31 16:50:20 +02:00
|
|
|
#include "pipe/p_screen.h"
|
|
|
|
#include "util/slab.h"
|
2021-01-06 09:57:49 +01:00
|
|
|
#include "compiler/nir/nir.h"
|
2020-10-06 11:42:27 -04:00
|
|
|
#include "util/disk_cache.h"
|
2021-02-18 22:07:56 -08:00
|
|
|
#include "util/log.h"
|
2018-08-31 16:50:20 +02:00
|
|
|
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
|
2020-10-30 10:01:42 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
// Source of MVK_VERSION
|
|
|
|
#include "MoltenVK/vk_mvk_moltenvk.h"
|
|
|
|
#endif
|
|
|
|
|
2018-08-31 16:50:20 +02:00
|
|
|
extern uint32_t zink_debug;
|
|
|
|
|
|
|
|
#define ZINK_DEBUG_NIR 0x1
|
|
|
|
#define ZINK_DEBUG_SPIRV 0x2
|
|
|
|
#define ZINK_DEBUG_TGSI 0x4
|
2020-11-04 15:41:11 +00:00
|
|
|
#define ZINK_DEBUG_VALIDATION 0x8
|
2018-08-31 16:50:20 +02:00
|
|
|
|
|
|
|
struct zink_screen {
|
|
|
|
struct pipe_screen base;
|
|
|
|
|
|
|
|
struct sw_winsys *winsys;
|
|
|
|
|
|
|
|
struct slab_parent_pool transfer_pool;
|
2020-10-06 10:13:58 -04:00
|
|
|
VkPipelineCache pipeline_cache;
|
2020-10-06 11:42:27 -04:00
|
|
|
size_t pipeline_cache_size;
|
|
|
|
struct disk_cache *disk_cache;
|
|
|
|
cache_key disk_cache_key;
|
2018-08-31 16:50:20 +02:00
|
|
|
|
2020-11-26 12:08:46 -05:00
|
|
|
unsigned shader_id;
|
|
|
|
|
2018-08-31 16:50:20 +02:00
|
|
|
VkInstance instance;
|
2020-11-27 01:32:39 +08:00
|
|
|
struct zink_instance_info instance_info;
|
|
|
|
|
2018-08-31 16:50:20 +02:00
|
|
|
VkPhysicalDevice pdev;
|
2018-10-24 09:46:05 +02:00
|
|
|
|
2020-09-26 14:49:49 +08:00
|
|
|
struct zink_device_info info;
|
2021-01-06 09:57:49 +01:00
|
|
|
struct nir_shader_compiler_options nir_options;
|
2020-09-26 14:49:49 +08:00
|
|
|
|
2019-10-23 11:59:03 +02:00
|
|
|
bool have_X8_D24_UNORM_PACK32;
|
|
|
|
bool have_D24_UNORM_S8_UINT;
|
2020-11-05 11:17:40 +00:00
|
|
|
bool have_triangle_fans;
|
2019-10-23 11:59:03 +02:00
|
|
|
|
2018-08-31 16:50:20 +02:00
|
|
|
uint32_t gfx_queue;
|
2020-07-10 14:40:01 -04:00
|
|
|
uint32_t timestamp_valid_bits;
|
2018-08-31 16:50:20 +02:00
|
|
|
VkDevice dev;
|
2020-11-04 15:41:11 +00:00
|
|
|
VkDebugUtilsMessengerEXT debugUtilsCallbackHandle;
|
2018-10-02 23:27:36 +01:00
|
|
|
|
2020-08-04 15:42:43 -04:00
|
|
|
uint32_t cur_custom_border_color_samplers;
|
|
|
|
|
2020-11-06 09:20:42 +01:00
|
|
|
bool needs_mesa_wsi;
|
|
|
|
|
2020-11-04 17:42:29 +00:00
|
|
|
PFN_vkGetPhysicalDeviceFeatures2 vk_GetPhysicalDeviceFeatures2;
|
|
|
|
PFN_vkGetPhysicalDeviceProperties2 vk_GetPhysicalDeviceProperties2;
|
|
|
|
|
2020-12-28 15:39:18 -05:00
|
|
|
PFN_vkCmdDrawIndirectCount vk_CmdDrawIndirectCount;
|
|
|
|
PFN_vkCmdDrawIndexedIndirectCount vk_CmdDrawIndexedIndirectCount;
|
|
|
|
|
2018-10-02 23:27:36 +01:00
|
|
|
PFN_vkGetMemoryFdKHR vk_GetMemoryFdKHR;
|
2018-10-15 00:15:50 +01:00
|
|
|
PFN_vkCmdBeginConditionalRenderingEXT vk_CmdBeginConditionalRenderingEXT;
|
|
|
|
PFN_vkCmdEndConditionalRenderingEXT vk_CmdEndConditionalRenderingEXT;
|
2020-06-01 14:59:15 -04:00
|
|
|
|
|
|
|
PFN_vkCmdBindTransformFeedbackBuffersEXT vk_CmdBindTransformFeedbackBuffersEXT;
|
|
|
|
PFN_vkCmdBeginTransformFeedbackEXT vk_CmdBeginTransformFeedbackEXT;
|
|
|
|
PFN_vkCmdEndTransformFeedbackEXT vk_CmdEndTransformFeedbackEXT;
|
|
|
|
PFN_vkCmdBeginQueryIndexedEXT vk_CmdBeginQueryIndexedEXT;
|
|
|
|
PFN_vkCmdEndQueryIndexedEXT vk_CmdEndQueryIndexedEXT;
|
|
|
|
PFN_vkCmdDrawIndirectByteCountEXT vk_CmdDrawIndirectByteCountEXT;
|
2020-07-10 14:42:08 -04:00
|
|
|
|
|
|
|
PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT vk_GetPhysicalDeviceCalibrateableTimeDomainsEXT;
|
|
|
|
PFN_vkGetCalibratedTimestampsEXT vk_GetCalibratedTimestampsEXT;
|
2020-09-16 12:56:05 -04:00
|
|
|
|
|
|
|
PFN_vkCmdSetViewportWithCountEXT vk_CmdSetViewportWithCountEXT;
|
|
|
|
PFN_vkCmdSetScissorWithCountEXT vk_CmdSetScissorWithCountEXT;
|
2020-09-28 14:20:07 -04:00
|
|
|
PFN_vkCmdBindVertexBuffers2EXT vk_CmdBindVertexBuffers2EXT;
|
2020-10-30 10:01:42 +00:00
|
|
|
|
2020-11-04 15:41:11 +00:00
|
|
|
PFN_vkCreateDebugUtilsMessengerEXT vk_CreateDebugUtilsMessengerEXT;
|
|
|
|
PFN_vkDestroyDebugUtilsMessengerEXT vk_DestroyDebugUtilsMessengerEXT;
|
|
|
|
|
2020-10-30 10:01:42 +00:00
|
|
|
#if defined(MVK_VERSION)
|
|
|
|
PFN_vkGetMoltenVKConfigurationMVK vk_GetMoltenVKConfigurationMVK;
|
|
|
|
PFN_vkSetMoltenVKConfigurationMVK vk_SetMoltenVKConfigurationMVK;
|
|
|
|
|
|
|
|
PFN_vkGetPhysicalDeviceMetalFeaturesMVK vk_GetPhysicalDeviceMetalFeaturesMVK;
|
|
|
|
PFN_vkGetVersionStringsMVK vk_GetVersionStringsMVK;
|
|
|
|
PFN_vkUseIOSurfaceMVK vk_UseIOSurfaceMVK;
|
|
|
|
PFN_vkGetIOSurfaceMVK vk_GetIOSurfaceMVK;
|
|
|
|
#endif
|
2020-09-23 15:48:27 -04:00
|
|
|
|
|
|
|
struct {
|
|
|
|
bool dual_color_blend_by_location;
|
|
|
|
} driconf;
|
2018-08-31 16:50:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct zink_screen *
|
|
|
|
zink_screen(struct pipe_screen *pipe)
|
|
|
|
{
|
|
|
|
return (struct zink_screen *)pipe;
|
|
|
|
}
|
|
|
|
|
|
|
|
VkFormat
|
2019-10-23 11:59:03 +02:00
|
|
|
zink_get_format(struct zink_screen *screen, enum pipe_format format);
|
2018-08-31 16:50:20 +02:00
|
|
|
|
2019-11-06 15:26:12 +01:00
|
|
|
bool
|
|
|
|
zink_is_depth_format_supported(struct zink_screen *screen, VkFormat format);
|
|
|
|
|
2020-12-02 17:28:06 -05:00
|
|
|
#define GET_PROC_ADDR(x) do { \
|
|
|
|
screen->vk_##x = (PFN_vk##x)vkGetDeviceProcAddr(screen->dev, "vk"#x); \
|
|
|
|
if (!screen->vk_##x) { \
|
2021-02-18 22:07:56 -08:00
|
|
|
mesa_loge("ZINK: vkGetDeviceProcAddr failed: vk"#x"\n"); \
|
2020-12-02 17:28:06 -05:00
|
|
|
return false; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define GET_PROC_ADDR_INSTANCE(x) do { \
|
|
|
|
screen->vk_##x = (PFN_vk##x)vkGetInstanceProcAddr(screen->instance, "vk"#x); \
|
|
|
|
if (!screen->vk_##x) { \
|
2021-02-18 22:07:56 -08:00
|
|
|
mesa_loge("ZINK: GetInstanceProcAddr failed: vk"#x"\n"); \
|
2020-12-02 17:28:06 -05:00
|
|
|
return false; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2021-02-22 15:50:06 +10:00
|
|
|
#define GET_PROC_ADDR_DEVICE_LOCAL(x) PFN_vk##x vk_##x = (PFN_vk##x)vkGetDeviceProcAddr(screen->dev, "vk"#x)
|
2020-12-02 17:28:06 -05:00
|
|
|
#define GET_PROC_ADDR_INSTANCE_LOCAL(instance, x) PFN_vk##x vk_##x = (PFN_vk##x)vkGetInstanceProcAddr(instance, "vk"#x)
|
|
|
|
|
2020-10-06 11:42:27 -04:00
|
|
|
void
|
|
|
|
zink_screen_update_pipeline_cache(struct zink_screen *screen);
|
|
|
|
|
2018-08-31 16:50:20 +02:00
|
|
|
#endif
|