José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
José Fonseca | 8771285 | 2014-01-17 16:27:50 +0000 | [diff] [blame] | 3 | * Copyright 2008 VMware, Inc. |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 4 | * All Rights Reserved. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sub license, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial portions |
| 16 | * of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
José Fonseca | 8771285 | 2014-01-17 16:27:50 +0000 | [diff] [blame] | 21 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | * |
| 26 | **************************************************************************/ |
| 27 | |
| 28 | |
| 29 | #include "util/u_memory.h" |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 30 | #include "util/u_math.h" |
| 31 | #include "util/u_cpu_detect.h" |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 32 | #include "util/u_format.h" |
José Fonseca | a7f67b1 | 2011-08-18 17:58:02 +0100 | [diff] [blame] | 33 | #include "util/u_string.h" |
José Fonseca | fe130a7 | 2010-04-06 22:49:57 +0100 | [diff] [blame] | 34 | #include "util/u_format_s3tc.h" |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 35 | #include "pipe/p_defines.h" |
| 36 | #include "pipe/p_screen.h" |
Luca Barbieri | a508d2d | 2010-09-05 20:50:50 +0200 | [diff] [blame] | 37 | #include "draw/draw_context.h" |
José Fonseca | edc0a00 | 2012-09-06 10:29:04 +0100 | [diff] [blame] | 38 | #include "gallivm/lp_bld_type.h" |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 39 | |
Emil Velikov | 89f80c2 | 2014-08-14 21:15:06 +0100 | [diff] [blame] | 40 | #include "os/os_misc.h" |
James Benton | 16f0d70 | 2012-12-03 07:00:37 +0000 | [diff] [blame] | 41 | #include "os/os_time.h" |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 42 | #include "lp_texture.h" |
Brian Paul | 2876b68 | 2009-12-11 17:32:45 -0700 | [diff] [blame] | 43 | #include "lp_fence.h" |
José Fonseca | 08dd41f | 2009-08-23 05:52:20 +0100 | [diff] [blame] | 44 | #include "lp_jit.h" |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 45 | #include "lp_screen.h" |
Keith Whitwell | 7f41f54 | 2010-02-08 12:55:59 +0000 | [diff] [blame] | 46 | #include "lp_context.h" |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 47 | #include "lp_debug.h" |
Keith Whitwell | 3c57c01 | 2010-03-09 15:25:42 +0000 | [diff] [blame] | 48 | #include "lp_public.h" |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 49 | #include "lp_limits.h" |
Roland Scheidegger | edac740 | 2010-07-13 19:58:58 +0200 | [diff] [blame] | 50 | #include "lp_rast.h" |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 51 | |
Keith Whitwell | 23e951d | 2010-03-04 16:23:05 +0000 | [diff] [blame] | 52 | #include "state_tracker/sw_winsys.h" |
| 53 | |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 54 | #ifdef DEBUG |
| 55 | int LP_DEBUG = 0; |
| 56 | |
| 57 | static const struct debug_named_value lp_debug_flags[] = { |
Joakim Sindholt | 8413b92 | 2010-06-01 20:11:30 +0200 | [diff] [blame] | 58 | { "pipe", DEBUG_PIPE, NULL }, |
| 59 | { "tgsi", DEBUG_TGSI, NULL }, |
| 60 | { "tex", DEBUG_TEX, NULL }, |
| 61 | { "setup", DEBUG_SETUP, NULL }, |
| 62 | { "rast", DEBUG_RAST, NULL }, |
| 63 | { "query", DEBUG_QUERY, NULL }, |
| 64 | { "screen", DEBUG_SCREEN, NULL }, |
Joakim Sindholt | 8413b92 | 2010-06-01 20:11:30 +0200 | [diff] [blame] | 65 | { "counters", DEBUG_COUNTERS, NULL }, |
Keith Whitwell | b6e03ea | 2010-08-20 15:14:19 +0100 | [diff] [blame] | 66 | { "scene", DEBUG_SCENE, NULL }, |
| 67 | { "fence", DEBUG_FENCE, NULL }, |
Keith Whitwell | bc759cd | 2010-09-08 18:37:45 +0100 | [diff] [blame] | 68 | { "mem", DEBUG_MEM, NULL }, |
Keith Whitwell | 0986355 | 2010-09-16 15:16:27 +0100 | [diff] [blame] | 69 | { "fs", DEBUG_FS, NULL }, |
Joakim Sindholt | 8413b92 | 2010-06-01 20:11:30 +0200 | [diff] [blame] | 70 | DEBUG_NAMED_VALUE_END |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 71 | }; |
| 72 | #endif |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 73 | |
Keith Whitwell | 5f00819 | 2010-09-16 10:45:52 +0100 | [diff] [blame] | 74 | int LP_PERF = 0; |
| 75 | static const struct debug_named_value lp_perf_flags[] = { |
| 76 | { "texmem", PERF_TEX_MEM, NULL }, |
| 77 | { "no_mipmap", PERF_NO_MIPMAPS, NULL }, |
| 78 | { "no_linear", PERF_NO_LINEAR, NULL }, |
| 79 | { "no_mip_linear", PERF_NO_MIP_LINEAR, NULL }, |
| 80 | { "no_tex", PERF_NO_TEX, NULL }, |
| 81 | { "no_blend", PERF_NO_BLEND, NULL }, |
| 82 | { "no_depth", PERF_NO_DEPTH, NULL }, |
| 83 | { "no_alphatest", PERF_NO_ALPHATEST, NULL }, |
| 84 | DEBUG_NAMED_VALUE_END |
| 85 | }; |
| 86 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 87 | |
| 88 | static const char * |
| 89 | llvmpipe_get_vendor(struct pipe_screen *screen) |
| 90 | { |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 91 | return "VMware, Inc."; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | |
| 95 | static const char * |
| 96 | llvmpipe_get_name(struct pipe_screen *screen) |
| 97 | { |
Brian Paul | b38c26f | 2011-07-19 08:42:46 -0600 | [diff] [blame] | 98 | static char buf[100]; |
José Fonseca | edc0a00 | 2012-09-06 10:29:04 +0100 | [diff] [blame] | 99 | util_snprintf(buf, sizeof(buf), "llvmpipe (LLVM %u.%u, %u bits)", |
| 100 | HAVE_LLVM >> 8, HAVE_LLVM & 0xff, |
| 101 | lp_native_vector_width ); |
Brian Paul | b38c26f | 2011-07-19 08:42:46 -0600 | [diff] [blame] | 102 | return buf; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | |
| 106 | static int |
José Fonseca | e1238b5 | 2010-05-11 11:11:03 +0100 | [diff] [blame] | 107 | llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 108 | { |
| 109 | switch (param) { |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 110 | case PIPE_CAP_NPOT_TEXTURES: |
Ilia Mirkin | 12d39b4 | 2013-10-04 04:32:15 -0400 | [diff] [blame] | 111 | case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 112 | return 1; |
| 113 | case PIPE_CAP_TWO_SIDED_STENCIL: |
| 114 | return 1; |
Jakob Bornecrantz | c4e89d1 | 2010-04-29 16:18:43 +0100 | [diff] [blame] | 115 | case PIPE_CAP_SM3: |
| 116 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 117 | case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: |
Roland Scheidegger | 8b8bca0 | 2013-02-12 03:41:48 +0100 | [diff] [blame] | 118 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 119 | case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: |
Dave Airlie | 77b2656 | 2012-12-05 06:50:07 +1000 | [diff] [blame] | 120 | return PIPE_MAX_SO_BUFFERS; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 121 | case PIPE_CAP_ANISOTROPIC_FILTER: |
| 122 | return 0; |
| 123 | case PIPE_CAP_POINT_SPRITE: |
| 124 | return 1; |
| 125 | case PIPE_CAP_MAX_RENDER_TARGETS: |
| 126 | return PIPE_MAX_COLOR_BUFS; |
| 127 | case PIPE_CAP_OCCLUSION_QUERY: |
| 128 | return 1; |
José Fonseca | 9976216 | 2012-12-09 09:50:34 +0000 | [diff] [blame] | 129 | case PIPE_CAP_QUERY_TIME_ELAPSED: |
José Fonseca | ab2f573 | 2012-12-09 10:15:19 +0000 | [diff] [blame] | 130 | return 0; |
James Benton | 16f0d70 | 2012-12-03 07:00:37 +0000 | [diff] [blame] | 131 | case PIPE_CAP_QUERY_TIMESTAMP: |
| 132 | return 1; |
Christoph Bumiller | f35e96d | 2013-03-29 13:02:49 +0100 | [diff] [blame] | 133 | case PIPE_CAP_QUERY_PIPELINE_STATISTICS: |
| 134 | return 0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 135 | case PIPE_CAP_TEXTURE_MIRROR_CLAMP: |
| 136 | return 1; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 137 | case PIPE_CAP_TEXTURE_SHADOW_MAP: |
| 138 | return 1; |
José Fonseca | 9881b5c | 2010-06-05 14:48:39 +0100 | [diff] [blame] | 139 | case PIPE_CAP_TEXTURE_SWIZZLE: |
| 140 | return 1; |
Christoph Bumiller | 729abfd | 2013-04-12 13:42:01 +0200 | [diff] [blame] | 141 | case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: |
| 142 | return 0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 143 | case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: |
Brian Paul | d73fadf | 2010-03-08 13:36:34 -0700 | [diff] [blame] | 144 | return LP_MAX_TEXTURE_2D_LEVELS; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 145 | case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: |
Brian Paul | d73fadf | 2010-03-08 13:36:34 -0700 | [diff] [blame] | 146 | return LP_MAX_TEXTURE_3D_LEVELS; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 147 | case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: |
Brian Paul | df73be9 | 2012-09-16 19:05:51 -0600 | [diff] [blame] | 148 | return LP_MAX_TEXTURE_CUBE_LEVELS; |
Roland Scheidegger | 6d50148 | 2012-11-29 04:08:32 +0100 | [diff] [blame] | 149 | case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: |
| 150 | return LP_MAX_TEXTURE_ARRAY_LAYERS; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 151 | case PIPE_CAP_BLEND_EQUATION_SEPARATE: |
| 152 | return 1; |
Roland Scheidegger | 1a9d01d | 2010-01-26 17:32:57 +0100 | [diff] [blame] | 153 | case PIPE_CAP_INDEP_BLEND_ENABLE: |
Brian Paul | 7b937cf | 2010-05-10 17:03:10 -0600 | [diff] [blame] | 154 | return 1; |
Roland Scheidegger | 1a9d01d | 2010-01-26 17:32:57 +0100 | [diff] [blame] | 155 | case PIPE_CAP_INDEP_BLEND_FUNC: |
Brian Paul | 96a2e89 | 2011-01-17 16:42:43 -0700 | [diff] [blame] | 156 | return 1; |
Luca Barbieri | 6c403750 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 157 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: |
| 158 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: |
José Fonseca | a930136 | 2013-04-18 11:39:19 +0100 | [diff] [blame] | 159 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: |
Luca Barbieri | 6c403750 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 160 | return 1; |
| 161 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: |
Luca Barbieri | 6c403750 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 162 | return 0; |
Brian Paul | 6692ed6 | 2010-10-21 19:03:38 -0600 | [diff] [blame] | 163 | case PIPE_CAP_PRIMITIVE_RESTART: |
| 164 | return 1; |
Marek Olšák | dc4c821 | 2012-01-10 00:19:00 +0100 | [diff] [blame] | 165 | case PIPE_CAP_DEPTH_CLIP_DISABLE: |
José Fonseca | 85d7f67 | 2013-10-15 18:08:26 -0700 | [diff] [blame] | 166 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 167 | case PIPE_CAP_SHADER_STENCIL_EXPORT: |
Roland Scheidegger | 4fd42a7 | 2015-06-03 01:34:06 +0200 | [diff] [blame] | 168 | return 1; |
Marek Olšák | 95c7881 | 2011-03-05 16:06:10 +0100 | [diff] [blame] | 169 | case PIPE_CAP_TGSI_INSTANCEID: |
| 170 | case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: |
Roland Scheidegger | eee9f6a | 2014-08-25 22:05:16 +0200 | [diff] [blame] | 171 | case PIPE_CAP_START_INSTANCE: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 172 | return 1; |
| 173 | case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: |
| 174 | return 0; |
Marek Olšák | 4a7f013 | 2011-03-29 18:18:05 +0200 | [diff] [blame] | 175 | case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 176 | return 1; |
| 177 | case PIPE_CAP_SEAMLESS_CUBE_MAP: |
| 178 | case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: |
Roland Scheidegger | ac81b6f | 2013-10-18 20:54:01 +0200 | [diff] [blame] | 179 | return 1; |
Roland Scheidegger | 0b6554b | 2012-11-27 03:26:49 +0100 | [diff] [blame] | 180 | /* this is a lie could support arbitrary large offsets */ |
Ilia Mirkin | c2f9ad5 | 2014-04-09 14:58:53 -0400 | [diff] [blame] | 181 | case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 182 | case PIPE_CAP_MIN_TEXEL_OFFSET: |
Roland Scheidegger | 4898669 | 2015-03-31 17:23:17 +0200 | [diff] [blame] | 183 | return -32; |
Ilia Mirkin | c2f9ad5 | 2014-04-09 14:58:53 -0400 | [diff] [blame] | 184 | case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 185 | case PIPE_CAP_MAX_TEXEL_OFFSET: |
Roland Scheidegger | 4898669 | 2015-03-31 17:23:17 +0200 | [diff] [blame] | 186 | return 31; |
Dave Airlie | ab14915 | 2011-11-07 17:31:49 +0000 | [diff] [blame] | 187 | case PIPE_CAP_CONDITIONAL_RENDER: |
Brian Paul | dcb48e7 | 2010-12-08 19:06:22 -0700 | [diff] [blame] | 188 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 189 | case PIPE_CAP_TEXTURE_BARRIER: |
| 190 | return 0; |
| 191 | case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: |
| 192 | case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: |
Dave Airlie | 77b2656 | 2012-12-05 06:50:07 +1000 | [diff] [blame] | 193 | return 16*4; |
Grigori Goronzy | d34d5fd | 2014-02-09 22:56:20 +0100 | [diff] [blame] | 194 | case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES: |
| 195 | case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: |
| 196 | return 1024; |
Ilia Mirkin | 746e526 | 2014-06-26 20:01:50 -0400 | [diff] [blame] | 197 | case PIPE_CAP_MAX_VERTEX_STREAMS: |
| 198 | return 1; |
Timothy Arceri | 89e6806 | 2014-08-19 21:09:58 -1000 | [diff] [blame] | 199 | case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE: |
| 200 | return 2048; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 201 | case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: |
Dave Airlie | 9e41b0b | 2012-12-13 20:17:58 +1000 | [diff] [blame] | 202 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 203 | case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: |
| 204 | return 0; |
| 205 | case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: |
| 206 | case PIPE_CAP_VERTEX_COLOR_CLAMPED: |
James Benton | 66fdf62 | 2012-09-13 16:05:08 +0100 | [diff] [blame] | 207 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 208 | case PIPE_CAP_GLSL_FEATURE_LEVEL: |
José Fonseca | 7380ce9 | 2014-04-24 15:00:12 +0100 | [diff] [blame] | 209 | return 330; |
Christoph Bumiller | 8b4f7b0 | 2012-02-06 16:29:03 +0100 | [diff] [blame] | 210 | case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: |
| 211 | return 0; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 212 | case PIPE_CAP_COMPUTE: |
| 213 | return 0; |
Marek Olšák | 978c1aa1 | 2012-04-11 15:40:00 +0200 | [diff] [blame] | 214 | case PIPE_CAP_USER_VERTEX_BUFFERS: |
Marek Olšák | 437ab1d | 2012-04-24 15:19:31 +0200 | [diff] [blame] | 215 | case PIPE_CAP_USER_INDEX_BUFFERS: |
Marek Olšák | 978c1aa1 | 2012-04-11 15:40:00 +0200 | [diff] [blame] | 216 | return 1; |
Brian Paul | 2ee0b44 | 2012-12-10 12:35:23 -0700 | [diff] [blame] | 217 | case PIPE_CAP_USER_CONSTANT_BUFFERS: |
| 218 | return 0; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 219 | case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: |
| 220 | case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: |
| 221 | case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: |
Christoph Bumiller | 8acaf86 | 2013-03-15 22:11:31 +0100 | [diff] [blame] | 222 | case PIPE_CAP_TGSI_TEXCOORD: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 223 | return 0; |
Christoph Bumiller | bc198f8 | 2013-04-05 14:29:36 +0200 | [diff] [blame] | 224 | case PIPE_CAP_DRAW_INDIRECT: |
| 225 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 226 | |
Roland Scheidegger | 62fd871 | 2014-08-28 03:38:55 +0200 | [diff] [blame] | 227 | case PIPE_CAP_CUBE_MAP_ARRAY: |
| 228 | return 1; |
Marek Olšák | 1b749dc | 2012-04-24 17:31:17 +0200 | [diff] [blame] | 229 | case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: |
| 230 | return 16; |
Marek Olšák | b9c9dd4 | 2012-09-11 22:41:20 +0200 | [diff] [blame] | 231 | case PIPE_CAP_TEXTURE_MULTISAMPLE: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 232 | return 0; |
Siavash Eliasi | 809d3a7 | 2013-11-28 12:26:30 +0330 | [diff] [blame] | 233 | case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: |
| 234 | return 64; |
Roland Scheidegger | 2018317 | 2013-02-25 20:23:18 +0100 | [diff] [blame] | 235 | case PIPE_CAP_TEXTURE_BUFFER_OBJECTS: |
| 236 | return 1; |
Marek Olšák | 52cb395 | 2013-05-02 03:24:33 +0200 | [diff] [blame] | 237 | case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: |
| 238 | return 65536; |
Roland Scheidegger | 2018317 | 2013-02-25 20:23:18 +0100 | [diff] [blame] | 239 | case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: |
| 240 | return 1; |
Marek Olšák | 3e10ab6 | 2013-03-14 17:18:43 +0100 | [diff] [blame] | 241 | case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: |
| 242 | return 0; |
Zack Rusin | eaabb4e | 2013-05-24 16:08:39 -0400 | [diff] [blame] | 243 | case PIPE_CAP_MAX_VIEWPORTS: |
Zack Rusin | 97b8ae4 | 2013-05-24 16:28:19 -0400 | [diff] [blame] | 244 | return PIPE_MAX_VIEWPORTS; |
Tom Stellard | 4e90bc9 | 2013-07-09 21:21:39 -0700 | [diff] [blame] | 245 | case PIPE_CAP_ENDIANNESS: |
| 246 | return PIPE_ENDIAN_NATIVE; |
Ilia Mirkin | 32b7124 | 2014-07-03 11:15:18 -0400 | [diff] [blame] | 247 | case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT: |
Roland Scheidegger | 763fc52 | 2014-11-18 23:04:36 +0100 | [diff] [blame] | 248 | return 1; |
Jose Fonseca | 08efcc0 | 2015-02-05 14:33:06 +0000 | [diff] [blame] | 249 | case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: |
| 250 | return 1; |
Dave Airlie | 2fcbec4 | 2013-09-21 18:45:43 +1000 | [diff] [blame] | 251 | case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: |
Roland Scheidegger | 4898669 | 2015-03-31 17:23:17 +0200 | [diff] [blame] | 252 | return 4; |
Dave Airlie | 2fcbec4 | 2013-09-21 18:45:43 +1000 | [diff] [blame] | 253 | case PIPE_CAP_TEXTURE_GATHER_SM5: |
Dave Airlie | be5276a | 2014-02-11 13:26:08 +1000 | [diff] [blame] | 254 | case PIPE_CAP_TEXTURE_QUERY_LOD: |
Ilia Mirkin | 88d8d88 | 2014-03-30 18:21:04 -0400 | [diff] [blame] | 255 | case PIPE_CAP_SAMPLE_SHADING: |
Ilia Mirkin | d95df4f | 2014-04-26 23:44:57 -0400 | [diff] [blame] | 256 | case PIPE_CAP_TEXTURE_GATHER_OFFSETS: |
Marek Olšák | 65ef78e | 2014-11-17 22:30:31 +0100 | [diff] [blame] | 257 | return 0; |
Christoph Bumiller | 4b586a2 | 2014-05-17 01:20:19 +0200 | [diff] [blame] | 258 | case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION: |
Marek Olšák | 65ef78e | 2014-11-17 22:30:31 +0100 | [diff] [blame] | 259 | return 1; |
Ilia Mirkin | 8ee74ce | 2014-08-14 00:04:41 -0400 | [diff] [blame] | 260 | case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE: |
Marek Olšák | 1a02bb7 | 2013-11-21 15:25:55 +0100 | [diff] [blame] | 261 | return 0; |
Roland Scheidegger | e6c66f4 | 2015-05-13 22:16:44 +0200 | [diff] [blame] | 262 | case PIPE_CAP_SAMPLER_VIEW_TARGET: |
| 263 | return 1; |
Dave Airlie | 76ba50a | 2013-11-27 19:47:51 +1000 | [diff] [blame] | 264 | case PIPE_CAP_FAKE_SW_MSAA: |
Giovanni Campagna | e57ad3d | 2014-07-23 19:28:52 +0100 | [diff] [blame] | 265 | return 1; |
Tobias Klausmann | 544c541 | 2014-08-17 17:16:08 +0200 | [diff] [blame] | 266 | case PIPE_CAP_CONDITIONAL_RENDER_INVERTED: |
| 267 | return 1; |
Emil Velikov | 89f80c2 | 2014-08-14 21:15:06 +0100 | [diff] [blame] | 268 | |
| 269 | case PIPE_CAP_VENDOR_ID: |
| 270 | return 0xFFFFFFFF; |
| 271 | case PIPE_CAP_DEVICE_ID: |
| 272 | return 0xFFFFFFFF; |
| 273 | case PIPE_CAP_ACCELERATED: |
| 274 | return 0; |
| 275 | case PIPE_CAP_VIDEO_MEMORY: { |
| 276 | /* XXX: Do we want to return the full amount fo system memory ? */ |
| 277 | uint64_t system_memory; |
| 278 | |
| 279 | if (!os_get_total_physical_memory(&system_memory)) |
| 280 | return 0; |
| 281 | |
| 282 | return (int)(system_memory >> 20); |
| 283 | } |
| 284 | case PIPE_CAP_UMA: |
| 285 | return 0; |
Mathias Fröhlich | 5608813 | 2014-09-14 15:17:07 +0200 | [diff] [blame] | 286 | case PIPE_CAP_CLIP_HALFZ: |
| 287 | return 1; |
Roland Scheidegger | ade8b26 | 2014-12-12 04:13:43 +0100 | [diff] [blame] | 288 | case PIPE_CAP_VERTEXID_NOBASE: |
| 289 | return 0; |
Ilia Mirkin | 7c211a1 | 2015-02-01 09:01:50 -0500 | [diff] [blame] | 290 | case PIPE_CAP_POLYGON_OFFSET_CLAMP: |
Marek Olšák | 44dc1d3 | 2015-08-10 19:37:01 +0200 | [diff] [blame] | 291 | case PIPE_CAP_TEXTURE_FLOAT_LINEAR: |
| 292 | case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR: |
Ilia Mirkin | 7c211a1 | 2015-02-01 09:01:50 -0500 | [diff] [blame] | 293 | return 1; |
Tobias Klausmann | 96f390f | 2016-05-08 22:44:10 +0200 | [diff] [blame] | 294 | case PIPE_CAP_CULL_DISTANCE: |
| 295 | return 1; |
Brian Paul | e9b86bb | 2016-06-03 14:55:47 -0600 | [diff] [blame] | 296 | case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS: |
| 297 | return 1; |
Axel Davy | eb1c12d | 2015-01-17 14:30:17 +0100 | [diff] [blame] | 298 | case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: |
Marek Olšák | 8b587ee | 2015-02-10 14:00:57 +0100 | [diff] [blame] | 299 | case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: |
Marek Olšák | 79ffc08a | 2015-04-29 15:44:55 +0200 | [diff] [blame] | 300 | case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: |
Marek Olšák | 2622293 | 2015-06-12 14:24:17 +0200 | [diff] [blame] | 301 | case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: |
Marek Olšák | 3b7800e | 2015-08-10 02:11:48 +0200 | [diff] [blame] | 302 | case PIPE_CAP_DEPTH_BOUNDS_TEST: |
Ilia Mirkin | f46a53f | 2015-09-11 17:29:49 -0400 | [diff] [blame] | 303 | case PIPE_CAP_TGSI_TXQS: |
Marek Olšák | f3b37e3 | 2015-09-27 19:32:07 +0200 | [diff] [blame] | 304 | case PIPE_CAP_FORCE_PERSAMPLE_INTERP: |
Marek Olšák | d74e7b6 | 2015-09-27 21:02:15 +0200 | [diff] [blame] | 305 | case PIPE_CAP_SHAREABLE_SHADERS: |
Ilia Mirkin | 3695b25 | 2015-11-09 13:27:07 -0500 | [diff] [blame] | 306 | case PIPE_CAP_CLEAR_TEXTURE: |
Ilia Mirkin | 87b4e4e | 2015-12-29 16:49:32 -0500 | [diff] [blame] | 307 | case PIPE_CAP_DRAW_PARAMETERS: |
Ilia Mirkin | e9f43d6 | 2016-01-02 18:55:48 -0500 | [diff] [blame] | 308 | case PIPE_CAP_TGSI_PACK_HALF_FLOAT: |
Ilia Mirkin | d67b9ba | 2015-12-31 13:30:13 -0500 | [diff] [blame] | 309 | case PIPE_CAP_MULTI_DRAW_INDIRECT: |
| 310 | case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS: |
Marek Olšák | 34738a9 | 2016-01-02 20:45:00 +0100 | [diff] [blame] | 311 | case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: |
| 312 | case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: |
Ilia Mirkin | ebfb544 | 2016-01-02 21:56:45 -0500 | [diff] [blame] | 313 | case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: |
Nicolai Hähnle | 654670b | 2016-01-11 17:38:08 -0500 | [diff] [blame] | 314 | case PIPE_CAP_INVALIDATE_BUFFER: |
Charmaine Lee | 3038e89 | 2016-01-14 10:22:17 -0700 | [diff] [blame] | 315 | case PIPE_CAP_GENERATE_MIPMAP: |
Rob Clark | d640837 | 2015-08-10 11:41:29 -0400 | [diff] [blame] | 316 | case PIPE_CAP_STRING_MARKER: |
Nicolai Hähnle | 3abb548 | 2016-01-26 10:26:30 -0500 | [diff] [blame] | 317 | case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY: |
Nicolai Hähnle | 6af6d7b | 2016-01-26 10:27:58 -0500 | [diff] [blame] | 318 | case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS: |
Ilia Mirkin | f9e6f46 | 2016-01-09 23:30:16 -0500 | [diff] [blame] | 319 | case PIPE_CAP_QUERY_BUFFER_OBJECT: |
Marek Olšák | d2e4c9e | 2016-02-01 21:56:50 +0100 | [diff] [blame] | 320 | case PIPE_CAP_QUERY_MEMORY_INFO: |
Marek Olšák | dcb2b77 | 2016-02-29 20:22:37 +0100 | [diff] [blame] | 321 | case PIPE_CAP_PCI_GROUP: |
| 322 | case PIPE_CAP_PCI_BUS: |
| 323 | case PIPE_CAP_PCI_DEVICE: |
| 324 | case PIPE_CAP_PCI_FUNCTION: |
Edward O'Callaghan | 4bc9130 | 2016-02-17 20:59:52 +1100 | [diff] [blame] | 325 | case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT: |
Bas Nieuwenhuizen | 70dcd84 | 2016-04-12 15:00:31 +0200 | [diff] [blame] | 326 | case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: |
Kenneth Graunke | 70048eb | 2016-05-20 21:05:34 -0700 | [diff] [blame] | 327 | case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES: |
Ilia Mirkin | edfa7a4 | 2016-05-29 11:39:52 -0400 | [diff] [blame] | 328 | case PIPE_CAP_TGSI_VOTE: |
Ilia Mirkin | 07fcb06 | 2016-06-11 15:26:45 -0400 | [diff] [blame^] | 329 | case PIPE_CAP_MAX_WINDOW_RECTANGLES: |
Axel Davy | eb1c12d | 2015-01-17 14:30:17 +0100 | [diff] [blame] | 330 | return 0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 331 | } |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 332 | /* should only get here on unhandled cases */ |
| 333 | debug_printf("Unexpected PIPE_CAP %d query\n", param); |
| 334 | return 0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 335 | } |
| 336 | |
Luca Barbieri | a508d2d | 2010-09-05 20:50:50 +0200 | [diff] [blame] | 337 | static int |
| 338 | llvmpipe_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_shader_cap param) |
| 339 | { |
| 340 | switch(shader) |
| 341 | { |
| 342 | case PIPE_SHADER_FRAGMENT: |
Dave Airlie | 2d80cad | 2012-01-11 19:48:00 +0000 | [diff] [blame] | 343 | switch (param) { |
Dave Airlie | 2d80cad | 2012-01-11 19:48:00 +0000 | [diff] [blame] | 344 | default: |
José Fonseca | 6dddd18 | 2012-07-12 20:47:20 +0100 | [diff] [blame] | 345 | return gallivm_get_shader_param(param); |
Dave Airlie | 2d80cad | 2012-01-11 19:48:00 +0000 | [diff] [blame] | 346 | } |
Luca Barbieri | a508d2d | 2010-09-05 20:50:50 +0200 | [diff] [blame] | 347 | case PIPE_SHADER_VERTEX: |
| 348 | case PIPE_SHADER_GEOMETRY: |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 349 | switch (param) { |
| 350 | case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: |
| 351 | /* At this time, the draw module and llvmpipe driver only |
| 352 | * support vertex shader texture lookups when LLVM is enabled in |
| 353 | * the draw module. |
| 354 | */ |
| 355 | if (debug_get_bool_option("DRAW_USE_LLVM", TRUE)) |
Brian Paul | cab2fed | 2012-08-09 20:59:44 -0600 | [diff] [blame] | 356 | return PIPE_MAX_SAMPLERS; |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 357 | else |
| 358 | return 0; |
Roland Scheidegger | 2983c03 | 2013-11-26 02:30:41 +0100 | [diff] [blame] | 359 | case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: |
| 360 | if (debug_get_bool_option("DRAW_USE_LLVM", TRUE)) |
| 361 | return PIPE_MAX_SHADER_SAMPLER_VIEWS; |
| 362 | else |
| 363 | return 0; |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 364 | default: |
| 365 | return draw_get_shader_param(shader, param); |
| 366 | } |
Luca Barbieri | a508d2d | 2010-09-05 20:50:50 +0200 | [diff] [blame] | 367 | default: |
| 368 | return 0; |
| 369 | } |
| 370 | } |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 371 | |
| 372 | static float |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 373 | llvmpipe_get_paramf(struct pipe_screen *screen, enum pipe_capf param) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 374 | { |
| 375 | switch (param) { |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 376 | case PIPE_CAPF_MAX_LINE_WIDTH: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 377 | /* fall-through */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 378 | case PIPE_CAPF_MAX_LINE_WIDTH_AA: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 379 | return 255.0; /* arbitrary */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 380 | case PIPE_CAPF_MAX_POINT_WIDTH: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 381 | /* fall-through */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 382 | case PIPE_CAPF_MAX_POINT_WIDTH_AA: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 383 | return 255.0; /* arbitrary */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 384 | case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 385 | return 16.0; /* not actually signficant at this time */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 386 | case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 387 | return 16.0; /* arbitrary */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 388 | case PIPE_CAPF_GUARD_BAND_LEFT: |
| 389 | case PIPE_CAPF_GUARD_BAND_TOP: |
| 390 | case PIPE_CAPF_GUARD_BAND_RIGHT: |
| 391 | case PIPE_CAPF_GUARD_BAND_BOTTOM: |
José Fonseca | cf9baf6 | 2010-05-12 17:25:17 +0100 | [diff] [blame] | 392 | return 0.0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 393 | } |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 394 | /* should only get here on unhandled cases */ |
| 395 | debug_printf("Unexpected PIPE_CAP %d query\n", param); |
| 396 | return 0.0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | |
| 400 | /** |
| 401 | * Query format support for creating a texture, drawing surface, etc. |
| 402 | * \param format the format to test |
| 403 | * \param type one of PIPE_TEXTURE, PIPE_SURFACE |
| 404 | */ |
| 405 | static boolean |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 406 | llvmpipe_is_format_supported( struct pipe_screen *_screen, |
Roland Scheidegger | e121a73 | 2010-05-17 21:23:31 +0200 | [diff] [blame] | 407 | enum pipe_format format, |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 408 | enum pipe_texture_target target, |
Roland Scheidegger | e121a73 | 2010-05-17 21:23:31 +0200 | [diff] [blame] | 409 | unsigned sample_count, |
Marek Olšák | e968975 | 2011-03-08 00:01:58 +0100 | [diff] [blame] | 410 | unsigned bind) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 411 | { |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 412 | struct llvmpipe_screen *screen = llvmpipe_screen(_screen); |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 413 | struct sw_winsys *winsys = screen->winsys; |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 414 | const struct util_format_description *format_desc; |
| 415 | |
| 416 | format_desc = util_format_description(format); |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 417 | if (!format_desc) |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 418 | return FALSE; |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 419 | |
Brian Paul | e6d8b40 | 2010-05-28 13:31:23 -0600 | [diff] [blame] | 420 | assert(target == PIPE_BUFFER || |
| 421 | target == PIPE_TEXTURE_1D || |
Roland Scheidegger | 6d50148 | 2012-11-29 04:08:32 +0100 | [diff] [blame] | 422 | target == PIPE_TEXTURE_1D_ARRAY || |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 423 | target == PIPE_TEXTURE_2D || |
Roland Scheidegger | 6d50148 | 2012-11-29 04:08:32 +0100 | [diff] [blame] | 424 | target == PIPE_TEXTURE_2D_ARRAY || |
Luca Barbieri | ae0ef6f | 2010-08-18 17:28:08 +0200 | [diff] [blame] | 425 | target == PIPE_TEXTURE_RECT || |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 426 | target == PIPE_TEXTURE_3D || |
Roland Scheidegger | ea05cfa | 2014-08-01 23:50:35 +0200 | [diff] [blame] | 427 | target == PIPE_TEXTURE_CUBE || |
| 428 | target == PIPE_TEXTURE_CUBE_ARRAY); |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 429 | |
Roland Scheidegger | e121a73 | 2010-05-17 21:23:31 +0200 | [diff] [blame] | 430 | if (sample_count > 1) |
| 431 | return FALSE; |
| 432 | |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 433 | if (bind & PIPE_BIND_RENDER_TARGET) { |
Roland Scheidegger | dc1cc92 | 2013-07-16 01:52:29 +0200 | [diff] [blame] | 434 | if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) { |
Roland Scheidegger | 9477d8c | 2014-03-20 16:43:36 +0100 | [diff] [blame] | 435 | /* this is a lie actually other formats COULD exist where we would fail */ |
Roland Scheidegger | dc1cc92 | 2013-07-16 01:52:29 +0200 | [diff] [blame] | 436 | if (format_desc->nr_channels < 3) |
| 437 | return FALSE; |
| 438 | } |
| 439 | else if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB) |
José Fonseca | fe130a7 | 2010-04-06 22:49:57 +0100 | [diff] [blame] | 440 | return FALSE; |
| 441 | |
Roland Scheidegger | b101a09 | 2013-03-22 20:09:18 +0100 | [diff] [blame] | 442 | if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN && |
| 443 | format != PIPE_FORMAT_R11G11B10_FLOAT) |
José Fonseca | fe130a7 | 2010-04-06 22:49:57 +0100 | [diff] [blame] | 444 | return FALSE; |
Roland Scheidegger | dc1cc92 | 2013-07-16 01:52:29 +0200 | [diff] [blame] | 445 | |
José Fonseca | 6916387 | 2012-11-28 19:25:05 +0000 | [diff] [blame] | 446 | assert(format_desc->block.width == 1); |
| 447 | assert(format_desc->block.height == 1); |
José Fonseca | fe130a7 | 2010-04-06 22:49:57 +0100 | [diff] [blame] | 448 | |
José Fonseca | 6916387 | 2012-11-28 19:25:05 +0000 | [diff] [blame] | 449 | if (format_desc->is_mixed) |
| 450 | return FALSE; |
| 451 | |
Roland Scheidegger | b101a09 | 2013-03-22 20:09:18 +0100 | [diff] [blame] | 452 | if (!format_desc->is_array && !format_desc->is_bitmask && |
| 453 | format != PIPE_FORMAT_R11G11B10_FLOAT) |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 454 | return FALSE; |
Brian Paul | 2db747c | 2016-06-03 15:06:28 -0600 | [diff] [blame] | 455 | } |
Roland Scheidegger | d03d9b6 | 2013-01-12 17:28:40 -0800 | [diff] [blame] | 456 | |
Brian Paul | 2db747c | 2016-06-03 15:06:28 -0600 | [diff] [blame] | 457 | if ((bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) && |
| 458 | ((bind & PIPE_BIND_DISPLAY_TARGET) == 0)) { |
| 459 | /* Disable all 3-channel formats, where channel size != 32 bits. |
| 460 | * In some cases we run into crashes (in generate_unswizzled_blend()), |
| 461 | * for 3-channel RGB16 variants, there was an apparent LLVM bug. |
| 462 | * In any case, disabling the shallower 3-channel formats avoids a |
| 463 | * number of issues with GL_ARB_copy_image support. |
Roland Scheidegger | d03d9b6 | 2013-01-12 17:28:40 -0800 | [diff] [blame] | 464 | */ |
Brian Paul | 2db747c | 2016-06-03 15:06:28 -0600 | [diff] [blame] | 465 | if (format_desc->is_array && |
| 466 | format_desc->nr_channels == 3 && |
| 467 | format_desc->block.bits != 96) { |
| 468 | return FALSE; |
Roland Scheidegger | d03d9b6 | 2013-01-12 17:28:40 -0800 | [diff] [blame] | 469 | } |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 470 | } |
| 471 | |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 472 | if (bind & PIPE_BIND_DISPLAY_TARGET) { |
| 473 | if(!winsys->is_displaytarget_format_supported(winsys, bind, format)) |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 474 | return FALSE; |
| 475 | } |
| 476 | |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 477 | if (bind & PIPE_BIND_DEPTH_STENCIL) { |
| 478 | if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) |
| 479 | return FALSE; |
| 480 | |
| 481 | if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 482 | return FALSE; |
| 483 | |
José Fonseca | 42f762d | 2013-01-29 13:27:44 +0000 | [diff] [blame] | 484 | /* TODO: Support stencil-only formats */ |
Marek Olšák | fb523cb | 2016-04-16 14:05:47 +0200 | [diff] [blame] | 485 | if (format_desc->swizzle[0] == PIPE_SWIZZLE_NONE) { |
José Fonseca | 42f762d | 2013-01-29 13:27:44 +0000 | [diff] [blame] | 486 | return FALSE; |
| 487 | } |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 488 | } |
| 489 | |
Roland Scheidegger | 6c6a439 | 2015-11-24 18:25:06 +0100 | [diff] [blame] | 490 | if (format_desc->layout == UTIL_FORMAT_LAYOUT_BPTC || |
| 491 | format_desc->layout == UTIL_FORMAT_LAYOUT_ASTC) { |
Ilia Mirkin | 19563f0 | 2014-07-22 21:08:14 -0400 | [diff] [blame] | 492 | /* Software decoding is not hooked up. */ |
| 493 | return FALSE; |
| 494 | } |
| 495 | |
Ilia Mirkin | 845b9e4 | 2015-02-18 22:23:12 -0500 | [diff] [blame] | 496 | if (format_desc->layout == UTIL_FORMAT_LAYOUT_ETC && |
| 497 | format != PIPE_FORMAT_ETC1_RGB8) |
| 498 | return FALSE; |
| 499 | |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 500 | if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { |
José Fonseca | 510669c | 2010-04-22 15:12:30 +0100 | [diff] [blame] | 501 | return util_format_s3tc_enabled; |
José Fonseca | 510669c | 2010-04-22 15:12:30 +0100 | [diff] [blame] | 502 | } |
| 503 | |
José Fonseca | a1b737d | 2011-11-01 12:28:47 +0000 | [diff] [blame] | 504 | /* |
Roland Scheidegger | d03d9b6 | 2013-01-12 17:28:40 -0800 | [diff] [blame] | 505 | * Everything can be supported by u_format |
| 506 | * (those without fetch_rgba_float might be not but shouldn't hit that) |
José Fonseca | a1b737d | 2011-11-01 12:28:47 +0000 | [diff] [blame] | 507 | */ |
| 508 | |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 509 | return TRUE; |
| 510 | } |
| 511 | |
| 512 | |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 513 | |
| 514 | |
| 515 | static void |
| 516 | llvmpipe_flush_frontbuffer(struct pipe_screen *_screen, |
Roland Scheidegger | 4c70014 | 2010-12-02 04:33:43 +0100 | [diff] [blame] | 517 | struct pipe_resource *resource, |
| 518 | unsigned level, unsigned layer, |
Dave Airlie | ba00f2f | 2013-11-28 11:08:11 +1000 | [diff] [blame] | 519 | void *context_private, |
| 520 | struct pipe_box *sub_box) |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 521 | { |
| 522 | struct llvmpipe_screen *screen = llvmpipe_screen(_screen); |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 523 | struct sw_winsys *winsys = screen->winsys; |
Roland Scheidegger | 4c70014 | 2010-12-02 04:33:43 +0100 | [diff] [blame] | 524 | struct llvmpipe_resource *texture = llvmpipe_resource(resource); |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 525 | |
| 526 | assert(texture->dt); |
| 527 | if (texture->dt) |
Dave Airlie | ba00f2f | 2013-11-28 11:08:11 +1000 | [diff] [blame] | 528 | winsys->displaytarget_display(winsys, texture->dt, context_private, sub_box); |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 529 | } |
| 530 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 531 | static void |
José Fonseca | 2d6b39f | 2009-08-09 23:10:19 +0100 | [diff] [blame] | 532 | llvmpipe_destroy_screen( struct pipe_screen *_screen ) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 533 | { |
José Fonseca | 2d6b39f | 2009-08-09 23:10:19 +0100 | [diff] [blame] | 534 | struct llvmpipe_screen *screen = llvmpipe_screen(_screen); |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 535 | struct sw_winsys *winsys = screen->winsys; |
José Fonseca | 2d6b39f | 2009-08-09 23:10:19 +0100 | [diff] [blame] | 536 | |
Roland Scheidegger | edac740 | 2010-07-13 19:58:58 +0200 | [diff] [blame] | 537 | if (screen->rast) |
| 538 | lp_rast_destroy(screen->rast); |
| 539 | |
José Fonseca | 08dd41f | 2009-08-23 05:52:20 +0100 | [diff] [blame] | 540 | lp_jit_screen_cleanup(screen); |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 541 | |
| 542 | if(winsys->destroy) |
| 543 | winsys->destroy(winsys); |
| 544 | |
Roland Scheidegger | edac740 | 2010-07-13 19:58:58 +0200 | [diff] [blame] | 545 | pipe_mutex_destroy(screen->rast_mutex); |
| 546 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 547 | FREE(screen); |
| 548 | } |
| 549 | |
| 550 | |
| 551 | |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 552 | |
| 553 | /** |
| 554 | * Fence reference counting. |
| 555 | */ |
| 556 | static void |
| 557 | llvmpipe_fence_reference(struct pipe_screen *screen, |
| 558 | struct pipe_fence_handle **ptr, |
| 559 | struct pipe_fence_handle *fence) |
| 560 | { |
| 561 | struct lp_fence **old = (struct lp_fence **) ptr; |
| 562 | struct lp_fence *f = (struct lp_fence *) fence; |
| 563 | |
| 564 | lp_fence_reference(old, f); |
| 565 | } |
| 566 | |
| 567 | |
| 568 | /** |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 569 | * Wait for the fence to finish. |
| 570 | */ |
Marek Olšák | bfe88e6 | 2011-03-07 22:57:54 +0100 | [diff] [blame] | 571 | static boolean |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 572 | llvmpipe_fence_finish(struct pipe_screen *screen, |
| 573 | struct pipe_fence_handle *fence_handle, |
Marek Olšák | b39bccb | 2011-03-05 21:23:54 +0100 | [diff] [blame] | 574 | uint64_t timeout) |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 575 | { |
| 576 | struct lp_fence *f = (struct lp_fence *) fence_handle; |
| 577 | |
Marek Olšák | 3da1c79 | 2015-06-26 13:13:16 +0200 | [diff] [blame] | 578 | if (!timeout) |
| 579 | return lp_fence_signalled(f); |
| 580 | |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 581 | lp_fence_wait(f); |
Marek Olšák | bfe88e6 | 2011-03-07 22:57:54 +0100 | [diff] [blame] | 582 | return TRUE; |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 583 | } |
| 584 | |
James Benton | 16f0d70 | 2012-12-03 07:00:37 +0000 | [diff] [blame] | 585 | static uint64_t |
| 586 | llvmpipe_get_timestamp(struct pipe_screen *_screen) |
| 587 | { |
| 588 | return os_time_get_nano(); |
| 589 | } |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 590 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 591 | /** |
| 592 | * Create a new pipe_screen object |
| 593 | * Note: we're not presently subclassing pipe_screen (no llvmpipe_screen). |
| 594 | */ |
| 595 | struct pipe_screen * |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 596 | llvmpipe_create_screen(struct sw_winsys *winsys) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 597 | { |
Török Edwin | 4d52a25 | 2010-05-06 22:19:57 +0100 | [diff] [blame] | 598 | struct llvmpipe_screen *screen; |
| 599 | |
Török Edwin | 4d52a25 | 2010-05-06 22:19:57 +0100 | [diff] [blame] | 600 | util_cpu_detect(); |
Adam Jackson | ca70de9 | 2013-04-04 17:16:22 -0400 | [diff] [blame] | 601 | |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 602 | #ifdef DEBUG |
| 603 | LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 ); |
| 604 | #endif |
| 605 | |
Keith Whitwell | 5f00819 | 2010-09-16 10:45:52 +0100 | [diff] [blame] | 606 | LP_PERF = debug_get_flags_option("LP_PERF", lp_perf_flags, 0 ); |
| 607 | |
José Fonseca | c88f3e0 | 2011-11-09 19:29:37 +0000 | [diff] [blame] | 608 | screen = CALLOC_STRUCT(llvmpipe_screen); |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 609 | if (!screen) |
| 610 | return NULL; |
| 611 | |
Brian Paul | 6b65847 | 2014-09-29 16:08:55 -0600 | [diff] [blame] | 612 | if (!lp_jit_screen_init(screen)) { |
| 613 | FREE(screen); |
| 614 | return NULL; |
| 615 | } |
| 616 | |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 617 | screen->winsys = winsys; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 618 | |
| 619 | screen->base.destroy = llvmpipe_destroy_screen; |
| 620 | |
| 621 | screen->base.get_name = llvmpipe_get_name; |
| 622 | screen->base.get_vendor = llvmpipe_get_vendor; |
Giuseppe Bilotta | 76039b3 | 2015-03-22 07:21:01 +0100 | [diff] [blame] | 623 | screen->base.get_device_vendor = llvmpipe_get_vendor; // TODO should be the CPU vendor |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 624 | screen->base.get_param = llvmpipe_get_param; |
Luca Barbieri | a508d2d | 2010-09-05 20:50:50 +0200 | [diff] [blame] | 625 | screen->base.get_shader_param = llvmpipe_get_shader_param; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 626 | screen->base.get_paramf = llvmpipe_get_paramf; |
| 627 | screen->base.is_format_supported = llvmpipe_is_format_supported; |
| 628 | |
Keith Whitwell | 7f41f54 | 2010-02-08 12:55:59 +0000 | [diff] [blame] | 629 | screen->base.context_create = llvmpipe_create_context; |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 630 | screen->base.flush_frontbuffer = llvmpipe_flush_frontbuffer; |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 631 | screen->base.fence_reference = llvmpipe_fence_reference; |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 632 | screen->base.fence_finish = llvmpipe_fence_finish; |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 633 | |
James Benton | 16f0d70 | 2012-12-03 07:00:37 +0000 | [diff] [blame] | 634 | screen->base.get_timestamp = llvmpipe_get_timestamp; |
| 635 | |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 636 | llvmpipe_init_screen_resource_funcs(&screen->base); |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 637 | |
José Fonseca | 65822eb | 2010-09-16 20:27:13 +0100 | [diff] [blame] | 638 | screen->num_threads = util_cpu_caps.nr_cpus > 1 ? util_cpu_caps.nr_cpus : 0; |
José Fonseca | 4175010 | 2011-06-17 14:48:28 +0100 | [diff] [blame] | 639 | #ifdef PIPE_SUBSYSTEM_EMBEDDED |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 640 | screen->num_threads = 0; |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 641 | #endif |
| 642 | screen->num_threads = debug_get_num_option("LP_NUM_THREADS", screen->num_threads); |
| 643 | screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS); |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 644 | |
Roland Scheidegger | edac740 | 2010-07-13 19:58:58 +0200 | [diff] [blame] | 645 | screen->rast = lp_rast_create(screen->num_threads); |
| 646 | if (!screen->rast) { |
| 647 | lp_jit_screen_cleanup(screen); |
| 648 | FREE(screen); |
| 649 | return NULL; |
| 650 | } |
| 651 | pipe_mutex_init(screen->rast_mutex); |
| 652 | |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 653 | util_format_s3tc_init(); |
| 654 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 655 | return &screen->base; |
| 656 | } |