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 | |
James Benton | 16f0d70 | 2012-12-03 07:00:37 +0000 | [diff] [blame] | 40 | #include "os/os_time.h" |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 41 | #include "lp_texture.h" |
Brian Paul | 2876b68 | 2009-12-11 17:32:45 -0700 | [diff] [blame] | 42 | #include "lp_fence.h" |
José Fonseca | 08dd41f | 2009-08-23 05:52:20 +0100 | [diff] [blame] | 43 | #include "lp_jit.h" |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 44 | #include "lp_screen.h" |
Keith Whitwell | 7f41f54 | 2010-02-08 12:55:59 +0000 | [diff] [blame] | 45 | #include "lp_context.h" |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 46 | #include "lp_debug.h" |
Keith Whitwell | 3c57c01 | 2010-03-09 15:25:42 +0000 | [diff] [blame] | 47 | #include "lp_public.h" |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 48 | #include "lp_limits.h" |
Roland Scheidegger | edac740 | 2010-07-13 19:58:58 +0200 | [diff] [blame] | 49 | #include "lp_rast.h" |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 50 | |
Keith Whitwell | 23e951d | 2010-03-04 16:23:05 +0000 | [diff] [blame] | 51 | #include "state_tracker/sw_winsys.h" |
| 52 | |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 53 | #ifdef DEBUG |
| 54 | int LP_DEBUG = 0; |
| 55 | |
| 56 | static const struct debug_named_value lp_debug_flags[] = { |
Joakim Sindholt | 8413b92 | 2010-06-01 20:11:30 +0200 | [diff] [blame] | 57 | { "pipe", DEBUG_PIPE, NULL }, |
| 58 | { "tgsi", DEBUG_TGSI, NULL }, |
| 59 | { "tex", DEBUG_TEX, NULL }, |
| 60 | { "setup", DEBUG_SETUP, NULL }, |
| 61 | { "rast", DEBUG_RAST, NULL }, |
| 62 | { "query", DEBUG_QUERY, NULL }, |
| 63 | { "screen", DEBUG_SCREEN, NULL }, |
Joakim Sindholt | 8413b92 | 2010-06-01 20:11:30 +0200 | [diff] [blame] | 64 | { "counters", DEBUG_COUNTERS, NULL }, |
Keith Whitwell | b6e03ea | 2010-08-20 15:14:19 +0100 | [diff] [blame] | 65 | { "scene", DEBUG_SCENE, NULL }, |
| 66 | { "fence", DEBUG_FENCE, NULL }, |
Keith Whitwell | bc759cd | 2010-09-08 18:37:45 +0100 | [diff] [blame] | 67 | { "mem", DEBUG_MEM, NULL }, |
Keith Whitwell | 0986355 | 2010-09-16 15:16:27 +0100 | [diff] [blame] | 68 | { "fs", DEBUG_FS, NULL }, |
Joakim Sindholt | 8413b92 | 2010-06-01 20:11:30 +0200 | [diff] [blame] | 69 | DEBUG_NAMED_VALUE_END |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 70 | }; |
| 71 | #endif |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 72 | |
Keith Whitwell | 5f00819 | 2010-09-16 10:45:52 +0100 | [diff] [blame] | 73 | int LP_PERF = 0; |
| 74 | static const struct debug_named_value lp_perf_flags[] = { |
| 75 | { "texmem", PERF_TEX_MEM, NULL }, |
| 76 | { "no_mipmap", PERF_NO_MIPMAPS, NULL }, |
| 77 | { "no_linear", PERF_NO_LINEAR, NULL }, |
| 78 | { "no_mip_linear", PERF_NO_MIP_LINEAR, NULL }, |
| 79 | { "no_tex", PERF_NO_TEX, NULL }, |
| 80 | { "no_blend", PERF_NO_BLEND, NULL }, |
| 81 | { "no_depth", PERF_NO_DEPTH, NULL }, |
| 82 | { "no_alphatest", PERF_NO_ALPHATEST, NULL }, |
| 83 | DEBUG_NAMED_VALUE_END |
| 84 | }; |
| 85 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 86 | |
| 87 | static const char * |
| 88 | llvmpipe_get_vendor(struct pipe_screen *screen) |
| 89 | { |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 90 | return "VMware, Inc."; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | |
| 94 | static const char * |
| 95 | llvmpipe_get_name(struct pipe_screen *screen) |
| 96 | { |
Brian Paul | b38c26f | 2011-07-19 08:42:46 -0600 | [diff] [blame] | 97 | static char buf[100]; |
José Fonseca | edc0a00 | 2012-09-06 10:29:04 +0100 | [diff] [blame] | 98 | util_snprintf(buf, sizeof(buf), "llvmpipe (LLVM %u.%u, %u bits)", |
| 99 | HAVE_LLVM >> 8, HAVE_LLVM & 0xff, |
| 100 | lp_native_vector_width ); |
Brian Paul | b38c26f | 2011-07-19 08:42:46 -0600 | [diff] [blame] | 101 | return buf; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | |
| 105 | static int |
José Fonseca | e1238b5 | 2010-05-11 11:11:03 +0100 | [diff] [blame] | 106 | llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 107 | { |
| 108 | switch (param) { |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 109 | case PIPE_CAP_NPOT_TEXTURES: |
Ilia Mirkin | 12d39b4 | 2013-10-04 04:32:15 -0400 | [diff] [blame] | 110 | case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 111 | return 1; |
| 112 | case PIPE_CAP_TWO_SIDED_STENCIL: |
| 113 | return 1; |
Jakob Bornecrantz | c4e89d1 | 2010-04-29 16:18:43 +0100 | [diff] [blame] | 114 | case PIPE_CAP_SM3: |
| 115 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 116 | case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: |
Roland Scheidegger | 8b8bca0 | 2013-02-12 03:41:48 +0100 | [diff] [blame] | 117 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 118 | case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: |
Dave Airlie | 77b2656 | 2012-12-05 06:50:07 +1000 | [diff] [blame] | 119 | return PIPE_MAX_SO_BUFFERS; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 120 | case PIPE_CAP_ANISOTROPIC_FILTER: |
| 121 | return 0; |
| 122 | case PIPE_CAP_POINT_SPRITE: |
| 123 | return 1; |
| 124 | case PIPE_CAP_MAX_RENDER_TARGETS: |
| 125 | return PIPE_MAX_COLOR_BUFS; |
| 126 | case PIPE_CAP_OCCLUSION_QUERY: |
| 127 | return 1; |
José Fonseca | 9976216 | 2012-12-09 09:50:34 +0000 | [diff] [blame] | 128 | case PIPE_CAP_QUERY_TIME_ELAPSED: |
José Fonseca | ab2f573 | 2012-12-09 10:15:19 +0000 | [diff] [blame] | 129 | return 0; |
James Benton | 16f0d70 | 2012-12-03 07:00:37 +0000 | [diff] [blame] | 130 | case PIPE_CAP_QUERY_TIMESTAMP: |
| 131 | return 1; |
Christoph Bumiller | f35e96d | 2013-03-29 13:02:49 +0100 | [diff] [blame] | 132 | case PIPE_CAP_QUERY_PIPELINE_STATISTICS: |
| 133 | return 0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 134 | case PIPE_CAP_TEXTURE_MIRROR_CLAMP: |
| 135 | return 1; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 136 | case PIPE_CAP_TEXTURE_SHADOW_MAP: |
| 137 | return 1; |
José Fonseca | 9881b5c | 2010-06-05 14:48:39 +0100 | [diff] [blame] | 138 | case PIPE_CAP_TEXTURE_SWIZZLE: |
| 139 | return 1; |
Christoph Bumiller | 729abfd | 2013-04-12 13:42:01 +0200 | [diff] [blame] | 140 | case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: |
| 141 | return 0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 142 | case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: |
Brian Paul | d73fadf | 2010-03-08 13:36:34 -0700 | [diff] [blame] | 143 | return LP_MAX_TEXTURE_2D_LEVELS; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 144 | case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: |
Brian Paul | d73fadf | 2010-03-08 13:36:34 -0700 | [diff] [blame] | 145 | return LP_MAX_TEXTURE_3D_LEVELS; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 146 | case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: |
Brian Paul | df73be9 | 2012-09-16 19:05:51 -0600 | [diff] [blame] | 147 | return LP_MAX_TEXTURE_CUBE_LEVELS; |
Roland Scheidegger | 6d50148 | 2012-11-29 04:08:32 +0100 | [diff] [blame] | 148 | case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: |
| 149 | return LP_MAX_TEXTURE_ARRAY_LAYERS; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 150 | case PIPE_CAP_BLEND_EQUATION_SEPARATE: |
| 151 | return 1; |
Roland Scheidegger | 1a9d01d | 2010-01-26 17:32:57 +0100 | [diff] [blame] | 152 | case PIPE_CAP_INDEP_BLEND_ENABLE: |
Brian Paul | 7b937cf | 2010-05-10 17:03:10 -0600 | [diff] [blame] | 153 | return 1; |
Roland Scheidegger | 1a9d01d | 2010-01-26 17:32:57 +0100 | [diff] [blame] | 154 | case PIPE_CAP_INDEP_BLEND_FUNC: |
Brian Paul | 96a2e89 | 2011-01-17 16:42:43 -0700 | [diff] [blame] | 155 | return 1; |
Luca Barbieri | 6c403750 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 156 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: |
| 157 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: |
José Fonseca | a930136 | 2013-04-18 11:39:19 +0100 | [diff] [blame] | 158 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: |
Luca Barbieri | 6c403750 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 159 | return 1; |
| 160 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: |
Luca Barbieri | 6c403750 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 161 | return 0; |
Brian Paul | 6692ed6 | 2010-10-21 19:03:38 -0600 | [diff] [blame] | 162 | case PIPE_CAP_PRIMITIVE_RESTART: |
| 163 | return 1; |
Marek Olšák | dc4c821 | 2012-01-10 00:19:00 +0100 | [diff] [blame] | 164 | case PIPE_CAP_DEPTH_CLIP_DISABLE: |
José Fonseca | 85d7f67 | 2013-10-15 18:08:26 -0700 | [diff] [blame] | 165 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 166 | case PIPE_CAP_SHADER_STENCIL_EXPORT: |
| 167 | return 0; |
Marek Olšák | 95c7881 | 2011-03-05 16:06:10 +0100 | [diff] [blame] | 168 | case PIPE_CAP_TGSI_INSTANCEID: |
| 169 | case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 170 | return 1; |
| 171 | case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: |
| 172 | return 0; |
Marek Olšák | 4a7f013 | 2011-03-29 18:18:05 +0200 | [diff] [blame] | 173 | case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 174 | return 1; |
| 175 | case PIPE_CAP_SEAMLESS_CUBE_MAP: |
| 176 | case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: |
Roland Scheidegger | ac81b6f | 2013-10-18 20:54:01 +0200 | [diff] [blame] | 177 | return 1; |
Roland Scheidegger | 0b6554b | 2012-11-27 03:26:49 +0100 | [diff] [blame] | 178 | /* this is a lie could support arbitrary large offsets */ |
Ilia Mirkin | c2f9ad5 | 2014-04-09 14:58:53 -0400 | [diff] [blame] | 179 | case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 180 | case PIPE_CAP_MIN_TEXEL_OFFSET: |
Roland Scheidegger | 0b6554b | 2012-11-27 03:26:49 +0100 | [diff] [blame] | 181 | return -8; |
Ilia Mirkin | c2f9ad5 | 2014-04-09 14:58:53 -0400 | [diff] [blame] | 182 | case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 183 | case PIPE_CAP_MAX_TEXEL_OFFSET: |
Roland Scheidegger | 0b6554b | 2012-11-27 03:26:49 +0100 | [diff] [blame] | 184 | return 7; |
Dave Airlie | ab14915 | 2011-11-07 17:31:49 +0000 | [diff] [blame] | 185 | case PIPE_CAP_CONDITIONAL_RENDER: |
Brian Paul | dcb48e7 | 2010-12-08 19:06:22 -0700 | [diff] [blame] | 186 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 187 | case PIPE_CAP_TEXTURE_BARRIER: |
| 188 | return 0; |
| 189 | case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: |
| 190 | case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: |
Dave Airlie | 77b2656 | 2012-12-05 06:50:07 +1000 | [diff] [blame] | 191 | return 16*4; |
Grigori Goronzy | d34d5fd | 2014-02-09 22:56:20 +0100 | [diff] [blame] | 192 | case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES: |
| 193 | case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: |
| 194 | return 1024; |
Ilia Mirkin | 746e526 | 2014-06-26 20:01:50 -0400 | [diff] [blame] | 195 | case PIPE_CAP_MAX_VERTEX_STREAMS: |
| 196 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 197 | case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: |
Dave Airlie | 9e41b0b | 2012-12-13 20:17:58 +1000 | [diff] [blame] | 198 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 199 | case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: |
| 200 | return 0; |
| 201 | case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: |
| 202 | case PIPE_CAP_VERTEX_COLOR_CLAMPED: |
James Benton | 66fdf62 | 2012-09-13 16:05:08 +0100 | [diff] [blame] | 203 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 204 | case PIPE_CAP_GLSL_FEATURE_LEVEL: |
José Fonseca | 7380ce9 | 2014-04-24 15:00:12 +0100 | [diff] [blame] | 205 | return 330; |
Christoph Bumiller | 8b4f7b0 | 2012-02-06 16:29:03 +0100 | [diff] [blame] | 206 | case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: |
| 207 | return 0; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 208 | case PIPE_CAP_COMPUTE: |
| 209 | return 0; |
Marek Olšák | 978c1aa1 | 2012-04-11 15:40:00 +0200 | [diff] [blame] | 210 | case PIPE_CAP_USER_VERTEX_BUFFERS: |
Marek Olšák | 437ab1d | 2012-04-24 15:19:31 +0200 | [diff] [blame] | 211 | case PIPE_CAP_USER_INDEX_BUFFERS: |
Marek Olšák | 978c1aa1 | 2012-04-11 15:40:00 +0200 | [diff] [blame] | 212 | return 1; |
Brian Paul | 2ee0b44 | 2012-12-10 12:35:23 -0700 | [diff] [blame] | 213 | case PIPE_CAP_USER_CONSTANT_BUFFERS: |
| 214 | return 0; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 215 | case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: |
| 216 | case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: |
| 217 | case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: |
Christoph Bumiller | 8acaf86 | 2013-03-15 22:11:31 +0100 | [diff] [blame] | 218 | case PIPE_CAP_TGSI_TEXCOORD: |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 219 | return 0; |
Christoph Bumiller | bc198f8 | 2013-04-05 14:29:36 +0200 | [diff] [blame] | 220 | case PIPE_CAP_DRAW_INDIRECT: |
| 221 | return 1; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 222 | |
Marek Olšák | 1b749dc | 2012-04-24 17:31:17 +0200 | [diff] [blame] | 223 | case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: |
| 224 | return 16; |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 225 | case PIPE_CAP_START_INSTANCE: |
Marek Olšák | b9c9dd4 | 2012-09-11 22:41:20 +0200 | [diff] [blame] | 226 | case PIPE_CAP_TEXTURE_MULTISAMPLE: |
Dave Airlie | add3a07 | 2012-11-10 06:34:14 +1000 | [diff] [blame] | 227 | case PIPE_CAP_CUBE_MAP_ARRAY: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 228 | return 0; |
Siavash Eliasi | 809d3a7 | 2013-11-28 12:26:30 +0330 | [diff] [blame] | 229 | case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: |
| 230 | return 64; |
Roland Scheidegger | 2018317 | 2013-02-25 20:23:18 +0100 | [diff] [blame] | 231 | case PIPE_CAP_TEXTURE_BUFFER_OBJECTS: |
| 232 | return 1; |
Marek Olšák | 52cb395 | 2013-05-02 03:24:33 +0200 | [diff] [blame] | 233 | case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: |
| 234 | return 65536; |
Roland Scheidegger | 2018317 | 2013-02-25 20:23:18 +0100 | [diff] [blame] | 235 | case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: |
| 236 | return 1; |
Marek Olšák | 3e10ab6 | 2013-03-14 17:18:43 +0100 | [diff] [blame] | 237 | case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: |
| 238 | return 0; |
Zack Rusin | eaabb4e | 2013-05-24 16:08:39 -0400 | [diff] [blame] | 239 | case PIPE_CAP_MAX_VIEWPORTS: |
Zack Rusin | 97b8ae4 | 2013-05-24 16:28:19 -0400 | [diff] [blame] | 240 | return PIPE_MAX_VIEWPORTS; |
Tom Stellard | 4e90bc9 | 2013-07-09 21:21:39 -0700 | [diff] [blame] | 241 | case PIPE_CAP_ENDIANNESS: |
| 242 | return PIPE_ENDIAN_NATIVE; |
Ilia Mirkin | 32b7124 | 2014-07-03 11:15:18 -0400 | [diff] [blame] | 243 | case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT: |
Dave Airlie | 2fcbec4 | 2013-09-21 18:45:43 +1000 | [diff] [blame] | 244 | case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: |
| 245 | case PIPE_CAP_TEXTURE_GATHER_SM5: |
Marek Olšák | db8886e | 2014-01-27 21:57:42 +0100 | [diff] [blame] | 246 | case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: |
Dave Airlie | be5276a | 2014-02-11 13:26:08 +1000 | [diff] [blame] | 247 | case PIPE_CAP_TEXTURE_QUERY_LOD: |
Ilia Mirkin | 88d8d88 | 2014-03-30 18:21:04 -0400 | [diff] [blame] | 248 | case PIPE_CAP_SAMPLE_SHADING: |
Ilia Mirkin | d95df4f | 2014-04-26 23:44:57 -0400 | [diff] [blame] | 249 | case PIPE_CAP_TEXTURE_GATHER_OFFSETS: |
Christoph Bumiller | 4b586a2 | 2014-05-17 01:20:19 +0200 | [diff] [blame] | 250 | case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION: |
Marek Olšák | 1a02bb7 | 2013-11-21 15:25:55 +0100 | [diff] [blame] | 251 | return 0; |
Dave Airlie | 76ba50a | 2013-11-27 19:47:51 +1000 | [diff] [blame] | 252 | case PIPE_CAP_FAKE_SW_MSAA: |
Giovanni Campagna | e57ad3d | 2014-07-23 19:28:52 +0100 | [diff] [blame^] | 253 | return 1; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 254 | } |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 255 | /* should only get here on unhandled cases */ |
| 256 | debug_printf("Unexpected PIPE_CAP %d query\n", param); |
| 257 | return 0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 258 | } |
| 259 | |
Luca Barbieri | a508d2d | 2010-09-05 20:50:50 +0200 | [diff] [blame] | 260 | static int |
| 261 | llvmpipe_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_shader_cap param) |
| 262 | { |
| 263 | switch(shader) |
| 264 | { |
| 265 | case PIPE_SHADER_FRAGMENT: |
Dave Airlie | 2d80cad | 2012-01-11 19:48:00 +0000 | [diff] [blame] | 266 | switch (param) { |
Dave Airlie | 2d80cad | 2012-01-11 19:48:00 +0000 | [diff] [blame] | 267 | default: |
José Fonseca | 6dddd18 | 2012-07-12 20:47:20 +0100 | [diff] [blame] | 268 | return gallivm_get_shader_param(param); |
Dave Airlie | 2d80cad | 2012-01-11 19:48:00 +0000 | [diff] [blame] | 269 | } |
Luca Barbieri | a508d2d | 2010-09-05 20:50:50 +0200 | [diff] [blame] | 270 | case PIPE_SHADER_VERTEX: |
| 271 | case PIPE_SHADER_GEOMETRY: |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 272 | switch (param) { |
| 273 | case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: |
| 274 | /* At this time, the draw module and llvmpipe driver only |
| 275 | * support vertex shader texture lookups when LLVM is enabled in |
| 276 | * the draw module. |
| 277 | */ |
| 278 | if (debug_get_bool_option("DRAW_USE_LLVM", TRUE)) |
Brian Paul | cab2fed | 2012-08-09 20:59:44 -0600 | [diff] [blame] | 279 | return PIPE_MAX_SAMPLERS; |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 280 | else |
| 281 | return 0; |
Roland Scheidegger | 2983c03 | 2013-11-26 02:30:41 +0100 | [diff] [blame] | 282 | case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: |
| 283 | if (debug_get_bool_option("DRAW_USE_LLVM", TRUE)) |
| 284 | return PIPE_MAX_SHADER_SAMPLER_VIEWS; |
| 285 | else |
| 286 | return 0; |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 287 | default: |
| 288 | return draw_get_shader_param(shader, param); |
| 289 | } |
Luca Barbieri | a508d2d | 2010-09-05 20:50:50 +0200 | [diff] [blame] | 290 | default: |
| 291 | return 0; |
| 292 | } |
| 293 | } |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 294 | |
| 295 | static float |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 296 | llvmpipe_get_paramf(struct pipe_screen *screen, enum pipe_capf param) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 297 | { |
| 298 | switch (param) { |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 299 | case PIPE_CAPF_MAX_LINE_WIDTH: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 300 | /* fall-through */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 301 | case PIPE_CAPF_MAX_LINE_WIDTH_AA: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 302 | return 255.0; /* arbitrary */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 303 | case PIPE_CAPF_MAX_POINT_WIDTH: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 304 | /* fall-through */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 305 | case PIPE_CAPF_MAX_POINT_WIDTH_AA: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 306 | return 255.0; /* arbitrary */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 307 | case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 308 | return 16.0; /* not actually signficant at this time */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 309 | case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 310 | return 16.0; /* arbitrary */ |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 311 | case PIPE_CAPF_GUARD_BAND_LEFT: |
| 312 | case PIPE_CAPF_GUARD_BAND_TOP: |
| 313 | case PIPE_CAPF_GUARD_BAND_RIGHT: |
| 314 | case PIPE_CAPF_GUARD_BAND_BOTTOM: |
José Fonseca | cf9baf6 | 2010-05-12 17:25:17 +0100 | [diff] [blame] | 315 | return 0.0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 316 | } |
Brian Paul | 056e9b4 | 2012-06-26 14:11:00 -0600 | [diff] [blame] | 317 | /* should only get here on unhandled cases */ |
| 318 | debug_printf("Unexpected PIPE_CAP %d query\n", param); |
| 319 | return 0.0; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | |
| 323 | /** |
| 324 | * Query format support for creating a texture, drawing surface, etc. |
| 325 | * \param format the format to test |
| 326 | * \param type one of PIPE_TEXTURE, PIPE_SURFACE |
| 327 | */ |
| 328 | static boolean |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 329 | llvmpipe_is_format_supported( struct pipe_screen *_screen, |
Roland Scheidegger | e121a73 | 2010-05-17 21:23:31 +0200 | [diff] [blame] | 330 | enum pipe_format format, |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 331 | enum pipe_texture_target target, |
Roland Scheidegger | e121a73 | 2010-05-17 21:23:31 +0200 | [diff] [blame] | 332 | unsigned sample_count, |
Marek Olšák | e968975 | 2011-03-08 00:01:58 +0100 | [diff] [blame] | 333 | unsigned bind) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 334 | { |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 335 | struct llvmpipe_screen *screen = llvmpipe_screen(_screen); |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 336 | struct sw_winsys *winsys = screen->winsys; |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 337 | const struct util_format_description *format_desc; |
| 338 | |
| 339 | format_desc = util_format_description(format); |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 340 | if (!format_desc) |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 341 | return FALSE; |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 342 | |
Brian Paul | e6d8b40 | 2010-05-28 13:31:23 -0600 | [diff] [blame] | 343 | assert(target == PIPE_BUFFER || |
| 344 | target == PIPE_TEXTURE_1D || |
Roland Scheidegger | 6d50148 | 2012-11-29 04:08:32 +0100 | [diff] [blame] | 345 | target == PIPE_TEXTURE_1D_ARRAY || |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 346 | target == PIPE_TEXTURE_2D || |
Roland Scheidegger | 6d50148 | 2012-11-29 04:08:32 +0100 | [diff] [blame] | 347 | target == PIPE_TEXTURE_2D_ARRAY || |
Luca Barbieri | ae0ef6f | 2010-08-18 17:28:08 +0200 | [diff] [blame] | 348 | target == PIPE_TEXTURE_RECT || |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 349 | target == PIPE_TEXTURE_3D || |
| 350 | target == PIPE_TEXTURE_CUBE); |
| 351 | |
Roland Scheidegger | e121a73 | 2010-05-17 21:23:31 +0200 | [diff] [blame] | 352 | if (sample_count > 1) |
| 353 | return FALSE; |
| 354 | |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 355 | if (bind & PIPE_BIND_RENDER_TARGET) { |
Roland Scheidegger | dc1cc92 | 2013-07-16 01:52:29 +0200 | [diff] [blame] | 356 | if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) { |
Roland Scheidegger | 9477d8c | 2014-03-20 16:43:36 +0100 | [diff] [blame] | 357 | /* 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] | 358 | if (format_desc->nr_channels < 3) |
| 359 | return FALSE; |
| 360 | } |
| 361 | else if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB) |
José Fonseca | fe130a7 | 2010-04-06 22:49:57 +0100 | [diff] [blame] | 362 | return FALSE; |
| 363 | |
Roland Scheidegger | b101a09 | 2013-03-22 20:09:18 +0100 | [diff] [blame] | 364 | if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN && |
| 365 | format != PIPE_FORMAT_R11G11B10_FLOAT) |
José Fonseca | fe130a7 | 2010-04-06 22:49:57 +0100 | [diff] [blame] | 366 | return FALSE; |
Roland Scheidegger | dc1cc92 | 2013-07-16 01:52:29 +0200 | [diff] [blame] | 367 | |
José Fonseca | 6916387 | 2012-11-28 19:25:05 +0000 | [diff] [blame] | 368 | assert(format_desc->block.width == 1); |
| 369 | assert(format_desc->block.height == 1); |
José Fonseca | fe130a7 | 2010-04-06 22:49:57 +0100 | [diff] [blame] | 370 | |
José Fonseca | 6916387 | 2012-11-28 19:25:05 +0000 | [diff] [blame] | 371 | if (format_desc->is_mixed) |
| 372 | return FALSE; |
| 373 | |
Roland Scheidegger | b101a09 | 2013-03-22 20:09:18 +0100 | [diff] [blame] | 374 | if (!format_desc->is_array && !format_desc->is_bitmask && |
| 375 | format != PIPE_FORMAT_R11G11B10_FLOAT) |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 376 | return FALSE; |
Roland Scheidegger | d03d9b6 | 2013-01-12 17:28:40 -0800 | [diff] [blame] | 377 | |
| 378 | /* |
| 379 | * XXX refuse formats known to crash in generate_unswizzled_blend(). |
| 380 | * These include all 3-channel 24bit RGB8 variants, plus 48bit |
| 381 | * (except those using floats) 3-channel RGB16 variants (the latter |
| 382 | * seems to be more of a llvm bug though). |
| 383 | * The mesa state tracker only seems to use these for SINT/UINT formats. |
| 384 | */ |
| 385 | if (format_desc->is_array && format_desc->nr_channels == 3) { |
| 386 | if (format_desc->block.bits == 24 || (format_desc->block.bits == 48 && |
| 387 | !util_format_is_float(format))) { |
| 388 | return FALSE; |
| 389 | } |
| 390 | } |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 391 | } |
| 392 | |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 393 | if (bind & PIPE_BIND_DISPLAY_TARGET) { |
| 394 | if(!winsys->is_displaytarget_format_supported(winsys, bind, format)) |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 395 | return FALSE; |
| 396 | } |
| 397 | |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 398 | if (bind & PIPE_BIND_DEPTH_STENCIL) { |
| 399 | if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) |
| 400 | return FALSE; |
| 401 | |
| 402 | if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 403 | return FALSE; |
| 404 | |
José Fonseca | 42f762d | 2013-01-29 13:27:44 +0000 | [diff] [blame] | 405 | /* TODO: Support stencil-only formats */ |
| 406 | if (format_desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_NONE) { |
| 407 | return FALSE; |
| 408 | } |
José Fonseca | b375526 | 2009-11-10 17:51:06 -0800 | [diff] [blame] | 409 | } |
| 410 | |
José Fonseca | adc7cd6 | 2010-04-25 14:52:27 +0100 | [diff] [blame] | 411 | if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { |
José Fonseca | 510669c | 2010-04-22 15:12:30 +0100 | [diff] [blame] | 412 | return util_format_s3tc_enabled; |
José Fonseca | 510669c | 2010-04-22 15:12:30 +0100 | [diff] [blame] | 413 | } |
| 414 | |
José Fonseca | a1b737d | 2011-11-01 12:28:47 +0000 | [diff] [blame] | 415 | /* |
Roland Scheidegger | d03d9b6 | 2013-01-12 17:28:40 -0800 | [diff] [blame] | 416 | * Everything can be supported by u_format |
| 417 | * (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] | 418 | */ |
| 419 | |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 420 | return TRUE; |
| 421 | } |
| 422 | |
| 423 | |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 424 | |
| 425 | |
| 426 | static void |
| 427 | llvmpipe_flush_frontbuffer(struct pipe_screen *_screen, |
Roland Scheidegger | 4c70014 | 2010-12-02 04:33:43 +0100 | [diff] [blame] | 428 | struct pipe_resource *resource, |
| 429 | unsigned level, unsigned layer, |
Dave Airlie | ba00f2f | 2013-11-28 11:08:11 +1000 | [diff] [blame] | 430 | void *context_private, |
| 431 | struct pipe_box *sub_box) |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 432 | { |
| 433 | struct llvmpipe_screen *screen = llvmpipe_screen(_screen); |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 434 | struct sw_winsys *winsys = screen->winsys; |
Roland Scheidegger | 4c70014 | 2010-12-02 04:33:43 +0100 | [diff] [blame] | 435 | struct llvmpipe_resource *texture = llvmpipe_resource(resource); |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 436 | |
| 437 | assert(texture->dt); |
| 438 | if (texture->dt) |
Dave Airlie | ba00f2f | 2013-11-28 11:08:11 +1000 | [diff] [blame] | 439 | winsys->displaytarget_display(winsys, texture->dt, context_private, sub_box); |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 440 | } |
| 441 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 442 | static void |
José Fonseca | 2d6b39f | 2009-08-09 23:10:19 +0100 | [diff] [blame] | 443 | llvmpipe_destroy_screen( struct pipe_screen *_screen ) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 444 | { |
José Fonseca | 2d6b39f | 2009-08-09 23:10:19 +0100 | [diff] [blame] | 445 | struct llvmpipe_screen *screen = llvmpipe_screen(_screen); |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 446 | struct sw_winsys *winsys = screen->winsys; |
José Fonseca | 2d6b39f | 2009-08-09 23:10:19 +0100 | [diff] [blame] | 447 | |
Roland Scheidegger | edac740 | 2010-07-13 19:58:58 +0200 | [diff] [blame] | 448 | if (screen->rast) |
| 449 | lp_rast_destroy(screen->rast); |
| 450 | |
José Fonseca | 08dd41f | 2009-08-23 05:52:20 +0100 | [diff] [blame] | 451 | lp_jit_screen_cleanup(screen); |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 452 | |
| 453 | if(winsys->destroy) |
| 454 | winsys->destroy(winsys); |
| 455 | |
Roland Scheidegger | edac740 | 2010-07-13 19:58:58 +0200 | [diff] [blame] | 456 | pipe_mutex_destroy(screen->rast_mutex); |
| 457 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 458 | FREE(screen); |
| 459 | } |
| 460 | |
| 461 | |
| 462 | |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 463 | |
| 464 | /** |
| 465 | * Fence reference counting. |
| 466 | */ |
| 467 | static void |
| 468 | llvmpipe_fence_reference(struct pipe_screen *screen, |
| 469 | struct pipe_fence_handle **ptr, |
| 470 | struct pipe_fence_handle *fence) |
| 471 | { |
| 472 | struct lp_fence **old = (struct lp_fence **) ptr; |
| 473 | struct lp_fence *f = (struct lp_fence *) fence; |
| 474 | |
| 475 | lp_fence_reference(old, f); |
| 476 | } |
| 477 | |
| 478 | |
| 479 | /** |
| 480 | * Has the fence been executed/finished? |
| 481 | */ |
Marek Olšák | bfe88e6 | 2011-03-07 22:57:54 +0100 | [diff] [blame] | 482 | static boolean |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 483 | llvmpipe_fence_signalled(struct pipe_screen *screen, |
Marek Olšák | bfe88e6 | 2011-03-07 22:57:54 +0100 | [diff] [blame] | 484 | struct pipe_fence_handle *fence) |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 485 | { |
| 486 | struct lp_fence *f = (struct lp_fence *) fence; |
| 487 | return lp_fence_signalled(f); |
| 488 | } |
| 489 | |
| 490 | |
| 491 | /** |
| 492 | * Wait for the fence to finish. |
| 493 | */ |
Marek Olšák | bfe88e6 | 2011-03-07 22:57:54 +0100 | [diff] [blame] | 494 | static boolean |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 495 | llvmpipe_fence_finish(struct pipe_screen *screen, |
| 496 | struct pipe_fence_handle *fence_handle, |
Marek Olšák | b39bccb | 2011-03-05 21:23:54 +0100 | [diff] [blame] | 497 | uint64_t timeout) |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 498 | { |
| 499 | struct lp_fence *f = (struct lp_fence *) fence_handle; |
| 500 | |
| 501 | lp_fence_wait(f); |
Marek Olšák | bfe88e6 | 2011-03-07 22:57:54 +0100 | [diff] [blame] | 502 | return TRUE; |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 503 | } |
| 504 | |
James Benton | 16f0d70 | 2012-12-03 07:00:37 +0000 | [diff] [blame] | 505 | static uint64_t |
| 506 | llvmpipe_get_timestamp(struct pipe_screen *_screen) |
| 507 | { |
| 508 | return os_time_get_nano(); |
| 509 | } |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 510 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 511 | /** |
| 512 | * Create a new pipe_screen object |
| 513 | * Note: we're not presently subclassing pipe_screen (no llvmpipe_screen). |
| 514 | */ |
| 515 | struct pipe_screen * |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 516 | llvmpipe_create_screen(struct sw_winsys *winsys) |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 517 | { |
Török Edwin | 4d52a25 | 2010-05-06 22:19:57 +0100 | [diff] [blame] | 518 | struct llvmpipe_screen *screen; |
| 519 | |
Török Edwin | 4d52a25 | 2010-05-06 22:19:57 +0100 | [diff] [blame] | 520 | util_cpu_detect(); |
Adam Jackson | ca70de9 | 2013-04-04 17:16:22 -0400 | [diff] [blame] | 521 | |
| 522 | #if defined(PIPE_ARCH_X86) && HAVE_LLVM < 0x0302 |
| 523 | /* require SSE2 due to LLVM PR6960. */ |
Török Edwin | 4d52a25 | 2010-05-06 22:19:57 +0100 | [diff] [blame] | 524 | if (!util_cpu_caps.has_sse2) |
| 525 | return NULL; |
| 526 | #endif |
| 527 | |
Keith Whitwell | dec35d0 | 2009-10-09 14:59:35 +0100 | [diff] [blame] | 528 | #ifdef DEBUG |
| 529 | LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 ); |
| 530 | #endif |
| 531 | |
Keith Whitwell | 5f00819 | 2010-09-16 10:45:52 +0100 | [diff] [blame] | 532 | LP_PERF = debug_get_flags_option("LP_PERF", lp_perf_flags, 0 ); |
| 533 | |
José Fonseca | c88f3e0 | 2011-11-09 19:29:37 +0000 | [diff] [blame] | 534 | screen = CALLOC_STRUCT(llvmpipe_screen); |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 535 | if (!screen) |
| 536 | return NULL; |
| 537 | |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 538 | screen->winsys = winsys; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 539 | |
| 540 | screen->base.destroy = llvmpipe_destroy_screen; |
| 541 | |
| 542 | screen->base.get_name = llvmpipe_get_name; |
| 543 | screen->base.get_vendor = llvmpipe_get_vendor; |
| 544 | screen->base.get_param = llvmpipe_get_param; |
Luca Barbieri | a508d2d | 2010-09-05 20:50:50 +0200 | [diff] [blame] | 545 | screen->base.get_shader_param = llvmpipe_get_shader_param; |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 546 | screen->base.get_paramf = llvmpipe_get_paramf; |
| 547 | screen->base.is_format_supported = llvmpipe_is_format_supported; |
| 548 | |
Keith Whitwell | 7f41f54 | 2010-02-08 12:55:59 +0000 | [diff] [blame] | 549 | screen->base.context_create = llvmpipe_create_context; |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 550 | screen->base.flush_frontbuffer = llvmpipe_flush_frontbuffer; |
Keith Whitwell | 5a45e53 | 2010-08-20 15:25:27 +0100 | [diff] [blame] | 551 | screen->base.fence_reference = llvmpipe_fence_reference; |
| 552 | screen->base.fence_signalled = llvmpipe_fence_signalled; |
| 553 | screen->base.fence_finish = llvmpipe_fence_finish; |
José Fonseca | e173a9b | 2009-08-29 20:02:25 +0100 | [diff] [blame] | 554 | |
James Benton | 16f0d70 | 2012-12-03 07:00:37 +0000 | [diff] [blame] | 555 | screen->base.get_timestamp = llvmpipe_get_timestamp; |
| 556 | |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 557 | llvmpipe_init_screen_resource_funcs(&screen->base); |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 558 | |
José Fonseca | 08dd41f | 2009-08-23 05:52:20 +0100 | [diff] [blame] | 559 | lp_jit_screen_init(screen); |
José Fonseca | 2d6b39f | 2009-08-09 23:10:19 +0100 | [diff] [blame] | 560 | |
José Fonseca | 65822eb | 2010-09-16 20:27:13 +0100 | [diff] [blame] | 561 | 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] | 562 | #ifdef PIPE_SUBSYSTEM_EMBEDDED |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 563 | screen->num_threads = 0; |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 564 | #endif |
| 565 | screen->num_threads = debug_get_num_option("LP_NUM_THREADS", screen->num_threads); |
| 566 | screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS); |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 567 | |
Roland Scheidegger | edac740 | 2010-07-13 19:58:58 +0200 | [diff] [blame] | 568 | screen->rast = lp_rast_create(screen->num_threads); |
| 569 | if (!screen->rast) { |
| 570 | lp_jit_screen_cleanup(screen); |
| 571 | FREE(screen); |
| 572 | return NULL; |
| 573 | } |
| 574 | pipe_mutex_init(screen->rast_mutex); |
| 575 | |
José Fonseca | 39be50d | 2010-04-24 13:20:39 +0100 | [diff] [blame] | 576 | util_format_s3tc_init(); |
| 577 | |
José Fonseca | 946f432 | 2009-07-26 23:44:38 +0100 | [diff] [blame] | 578 | return &screen->base; |
| 579 | } |