2018-08-31 15:50:20 +01: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "zink_screen.h"
|
|
|
|
|
|
|
|
#include "zink_compiler.h"
|
|
|
|
#include "zink_context.h"
|
2020-09-26 07:49:49 +01:00
|
|
|
#include "zink_device_info.h"
|
2018-08-31 15:50:20 +01:00
|
|
|
#include "zink_fence.h"
|
2020-12-07 18:50:04 +00:00
|
|
|
#include "zink_format.h"
|
2020-11-26 17:32:39 +00:00
|
|
|
#include "zink_instance.h"
|
2018-08-31 15:50:20 +01:00
|
|
|
#include "zink_public.h"
|
|
|
|
#include "zink_resource.h"
|
|
|
|
|
|
|
|
#include "os/os_process.h"
|
|
|
|
#include "util/u_debug.h"
|
2019-06-27 23:05:31 +01:00
|
|
|
#include "util/format/u_format.h"
|
2018-08-31 15:50:20 +01:00
|
|
|
#include "util/u_math.h"
|
|
|
|
#include "util/u_memory.h"
|
|
|
|
#include "util/u_screen.h"
|
|
|
|
#include "util/u_string.h"
|
2020-12-15 09:41:57 +00:00
|
|
|
#include "util/u_transfer_helper.h"
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2019-12-03 23:01:31 +00:00
|
|
|
#include "frontend/sw_winsys.h"
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
static const struct debug_named_value
|
2020-12-17 16:07:30 +00:00
|
|
|
zink_debug_options[] = {
|
2018-08-31 15:50:20 +01:00
|
|
|
{ "nir", ZINK_DEBUG_NIR, "Dump NIR during program compile" },
|
|
|
|
{ "spirv", ZINK_DEBUG_SPIRV, "Dump SPIR-V during program compile" },
|
|
|
|
{ "tgsi", ZINK_DEBUG_TGSI, "Dump TGSI during program compile" },
|
2020-11-04 15:41:11 +00:00
|
|
|
{ "validation", ZINK_DEBUG_VALIDATION, "Dump Validation layer output" },
|
2018-08-31 15:50:20 +01:00
|
|
|
DEBUG_NAMED_VALUE_END
|
|
|
|
};
|
|
|
|
|
2020-12-17 16:07:30 +00:00
|
|
|
DEBUG_GET_ONCE_FLAGS_OPTION(zink_debug, "ZINK_DEBUG", zink_debug_options, 0)
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
uint32_t
|
|
|
|
zink_debug;
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
zink_get_vendor(struct pipe_screen *pscreen)
|
|
|
|
{
|
|
|
|
return "Collabora Ltd";
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
zink_get_device_vendor(struct pipe_screen *pscreen)
|
|
|
|
{
|
|
|
|
struct zink_screen *screen = zink_screen(pscreen);
|
|
|
|
static char buf[1000];
|
2020-09-28 11:43:36 +01:00
|
|
|
snprintf(buf, sizeof(buf), "Unknown (vendor-id: 0x%04x)", screen->info.props.vendorID);
|
2018-08-31 15:50:20 +01:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
zink_get_name(struct pipe_screen *pscreen)
|
|
|
|
{
|
|
|
|
struct zink_screen *screen = zink_screen(pscreen);
|
|
|
|
static char buf[1000];
|
2020-09-28 11:43:36 +01:00
|
|
|
snprintf(buf, sizeof(buf), "zink (%s)", screen->info.props.deviceName);
|
2018-08-31 15:50:20 +01:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
get_video_mem(struct zink_screen *screen)
|
|
|
|
{
|
|
|
|
VkDeviceSize size = 0;
|
2020-09-28 11:43:36 +01:00
|
|
|
for (uint32_t i = 0; i < screen->info.mem_props.memoryHeapCount; ++i) {
|
|
|
|
if (screen->info.mem_props.memoryHeaps[i].flags &
|
2020-06-09 20:54:23 +01:00
|
|
|
VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
|
2020-09-28 11:43:36 +01:00
|
|
|
size += screen->info.mem_props.memoryHeaps[i].size;
|
2020-06-09 20:54:23 +01:00
|
|
|
}
|
2018-08-31 15:50:20 +01:00
|
|
|
return (int)(size >> 20);
|
|
|
|
}
|
|
|
|
|
2020-08-12 22:02:42 +01:00
|
|
|
static int
|
|
|
|
zink_get_compute_param(struct pipe_screen *pscreen, enum pipe_shader_ir ir_type,
|
|
|
|
enum pipe_compute_cap param, void *ret)
|
|
|
|
{
|
|
|
|
struct zink_screen *screen = zink_screen(pscreen);
|
|
|
|
#define RET(x) do { \
|
|
|
|
if (ret) \
|
|
|
|
memcpy(ret, x, sizeof(x)); \
|
|
|
|
return sizeof(x); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
switch (param) {
|
|
|
|
case PIPE_COMPUTE_CAP_ADDRESS_BITS:
|
|
|
|
RET((uint32_t []){ 32 });
|
|
|
|
|
|
|
|
case PIPE_COMPUTE_CAP_IR_TARGET:
|
|
|
|
if (ret)
|
|
|
|
strcpy(ret, "nir");
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
case PIPE_COMPUTE_CAP_GRID_DIMENSION:
|
|
|
|
RET((uint64_t []) { 3 });
|
|
|
|
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_GRID_SIZE:
|
|
|
|
RET(((uint64_t []) { screen->info.props.limits.maxComputeWorkGroupCount[0],
|
|
|
|
screen->info.props.limits.maxComputeWorkGroupCount[1],
|
|
|
|
screen->info.props.limits.maxComputeWorkGroupCount[2] }));
|
|
|
|
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE:
|
|
|
|
/* MaxComputeWorkGroupSize[0..2] */
|
|
|
|
RET(((uint64_t []) {screen->info.props.limits.maxComputeWorkGroupSize[0],
|
|
|
|
screen->info.props.limits.maxComputeWorkGroupSize[1],
|
|
|
|
screen->info.props.limits.maxComputeWorkGroupSize[2]}));
|
|
|
|
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK:
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_VARIABLE_THREADS_PER_BLOCK:
|
|
|
|
RET((uint64_t []) { screen->info.props.limits.maxComputeWorkGroupInvocations });
|
|
|
|
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE:
|
|
|
|
RET((uint64_t []) { screen->info.props.limits.maxComputeSharedMemorySize });
|
|
|
|
|
|
|
|
case PIPE_COMPUTE_CAP_IMAGES_SUPPORTED:
|
|
|
|
RET((uint32_t []) { 1 });
|
|
|
|
|
|
|
|
case PIPE_COMPUTE_CAP_SUBGROUP_SIZE:
|
|
|
|
RET((uint32_t []) { screen->info.props11.subgroupSize });
|
|
|
|
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE:
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY:
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS:
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE:
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE:
|
|
|
|
case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE:
|
|
|
|
// XXX: I think these are for Clover...
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unreachable("unknown compute param");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
static int
|
|
|
|
zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
|
|
|
{
|
|
|
|
struct zink_screen *screen = zink_screen(pscreen);
|
|
|
|
|
|
|
|
switch (param) {
|
2021-01-21 16:09:55 +00:00
|
|
|
case PIPE_CAP_ANISOTROPIC_FILTER:
|
|
|
|
return screen->info.feats.features.samplerAnisotropy;
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_NPOT_TEXTURES:
|
2020-06-17 22:40:04 +01:00
|
|
|
case PIPE_CAP_TGSI_TEXCOORD:
|
2020-07-11 16:46:21 +01:00
|
|
|
case PIPE_CAP_DRAW_INDIRECT:
|
2020-07-15 18:51:18 +01:00
|
|
|
case PIPE_CAP_TEXTURE_QUERY_LOD:
|
2020-12-18 02:29:26 +00:00
|
|
|
case PIPE_CAP_GLSL_TESS_LEVELS_AS_INPUTS:
|
2020-08-13 18:50:21 +01:00
|
|
|
case PIPE_CAP_CLEAR_TEXTURE:
|
2020-08-07 14:42:43 +01:00
|
|
|
case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:
|
2020-08-07 16:28:37 +01:00
|
|
|
case PIPE_CAP_FORCE_PERSAMPLE_INTERP:
|
2020-08-07 16:03:39 +01:00
|
|
|
case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
|
2020-08-18 16:35:45 +01:00
|
|
|
case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE:
|
2020-08-13 15:55:13 +01:00
|
|
|
case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
|
2020-08-14 22:39:49 +01:00
|
|
|
case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
|
2020-08-17 20:09:31 +01:00
|
|
|
case PIPE_CAP_QUERY_BUFFER_OBJECT:
|
2020-08-18 16:41:16 +01:00
|
|
|
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
|
2020-08-18 20:08:15 +01:00
|
|
|
case PIPE_CAP_CLIP_HALFZ:
|
2018-08-31 15:50:20 +01:00
|
|
|
return 1;
|
|
|
|
|
2021-01-22 08:07:12 +00:00
|
|
|
case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:
|
|
|
|
return screen->info.feats.features.robustBufferAccess;
|
|
|
|
|
2020-08-20 14:22:37 +01:00
|
|
|
case PIPE_CAP_MULTI_DRAW_INDIRECT:
|
2021-01-22 08:15:10 +00:00
|
|
|
return screen->info.feats.features.multiDrawIndirect;
|
|
|
|
|
2020-08-20 14:22:37 +01:00
|
|
|
case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
|
2021-01-22 08:22:12 +00:00
|
|
|
return screen->instance_info.have_KHR_draw_indirect_count;
|
2020-08-20 14:22:37 +01:00
|
|
|
|
2020-08-03 20:37:35 +01:00
|
|
|
case PIPE_CAP_START_INSTANCE:
|
2021-01-15 18:24:20 +00:00
|
|
|
return screen->info.feats11.shaderDrawParameters;
|
2020-08-03 20:37:35 +01:00
|
|
|
|
2020-07-10 14:48:23 +01:00
|
|
|
case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.have_EXT_vertex_attribute_divisor;
|
2020-07-10 14:48:23 +01:00
|
|
|
|
2020-07-30 19:11:21 +01:00
|
|
|
case PIPE_CAP_MAX_VERTEX_STREAMS:
|
|
|
|
return screen->info.tf_props.maxTransformFeedbackStreams;
|
|
|
|
|
2020-11-05 18:01:24 +00:00
|
|
|
case PIPE_CAP_INT64:
|
|
|
|
case PIPE_CAP_INT64_DIVMOD:
|
|
|
|
case PIPE_CAP_DOUBLES:
|
|
|
|
return 1;
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
|
2020-09-28 11:43:36 +01:00
|
|
|
if (!screen->info.feats.features.dualSrcBlend)
|
2020-02-04 10:21:58 +00:00
|
|
|
return 0;
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxFragmentDualSrcAttachments;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_MAX_RENDER_TARGETS:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxColorAttachments;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2018-10-03 00:57:41 +01:00
|
|
|
case PIPE_CAP_OCCLUSION_QUERY:
|
2019-07-17 10:26:53 +01:00
|
|
|
return 1;
|
|
|
|
|
2018-10-03 00:57:41 +01:00
|
|
|
case PIPE_CAP_QUERY_TIME_ELAPSED:
|
2020-10-29 10:54:28 +00:00
|
|
|
return screen->timestamp_valid_bits > 0;
|
2018-10-03 00:57:41 +01:00
|
|
|
|
2020-02-03 16:41:18 +00:00
|
|
|
case PIPE_CAP_TEXTURE_MULTISAMPLE:
|
|
|
|
return 1;
|
|
|
|
|
2021-01-22 08:11:51 +00:00
|
|
|
case PIPE_CAP_SAMPLE_SHADING:
|
|
|
|
return screen->info.feats.features.sampleRateShading;
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_TEXTURE_SWIZZLE:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PIPE_CAP_MAX_TEXTURE_2D_SIZE:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxImageDimension2D;
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
|
2020-09-28 11:43:36 +01:00
|
|
|
return 1 + util_logbase2(screen->info.props.limits.maxImageDimension3D);
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
|
2020-09-28 11:43:36 +01:00
|
|
|
return 1 + util_logbase2(screen->info.props.limits.maxImageDimensionCube);
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD:
|
|
|
|
case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES:
|
|
|
|
case PIPE_CAP_VERTEX_SHADER_SATURATE:
|
|
|
|
return 1;
|
|
|
|
|
2021-01-22 08:09:03 +00:00
|
|
|
case PIPE_CAP_BLEND_EQUATION_SEPARATE:
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_INDEP_BLEND_ENABLE:
|
|
|
|
case PIPE_CAP_INDEP_BLEND_FUNC:
|
2021-01-22 08:09:03 +00:00
|
|
|
return screen->info.feats.features.independentBlend;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2020-06-01 20:01:47 +01:00
|
|
|
case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.have_EXT_transform_feedback ? screen->info.tf_props.maxTransformFeedbackBuffers : 0;
|
2020-06-01 20:01:47 +01:00
|
|
|
case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
|
|
|
|
case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS:
|
2021-01-22 11:41:42 +00:00
|
|
|
return screen->info.have_EXT_transform_feedback;
|
2020-06-01 20:01:47 +01:00
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxImageArrayLayers;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_DEPTH_CLIP_DISABLE:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.feats.features.depthClamp;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2020-01-30 19:35:04 +00:00
|
|
|
case PIPE_CAP_TGSI_INSTANCEID:
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
|
|
|
|
case PIPE_CAP_SEAMLESS_CUBE_MAP:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PIPE_CAP_MIN_TEXEL_OFFSET:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.minTexelOffset;
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MAX_TEXEL_OFFSET:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxTexelOffset;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
|
|
|
|
return 1;
|
|
|
|
|
2018-10-15 00:15:50 +01:00
|
|
|
case PIPE_CAP_CONDITIONAL_RENDER:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.have_EXT_conditional_rendering;
|
2018-10-15 00:15:50 +01:00
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY:
|
2020-02-03 16:41:46 +00:00
|
|
|
return 130;
|
2020-07-01 20:51:14 +01:00
|
|
|
case PIPE_CAP_GLSL_FEATURE_LEVEL:
|
2020-08-18 16:36:20 +01:00
|
|
|
return 440;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_COMPUTE:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.minUniformBufferOffsetAlignment;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2018-10-03 00:57:41 +01:00
|
|
|
case PIPE_CAP_QUERY_TIMESTAMP:
|
2020-10-29 10:54:28 +00:00
|
|
|
return screen->info.have_EXT_calibrated_timestamps &&
|
|
|
|
screen->timestamp_valid_bits > 0;
|
2018-10-03 00:57:41 +01:00
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.minMemoryMapAlignment;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_CUBE_MAP_ARRAY:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.feats.features.imageCubeArray;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2020-01-30 22:15:51 +00:00
|
|
|
case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
|
2020-07-31 14:32:23 +01:00
|
|
|
case PIPE_CAP_PRIMITIVE_RESTART:
|
2020-01-30 22:15:51 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.minTexelBufferOffsetAlignment;
|
2020-01-30 22:15:51 +00:00
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
|
|
|
|
return 0; /* unsure */
|
|
|
|
|
|
|
|
case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxTexelBufferElements;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_ENDIANNESS:
|
|
|
|
return PIPE_ENDIAN_NATIVE; /* unsure */
|
|
|
|
|
|
|
|
case PIPE_CAP_MAX_VIEWPORTS:
|
2020-08-03 16:53:44 +01:00
|
|
|
return screen->info.props.limits.maxViewports;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2020-11-17 23:52:54 +00:00
|
|
|
case PIPE_CAP_IMAGE_LOAD_FORMATTED:
|
2021-01-22 18:19:53 +00:00
|
|
|
return screen->info.feats.features.shaderStorageImageExtendedFormats &&
|
|
|
|
screen->info.feats.features.shaderStorageImageReadWithoutFormat &&
|
|
|
|
screen->info.feats.features.shaderStorageImageWriteWithoutFormat;
|
2020-11-17 23:52:54 +00:00
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxGeometryOutputVertices;
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS:
|
2020-10-14 15:42:17 +01:00
|
|
|
return screen->info.props.limits.maxGeometryTotalOutputComponents;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.minTexelGatherOffset;
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxTexelGatherOffset;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2020-01-30 15:50:59 +00:00
|
|
|
case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
|
|
|
|
return 1;
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_VENDOR_ID:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.vendorID;
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_CAP_DEVICE_ID:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.deviceID;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_ACCELERATED:
|
|
|
|
return 1;
|
|
|
|
case PIPE_CAP_VIDEO_MEMORY:
|
|
|
|
return get_video_mem(screen);
|
|
|
|
case PIPE_CAP_UMA:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxVertexInputBindingStride;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_SAMPLER_VIEW_TARGET:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PIPE_CAP_TEXTURE_FLOAT_LINEAR:
|
|
|
|
case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PIPE_CAP_SHAREABLE_SHADERS:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.minStorageBufferOffsetAlignment;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_PCI_GROUP:
|
|
|
|
case PIPE_CAP_PCI_BUS:
|
|
|
|
case PIPE_CAP_PCI_DEVICE:
|
|
|
|
case PIPE_CAP_PCI_FUNCTION:
|
|
|
|
return 0; /* TODO: figure these out */
|
|
|
|
|
|
|
|
case PIPE_CAP_CULL_DISTANCE:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.feats.features.shaderCullDistance;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.viewportSubPixelBits;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
|
|
|
|
return 0; /* not sure */
|
|
|
|
|
|
|
|
case PIPE_CAP_MAX_GS_INVOCATIONS:
|
2020-10-14 15:42:17 +01:00
|
|
|
return screen->info.props.limits.maxGeometryShaderInvocations;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_MAX_COMBINED_SHADER_BUFFERS:
|
2021-01-27 14:58:13 +00:00
|
|
|
/* gallium handles this automatically */
|
|
|
|
return 0;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_MAX_SHADER_BUFFER_SIZE:
|
2020-06-26 20:17:32 +01:00
|
|
|
return 65536;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
|
|
|
|
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
|
|
|
|
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
|
|
|
|
return 0;
|
|
|
|
|
2019-07-25 13:06:53 +01:00
|
|
|
case PIPE_CAP_NIR_COMPACT_ARRAYS:
|
|
|
|
return 1;
|
|
|
|
|
2019-07-22 12:24:14 +01:00
|
|
|
case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
|
|
|
|
return 1;
|
|
|
|
|
2020-06-17 18:47:22 +01:00
|
|
|
case PIPE_CAP_VIEWPORT_TRANSFORM_LOWERED:
|
|
|
|
return 1;
|
|
|
|
|
2019-01-24 03:13:26 +00:00
|
|
|
case PIPE_CAP_FLATSHADE:
|
2019-07-25 13:09:52 +01:00
|
|
|
case PIPE_CAP_ALPHA_TEST:
|
2019-07-25 13:06:53 +01:00
|
|
|
case PIPE_CAP_CLIP_PLANES:
|
2019-07-18 16:04:09 +01:00
|
|
|
case PIPE_CAP_POINT_SIZE_FIXED:
|
2019-07-25 12:50:40 +01:00
|
|
|
case PIPE_CAP_TWO_SIDED_COLOR:
|
2019-01-24 03:13:26 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-09-08 20:08:20 +01:00
|
|
|
case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
|
|
|
|
return screen->info.props.limits.maxTessellationControlPerVertexOutputComponents / 4;
|
|
|
|
case PIPE_CAP_MAX_VARYINGS:
|
|
|
|
/* need to reserve up to 60 of our varying components and 16 slots for streamout */
|
|
|
|
return MIN2(screen->info.props.limits.maxVertexOutputComponents / 4 / 2, 16);
|
|
|
|
|
2019-10-23 11:16:22 +01:00
|
|
|
case PIPE_CAP_DMABUF:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.have_KHR_external_memory_fd;
|
2019-10-23 11:16:22 +01:00
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
default:
|
|
|
|
return u_pipe_screen_get_param_defaults(pscreen, param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static float
|
|
|
|
zink_get_paramf(struct pipe_screen *pscreen, enum pipe_capf param)
|
|
|
|
{
|
|
|
|
struct zink_screen *screen = zink_screen(pscreen);
|
|
|
|
|
|
|
|
switch (param) {
|
|
|
|
case PIPE_CAPF_MAX_LINE_WIDTH:
|
|
|
|
case PIPE_CAPF_MAX_LINE_WIDTH_AA:
|
2021-02-02 10:40:41 +00:00
|
|
|
if (!screen->info.feats.features.wideLines)
|
|
|
|
return 1.0f;
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.lineWidthRange[1];
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAPF_MAX_POINT_WIDTH:
|
|
|
|
case PIPE_CAPF_MAX_POINT_WIDTH_AA:
|
2021-02-02 10:40:41 +00:00
|
|
|
if (!screen->info.feats.features.largePoints)
|
|
|
|
return 1.0f;
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.pointSizeRange[1];
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY:
|
2021-02-02 10:40:41 +00:00
|
|
|
if (!screen->info.feats.features.samplerAnisotropy)
|
|
|
|
return 1.0f;
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxSamplerAnisotropy;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS:
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.maxSamplerLodBias;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_CAPF_MIN_CONSERVATIVE_RASTER_DILATE:
|
|
|
|
case PIPE_CAPF_MAX_CONSERVATIVE_RASTER_DILATE:
|
|
|
|
case PIPE_CAPF_CONSERVATIVE_RASTER_DILATE_GRANULARITY:
|
|
|
|
return 0.0f; /* not implemented */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* should only get here on unhandled cases */
|
2021-02-02 10:42:18 +00:00
|
|
|
return 0.0f;
|
2018-08-31 15:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
zink_get_shader_param(struct pipe_screen *pscreen,
|
|
|
|
enum pipe_shader_type shader,
|
|
|
|
enum pipe_shader_cap param)
|
|
|
|
{
|
|
|
|
struct zink_screen *screen = zink_screen(pscreen);
|
|
|
|
|
|
|
|
switch (param) {
|
|
|
|
case PIPE_SHADER_CAP_MAX_INSTRUCTIONS:
|
2020-10-14 15:42:17 +01:00
|
|
|
switch (shader) {
|
|
|
|
case PIPE_SHADER_FRAGMENT:
|
|
|
|
case PIPE_SHADER_VERTEX:
|
|
|
|
return INT_MAX;
|
2020-12-18 02:29:26 +00:00
|
|
|
case PIPE_SHADER_TESS_CTRL:
|
|
|
|
case PIPE_SHADER_TESS_EVAL:
|
2021-01-22 11:23:10 +00:00
|
|
|
if (screen->info.have_KHR_vulkan_memory_model &&
|
|
|
|
screen->info.feats.features.tessellationShader &&
|
2021-02-03 20:29:39 +00:00
|
|
|
screen->info.have_KHR_maintenance2)
|
2020-12-18 02:29:26 +00:00
|
|
|
return INT_MAX;
|
|
|
|
break;
|
2020-10-23 08:35:51 +01:00
|
|
|
|
|
|
|
case PIPE_SHADER_GEOMETRY:
|
|
|
|
if (screen->info.feats.features.geometryShader)
|
|
|
|
return INT_MAX;
|
|
|
|
break;
|
|
|
|
|
2020-08-12 22:02:42 +01:00
|
|
|
case PIPE_SHADER_COMPUTE:
|
|
|
|
return INT_MAX;
|
2020-10-14 15:42:17 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS:
|
|
|
|
case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS:
|
|
|
|
case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS:
|
|
|
|
case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
|
|
|
|
if (shader == PIPE_SHADER_VERTEX ||
|
|
|
|
shader == PIPE_SHADER_FRAGMENT)
|
|
|
|
return INT_MAX;
|
|
|
|
return 0;
|
|
|
|
|
2021-01-04 20:28:13 +00:00
|
|
|
case PIPE_SHADER_CAP_MAX_INPUTS: {
|
|
|
|
uint32_t max = 0;
|
2018-08-31 15:50:20 +01:00
|
|
|
switch (shader) {
|
|
|
|
case PIPE_SHADER_VERTEX:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = MIN2(screen->info.props.limits.maxVertexInputAttributes, PIPE_MAX_ATTRIBS);
|
|
|
|
break;
|
2020-12-18 02:29:26 +00:00
|
|
|
case PIPE_SHADER_TESS_CTRL:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = screen->info.props.limits.maxTessellationControlPerVertexInputComponents / 4;
|
|
|
|
break;
|
2020-12-18 02:29:26 +00:00
|
|
|
case PIPE_SHADER_TESS_EVAL:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = screen->info.props.limits.maxTessellationEvaluationInputComponents / 4;
|
|
|
|
break;
|
2020-10-14 15:42:17 +01:00
|
|
|
case PIPE_SHADER_GEOMETRY:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = screen->info.props.limits.maxGeometryInputComponents;
|
|
|
|
break;
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_SHADER_FRAGMENT:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = screen->info.props.limits.maxFragmentInputComponents / 4;
|
|
|
|
break;
|
2018-08-31 15:50:20 +01:00
|
|
|
default:
|
|
|
|
return 0; /* unsupported stage */
|
|
|
|
}
|
2021-01-04 20:28:13 +00:00
|
|
|
return MIN2(max, 64); // prevent overflowing struct shader_info::inputs_read
|
|
|
|
}
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2021-01-04 20:28:13 +00:00
|
|
|
case PIPE_SHADER_CAP_MAX_OUTPUTS: {
|
|
|
|
uint32_t max = 0;
|
2018-08-31 15:50:20 +01:00
|
|
|
switch (shader) {
|
|
|
|
case PIPE_SHADER_VERTEX:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = screen->info.props.limits.maxVertexOutputComponents / 4;
|
|
|
|
break;
|
2020-12-18 02:29:26 +00:00
|
|
|
case PIPE_SHADER_TESS_CTRL:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = screen->info.props.limits.maxTessellationControlPerVertexOutputComponents / 4;
|
|
|
|
break;
|
2020-12-18 02:29:26 +00:00
|
|
|
case PIPE_SHADER_TESS_EVAL:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = screen->info.props.limits.maxTessellationEvaluationOutputComponents / 4;
|
|
|
|
break;
|
2020-10-14 15:42:17 +01:00
|
|
|
case PIPE_SHADER_GEOMETRY:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = screen->info.props.limits.maxGeometryOutputComponents / 4;
|
|
|
|
break;
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_SHADER_FRAGMENT:
|
2021-01-04 20:28:13 +00:00
|
|
|
max = screen->info.props.limits.maxColorAttachments;
|
|
|
|
break;
|
2018-08-31 15:50:20 +01:00
|
|
|
default:
|
|
|
|
return 0; /* unsupported stage */
|
|
|
|
}
|
2021-01-04 20:28:13 +00:00
|
|
|
return MIN2(max, 64); // prevent overflowing struct shader_info::outputs_read/written
|
|
|
|
}
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
|
2020-06-26 20:17:32 +01:00
|
|
|
return 65536;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
|
2020-12-07 20:30:32 +00:00
|
|
|
return MIN2(screen->info.props.limits.maxPerStageDescriptorUniformBuffers,
|
|
|
|
PIPE_MAX_CONSTANT_BUFFERS);
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_MAX_TEMPS:
|
|
|
|
return INT_MAX;
|
|
|
|
|
2019-10-30 10:25:00 +00:00
|
|
|
case PIPE_SHADER_CAP_INTEGERS:
|
|
|
|
return 1;
|
|
|
|
|
2020-06-26 20:57:11 +01:00
|
|
|
case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:
|
|
|
|
return 1;
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR:
|
|
|
|
case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR:
|
|
|
|
case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:
|
|
|
|
case PIPE_SHADER_CAP_SUBROUTINES:
|
|
|
|
case PIPE_SHADER_CAP_INT64_ATOMICS:
|
|
|
|
case PIPE_SHADER_CAP_FP16:
|
2020-05-10 22:05:00 +01:00
|
|
|
case PIPE_SHADER_CAP_FP16_DERIVATIVES:
|
|
|
|
case PIPE_SHADER_CAP_INT16:
|
2020-08-05 18:21:46 +01:00
|
|
|
case PIPE_SHADER_CAP_GLSL_16BIT_CONSTS:
|
2018-08-31 15:50:20 +01:00
|
|
|
return 0; /* not implemented */
|
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_PREFERRED_IR:
|
|
|
|
return PIPE_SHADER_IR_NIR;
|
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
|
2021-01-12 21:40:41 +00:00
|
|
|
case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
|
2018-08-31 15:50:20 +01:00
|
|
|
case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
|
2021-01-12 21:40:41 +00:00
|
|
|
return MIN2(MIN2(screen->info.props.limits.maxPerStageDescriptorSamplers,
|
|
|
|
screen->info.props.limits.maxPerStageDescriptorSampledImages),
|
|
|
|
PIPE_MAX_SAMPLERS);
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED:
|
|
|
|
case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED:
|
|
|
|
case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE:
|
|
|
|
return 0; /* no idea */
|
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
|
|
|
|
return 32; /* arbitrary */
|
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS:
|
2021-01-05 13:51:28 +00:00
|
|
|
/* TODO: this limitation is dumb, and will need some fixes in mesa */
|
|
|
|
return MIN2(screen->info.props.limits.maxPerStageDescriptorStorageBuffers, PIPE_MAX_SHADER_BUFFERS);
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_SUPPORTED_IRS:
|
|
|
|
return (1 << PIPE_SHADER_IR_NIR) | (1 << PIPE_SHADER_IR_TGSI);
|
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_MAX_SHADER_IMAGES:
|
2020-11-17 23:52:54 +00:00
|
|
|
if (screen->info.have_KHR_vulkan_memory_model &&
|
|
|
|
(screen->info.feats.features.shaderStorageImageExtendedFormats ||
|
|
|
|
(screen->info.feats.features.shaderStorageImageWriteWithoutFormat &&
|
|
|
|
screen->info.feats.features.shaderStorageImageReadWithoutFormat)))
|
|
|
|
return MIN2(screen->info.props.limits.maxPerStageDescriptorStorageImages,
|
|
|
|
PIPE_MAX_SHADER_IMAGES);
|
2020-05-13 16:13:47 +01:00
|
|
|
return 0;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD:
|
|
|
|
case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS:
|
|
|
|
return 0; /* unsure */
|
|
|
|
|
|
|
|
case PIPE_SHADER_CAP_TGSI_LDEXP_SUPPORTED:
|
|
|
|
case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS:
|
|
|
|
case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS:
|
|
|
|
case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* should only get here on unhandled cases */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-05 02:41:37 +00:00
|
|
|
static VkSampleCountFlagBits
|
|
|
|
vk_sample_count_flags(uint32_t sample_count)
|
|
|
|
{
|
|
|
|
switch (sample_count) {
|
|
|
|
case 1: return VK_SAMPLE_COUNT_1_BIT;
|
|
|
|
case 2: return VK_SAMPLE_COUNT_2_BIT;
|
|
|
|
case 4: return VK_SAMPLE_COUNT_4_BIT;
|
|
|
|
case 8: return VK_SAMPLE_COUNT_8_BIT;
|
|
|
|
case 16: return VK_SAMPLE_COUNT_16_BIT;
|
|
|
|
case 32: return VK_SAMPLE_COUNT_32_BIT;
|
|
|
|
case 64: return VK_SAMPLE_COUNT_64_BIT;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
static bool
|
|
|
|
zink_is_format_supported(struct pipe_screen *pscreen,
|
|
|
|
enum pipe_format format,
|
|
|
|
enum pipe_texture_target target,
|
|
|
|
unsigned sample_count,
|
|
|
|
unsigned storage_sample_count,
|
|
|
|
unsigned bind)
|
|
|
|
{
|
|
|
|
struct zink_screen *screen = zink_screen(pscreen);
|
|
|
|
|
2018-11-05 02:41:37 +00:00
|
|
|
if (format == PIPE_FORMAT_NONE)
|
2020-09-28 11:43:36 +01:00
|
|
|
return screen->info.props.limits.framebufferNoAttachmentsSampleCounts &
|
2018-11-05 02:41:37 +00:00
|
|
|
vk_sample_count_flags(sample_count);
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2019-10-23 10:59:03 +01:00
|
|
|
VkFormat vkformat = zink_get_format(screen, format);
|
2018-08-31 15:50:20 +01:00
|
|
|
if (vkformat == VK_FORMAT_UNDEFINED)
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2018-11-05 02:41:37 +00:00
|
|
|
if (sample_count >= 1) {
|
|
|
|
VkSampleCountFlagBits sample_mask = vk_sample_count_flags(sample_count);
|
2019-11-28 17:41:30 +00:00
|
|
|
if (!sample_mask)
|
|
|
|
return false;
|
2019-07-10 13:59:58 +01:00
|
|
|
const struct util_format_description *desc = util_format_description(format);
|
2018-11-05 02:41:37 +00:00
|
|
|
if (util_format_is_depth_or_stencil(format)) {
|
|
|
|
if (util_format_has_depth(desc)) {
|
|
|
|
if (bind & PIPE_BIND_DEPTH_STENCIL &&
|
2020-09-28 11:43:36 +01:00
|
|
|
(screen->info.props.limits.framebufferDepthSampleCounts & sample_mask) != sample_mask)
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-11-05 02:41:37 +00:00
|
|
|
if (bind & PIPE_BIND_SAMPLER_VIEW &&
|
2020-09-28 11:43:36 +01:00
|
|
|
(screen->info.props.limits.sampledImageDepthSampleCounts & sample_mask) != sample_mask)
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-11-05 02:41:37 +00:00
|
|
|
}
|
|
|
|
if (util_format_has_stencil(desc)) {
|
|
|
|
if (bind & PIPE_BIND_DEPTH_STENCIL &&
|
2020-09-28 11:43:36 +01:00
|
|
|
(screen->info.props.limits.framebufferStencilSampleCounts & sample_mask) != sample_mask)
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-11-05 02:41:37 +00:00
|
|
|
if (bind & PIPE_BIND_SAMPLER_VIEW &&
|
2020-09-28 11:43:36 +01:00
|
|
|
(screen->info.props.limits.sampledImageStencilSampleCounts & sample_mask) != sample_mask)
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-11-05 02:41:37 +00:00
|
|
|
}
|
|
|
|
} else if (util_format_is_pure_integer(format)) {
|
|
|
|
if (bind & PIPE_BIND_RENDER_TARGET &&
|
2020-09-28 11:43:36 +01:00
|
|
|
!(screen->info.props.limits.framebufferColorSampleCounts & sample_mask))
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-11-05 02:41:37 +00:00
|
|
|
if (bind & PIPE_BIND_SAMPLER_VIEW &&
|
2020-09-28 11:43:36 +01:00
|
|
|
!(screen->info.props.limits.sampledImageIntegerSampleCounts & sample_mask))
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-11-05 02:41:37 +00:00
|
|
|
} else {
|
|
|
|
if (bind & PIPE_BIND_RENDER_TARGET &&
|
2020-09-28 11:43:36 +01:00
|
|
|
!(screen->info.props.limits.framebufferColorSampleCounts & sample_mask))
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-11-05 02:41:37 +00:00
|
|
|
if (bind & PIPE_BIND_SAMPLER_VIEW &&
|
2020-09-28 11:43:36 +01:00
|
|
|
!(screen->info.props.limits.sampledImageColorSampleCounts & sample_mask))
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-11-05 02:41:37 +00:00
|
|
|
}
|
2020-11-17 23:52:11 +00:00
|
|
|
if (bind & PIPE_BIND_SHADER_IMAGE) {
|
|
|
|
if (!screen->info.feats.features.shaderStorageImageMultisample)
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-05 02:41:37 +00:00
|
|
|
}
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
VkFormatProperties props;
|
|
|
|
vkGetPhysicalDeviceFormatProperties(screen->pdev, vkformat, &props);
|
|
|
|
|
|
|
|
if (target == PIPE_BUFFER) {
|
|
|
|
if (bind & PIPE_BIND_VERTEX_BUFFER &&
|
|
|
|
!(props.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT))
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-08-31 15:50:20 +01:00
|
|
|
} else {
|
|
|
|
/* all other targets are texture-targets */
|
|
|
|
if (bind & PIPE_BIND_RENDER_TARGET &&
|
|
|
|
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
if (bind & PIPE_BIND_BLENDABLE &&
|
|
|
|
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT))
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
if (bind & PIPE_BIND_SAMPLER_VIEW &&
|
2020-08-07 14:41:12 +01:00
|
|
|
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ((bind & PIPE_BIND_SAMPLER_VIEW) || (bind & PIPE_BIND_RENDER_TARGET)) {
|
|
|
|
/* if this is a 3-component texture, force gallium to give us 4 components by rejecting this one */
|
|
|
|
const struct util_format_description *desc = util_format_description(format);
|
|
|
|
if (desc->nr_channels == 3 &&
|
|
|
|
(desc->block.bits == 24 || desc->block.bits == 48 || desc->block.bits == 96))
|
|
|
|
return false;
|
|
|
|
}
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
if (bind & PIPE_BIND_DEPTH_STENCIL &&
|
|
|
|
!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2018-08-31 15:50:20 +01:00
|
|
|
}
|
|
|
|
|
2019-07-10 13:59:58 +01:00
|
|
|
if (util_format_is_compressed(format)) {
|
|
|
|
const struct util_format_description *desc = util_format_description(format);
|
|
|
|
if (desc->layout == UTIL_FORMAT_LAYOUT_BPTC &&
|
2020-09-28 11:43:36 +01:00
|
|
|
!screen->info.feats.features.textureCompressionBC)
|
2019-11-28 17:41:05 +00:00
|
|
|
return false;
|
2019-07-10 13:59:58 +01:00
|
|
|
}
|
2018-10-03 06:25:09 +01:00
|
|
|
|
2019-11-28 17:41:05 +00:00
|
|
|
return true;
|
2018-08-31 15:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zink_destroy_screen(struct pipe_screen *pscreen)
|
|
|
|
{
|
|
|
|
struct zink_screen *screen = zink_screen(pscreen);
|
2020-11-04 15:41:11 +00:00
|
|
|
|
|
|
|
if (VK_NULL_HANDLE != screen->debugUtilsCallbackHandle) {
|
|
|
|
screen->vk_DestroyDebugUtilsMessengerEXT(screen->instance, screen->debugUtilsCallbackHandle, NULL);
|
|
|
|
}
|
|
|
|
|
2020-12-15 09:41:57 +00:00
|
|
|
u_transfer_helper_destroy(pscreen->transfer_helper);
|
|
|
|
|
2020-12-15 09:42:11 +00:00
|
|
|
vkDestroyDevice(screen->dev, NULL);
|
|
|
|
vkDestroyInstance(screen->instance, NULL);
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
slab_destroy_parent(&screen->transfer_pool);
|
|
|
|
FREE(screen);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VkPhysicalDevice
|
|
|
|
choose_pdev(const VkInstance instance)
|
|
|
|
{
|
|
|
|
uint32_t i, pdev_count;
|
2021-02-03 04:17:46 +00:00
|
|
|
VkPhysicalDevice *pdevs, pdev = NULL;
|
2021-02-05 11:48:37 +00:00
|
|
|
VkResult result = vkEnumeratePhysicalDevices(instance, &pdev_count, NULL);
|
|
|
|
if (result != VK_SUCCESS)
|
|
|
|
return VK_NULL_HANDLE;
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
assert(pdev_count > 0);
|
|
|
|
|
|
|
|
pdevs = malloc(sizeof(*pdevs) * pdev_count);
|
2021-02-05 11:48:37 +00:00
|
|
|
result = vkEnumeratePhysicalDevices(instance, &pdev_count, pdevs);
|
|
|
|
assert(result == VK_SUCCESS);
|
2018-08-31 15:50:20 +01:00
|
|
|
assert(pdev_count > 0);
|
|
|
|
|
|
|
|
for (i = 0; i < pdev_count; ++i) {
|
|
|
|
VkPhysicalDeviceProperties props;
|
|
|
|
vkGetPhysicalDeviceProperties(pdevs[i], &props);
|
zink: support using lavapipe
This is really nasty, and shouldn't really be needed, but we have a
problem where both Zink and Lavapipe checks $GALLIUM_DRIVER, meaning that
Zink tries to use Lavapipe, and Lavapipe tries to use Zink.
This patch side-steps that by temporarily setting $GALLIUM_DRIVER to
"llvmpipe", giving Lavapipe a chance to succeed.
This is not great at all. The most obvious problem is that this is super
thread-unsafe, effectively modifying global state without any care. In
reality, we'd only want the pipe-loader in the *same thread* to ignore
Zink, but it's not so obvious how to do that without introducing lots of
ugly zink-specific cruft.
People shouldn't be using Zink if they don't have a GPU, it's going to
be much better to use LLVMpipe in that case. So let's not worry too much
about this case, and instead guard this dangerous logic with an
ZINK_USE_LAVAPIPE environment variable. This means this behavior only
happens if people opt in to it.
With this in place, we can start using Zink + Lavapipe on CI.
In the longer run, it might be better to use Adam Jackson's copper
loader instead, and drop exposing Zink as a software rasterizer
entirely. But that's something for the great future where we have flying
cars and all.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>
2020-12-02 16:26:26 +00:00
|
|
|
|
|
|
|
#ifdef ZINK_WITH_SWRAST_VK
|
|
|
|
char *use_lavapipe = getenv("ZINK_USE_LAVAPIPE");
|
|
|
|
if (use_lavapipe) {
|
|
|
|
if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) {
|
|
|
|
pdev = pdevs[i];
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif
|
2021-02-03 04:17:46 +00:00
|
|
|
if (props.deviceType != VK_PHYSICAL_DEVICE_TYPE_CPU) {
|
2018-08-31 15:50:20 +01:00
|
|
|
pdev = pdevs[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(pdevs);
|
|
|
|
return pdev;
|
|
|
|
}
|
|
|
|
|
2020-07-10 19:40:01 +01:00
|
|
|
static void
|
|
|
|
update_queue_props(struct zink_screen *screen)
|
2018-08-31 15:50:20 +01:00
|
|
|
{
|
|
|
|
uint32_t num_queues;
|
2020-07-10 19:40:01 +01:00
|
|
|
vkGetPhysicalDeviceQueueFamilyProperties(screen->pdev, &num_queues, NULL);
|
2018-08-31 15:50:20 +01:00
|
|
|
assert(num_queues > 0);
|
|
|
|
|
|
|
|
VkQueueFamilyProperties *props = malloc(sizeof(*props) * num_queues);
|
2020-07-10 19:40:01 +01:00
|
|
|
vkGetPhysicalDeviceQueueFamilyProperties(screen->pdev, &num_queues, props);
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < num_queues; i++) {
|
|
|
|
if (props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
|
2020-07-10 19:40:01 +01:00
|
|
|
screen->gfx_queue = i;
|
|
|
|
screen->timestamp_valid_bits = props[i].timestampValidBits;
|
|
|
|
break;
|
2018-08-31 15:50:20 +01:00
|
|
|
}
|
|
|
|
}
|
2020-07-10 19:40:01 +01:00
|
|
|
free(props);
|
2018-08-31 15:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zink_flush_frontbuffer(struct pipe_screen *pscreen,
|
2020-12-10 18:50:54 +00:00
|
|
|
struct pipe_context *pcontext,
|
2018-08-31 15:50:20 +01:00
|
|
|
struct pipe_resource *pres,
|
|
|
|
unsigned level, unsigned layer,
|
|
|
|
void *winsys_drawable_handle,
|
|
|
|
struct pipe_box *sub_box)
|
|
|
|
{
|
|
|
|
struct zink_screen *screen = zink_screen(pscreen);
|
|
|
|
struct sw_winsys *winsys = screen->winsys;
|
|
|
|
struct zink_resource *res = zink_resource(pres);
|
|
|
|
|
2018-10-02 23:27:36 +01:00
|
|
|
if (!winsys)
|
|
|
|
return;
|
2018-08-31 15:50:20 +01:00
|
|
|
void *map = winsys->displaytarget_map(winsys, res->dt, 0);
|
|
|
|
|
|
|
|
if (map) {
|
|
|
|
VkImageSubresource isr = {};
|
|
|
|
isr.aspectMask = res->aspect;
|
|
|
|
isr.mipLevel = level;
|
|
|
|
isr.arrayLayer = layer;
|
|
|
|
VkSubresourceLayout layout;
|
|
|
|
vkGetImageSubresourceLayout(screen->dev, res->image, &isr, &layout);
|
|
|
|
|
|
|
|
void *ptr;
|
|
|
|
VkResult result = vkMapMemory(screen->dev, res->mem, res->offset, res->size, 0, &ptr);
|
|
|
|
if (result != VK_SUCCESS) {
|
|
|
|
debug_printf("failed to map memory for display\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < pres->height0; ++i) {
|
|
|
|
uint8_t *src = (uint8_t *)ptr + i * layout.rowPitch;
|
|
|
|
uint8_t *dst = (uint8_t *)map + i * res->dt_stride;
|
|
|
|
memcpy(dst, src, res->dt_stride);
|
|
|
|
}
|
|
|
|
vkUnmapMemory(screen->dev, res->mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
winsys->displaytarget_unmap(winsys, res->dt);
|
|
|
|
|
|
|
|
assert(res->dt);
|
|
|
|
if (res->dt)
|
|
|
|
winsys->displaytarget_display(winsys, res->dt, winsys_drawable_handle, sub_box);
|
|
|
|
}
|
|
|
|
|
2020-12-07 18:50:04 +00:00
|
|
|
bool
|
|
|
|
zink_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum pipe_format
|
|
|
|
emulate_x8(enum pipe_format format)
|
|
|
|
{
|
|
|
|
/* convert missing X8 variants to A8 */
|
|
|
|
switch (format) {
|
|
|
|
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
|
|
|
return PIPE_FORMAT_B8G8R8A8_UNORM;
|
|
|
|
|
|
|
|
case PIPE_FORMAT_B8G8R8X8_SRGB:
|
|
|
|
return PIPE_FORMAT_B8G8R8A8_SRGB;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VkFormat
|
|
|
|
zink_get_format(struct zink_screen *screen, enum pipe_format format)
|
|
|
|
{
|
|
|
|
VkFormat ret = zink_pipe_format_to_vk_format(emulate_x8(format));
|
|
|
|
|
2021-02-10 14:47:57 +00:00
|
|
|
if (format == PIPE_FORMAT_X24S8_UINT)
|
|
|
|
/* valid when using aspects to extract stencil,
|
|
|
|
* fails format test because it's emulated */
|
|
|
|
ret = VK_FORMAT_D24_UNORM_S8_UINT;
|
|
|
|
|
2020-12-07 18:50:04 +00:00
|
|
|
if (ret == VK_FORMAT_X8_D24_UNORM_PACK32 &&
|
|
|
|
!screen->have_X8_D24_UNORM_PACK32) {
|
|
|
|
assert(zink_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(zink_is_depth_format_supported(screen,
|
|
|
|
VK_FORMAT_D32_SFLOAT_S8_UINT));
|
|
|
|
return VK_FORMAT_D32_SFLOAT_S8_UINT;
|
|
|
|
}
|
|
|
|
|
2020-12-26 17:43:52 +00:00
|
|
|
if ((ret == VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT &&
|
|
|
|
!screen->info.format_4444_feats.formatA4B4G4R4) ||
|
|
|
|
(ret == VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT &&
|
|
|
|
!screen->info.format_4444_feats.formatA4R4G4B4))
|
|
|
|
return VK_FORMAT_UNDEFINED;
|
|
|
|
|
2020-12-07 18:50:04 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-10-30 10:01:42 +00:00
|
|
|
static bool
|
|
|
|
load_device_extensions(struct zink_screen *screen)
|
|
|
|
{
|
2020-09-28 11:43:36 +01:00
|
|
|
if (screen->info.have_EXT_transform_feedback) {
|
2020-06-01 19:59:15 +01:00
|
|
|
GET_PROC_ADDR(CmdBindTransformFeedbackBuffersEXT);
|
|
|
|
GET_PROC_ADDR(CmdBeginTransformFeedbackEXT);
|
|
|
|
GET_PROC_ADDR(CmdEndTransformFeedbackEXT);
|
|
|
|
GET_PROC_ADDR(CmdBeginQueryIndexedEXT);
|
|
|
|
GET_PROC_ADDR(CmdEndQueryIndexedEXT);
|
|
|
|
GET_PROC_ADDR(CmdDrawIndirectByteCountEXT);
|
|
|
|
}
|
2020-09-28 11:43:36 +01:00
|
|
|
if (screen->info.have_KHR_external_memory_fd)
|
2020-05-08 11:07:48 +01:00
|
|
|
GET_PROC_ADDR(GetMemoryFdKHR);
|
|
|
|
|
2020-09-28 11:43:36 +01:00
|
|
|
if (screen->info.have_EXT_conditional_rendering) {
|
2018-10-15 00:15:50 +01:00
|
|
|
GET_PROC_ADDR(CmdBeginConditionalRenderingEXT);
|
|
|
|
GET_PROC_ADDR(CmdEndConditionalRenderingEXT);
|
|
|
|
}
|
|
|
|
|
2020-09-28 11:43:36 +01:00
|
|
|
if (screen->info.have_EXT_calibrated_timestamps) {
|
2020-07-10 19:42:08 +01:00
|
|
|
GET_PROC_ADDR_INSTANCE(GetPhysicalDeviceCalibrateableTimeDomainsEXT);
|
|
|
|
GET_PROC_ADDR(GetCalibratedTimestampsEXT);
|
|
|
|
|
|
|
|
uint32_t num_domains = 0;
|
|
|
|
screen->vk_GetPhysicalDeviceCalibrateableTimeDomainsEXT(screen->pdev, &num_domains, NULL);
|
|
|
|
assert(num_domains > 0);
|
|
|
|
|
|
|
|
VkTimeDomainEXT *domains = malloc(sizeof(VkTimeDomainEXT) * num_domains);
|
|
|
|
screen->vk_GetPhysicalDeviceCalibrateableTimeDomainsEXT(screen->pdev, &num_domains, domains);
|
|
|
|
|
|
|
|
/* VK_TIME_DOMAIN_DEVICE_EXT is used for the ctx->get_timestamp hook and is the only one we really need */
|
2020-08-25 19:30:07 +01:00
|
|
|
ASSERTED bool have_device_time = false;
|
2020-07-10 19:42:08 +01:00
|
|
|
for (unsigned i = 0; i < num_domains; i++) {
|
|
|
|
if (domains[i] == VK_TIME_DOMAIN_DEVICE_EXT) {
|
|
|
|
have_device_time = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(have_device_time);
|
|
|
|
free(domains);
|
|
|
|
}
|
2020-09-16 17:56:05 +01:00
|
|
|
if (screen->info.have_EXT_extended_dynamic_state) {
|
|
|
|
GET_PROC_ADDR(CmdSetViewportWithCountEXT);
|
|
|
|
GET_PROC_ADDR(CmdSetScissorWithCountEXT);
|
|
|
|
}
|
2020-07-10 19:42:08 +01:00
|
|
|
|
2020-11-05 11:17:40 +00:00
|
|
|
screen->have_triangle_fans = true;
|
|
|
|
#if defined(VK_EXTX_PORTABILITY_SUBSET_EXTENSION_NAME)
|
|
|
|
if (screen->info.have_EXTX_portability_subset) {
|
|
|
|
screen->have_triangle_fans = (VK_TRUE == screen->info.portability_subset_extx_feats.triangleFans);
|
|
|
|
}
|
|
|
|
#endif // VK_EXTX_PORTABILITY_SUBSET_EXTENSION_NAME
|
|
|
|
|
2020-10-30 10:01:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-04 15:41:11 +00:00
|
|
|
static VkBool32 VKAPI_CALL
|
|
|
|
zink_debug_util_callback(
|
|
|
|
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
|
|
|
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
|
|
|
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
|
|
|
|
void *pUserData)
|
|
|
|
{
|
|
|
|
const char *severity = "MSG";
|
|
|
|
|
|
|
|
// Pick message prefix and color to use.
|
|
|
|
// Only MacOS and Linux have been tested for color support
|
|
|
|
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
|
|
|
|
severity = "ERR";
|
|
|
|
} else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
|
|
|
|
severity = "WRN";
|
|
|
|
} else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) {
|
|
|
|
severity = "NFO";
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "zink DEBUG: %s: '%s'\n", severity, pCallbackData->pMessage);
|
|
|
|
return VK_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
create_debug(struct zink_screen *screen)
|
|
|
|
{
|
|
|
|
GET_PROC_ADDR_INSTANCE(CreateDebugUtilsMessengerEXT);
|
|
|
|
GET_PROC_ADDR_INSTANCE(DestroyDebugUtilsMessengerEXT);
|
|
|
|
|
|
|
|
if (!screen->vk_CreateDebugUtilsMessengerEXT || !screen->vk_DestroyDebugUtilsMessengerEXT)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
VkDebugUtilsMessengerCreateInfoEXT vkDebugUtilsMessengerCreateInfoEXT = {
|
|
|
|
VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
|
|
|
|
NULL,
|
|
|
|
0, // flags
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
|
|
|
|
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT,
|
|
|
|
zink_debug_util_callback,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
VkDebugUtilsMessengerEXT vkDebugUtilsCallbackEXT = VK_NULL_HANDLE;
|
|
|
|
|
|
|
|
screen->vk_CreateDebugUtilsMessengerEXT(
|
|
|
|
screen->instance,
|
|
|
|
&vkDebugUtilsMessengerCreateInfoEXT,
|
|
|
|
NULL,
|
|
|
|
&vkDebugUtilsCallbackEXT
|
|
|
|
);
|
|
|
|
|
|
|
|
screen->debugUtilsCallbackHandle = vkDebugUtilsCallbackEXT;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-30 10:01:42 +00:00
|
|
|
static bool
|
|
|
|
zink_internal_setup_moltenvk(struct zink_screen *screen)
|
|
|
|
{
|
2020-12-09 17:20:45 +00:00
|
|
|
#if defined(MVK_VERSION)
|
2020-12-28 20:26:09 +00:00
|
|
|
if (!screen->instance_info.have_MVK_moltenvk)
|
2020-10-30 10:01:42 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
GET_PROC_ADDR_INSTANCE(GetMoltenVKConfigurationMVK);
|
|
|
|
GET_PROC_ADDR_INSTANCE(SetMoltenVKConfigurationMVK);
|
|
|
|
|
|
|
|
GET_PROC_ADDR_INSTANCE(GetPhysicalDeviceMetalFeaturesMVK);
|
|
|
|
GET_PROC_ADDR_INSTANCE(GetVersionStringsMVK);
|
|
|
|
GET_PROC_ADDR_INSTANCE(UseIOSurfaceMVK);
|
|
|
|
GET_PROC_ADDR_INSTANCE(GetIOSurfaceMVK);
|
|
|
|
|
|
|
|
if (screen->vk_GetVersionStringsMVK) {
|
|
|
|
char molten_version[64] = {0};
|
|
|
|
char vulkan_version[64] = {0};
|
|
|
|
|
|
|
|
(*screen->vk_GetVersionStringsMVK)(molten_version, sizeof(molten_version) - 1, vulkan_version, sizeof(vulkan_version) - 1);
|
|
|
|
|
|
|
|
printf("zink: MoltenVK %s Vulkan %s \n", molten_version, vulkan_version);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (screen->vk_GetMoltenVKConfigurationMVK && screen->vk_SetMoltenVKConfigurationMVK) {
|
|
|
|
MVKConfiguration molten_config = {0};
|
|
|
|
size_t molten_config_size = sizeof(molten_config);
|
|
|
|
|
|
|
|
VkResult res = (*screen->vk_GetMoltenVKConfigurationMVK)(screen->instance, &molten_config, &molten_config_size);
|
|
|
|
if (res == VK_SUCCESS || res == VK_INCOMPLETE) {
|
|
|
|
// Needed to allow MoltenVK to accept VkImageView swizzles.
|
2020-12-12 02:41:39 +00:00
|
|
|
// Encountered when using VK_FORMAT_R8G8_UNORM
|
2020-10-30 10:01:42 +00:00
|
|
|
molten_config.fullImageViewSwizzle = VK_TRUE;
|
|
|
|
(*screen->vk_SetMoltenVKConfigurationMVK)(screen->instance, &molten_config, &molten_config_size);
|
|
|
|
}
|
|
|
|
}
|
2020-12-09 17:20:45 +00:00
|
|
|
#endif // MVK_VERSION
|
2020-04-30 18:06:51 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-06 08:20:42 +00:00
|
|
|
static void
|
|
|
|
check_device_needs_mesa_wsi(struct zink_screen *screen)
|
|
|
|
{
|
2020-12-31 17:47:58 +00:00
|
|
|
if (
|
|
|
|
/* Raspberry Pi 4 V3DV driver */
|
|
|
|
(screen->info.props.vendorID == 0x14E4 &&
|
|
|
|
screen->info.props.deviceID == 42) ||
|
|
|
|
/* RADV */
|
|
|
|
screen->info.driver_props.driverID == VK_DRIVER_ID_MESA_RADV_KHR
|
|
|
|
) {
|
2020-11-06 08:20:42 +00:00
|
|
|
screen->needs_mesa_wsi = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-08 22:02:47 +00:00
|
|
|
static uint32_t
|
|
|
|
zink_get_loader_version(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t loader_version = VK_API_VERSION_1_0;
|
|
|
|
|
|
|
|
// Get the Loader version
|
|
|
|
GET_PROC_ADDR_INSTANCE_LOCAL(NULL, EnumerateInstanceVersion);
|
|
|
|
if (vk_EnumerateInstanceVersion) {
|
|
|
|
uint32_t loader_version_temp = VK_API_VERSION_1_0;
|
|
|
|
if (VK_SUCCESS == (*vk_EnumerateInstanceVersion)(&loader_version_temp)) {
|
|
|
|
loader_version = loader_version_temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return loader_version;
|
|
|
|
}
|
|
|
|
|
2020-12-08 22:11:19 +00:00
|
|
|
static VkDevice
|
|
|
|
zink_create_logical_device(struct zink_screen *screen)
|
|
|
|
{
|
|
|
|
VkDevice dev = VK_NULL_HANDLE;
|
|
|
|
|
|
|
|
VkDeviceQueueCreateInfo qci = {};
|
|
|
|
float dummy = 0.0f;
|
|
|
|
qci.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
|
|
|
qci.queueFamilyIndex = screen->gfx_queue;
|
|
|
|
qci.queueCount = 1;
|
|
|
|
qci.pQueuePriorities = &dummy;
|
|
|
|
|
|
|
|
VkDeviceCreateInfo dci = {};
|
|
|
|
dci.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
|
|
|
dci.queueCreateInfoCount = 1;
|
|
|
|
dci.pQueueCreateInfos = &qci;
|
|
|
|
/* extensions don't have bool members in pEnabledFeatures.
|
|
|
|
* this requires us to pass the whole VkPhysicalDeviceFeatures2 struct
|
|
|
|
*/
|
|
|
|
if (screen->info.feats.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2) {
|
|
|
|
dci.pNext = &screen->info.feats;
|
|
|
|
} else {
|
|
|
|
dci.pEnabledFeatures = &screen->info.feats.features;
|
|
|
|
}
|
|
|
|
|
|
|
|
dci.ppEnabledExtensionNames = screen->info.extensions;
|
|
|
|
dci.enabledExtensionCount = screen->info.num_extensions;
|
|
|
|
|
|
|
|
vkCreateDevice(screen->pdev, &dci, NULL, &dev);
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
2020-12-02 20:38:35 +00:00
|
|
|
static struct zink_screen *
|
|
|
|
zink_internal_create_screen(const struct pipe_screen_config *config)
|
2018-08-31 15:50:20 +01:00
|
|
|
{
|
|
|
|
struct zink_screen *screen = CALLOC_STRUCT(zink_screen);
|
|
|
|
if (!screen)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
zink_debug = debug_get_option_zink_debug();
|
|
|
|
|
2020-12-16 22:44:50 +00:00
|
|
|
screen->instance_info.loader_version = zink_get_loader_version();
|
|
|
|
screen->instance = zink_create_instance(&screen->instance_info);
|
|
|
|
|
2020-11-04 17:42:29 +00:00
|
|
|
if (!screen->instance)
|
|
|
|
goto fail;
|
|
|
|
|
2021-01-15 09:16:54 +00:00
|
|
|
if (!zink_load_instance_extensions(screen))
|
2020-11-06 08:02:21 +00:00
|
|
|
goto fail;
|
|
|
|
|
2020-12-24 00:15:38 +00:00
|
|
|
if (screen->instance_info.have_EXT_debug_utils && !create_debug(screen))
|
2020-11-04 15:41:11 +00:00
|
|
|
debug_printf("ZINK: failed to setup debug utils\n");
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
screen->pdev = choose_pdev(screen->instance);
|
2021-02-05 11:49:50 +00:00
|
|
|
if (screen->pdev == VK_NULL_HANDLE)
|
2021-02-03 04:17:46 +00:00
|
|
|
goto fail;
|
|
|
|
|
2020-07-10 19:40:01 +01:00
|
|
|
update_queue_props(screen);
|
2018-08-31 15:50:20 +01:00
|
|
|
|
2019-11-06 14:26:12 +00:00
|
|
|
screen->have_X8_D24_UNORM_PACK32 = zink_is_depth_format_supported(screen,
|
|
|
|
VK_FORMAT_X8_D24_UNORM_PACK32);
|
|
|
|
screen->have_D24_UNORM_S8_UINT = zink_is_depth_format_supported(screen,
|
|
|
|
VK_FORMAT_D24_UNORM_S8_UINT);
|
2019-10-23 10:59:03 +01:00
|
|
|
|
2020-09-26 07:49:49 +01:00
|
|
|
if (!zink_get_physical_device_info(screen)) {
|
|
|
|
debug_printf("ZINK: failed to detect features\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2020-11-06 08:20:42 +00:00
|
|
|
/* Some Vulkan implementations have special requirements for WSI
|
|
|
|
* allocations.
|
|
|
|
*/
|
|
|
|
check_device_needs_mesa_wsi(screen);
|
|
|
|
|
2020-10-30 10:01:42 +00:00
|
|
|
zink_internal_setup_moltenvk(screen);
|
|
|
|
|
2020-12-08 22:11:19 +00:00
|
|
|
screen->dev = zink_create_logical_device(screen);
|
|
|
|
if (!screen->dev)
|
2018-08-31 15:50:20 +01:00
|
|
|
goto fail;
|
|
|
|
|
2020-04-30 18:06:51 +01:00
|
|
|
if (!load_device_extensions(screen))
|
|
|
|
goto fail;
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
screen->base.get_name = zink_get_name;
|
|
|
|
screen->base.get_vendor = zink_get_vendor;
|
|
|
|
screen->base.get_device_vendor = zink_get_device_vendor;
|
2020-08-12 22:02:42 +01:00
|
|
|
screen->base.get_compute_param = zink_get_compute_param;
|
2018-08-31 15:50:20 +01:00
|
|
|
screen->base.get_param = zink_get_param;
|
|
|
|
screen->base.get_paramf = zink_get_paramf;
|
|
|
|
screen->base.get_shader_param = zink_get_shader_param;
|
|
|
|
screen->base.get_compiler_options = zink_get_compiler_options;
|
|
|
|
screen->base.is_format_supported = zink_is_format_supported;
|
|
|
|
screen->base.context_create = zink_context_create;
|
|
|
|
screen->base.flush_frontbuffer = zink_flush_frontbuffer;
|
|
|
|
screen->base.destroy = zink_destroy_screen;
|
|
|
|
|
|
|
|
zink_screen_resource_init(&screen->base);
|
|
|
|
zink_screen_fence_init(&screen->base);
|
|
|
|
|
2021-01-06 08:57:49 +00:00
|
|
|
zink_screen_init_compiler(screen);
|
|
|
|
|
2018-08-31 15:50:20 +01:00
|
|
|
slab_create_parent(&screen->transfer_pool, sizeof(struct zink_transfer), 16);
|
|
|
|
|
2020-12-02 20:38:35 +00:00
|
|
|
return screen;
|
2018-08-31 15:50:20 +01:00
|
|
|
|
|
|
|
fail:
|
|
|
|
FREE(screen);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-10-02 23:27:36 +01:00
|
|
|
|
|
|
|
struct pipe_screen *
|
|
|
|
zink_create_screen(struct sw_winsys *winsys)
|
|
|
|
{
|
zink: support using lavapipe
This is really nasty, and shouldn't really be needed, but we have a
problem where both Zink and Lavapipe checks $GALLIUM_DRIVER, meaning that
Zink tries to use Lavapipe, and Lavapipe tries to use Zink.
This patch side-steps that by temporarily setting $GALLIUM_DRIVER to
"llvmpipe", giving Lavapipe a chance to succeed.
This is not great at all. The most obvious problem is that this is super
thread-unsafe, effectively modifying global state without any care. In
reality, we'd only want the pipe-loader in the *same thread* to ignore
Zink, but it's not so obvious how to do that without introducing lots of
ugly zink-specific cruft.
People shouldn't be using Zink if they don't have a GPU, it's going to
be much better to use LLVMpipe in that case. So let's not worry too much
about this case, and instead guard this dangerous logic with an
ZINK_USE_LAVAPIPE environment variable. This means this behavior only
happens if people opt in to it.
With this in place, we can start using Zink + Lavapipe on CI.
In the longer run, it might be better to use Adam Jackson's copper
loader instead, and drop exposing Zink as a software rasterizer
entirely. But that's something for the great future where we have flying
cars and all.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>
2020-12-02 16:26:26 +00:00
|
|
|
#ifdef ZINK_WITH_SWRAST_VK
|
|
|
|
char *use_lavapipe = getenv("ZINK_USE_LAVAPIPE"), *gallium_driver = NULL;
|
|
|
|
if (use_lavapipe) {
|
|
|
|
/**
|
|
|
|
* HACK: Temorarily unset $GALLIUM_DRIVER to prevent Lavapipe from
|
|
|
|
* recursively trying to use zink as the gallium driver.
|
|
|
|
*
|
|
|
|
* This is not thread-safe, so if an application creates another
|
|
|
|
* context in another thread at the same time, well, we're out of
|
|
|
|
* luck!
|
|
|
|
*/
|
|
|
|
gallium_driver = getenv("GALLIUM_DRIVER");
|
2021-02-10 13:27:52 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
_putenv("GALLIUM_DRIVER=llvmpipe");
|
|
|
|
#else
|
zink: support using lavapipe
This is really nasty, and shouldn't really be needed, but we have a
problem where both Zink and Lavapipe checks $GALLIUM_DRIVER, meaning that
Zink tries to use Lavapipe, and Lavapipe tries to use Zink.
This patch side-steps that by temporarily setting $GALLIUM_DRIVER to
"llvmpipe", giving Lavapipe a chance to succeed.
This is not great at all. The most obvious problem is that this is super
thread-unsafe, effectively modifying global state without any care. In
reality, we'd only want the pipe-loader in the *same thread* to ignore
Zink, but it's not so obvious how to do that without introducing lots of
ugly zink-specific cruft.
People shouldn't be using Zink if they don't have a GPU, it's going to
be much better to use LLVMpipe in that case. So let's not worry too much
about this case, and instead guard this dangerous logic with an
ZINK_USE_LAVAPIPE environment variable. This means this behavior only
happens if people opt in to it.
With this in place, we can start using Zink + Lavapipe on CI.
In the longer run, it might be better to use Adam Jackson's copper
loader instead, and drop exposing Zink as a software rasterizer
entirely. But that's something for the great future where we have flying
cars and all.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>
2020-12-02 16:26:26 +00:00
|
|
|
setenv("GALLIUM_DRIVER", "llvmpipe", 1);
|
2021-02-10 13:27:52 +00:00
|
|
|
#endif
|
zink: support using lavapipe
This is really nasty, and shouldn't really be needed, but we have a
problem where both Zink and Lavapipe checks $GALLIUM_DRIVER, meaning that
Zink tries to use Lavapipe, and Lavapipe tries to use Zink.
This patch side-steps that by temporarily setting $GALLIUM_DRIVER to
"llvmpipe", giving Lavapipe a chance to succeed.
This is not great at all. The most obvious problem is that this is super
thread-unsafe, effectively modifying global state without any care. In
reality, we'd only want the pipe-loader in the *same thread* to ignore
Zink, but it's not so obvious how to do that without introducing lots of
ugly zink-specific cruft.
People shouldn't be using Zink if they don't have a GPU, it's going to
be much better to use LLVMpipe in that case. So let's not worry too much
about this case, and instead guard this dangerous logic with an
ZINK_USE_LAVAPIPE environment variable. This means this behavior only
happens if people opt in to it.
With this in place, we can start using Zink + Lavapipe on CI.
In the longer run, it might be better to use Adam Jackson's copper
loader instead, and drop exposing Zink as a software rasterizer
entirely. But that's something for the great future where we have flying
cars and all.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>
2020-12-02 16:26:26 +00:00
|
|
|
}
|
|
|
|
#endif
|
2020-12-02 20:38:35 +00:00
|
|
|
|
zink: support using lavapipe
This is really nasty, and shouldn't really be needed, but we have a
problem where both Zink and Lavapipe checks $GALLIUM_DRIVER, meaning that
Zink tries to use Lavapipe, and Lavapipe tries to use Zink.
This patch side-steps that by temporarily setting $GALLIUM_DRIVER to
"llvmpipe", giving Lavapipe a chance to succeed.
This is not great at all. The most obvious problem is that this is super
thread-unsafe, effectively modifying global state without any care. In
reality, we'd only want the pipe-loader in the *same thread* to ignore
Zink, but it's not so obvious how to do that without introducing lots of
ugly zink-specific cruft.
People shouldn't be using Zink if they don't have a GPU, it's going to
be much better to use LLVMpipe in that case. So let's not worry too much
about this case, and instead guard this dangerous logic with an
ZINK_USE_LAVAPIPE environment variable. This means this behavior only
happens if people opt in to it.
With this in place, we can start using Zink + Lavapipe on CI.
In the longer run, it might be better to use Adam Jackson's copper
loader instead, and drop exposing Zink as a software rasterizer
entirely. But that's something for the great future where we have flying
cars and all.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>
2020-12-02 16:26:26 +00:00
|
|
|
struct zink_screen *ret = zink_internal_create_screen(NULL);
|
2020-12-02 20:38:35 +00:00
|
|
|
if (ret)
|
|
|
|
ret->winsys = winsys;
|
|
|
|
|
zink: support using lavapipe
This is really nasty, and shouldn't really be needed, but we have a
problem where both Zink and Lavapipe checks $GALLIUM_DRIVER, meaning that
Zink tries to use Lavapipe, and Lavapipe tries to use Zink.
This patch side-steps that by temporarily setting $GALLIUM_DRIVER to
"llvmpipe", giving Lavapipe a chance to succeed.
This is not great at all. The most obvious problem is that this is super
thread-unsafe, effectively modifying global state without any care. In
reality, we'd only want the pipe-loader in the *same thread* to ignore
Zink, but it's not so obvious how to do that without introducing lots of
ugly zink-specific cruft.
People shouldn't be using Zink if they don't have a GPU, it's going to
be much better to use LLVMpipe in that case. So let's not worry too much
about this case, and instead guard this dangerous logic with an
ZINK_USE_LAVAPIPE environment variable. This means this behavior only
happens if people opt in to it.
With this in place, we can start using Zink + Lavapipe on CI.
In the longer run, it might be better to use Adam Jackson's copper
loader instead, and drop exposing Zink as a software rasterizer
entirely. But that's something for the great future where we have flying
cars and all.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>
2020-12-02 16:26:26 +00:00
|
|
|
#ifdef ZINK_WITH_SWRAST_VK
|
2021-02-10 13:27:52 +00:00
|
|
|
if (gallium_driver) {
|
|
|
|
#ifdef _WIN32
|
|
|
|
char envstr[64] = "";
|
|
|
|
snprintf(envstr, 64, "GALLIUM_DRIVER=%s", gallium_driver);
|
|
|
|
_putenv(envstr);
|
|
|
|
#else
|
zink: support using lavapipe
This is really nasty, and shouldn't really be needed, but we have a
problem where both Zink and Lavapipe checks $GALLIUM_DRIVER, meaning that
Zink tries to use Lavapipe, and Lavapipe tries to use Zink.
This patch side-steps that by temporarily setting $GALLIUM_DRIVER to
"llvmpipe", giving Lavapipe a chance to succeed.
This is not great at all. The most obvious problem is that this is super
thread-unsafe, effectively modifying global state without any care. In
reality, we'd only want the pipe-loader in the *same thread* to ignore
Zink, but it's not so obvious how to do that without introducing lots of
ugly zink-specific cruft.
People shouldn't be using Zink if they don't have a GPU, it's going to
be much better to use LLVMpipe in that case. So let's not worry too much
about this case, and instead guard this dangerous logic with an
ZINK_USE_LAVAPIPE environment variable. This means this behavior only
happens if people opt in to it.
With this in place, we can start using Zink + Lavapipe on CI.
In the longer run, it might be better to use Adam Jackson's copper
loader instead, and drop exposing Zink as a software rasterizer
entirely. But that's something for the great future where we have flying
cars and all.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>
2020-12-02 16:26:26 +00:00
|
|
|
setenv("GALLIUM_DRIVER", gallium_driver, 1);
|
|
|
|
#endif
|
2021-02-10 13:27:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
zink: support using lavapipe
This is really nasty, and shouldn't really be needed, but we have a
problem where both Zink and Lavapipe checks $GALLIUM_DRIVER, meaning that
Zink tries to use Lavapipe, and Lavapipe tries to use Zink.
This patch side-steps that by temporarily setting $GALLIUM_DRIVER to
"llvmpipe", giving Lavapipe a chance to succeed.
This is not great at all. The most obvious problem is that this is super
thread-unsafe, effectively modifying global state without any care. In
reality, we'd only want the pipe-loader in the *same thread* to ignore
Zink, but it's not so obvious how to do that without introducing lots of
ugly zink-specific cruft.
People shouldn't be using Zink if they don't have a GPU, it's going to
be much better to use LLVMpipe in that case. So let's not worry too much
about this case, and instead guard this dangerous logic with an
ZINK_USE_LAVAPIPE environment variable. This means this behavior only
happens if people opt in to it.
With this in place, we can start using Zink + Lavapipe on CI.
In the longer run, it might be better to use Adam Jackson's copper
loader instead, and drop exposing Zink as a software rasterizer
entirely. But that's something for the great future where we have flying
cars and all.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>
2020-12-02 16:26:26 +00:00
|
|
|
|
2020-12-02 20:38:35 +00:00
|
|
|
return &ret->base;
|
2018-10-02 23:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct pipe_screen *
|
2020-09-23 20:42:18 +01:00
|
|
|
zink_drm_create_screen(int fd, const struct pipe_screen_config *config)
|
2018-10-02 23:27:36 +01:00
|
|
|
{
|
2020-12-02 20:38:35 +00:00
|
|
|
struct zink_screen *ret = zink_internal_create_screen(config);
|
|
|
|
|
|
|
|
if (ret && !ret->info.have_KHR_external_memory_fd) {
|
|
|
|
debug_printf("ZINK: KHR_external_memory_fd required!\n");
|
|
|
|
free(ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &ret->base;
|
2018-10-02 23:27:36 +01:00
|
|
|
}
|