Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Jerome Glisse <glisse@freedesktop.org> |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * on the rights to use, copy, modify, merge, publish, distribute, sub |
| 8 | * license, and/or sell copies of the Software, and to permit persons to whom |
| 9 | * the Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, |
| 19 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 20 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 21 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ |
Marek Olšák | 7209703 | 2014-01-22 18:50:36 +0100 | [diff] [blame] | 23 | |
Andreas Hartmetz | 786af2f | 2014-01-04 18:44:33 +0100 | [diff] [blame] | 24 | #include "si_pipe.h" |
Marek Olšák | 70de433 | 2016-01-27 00:29:53 +0100 | [diff] [blame] | 25 | #include "si_shader.h" |
Marek Olšák | 7209703 | 2014-01-22 18:50:36 +0100 | [diff] [blame] | 26 | #include "si_public.h" |
Marek Olšák | 955505f | 2014-08-07 21:14:31 +0200 | [diff] [blame] | 27 | #include "sid.h" |
Marek Olšák | 7209703 | 2014-01-22 18:50:36 +0100 | [diff] [blame] | 28 | |
Tom Stellard | 761e36b | 2014-10-15 12:24:30 -0400 | [diff] [blame] | 29 | #include "radeon/radeon_llvm_emit.h" |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 30 | #include "radeon/radeon_uvd.h" |
Marek Olšák | 7209703 | 2014-01-22 18:50:36 +0100 | [diff] [blame] | 31 | #include "util/u_memory.h" |
Bas Nieuwenhuizen | aabc7d6 | 2016-03-10 21:23:49 +0100 | [diff] [blame] | 32 | #include "util/u_suballoc.h" |
Marek Olšák | 7209703 | 2014-01-22 18:50:36 +0100 | [diff] [blame] | 33 | #include "vl/vl_decoder.h" |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 34 | |
| 35 | /* |
| 36 | * pipe_context |
| 37 | */ |
Andreas Hartmetz | eb0ddb6 | 2014-01-07 03:07:55 +0100 | [diff] [blame] | 38 | static void si_destroy_context(struct pipe_context *context) |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 39 | { |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 40 | struct si_context *sctx = (struct si_context *)context; |
Marek Olšák | 59b3556 | 2014-09-19 00:16:12 +0200 | [diff] [blame] | 41 | int i; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 42 | |
Bas Nieuwenhuizen | cbe3421 | 2016-05-31 13:44:03 +0200 | [diff] [blame] | 43 | si_dec_framebuffer_counters(&sctx->framebuffer.state); |
| 44 | |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 45 | si_release_all_descriptors(sctx); |
Marek Olšák | c8e70e6 | 2013-08-06 06:42:22 +0200 | [diff] [blame] | 46 | |
Bas Nieuwenhuizen | aabc7d6 | 2016-03-10 21:23:49 +0100 | [diff] [blame] | 47 | if (sctx->ce_suballocator) |
| 48 | u_suballocator_destroy(sctx->ce_suballocator); |
| 49 | |
Marek Olšák | 711623f | 2014-09-18 21:40:02 +0200 | [diff] [blame] | 50 | pipe_resource_reference(&sctx->esgs_ring, NULL); |
| 51 | pipe_resource_reference(&sctx->gsvs_ring, NULL); |
Marek Olšák | b6f4fdf | 2015-02-22 17:25:37 +0100 | [diff] [blame] | 52 | pipe_resource_reference(&sctx->tf_ring, NULL); |
Bas Nieuwenhuizen | d27ff7d | 2016-05-02 09:54:11 +0200 | [diff] [blame] | 53 | pipe_resource_reference(&sctx->tess_offchip_ring, NULL); |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 54 | pipe_resource_reference(&sctx->null_const_buf.buffer, NULL); |
Marek Olšák | a9971e8 | 2015-08-30 14:13:10 +0200 | [diff] [blame] | 55 | r600_resource_reference(&sctx->border_color_buffer, NULL); |
| 56 | free(sctx->border_color_table); |
Tom Stellard | 2397a72 | 2014-12-10 09:13:59 -0500 | [diff] [blame] | 57 | r600_resource_reference(&sctx->scratch_buffer, NULL); |
Bas Nieuwenhuizen | ba1f66a | 2016-04-02 13:04:18 +0200 | [diff] [blame] | 58 | r600_resource_reference(&sctx->compute_scratch_buffer, NULL); |
Marek Olšák | f1be3d8 | 2015-06-27 14:03:46 +0200 | [diff] [blame] | 59 | sctx->b.ws->fence_reference(&sctx->last_gfx_fence, NULL); |
Michel Dänzer | 9ccaa24 | 2012-09-07 16:09:08 +0200 | [diff] [blame] | 60 | |
Marek Olšák | 638fa80 | 2014-12-31 00:42:22 +0100 | [diff] [blame] | 61 | si_pm4_free_state(sctx, sctx->init_config, ~0); |
Marek Olšák | b1c5f3f | 2015-11-08 13:34:44 +0100 | [diff] [blame] | 62 | if (sctx->init_config_gs_rings) |
| 63 | si_pm4_free_state(sctx, sctx->init_config_gs_rings, ~0); |
Jan Vesely | 47b390f | 2016-05-17 09:25:44 -0400 | [diff] [blame] | 64 | for (i = 0; i < ARRAY_SIZE(sctx->vgt_shader_config); i++) |
Marek Olšák | 59b3556 | 2014-09-19 00:16:12 +0200 | [diff] [blame] | 65 | si_pm4_delete_state(sctx, vgt_shader_config, sctx->vgt_shader_config[i]); |
Michel Dänzer | 404b29d | 2013-11-21 16:45:28 +0900 | [diff] [blame] | 66 | |
Marek Olšák | 9b54ce3 | 2015-10-07 01:48:18 +0200 | [diff] [blame] | 67 | if (sctx->fixed_func_tcs_shader.cso) |
| 68 | sctx->b.b.delete_tcs_state(&sctx->b.b, sctx->fixed_func_tcs_shader.cso); |
Marek Olšák | 6d6208a | 2015-05-06 19:34:09 +0200 | [diff] [blame] | 69 | if (sctx->custom_dsa_flush) |
| 70 | sctx->b.b.delete_depth_stencil_alpha_state(&sctx->b.b, sctx->custom_dsa_flush); |
| 71 | if (sctx->custom_blend_resolve) |
| 72 | sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_resolve); |
| 73 | if (sctx->custom_blend_decompress) |
| 74 | sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_decompress); |
| 75 | if (sctx->custom_blend_fastclear) |
| 76 | sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_fastclear); |
Bas Nieuwenhuizen | 1e48ec7 | 2015-10-21 00:10:41 +0200 | [diff] [blame] | 77 | if (sctx->custom_blend_dcc_decompress) |
| 78 | sctx->b.b.delete_blend_state(&sctx->b.b, sctx->custom_blend_dcc_decompress); |
Marek Olšák | 6a5499b | 2014-03-04 17:49:39 +0100 | [diff] [blame] | 79 | util_unreference_framebuffer_state(&sctx->framebuffer.state); |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 80 | |
Marek Olšák | 6d6208a | 2015-05-06 19:34:09 +0200 | [diff] [blame] | 81 | if (sctx->blitter) |
| 82 | util_blitter_destroy(sctx->blitter); |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 83 | |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 84 | r600_common_context_cleanup(&sctx->b); |
Michel Dänzer | d64adc3 | 2015-03-26 11:32:59 +0900 | [diff] [blame] | 85 | |
Michel Dänzer | d64adc3 | 2015-03-26 11:32:59 +0900 | [diff] [blame] | 86 | LLVMDisposeTargetMachine(sctx->tm); |
Michel Dänzer | d64adc3 | 2015-03-26 11:32:59 +0900 | [diff] [blame] | 87 | |
Marek Olšák | 2c14a6d | 2015-08-19 11:53:25 +0200 | [diff] [blame] | 88 | r600_resource_reference(&sctx->trace_buf, NULL); |
| 89 | r600_resource_reference(&sctx->last_trace_buf, NULL); |
Marek Olšák | be6dc87 | 2015-08-15 12:46:17 +0200 | [diff] [blame] | 90 | free(sctx->last_ib); |
Marek Olšák | cc92b90 | 2015-09-27 01:38:48 +0200 | [diff] [blame] | 91 | if (sctx->last_bo_list) { |
| 92 | for (i = 0; i < sctx->last_bo_count; i++) |
| 93 | pb_reference(&sctx->last_bo_list[i].buf, NULL); |
| 94 | free(sctx->last_bo_list); |
| 95 | } |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 96 | FREE(sctx); |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 97 | } |
| 98 | |
Marek Olšák | bf2c342 | 2015-04-30 17:02:38 +0200 | [diff] [blame] | 99 | static enum pipe_reset_status |
| 100 | si_amdgpu_get_reset_status(struct pipe_context *ctx) |
| 101 | { |
| 102 | struct si_context *sctx = (struct si_context *)ctx; |
| 103 | |
| 104 | return sctx->b.ws->ctx_query_reset_status(sctx->b.ctx); |
| 105 | } |
| 106 | |
Marek Olšák | 0fc21ec | 2015-07-25 18:40:59 +0200 | [diff] [blame] | 107 | static struct pipe_context *si_create_context(struct pipe_screen *screen, |
| 108 | void *priv, unsigned flags) |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 109 | { |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 110 | struct si_context *sctx = CALLOC_STRUCT(si_context); |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 111 | struct si_screen* sscreen = (struct si_screen *)screen; |
Marek Olšák | dd72c32 | 2014-04-11 22:14:27 +0200 | [diff] [blame] | 112 | struct radeon_winsys *ws = sscreen->b.ws; |
Michel Dänzer | d64adc3 | 2015-03-26 11:32:59 +0900 | [diff] [blame] | 113 | LLVMTargetRef r600_target; |
Michel Dänzer | d64adc3 | 2015-03-26 11:32:59 +0900 | [diff] [blame] | 114 | const char *triple = "amdgcn--"; |
Marek Olšák | 4569bf9 | 2013-10-30 20:44:23 +0100 | [diff] [blame] | 115 | int shader, i; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 116 | |
Edward O'Callaghan | 13eb5f5 | 2015-12-04 22:08:22 +1100 | [diff] [blame] | 117 | if (!sctx) |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 118 | return NULL; |
| 119 | |
Marek Olšák | 9bd7928 | 2015-09-26 03:15:40 +0200 | [diff] [blame] | 120 | if (sscreen->b.debug_flags & DBG_CHECK_VM) |
| 121 | flags |= PIPE_CONTEXT_DEBUG; |
| 122 | |
Marek Olšák | 4e5c70e | 2014-01-21 18:01:01 +0100 | [diff] [blame] | 123 | sctx->b.b.screen = screen; /* this must be set first */ |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 124 | sctx->b.b.priv = priv; |
| 125 | sctx->b.b.destroy = si_destroy_context; |
Grazvydas Ignotas | 3206d4e | 2015-08-10 00:42:32 +0300 | [diff] [blame] | 126 | sctx->b.set_atom_dirty = (void *)si_set_atom_dirty; |
Marek Olšák | 4e5c70e | 2014-01-21 18:01:01 +0100 | [diff] [blame] | 127 | sctx->screen = sscreen; /* Easy accessing of screen/winsys. */ |
Marek Olšák | be6dc87 | 2015-08-15 12:46:17 +0200 | [diff] [blame] | 128 | sctx->is_debug = (flags & PIPE_CONTEXT_DEBUG) != 0; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 129 | |
Marek Olšák | 4e5c70e | 2014-01-21 18:01:01 +0100 | [diff] [blame] | 130 | if (!r600_common_context_init(&sctx->b, &sscreen->b)) |
| 131 | goto fail; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 132 | |
Marek Olšák | bf2c342 | 2015-04-30 17:02:38 +0200 | [diff] [blame] | 133 | if (sscreen->b.info.drm_major == 3) |
| 134 | sctx->b.b.get_device_reset_status = si_amdgpu_get_reset_status; |
| 135 | |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 136 | si_init_blit_functions(sctx); |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 137 | si_init_compute_functions(sctx); |
Marek Olšák | 2d3ae15 | 2015-07-25 01:25:07 +0200 | [diff] [blame] | 138 | si_init_cp_dma_functions(sctx); |
Marek Olšák | 110873e | 2015-08-15 23:56:22 +0200 | [diff] [blame] | 139 | si_init_debug_functions(sctx); |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 140 | |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 141 | if (sscreen->b.info.has_uvd) { |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 142 | sctx->b.b.create_video_codec = si_uvd_create_decoder; |
| 143 | sctx->b.b.create_video_buffer = si_video_buffer_create; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 144 | } else { |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 145 | sctx->b.b.create_video_codec = vl_create_decoder; |
| 146 | sctx->b.b.create_video_buffer = vl_video_buffer_create; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 147 | } |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 148 | |
Marek Olšák | 8140154 | 2016-03-11 15:24:05 +0100 | [diff] [blame] | 149 | sctx->b.gfx.cs = ws->cs_create(sctx->b.ctx, RING_GFX, |
| 150 | si_context_gfx_flush, sctx); |
Bas Nieuwenhuizen | 8fee75d | 2016-04-13 22:31:17 +0200 | [diff] [blame] | 151 | |
| 152 | if (!(sscreen->b.debug_flags & DBG_NO_CE) && ws->cs_add_const_ib) { |
| 153 | sctx->ce_ib = ws->cs_add_const_ib(sctx->b.gfx.cs); |
| 154 | if (!sctx->ce_ib) |
| 155 | goto fail; |
| 156 | |
| 157 | if (ws->cs_add_const_preamble_ib) { |
| 158 | sctx->ce_preamble_ib = |
| 159 | ws->cs_add_const_preamble_ib(sctx->b.gfx.cs); |
| 160 | |
| 161 | if (!sctx->ce_preamble_ib) |
| 162 | goto fail; |
| 163 | } |
Bas Nieuwenhuizen | aabc7d6 | 2016-03-10 21:23:49 +0100 | [diff] [blame] | 164 | |
| 165 | sctx->ce_suballocator = |
| 166 | u_suballocator_create(&sctx->b.b, 1024 * 1024, |
Marek Olšák | ada3d8f | 2016-05-31 19:06:45 +0200 | [diff] [blame] | 167 | PIPE_BIND_CUSTOM, |
Bas Nieuwenhuizen | aabc7d6 | 2016-03-10 21:23:49 +0100 | [diff] [blame] | 168 | PIPE_USAGE_DEFAULT, FALSE); |
| 169 | if (!sctx->ce_suballocator) |
| 170 | goto fail; |
Bas Nieuwenhuizen | 8fee75d | 2016-04-13 22:31:17 +0200 | [diff] [blame] | 171 | } |
| 172 | |
Marek Olšák | 6cc8f6c | 2015-11-07 14:00:30 +0100 | [diff] [blame] | 173 | sctx->b.gfx.flush = si_context_gfx_flush; |
Marek Olšák | c8e70e6 | 2013-08-06 06:42:22 +0200 | [diff] [blame] | 174 | |
Marek Olšák | a9971e8 | 2015-08-30 14:13:10 +0200 | [diff] [blame] | 175 | /* Border colors. */ |
| 176 | sctx->border_color_table = malloc(SI_MAX_BORDER_COLORS * |
| 177 | sizeof(*sctx->border_color_table)); |
| 178 | if (!sctx->border_color_table) |
| 179 | goto fail; |
| 180 | |
| 181 | sctx->border_color_buffer = (struct r600_resource*) |
| 182 | pipe_buffer_create(screen, PIPE_BIND_CUSTOM, PIPE_USAGE_DEFAULT, |
| 183 | SI_MAX_BORDER_COLORS * |
| 184 | sizeof(*sctx->border_color_table)); |
| 185 | if (!sctx->border_color_buffer) |
| 186 | goto fail; |
| 187 | |
| 188 | sctx->border_color_map = |
Marek Olšák | cf811fa | 2015-12-07 00:00:59 +0100 | [diff] [blame] | 189 | ws->buffer_map(sctx->border_color_buffer->buf, |
Marek Olšák | a9971e8 | 2015-08-30 14:13:10 +0200 | [diff] [blame] | 190 | NULL, PIPE_TRANSFER_WRITE); |
| 191 | if (!sctx->border_color_map) |
| 192 | goto fail; |
| 193 | |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 194 | si_init_all_descriptors(sctx); |
Marek Olšák | 0aa2446 | 2015-07-16 14:42:38 +0200 | [diff] [blame] | 195 | si_init_state_functions(sctx); |
| 196 | si_init_shader_functions(sctx); |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 197 | |
Marek Olšák | 498a40c | 2016-04-22 22:03:24 +0200 | [diff] [blame] | 198 | if (sctx->b.chip_class >= CIK) |
| 199 | cik_init_sdma_functions(sctx); |
| 200 | else |
| 201 | si_init_dma_functions(sctx); |
| 202 | |
Marek Olšák | d13d2fd | 2014-09-06 17:07:50 +0200 | [diff] [blame] | 203 | if (sscreen->b.debug_flags & DBG_FORCE_DMA) |
| 204 | sctx->b.b.resource_copy_region = sctx->b.dma_copy; |
| 205 | |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 206 | sctx->blitter = util_blitter_create(&sctx->b.b); |
| 207 | if (sctx->blitter == NULL) |
Marek Olšák | a81c3e0 | 2013-08-14 01:04:39 +0200 | [diff] [blame] | 208 | goto fail; |
Marek Olšák | db51ab6 | 2014-08-18 00:55:40 +0200 | [diff] [blame] | 209 | sctx->blitter->draw_rectangle = r600_draw_rectangle; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 210 | |
Marek Olšák | 74aa648 | 2015-08-29 15:05:53 +0200 | [diff] [blame] | 211 | sctx->sample_mask.sample_mask = 0xffff; |
| 212 | |
Marek Olšák | 9eb3b9d | 2013-08-31 00:13:43 +0200 | [diff] [blame] | 213 | /* these must be last */ |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 214 | si_begin_new_cs(sctx); |
Marek Olšák | 62d55c0 | 2014-01-22 00:06:32 +0100 | [diff] [blame] | 215 | r600_query_init_backend_mask(&sctx->b); /* this emits commands and must be last */ |
Marek Olšák | 4569bf9 | 2013-10-30 20:44:23 +0100 | [diff] [blame] | 216 | |
| 217 | /* CIK cannot unbind a constant buffer (S_BUFFER_LOAD is buggy |
| 218 | * with a NULL buffer). We need to use a dummy buffer instead. */ |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 219 | if (sctx->b.chip_class == CIK) { |
| 220 | sctx->null_const_buf.buffer = pipe_buffer_create(screen, PIPE_BIND_CONSTANT_BUFFER, |
Marek Olšák | c321144 | 2014-02-03 03:42:17 +0100 | [diff] [blame] | 221 | PIPE_USAGE_DEFAULT, 16); |
Marek Olšák | ae418a7 | 2015-09-10 19:25:14 +0200 | [diff] [blame] | 222 | if (!sctx->null_const_buf.buffer) |
| 223 | goto fail; |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 224 | sctx->null_const_buf.buffer_size = sctx->null_const_buf.buffer->width0; |
Marek Olšák | 4569bf9 | 2013-10-30 20:44:23 +0100 | [diff] [blame] | 225 | |
| 226 | for (shader = 0; shader < SI_NUM_SHADERS; shader++) { |
Marek Olšák | ee2a818 | 2014-07-07 23:27:19 +0200 | [diff] [blame] | 227 | for (i = 0; i < SI_NUM_CONST_BUFFERS; i++) { |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 228 | sctx->b.b.set_constant_buffer(&sctx->b.b, shader, i, |
| 229 | &sctx->null_const_buf); |
Marek Olšák | 4569bf9 | 2013-10-30 20:44:23 +0100 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
| 233 | /* Clear the NULL constant buffer, because loads should return zeros. */ |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 234 | sctx->b.clear_buffer(&sctx->b.b, sctx->null_const_buf.buffer, 0, |
Marek Olšák | f564b61 | 2016-04-22 10:26:28 +0200 | [diff] [blame] | 235 | sctx->null_const_buf.buffer->width0, 0, |
| 236 | R600_COHERENCY_SHADER); |
Marek Olšák | 4569bf9 | 2013-10-30 20:44:23 +0100 | [diff] [blame] | 237 | } |
| 238 | |
Marek Olšák | 26b69ad | 2016-06-08 14:34:11 +0200 | [diff] [blame] | 239 | uint64_t max_threads_per_block; |
| 240 | screen->get_compute_param(screen, PIPE_SHADER_IR_TGSI, |
| 241 | PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK, |
| 242 | &max_threads_per_block); |
| 243 | |
| 244 | /* The maximum number of scratch waves. Scratch space isn't divided |
| 245 | * evenly between CUs. The number is only a function of the number of CUs. |
| 246 | * We can decrease the constant to decrease the scratch buffer size. |
| 247 | * |
| 248 | * sctx->scratch_waves must be >= the maximum posible size of |
| 249 | * 1 threadgroup, so that the hw doesn't hang from being unable |
| 250 | * to start any. |
| 251 | * |
| 252 | * The recommended value is 4 per CU at most. Higher numbers don't |
| 253 | * bring much benefit, but they still occupy chip resources (think |
| 254 | * async compute). I've seen ~2% performance difference between 4 and 32. |
Tom Stellard | 2397a72 | 2014-12-10 09:13:59 -0500 | [diff] [blame] | 255 | */ |
Marek Olšák | 26b69ad | 2016-06-08 14:34:11 +0200 | [diff] [blame] | 256 | sctx->scratch_waves = MAX2(32 * sscreen->b.info.num_good_compute_units, |
| 257 | max_threads_per_block / 64); |
Tom Stellard | 2397a72 | 2014-12-10 09:13:59 -0500 | [diff] [blame] | 258 | |
Michel Dänzer | d64adc3 | 2015-03-26 11:32:59 +0900 | [diff] [blame] | 259 | /* Initialize LLVM TargetMachine */ |
| 260 | r600_target = radeon_llvm_get_r600_target(triple); |
| 261 | sctx->tm = LLVMCreateTargetMachine(r600_target, triple, |
| 262 | r600_get_llvm_processor_name(sscreen->b.family), |
Axel Davy | dda7a84 | 2016-01-15 10:47:42 +0100 | [diff] [blame] | 263 | #if HAVE_LLVM >= 0x0308 |
| 264 | sscreen->b.debug_flags & DBG_SI_SCHED ? |
| 265 | "+DumpCode,+vgpr-spilling,+si-scheduler" : |
| 266 | #endif |
| 267 | "+DumpCode,+vgpr-spilling", |
Michel Dänzer | d64adc3 | 2015-03-26 11:32:59 +0900 | [diff] [blame] | 268 | LLVMCodeGenLevelDefault, |
| 269 | LLVMRelocDefault, |
| 270 | LLVMCodeModelDefault); |
Michel Dänzer | d64adc3 | 2015-03-26 11:32:59 +0900 | [diff] [blame] | 271 | |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 272 | return &sctx->b.b; |
Marek Olšák | a81c3e0 | 2013-08-14 01:04:39 +0200 | [diff] [blame] | 273 | fail: |
Marek Olšák | a9971e8 | 2015-08-30 14:13:10 +0200 | [diff] [blame] | 274 | fprintf(stderr, "radeonsi: Failed to create a context.\n"); |
Andreas Hartmetz | 8662e66 | 2014-01-11 16:00:50 +0100 | [diff] [blame] | 275 | si_destroy_context(&sctx->b.b); |
Marek Olšák | a81c3e0 | 2013-08-14 01:04:39 +0200 | [diff] [blame] | 276 | return NULL; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | /* |
| 280 | * pipe_screen |
| 281 | */ |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 282 | |
Andreas Hartmetz | eb0ddb6 | 2014-01-07 03:07:55 +0100 | [diff] [blame] | 283 | static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param) |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 284 | { |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 285 | struct si_screen *sscreen = (struct si_screen *)pscreen; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 286 | |
| 287 | switch (param) { |
| 288 | /* Supported features (boolean caps). */ |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 289 | case PIPE_CAP_TWO_SIDED_STENCIL: |
Tom Stellard | 69a9218 | 2012-04-14 17:37:37 -0400 | [diff] [blame] | 290 | case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 291 | case PIPE_CAP_ANISOTROPIC_FILTER: |
| 292 | case PIPE_CAP_POINT_SPRITE: |
| 293 | case PIPE_CAP_OCCLUSION_QUERY: |
| 294 | case PIPE_CAP_TEXTURE_SHADOW_MAP: |
| 295 | case PIPE_CAP_TEXTURE_MIRROR_CLAMP: |
| 296 | case PIPE_CAP_BLEND_EQUATION_SEPARATE: |
| 297 | case PIPE_CAP_TEXTURE_SWIZZLE: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 298 | case PIPE_CAP_DEPTH_CLIP_DISABLE: |
| 299 | case PIPE_CAP_SHADER_STENCIL_EXPORT: |
| 300 | case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: |
| 301 | case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: |
| 302 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: |
| 303 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: |
Marek Olšák | 3958378 | 2014-11-17 20:51:56 +0100 | [diff] [blame] | 304 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 305 | case PIPE_CAP_SM3: |
| 306 | case PIPE_CAP_SEAMLESS_CUBE_MAP: |
| 307 | case PIPE_CAP_PRIMITIVE_RESTART: |
| 308 | case PIPE_CAP_CONDITIONAL_RENDER: |
| 309 | case PIPE_CAP_TEXTURE_BARRIER: |
| 310 | case PIPE_CAP_INDEP_BLEND_ENABLE: |
| 311 | case PIPE_CAP_INDEP_BLEND_FUNC: |
| 312 | case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: |
| 313 | case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: |
Marek Olšák | 2a311b1 | 2012-04-24 01:23:33 +0200 | [diff] [blame] | 314 | case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: |
| 315 | case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: |
| 316 | case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: |
Marek Olšák | 437ab1d | 2012-04-24 15:19:31 +0200 | [diff] [blame] | 317 | case PIPE_CAP_USER_INDEX_BUFFERS: |
| 318 | case PIPE_CAP_USER_CONSTANT_BUFFERS: |
Fredrik Höglund | af37212 | 2012-06-18 22:50:02 +0200 | [diff] [blame] | 319 | case PIPE_CAP_START_INSTANCE: |
Michel Dänzer | d0f51fe | 2012-09-05 18:27:02 +0200 | [diff] [blame] | 320 | case PIPE_CAP_NPOT_TEXTURES: |
Ilia Mirkin | 12d39b4 | 2013-10-04 04:32:15 -0400 | [diff] [blame] | 321 | case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: |
Marek Olšák | 5bc871a | 2015-10-07 02:36:38 +0200 | [diff] [blame] | 322 | case PIPE_CAP_VERTEX_COLOR_CLAMPED: |
Marek Olšák | 208d1ed | 2015-10-07 01:47:00 +0200 | [diff] [blame] | 323 | case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: |
Marek Olšák | 3e10ab6 | 2013-03-14 17:18:43 +0100 | [diff] [blame] | 324 | case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: |
Christian König | e4ed587 | 2013-03-21 18:02:52 +0100 | [diff] [blame] | 325 | case PIPE_CAP_TGSI_INSTANCEID: |
Tom Stellard | 302f53d | 2012-10-25 13:50:10 -0400 | [diff] [blame] | 326 | case PIPE_CAP_COMPUTE: |
Marek Olšák | dbeedbb | 2013-10-31 15:08:49 +0100 | [diff] [blame] | 327 | case PIPE_CAP_TEXTURE_BUFFER_OBJECTS: |
Ilia Mirkin | 32b7124 | 2014-07-03 11:15:18 -0400 | [diff] [blame] | 328 | case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT: |
Marek Olšák | 8739c60 | 2014-01-22 00:08:11 +0100 | [diff] [blame] | 329 | case PIPE_CAP_QUERY_PIPELINE_STATISTICS: |
Marek Olšák | 6381dd7 | 2014-01-27 21:46:21 +0100 | [diff] [blame] | 330 | case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: |
Marek Olšák | 2484daa | 2014-04-22 21:23:29 +0200 | [diff] [blame] | 331 | case PIPE_CAP_CUBE_MAP_ARRAY: |
Marek Olšák | f98a7d8 | 2014-05-07 13:15:41 +0200 | [diff] [blame] | 332 | case PIPE_CAP_SAMPLE_SHADING: |
Marek Olšák | 2a7b57a | 2014-04-24 03:03:43 +0200 | [diff] [blame] | 333 | case PIPE_CAP_DRAW_INDIRECT: |
Mathias Fröhlich | 5608813 | 2014-09-14 15:17:07 +0200 | [diff] [blame] | 334 | case PIPE_CAP_CLIP_HALFZ: |
Marek Olšák | ff80422 | 2014-11-08 16:03:13 +0100 | [diff] [blame] | 335 | case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION: |
Ilia Mirkin | 7c211a1 | 2015-02-01 09:01:50 -0500 | [diff] [blame] | 336 | case PIPE_CAP_POLYGON_OFFSET_CLAMP: |
Axel Davy | eb1c12d | 2015-01-17 14:30:17 +0100 | [diff] [blame] | 337 | case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: |
Marek Olšák | f5832f3 | 2015-03-15 18:53:50 +0100 | [diff] [blame] | 338 | case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: |
Marek Olšák | e4339bc | 2015-05-09 19:36:17 +0200 | [diff] [blame] | 339 | case PIPE_CAP_TGSI_TEXCOORD: |
Dave Airlie | bb9d59a | 2015-07-17 05:35:30 +0100 | [diff] [blame] | 340 | case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE: |
Edward O'Callaghan | 8254672 | 2015-07-27 11:01:47 +1000 | [diff] [blame] | 341 | case PIPE_CAP_CONDITIONAL_RENDER_INVERTED: |
Marek Olšák | 44dc1d3 | 2015-08-10 19:37:01 +0200 | [diff] [blame] | 342 | case PIPE_CAP_TEXTURE_FLOAT_LINEAR: |
| 343 | case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR: |
Marek Olšák | 9b54ce3 | 2015-10-07 01:48:18 +0200 | [diff] [blame] | 344 | case PIPE_CAP_SHAREABLE_SHADERS: |
Marek Olšák | 97f58fb | 2015-08-10 02:23:21 +0200 | [diff] [blame] | 345 | case PIPE_CAP_DEPTH_BOUNDS_TEST: |
Marek Olšák | 1232196 | 2015-03-17 14:46:04 +0100 | [diff] [blame] | 346 | case PIPE_CAP_SAMPLER_VIEW_TARGET: |
Marek Olšák | e6d3846 | 2015-09-06 16:26:21 +0200 | [diff] [blame] | 347 | case PIPE_CAP_TEXTURE_QUERY_LOD: |
| 348 | case PIPE_CAP_TEXTURE_GATHER_SM5: |
Ilia Mirkin | 72ebd53 | 2015-09-18 19:08:35 -0400 | [diff] [blame] | 349 | case PIPE_CAP_TGSI_TXQS: |
Marek Olšák | 814b7d1 | 2015-09-28 23:50:12 +0200 | [diff] [blame] | 350 | case PIPE_CAP_FORCE_PERSAMPLE_INTERP: |
Marek Olšák | ce9db16 | 2015-08-24 01:19:35 +0200 | [diff] [blame] | 351 | case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS: |
Marek Olšák | 4ea0feb | 2016-01-02 23:09:58 +0100 | [diff] [blame] | 352 | case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: |
| 353 | case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: |
Nicolai Hähnle | 321140d | 2016-01-14 09:41:04 -0500 | [diff] [blame] | 354 | case PIPE_CAP_INVALIDATE_BUFFER: |
Nicolai Hähnle | 7dd31b8 | 2016-01-26 10:29:50 -0500 | [diff] [blame] | 355 | case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS: |
Marek Olšák | 635555a | 2016-02-02 02:09:36 +0100 | [diff] [blame] | 356 | case PIPE_CAP_QUERY_MEMORY_INFO: |
Marek Olšák | 100796c | 2016-02-10 21:48:59 +0100 | [diff] [blame] | 357 | case PIPE_CAP_TGSI_PACK_HALF_FLOAT: |
Edward O'Callaghan | 483a686 | 2016-01-02 05:53:57 +1100 | [diff] [blame] | 358 | case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT: |
Bas Nieuwenhuizen | 126da23 | 2016-04-03 21:49:44 +0200 | [diff] [blame] | 359 | case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: |
Marek Olšák | 70a2547 | 2016-06-10 03:03:11 +0200 | [diff] [blame^] | 360 | case PIPE_CAP_GENERATE_MIPMAP: |
Marek Olšák | aafb0f9 | 2013-08-17 02:47:21 +0200 | [diff] [blame] | 361 | return 1; |
Marek Olšák | 21d9a1b | 2013-08-16 15:21:45 +0200 | [diff] [blame] | 362 | |
Marek Olšák | 7713d59 | 2015-02-10 16:02:54 +0100 | [diff] [blame] | 363 | case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: |
| 364 | return !SI_BIG_ENDIAN && sscreen->b.info.has_userptr; |
| 365 | |
Marek Olšák | 914365c | 2015-04-29 15:27:50 +0200 | [diff] [blame] | 366 | case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: |
Marek Olšák | bf2c342 | 2015-04-30 17:02:38 +0200 | [diff] [blame] | 367 | return (sscreen->b.info.drm_major == 2 && |
| 368 | sscreen->b.info.drm_minor >= 43) || |
| 369 | sscreen->b.info.drm_major == 3; |
Marek Olšák | 914365c | 2015-04-29 15:27:50 +0200 | [diff] [blame] | 370 | |
Marek Olšák | 2f1c449 | 2013-07-30 22:29:30 +0200 | [diff] [blame] | 371 | case PIPE_CAP_TEXTURE_MULTISAMPLE: |
Marek Olšák | 751e869 | 2013-11-20 13:48:19 +0100 | [diff] [blame] | 372 | /* 2D tiling on CIK is supported since DRM 2.35.0 */ |
Marek Olšák | a66d934 | 2014-07-08 02:50:57 +0200 | [diff] [blame] | 373 | return sscreen->b.chip_class < CIK || |
Marek Olšák | 8ba70e0 | 2015-04-16 20:35:27 +0200 | [diff] [blame] | 374 | (sscreen->b.info.drm_major == 2 && |
| 375 | sscreen->b.info.drm_minor >= 35) || |
| 376 | sscreen->b.info.drm_major == 3; |
Marek Olšák | 2f1c449 | 2013-07-30 22:29:30 +0200 | [diff] [blame] | 377 | |
Marek Olšák | c9f2af3 | 2012-10-28 17:52:48 +0100 | [diff] [blame] | 378 | case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: |
Marek Olšák | de5094d | 2014-03-09 22:29:20 +0100 | [diff] [blame] | 379 | return R600_MAP_BUFFER_ALIGNMENT; |
Marek Olšák | c9f2af3 | 2012-10-28 17:52:48 +0100 | [diff] [blame] | 380 | |
Marek Olšák | 1b749dc | 2012-04-24 17:31:17 +0200 | [diff] [blame] | 381 | case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: |
Marek Olšák | e219842 | 2014-03-09 20:05:54 +0100 | [diff] [blame] | 382 | case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: |
Marek Olšák | e6d3846 | 2015-09-06 16:26:21 +0200 | [diff] [blame] | 383 | case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: |
Marek Olšák | e219842 | 2014-03-09 20:05:54 +0100 | [diff] [blame] | 384 | return 4; |
Nicolai Hähnle | 9e9a2bb | 2016-04-13 09:11:44 -0500 | [diff] [blame] | 385 | case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: |
| 386 | return HAVE_LLVM >= 0x0309 ? 4 : 0; |
Marek Olšák | 1b749dc | 2012-04-24 17:31:17 +0200 | [diff] [blame] | 387 | |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 388 | case PIPE_CAP_GLSL_FEATURE_LEVEL: |
Bas Nieuwenhuizen | 2cee0d0 | 2016-04-19 00:47:49 +0200 | [diff] [blame] | 389 | if (pscreen->get_shader_param(pscreen, PIPE_SHADER_COMPUTE, |
| 390 | PIPE_SHADER_CAP_SUPPORTED_IRS) & |
| 391 | (1 << PIPE_SHADER_IR_TGSI)) |
| 392 | return 430; |
Nicolai Hähnle | 10cfd7a | 2016-03-17 19:53:36 -0500 | [diff] [blame] | 393 | return HAVE_LLVM >= 0x0309 ? 420 : |
| 394 | HAVE_LLVM >= 0x0307 ? 410 : 330; |
Marek Olšák | dbeedbb | 2013-10-31 15:08:49 +0100 | [diff] [blame] | 395 | |
Marek Olšák | dbeedbb | 2013-10-31 15:08:49 +0100 | [diff] [blame] | 396 | case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 397 | return MIN2(sscreen->b.info.vram_size, 0xFFFFFFFF); |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 398 | |
Nicolai Hähnle | 3abb548 | 2016-01-26 10:26:30 -0500 | [diff] [blame] | 399 | case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY: |
| 400 | return 0; |
| 401 | |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 402 | /* Unsupported features. */ |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 403 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 404 | case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: |
Marek Olšák | 2a311b1 | 2012-04-24 01:23:33 +0200 | [diff] [blame] | 405 | case PIPE_CAP_USER_VERTEX_BUFFERS: |
Dave Airlie | 76ba50a | 2013-11-27 19:47:51 +1000 | [diff] [blame] | 406 | case PIPE_CAP_FAKE_SW_MSAA: |
Ilia Mirkin | d95df4f | 2014-04-26 23:44:57 -0400 | [diff] [blame] | 407 | case PIPE_CAP_TEXTURE_GATHER_OFFSETS: |
Roland Scheidegger | ade8b26 | 2014-12-12 04:13:43 +0100 | [diff] [blame] | 408 | case PIPE_CAP_VERTEXID_NOBASE: |
Ilia Mirkin | 3695b25 | 2015-11-09 13:27:07 -0500 | [diff] [blame] | 409 | case PIPE_CAP_CLEAR_TEXTURE: |
Ilia Mirkin | 87b4e4e | 2015-12-29 16:49:32 -0500 | [diff] [blame] | 410 | case PIPE_CAP_DRAW_PARAMETERS: |
Ilia Mirkin | d67b9ba | 2015-12-31 13:30:13 -0500 | [diff] [blame] | 411 | case PIPE_CAP_MULTI_DRAW_INDIRECT: |
| 412 | case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS: |
Rob Clark | d640837 | 2015-08-10 11:41:29 -0400 | [diff] [blame] | 413 | case PIPE_CAP_STRING_MARKER: |
Ilia Mirkin | f9e6f46 | 2016-01-09 23:30:16 -0500 | [diff] [blame] | 414 | case PIPE_CAP_QUERY_BUFFER_OBJECT: |
Tobias Klausmann | 2be258e | 2016-05-08 22:44:07 +0200 | [diff] [blame] | 415 | case PIPE_CAP_CULL_DISTANCE: |
Kenneth Graunke | 70048eb | 2016-05-20 21:05:34 -0700 | [diff] [blame] | 416 | case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES: |
Ilia Mirkin | edfa7a4 | 2016-05-29 11:39:52 -0400 | [diff] [blame] | 417 | case PIPE_CAP_TGSI_VOTE: |
Ilia Mirkin | 07fcb06 | 2016-06-11 15:26:45 -0400 | [diff] [blame] | 418 | case PIPE_CAP_MAX_WINDOW_RECTANGLES: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 419 | return 0; |
| 420 | |
Marek Olšák | bac12c8 | 2015-02-22 18:46:53 +0100 | [diff] [blame] | 421 | case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: |
| 422 | return 30; |
| 423 | |
Marek Olšák | 164de0d | 2013-10-30 21:44:07 +0100 | [diff] [blame] | 424 | case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: |
| 425 | return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600; |
| 426 | |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 427 | /* Stream output. */ |
| 428 | case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 429 | return sscreen->b.has_streamout ? 4 : 0; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 430 | case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 431 | return sscreen->b.has_streamout ? 1 : 0; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 432 | case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: |
| 433 | case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 434 | return sscreen->b.has_streamout ? 32*4 : 0; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 435 | |
Grigori Goronzy | d34d5fd | 2014-02-09 22:56:20 +0100 | [diff] [blame] | 436 | /* Geometry shader output. */ |
| 437 | case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES: |
| 438 | return 1024; |
| 439 | case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: |
| 440 | return 4095; |
Ilia Mirkin | 746e526 | 2014-06-26 20:01:50 -0400 | [diff] [blame] | 441 | case PIPE_CAP_MAX_VERTEX_STREAMS: |
Dave Airlie | 3c73c41 | 2015-07-20 02:37:14 +0100 | [diff] [blame] | 442 | return 4; |
Grigori Goronzy | d34d5fd | 2014-02-09 22:56:20 +0100 | [diff] [blame] | 443 | |
Timothy Arceri | 89e6806 | 2014-08-19 21:09:58 -1000 | [diff] [blame] | 444 | case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE: |
| 445 | return 2048; |
| 446 | |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 447 | /* Texturing. */ |
| 448 | case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 449 | case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: |
Marek Olšák | 4f1f323 | 2014-03-09 20:03:57 +0100 | [diff] [blame] | 450 | return 15; /* 16384 */ |
| 451 | case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: |
| 452 | /* textures support 8192, but layered rendering supports 2048 */ |
| 453 | return 12; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 454 | case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: |
Marek Olšák | 4f1f323 | 2014-03-09 20:03:57 +0100 | [diff] [blame] | 455 | /* textures support 8192, but layered rendering supports 2048 */ |
| 456 | return 2048; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 457 | |
| 458 | /* Render targets. */ |
| 459 | case PIPE_CAP_MAX_RENDER_TARGETS: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 460 | return 8; |
| 461 | |
Marek Olšák | a62cd69 | 2013-09-21 19:45:08 +0200 | [diff] [blame] | 462 | case PIPE_CAP_MAX_VIEWPORTS: |
Marek Olšák | 2ca5566 | 2016-04-10 04:26:50 +0200 | [diff] [blame] | 463 | return R600_MAX_VIEWPORTS; |
Marek Olšák | a62cd69 | 2013-09-21 19:45:08 +0200 | [diff] [blame] | 464 | |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 465 | /* Timer queries, present when the clock frequency is non zero. */ |
Niels Ole Salscheider | db6f416 | 2013-08-09 11:59:28 +0200 | [diff] [blame] | 466 | case PIPE_CAP_QUERY_TIMESTAMP: |
José Fonseca | 9976216 | 2012-12-09 09:50:34 +0000 | [diff] [blame] | 467 | case PIPE_CAP_QUERY_TIME_ELAPSED: |
Marek Olšák | 1e864d7 | 2016-01-30 01:27:46 +0100 | [diff] [blame] | 468 | return sscreen->b.info.clock_crystal_freq != 0; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 469 | |
Ilia Mirkin | c2f9ad5 | 2014-04-09 14:58:53 -0400 | [diff] [blame] | 470 | case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 471 | case PIPE_CAP_MIN_TEXEL_OFFSET: |
Marek Olšák | c7b5a5c | 2014-06-06 03:00:18 +0200 | [diff] [blame] | 472 | return -32; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 473 | |
Ilia Mirkin | c2f9ad5 | 2014-04-09 14:58:53 -0400 | [diff] [blame] | 474 | case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 475 | case PIPE_CAP_MAX_TEXEL_OFFSET: |
Marek Olšák | c7b5a5c | 2014-06-06 03:00:18 +0200 | [diff] [blame] | 476 | return 31; |
| 477 | |
Tom Stellard | 4e90bc9 | 2013-07-09 21:21:39 -0700 | [diff] [blame] | 478 | case PIPE_CAP_ENDIANNESS: |
| 479 | return PIPE_ENDIAN_LITTLE; |
Emil Velikov | de01443 | 2014-08-14 20:57:29 +0100 | [diff] [blame] | 480 | |
| 481 | case PIPE_CAP_VENDOR_ID: |
Marek Olšák | ec74dee | 2016-02-25 22:32:26 +0100 | [diff] [blame] | 482 | return ATI_VENDOR_ID; |
Emil Velikov | de01443 | 2014-08-14 20:57:29 +0100 | [diff] [blame] | 483 | case PIPE_CAP_DEVICE_ID: |
| 484 | return sscreen->b.info.pci_id; |
| 485 | case PIPE_CAP_ACCELERATED: |
| 486 | return 1; |
| 487 | case PIPE_CAP_VIDEO_MEMORY: |
| 488 | return sscreen->b.info.vram_size >> 20; |
| 489 | case PIPE_CAP_UMA: |
| 490 | return 0; |
Marek Olšák | dcb2b77 | 2016-02-29 20:22:37 +0100 | [diff] [blame] | 491 | case PIPE_CAP_PCI_GROUP: |
| 492 | return sscreen->b.info.pci_domain; |
| 493 | case PIPE_CAP_PCI_BUS: |
| 494 | return sscreen->b.info.pci_bus; |
| 495 | case PIPE_CAP_PCI_DEVICE: |
| 496 | return sscreen->b.info.pci_dev; |
| 497 | case PIPE_CAP_PCI_FUNCTION: |
| 498 | return sscreen->b.info.pci_func; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 499 | } |
| 500 | return 0; |
| 501 | } |
| 502 | |
Andreas Hartmetz | eb0ddb6 | 2014-01-07 03:07:55 +0100 | [diff] [blame] | 503 | static int si_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enum pipe_shader_cap param) |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 504 | { |
Bas Nieuwenhuizen | 464cef5 | 2016-03-19 15:16:50 +0100 | [diff] [blame] | 505 | struct si_screen *sscreen = (struct si_screen *)pscreen; |
| 506 | |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 507 | switch(shader) |
| 508 | { |
| 509 | case PIPE_SHADER_FRAGMENT: |
| 510 | case PIPE_SHADER_VERTEX: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 511 | case PIPE_SHADER_GEOMETRY: |
Michel Dänzer | d7c68e2 | 2014-01-24 17:51:34 +0900 | [diff] [blame] | 512 | break; |
Marek Olšák | bac12c8 | 2015-02-22 18:46:53 +0100 | [diff] [blame] | 513 | case PIPE_SHADER_TESS_CTRL: |
| 514 | case PIPE_SHADER_TESS_EVAL: |
| 515 | /* LLVM 3.6.2 is required for tessellation because of bug fixes there */ |
Marek Olšák | 100796c | 2016-02-10 21:48:59 +0100 | [diff] [blame] | 516 | if (HAVE_LLVM == 0x0306 && MESA_LLVM_VERSION_PATCH < 2) |
Marek Olšák | bac12c8 | 2015-02-22 18:46:53 +0100 | [diff] [blame] | 517 | return 0; |
| 518 | break; |
Tom Stellard | 302f53d | 2012-10-25 13:50:10 -0400 | [diff] [blame] | 519 | case PIPE_SHADER_COMPUTE: |
| 520 | switch (param) { |
| 521 | case PIPE_SHADER_CAP_PREFERRED_IR: |
Tom Stellard | 1f4e48d | 2014-09-25 18:11:24 -0700 | [diff] [blame] | 522 | return PIPE_SHADER_IR_NATIVE; |
Samuel Pitoiset | 5e09ac7 | 2016-02-03 18:57:58 +0100 | [diff] [blame] | 523 | |
Bas Nieuwenhuizen | 464cef5 | 2016-03-19 15:16:50 +0100 | [diff] [blame] | 524 | case PIPE_SHADER_CAP_SUPPORTED_IRS: { |
| 525 | int ir = 1 << PIPE_SHADER_IR_NATIVE; |
Samuel Pitoiset | 5e09ac7 | 2016-02-03 18:57:58 +0100 | [diff] [blame] | 526 | |
Bas Nieuwenhuizen | 464cef5 | 2016-03-19 15:16:50 +0100 | [diff] [blame] | 527 | /* Old kernels disallowed some register writes for SI |
| 528 | * that are used for indirect dispatches. */ |
| 529 | if (HAVE_LLVM >= 0x309 && (sscreen->b.chip_class >= CIK || |
| 530 | sscreen->b.info.drm_major == 3 || |
| 531 | (sscreen->b.info.drm_major == 2 && |
| 532 | sscreen->b.info.drm_minor >= 45))) |
| 533 | ir |= 1 << PIPE_SHADER_IR_TGSI; |
| 534 | |
| 535 | return ir; |
| 536 | } |
Tom Stellard | fea996c | 2014-06-17 08:52:34 -0700 | [diff] [blame] | 537 | case PIPE_SHADER_CAP_DOUBLES: |
Tom Stellard | da85ab4 | 2015-02-26 23:25:14 +0000 | [diff] [blame] | 538 | return HAVE_LLVM >= 0x0307; |
| 539 | |
Tom Stellard | 72969e0 | 2014-08-07 15:31:17 -0400 | [diff] [blame] | 540 | case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE: { |
| 541 | uint64_t max_const_buffer_size; |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 542 | pscreen->get_compute_param(pscreen, PIPE_SHADER_IR_TGSI, |
Tom Stellard | 72969e0 | 2014-08-07 15:31:17 -0400 | [diff] [blame] | 543 | PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE, |
| 544 | &max_const_buffer_size); |
| 545 | return max_const_buffer_size; |
| 546 | } |
Tom Stellard | 302f53d | 2012-10-25 13:50:10 -0400 | [diff] [blame] | 547 | default: |
Tom Stellard | 4c53d2a | 2015-03-21 00:27:16 +0000 | [diff] [blame] | 548 | /* If compute shaders don't require a special value |
| 549 | * for this cap, we can return the same value we |
| 550 | * do for other shader types. */ |
| 551 | break; |
Tom Stellard | 302f53d | 2012-10-25 13:50:10 -0400 | [diff] [blame] | 552 | } |
Tom Stellard | 4c53d2a | 2015-03-21 00:27:16 +0000 | [diff] [blame] | 553 | break; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 554 | default: |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 555 | return 0; |
| 556 | } |
| 557 | |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 558 | switch (param) { |
| 559 | case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: |
| 560 | case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: |
| 561 | case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: |
| 562 | case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: |
| 563 | return 16384; |
| 564 | case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: |
Marek Olšák | 225228a | 2013-01-31 19:40:24 +0100 | [diff] [blame] | 565 | return 32; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 566 | case PIPE_SHADER_CAP_MAX_INPUTS: |
Marek Olšák | ee2a818 | 2014-07-07 23:27:19 +0200 | [diff] [blame] | 567 | return shader == PIPE_SHADER_VERTEX ? SI_NUM_VERTEX_BUFFERS : 32; |
Marek Olšák | 5f5b83c | 2014-10-01 20:28:17 +0200 | [diff] [blame] | 568 | case PIPE_SHADER_CAP_MAX_OUTPUTS: |
| 569 | return shader == PIPE_SHADER_FRAGMENT ? 8 : 32; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 570 | case PIPE_SHADER_CAP_MAX_TEMPS: |
| 571 | return 256; /* Max native temporaries. */ |
Marek Olšák | 04f2c88 | 2014-07-24 20:32:08 +0200 | [diff] [blame] | 572 | case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE: |
| 573 | return 4096 * sizeof(float[4]); /* actually only memory limits this */ |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 574 | case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: |
Marek Olšák | 0954d5e | 2016-04-19 02:14:53 +0200 | [diff] [blame] | 575 | return SI_NUM_CONST_BUFFERS; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 576 | case PIPE_SHADER_CAP_MAX_PREDS: |
| 577 | return 0; /* FIXME */ |
| 578 | case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: |
| 579 | return 1; |
Brian Paul | 13f3ae5 | 2013-02-01 11:16:54 -0700 | [diff] [blame] | 580 | case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: |
Marek Olšák | f9fd0c4 | 2015-03-02 02:40:57 +0100 | [diff] [blame] | 581 | return 1; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 582 | case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: |
Michel Dänzer | 3b3687a | 2014-01-22 18:47:21 +0900 | [diff] [blame] | 583 | /* Indirection of geometry shader input dimension is not |
| 584 | * handled yet |
| 585 | */ |
Marek Olšák | bac12c8 | 2015-02-22 18:46:53 +0100 | [diff] [blame] | 586 | return shader != PIPE_SHADER_GEOMETRY; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 587 | case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: |
| 588 | case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: |
| 589 | case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: |
Christian König | 90862c85 | 2013-03-07 12:00:18 +0100 | [diff] [blame] | 590 | return 1; |
Tom Stellard | ae9be35 | 2012-07-25 08:22:30 -0400 | [diff] [blame] | 591 | case PIPE_SHADER_CAP_INTEGERS: |
| 592 | return 1; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 593 | case PIPE_SHADER_CAP_SUBROUTINES: |
| 594 | return 0; |
| 595 | case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: |
Roland Scheidegger | 2983c03 | 2013-11-26 02:30:41 +0100 | [diff] [blame] | 596 | case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: |
Marek Olšák | 0954d5e | 2016-04-19 02:14:53 +0200 | [diff] [blame] | 597 | return SI_NUM_SAMPLERS; |
Marek Olšák | 7b01bc1 | 2012-10-11 21:35:45 +0200 | [diff] [blame] | 598 | case PIPE_SHADER_CAP_PREFERRED_IR: |
| 599 | return PIPE_SHADER_IR_TGSI; |
Samuel Pitoiset | 5e09ac7 | 2016-02-03 18:57:58 +0100 | [diff] [blame] | 600 | case PIPE_SHADER_CAP_SUPPORTED_IRS: |
| 601 | return 0; |
Tom Stellard | fea996c | 2014-06-17 08:52:34 -0700 | [diff] [blame] | 602 | case PIPE_SHADER_CAP_DOUBLES: |
Dave Airlie | 4cbf0a0 | 2015-07-01 04:58:24 +0100 | [diff] [blame] | 603 | return HAVE_LLVM >= 0x0307; |
Ilia Mirkin | 899d779 | 2014-07-25 17:03:33 -0400 | [diff] [blame] | 604 | case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: |
Ilia Mirkin | 924ee3f | 2014-07-25 17:48:01 -0400 | [diff] [blame] | 605 | case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: |
Tom Stellard | fea996c | 2014-06-17 08:52:34 -0700 | [diff] [blame] | 606 | return 0; |
Marek Olšák | d73c1c1 | 2015-02-28 00:44:19 +0100 | [diff] [blame] | 607 | case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: |
Marek Olšák | b6ebe7e | 2015-05-25 19:30:44 +0200 | [diff] [blame] | 608 | case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: |
Marek Olšák | d73c1c1 | 2015-02-28 00:44:19 +0100 | [diff] [blame] | 609 | return 1; |
Marek Olšák | 814f314 | 2015-10-20 18:26:02 +0200 | [diff] [blame] | 610 | case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT: |
| 611 | return 32; |
Ilia Mirkin | 266d001 | 2015-09-26 20:27:42 -0400 | [diff] [blame] | 612 | case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: |
Nicolai Hähnle | bfd11c5 | 2016-03-15 16:25:42 -0500 | [diff] [blame] | 613 | return HAVE_LLVM >= 0x0309 ? SI_NUM_SHADER_BUFFERS : 0; |
Edward O'Callaghan | 5219eb1 | 2016-01-11 00:50:32 +1100 | [diff] [blame] | 614 | case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: |
| 615 | return HAVE_LLVM >= 0x0309 ? SI_NUM_IMAGES : 0; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 616 | } |
| 617 | return 0; |
| 618 | } |
| 619 | |
Andreas Hartmetz | eb0ddb6 | 2014-01-07 03:07:55 +0100 | [diff] [blame] | 620 | static void si_destroy_screen(struct pipe_screen* pscreen) |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 621 | { |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 622 | struct si_screen *sscreen = (struct si_screen *)pscreen; |
Marek Olšák | 70de433 | 2016-01-27 00:29:53 +0100 | [diff] [blame] | 623 | struct si_shader_part *parts[] = { |
| 624 | sscreen->vs_prologs, |
Marek Olšák | e1b2169 | 2016-01-27 00:33:07 +0100 | [diff] [blame] | 625 | sscreen->vs_epilogs, |
Marek Olšák | eb10919 | 2016-01-27 00:38:03 +0100 | [diff] [blame] | 626 | sscreen->tcs_epilogs, |
Marek Olšák | 4636d9b | 2016-02-15 23:57:54 +0100 | [diff] [blame] | 627 | sscreen->ps_prologs, |
Marek Olšák | e79bb74 | 2016-01-27 00:50:29 +0100 | [diff] [blame] | 628 | sscreen->ps_epilogs |
Marek Olšák | 70de433 | 2016-01-27 00:29:53 +0100 | [diff] [blame] | 629 | }; |
| 630 | unsigned i; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 631 | |
Edward O'Callaghan | 13eb5f5 | 2015-12-04 22:08:22 +1100 | [diff] [blame] | 632 | if (!sscreen) |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 633 | return; |
| 634 | |
Marek Olšák | ac330d4 | 2014-04-09 00:26:32 +0200 | [diff] [blame] | 635 | if (!sscreen->b.ws->unref(sscreen->b.ws)) |
Christian König | 4871128 | 2013-09-25 13:59:56 +0200 | [diff] [blame] | 636 | return; |
| 637 | |
Marek Olšák | 70de433 | 2016-01-27 00:29:53 +0100 | [diff] [blame] | 638 | /* Free shader parts. */ |
| 639 | for (i = 0; i < ARRAY_SIZE(parts); i++) { |
| 640 | while (parts[i]) { |
| 641 | struct si_shader_part *part = parts[i]; |
| 642 | |
| 643 | parts[i] = part->next; |
| 644 | radeon_shader_binary_clean(&part->binary); |
| 645 | FREE(part); |
| 646 | } |
| 647 | } |
| 648 | pipe_mutex_destroy(sscreen->shader_parts_mutex); |
Marek Olšák | ff360a5 | 2016-02-11 15:49:34 +0100 | [diff] [blame] | 649 | si_destroy_shader_cache(sscreen); |
Tom Stellard | e28f9d0 | 2015-01-07 13:49:12 -0500 | [diff] [blame] | 650 | r600_destroy_common_screen(&sscreen->b); |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 651 | } |
| 652 | |
Marek Olšák | 0608304 | 2015-10-19 02:45:56 +0200 | [diff] [blame] | 653 | static bool si_init_gs_info(struct si_screen *sscreen) |
| 654 | { |
| 655 | switch (sscreen->b.family) { |
| 656 | case CHIP_OLAND: |
| 657 | case CHIP_HAINAN: |
| 658 | case CHIP_KAVERI: |
| 659 | case CHIP_KABINI: |
| 660 | case CHIP_MULLINS: |
| 661 | case CHIP_ICELAND: |
| 662 | case CHIP_CARRIZO: |
Alex Deucher | 830e57b | 2015-10-23 18:31:57 -0400 | [diff] [blame] | 663 | case CHIP_STONEY: |
Marek Olšák | 0608304 | 2015-10-19 02:45:56 +0200 | [diff] [blame] | 664 | sscreen->gs_table_depth = 16; |
| 665 | return true; |
| 666 | case CHIP_TAHITI: |
| 667 | case CHIP_PITCAIRN: |
| 668 | case CHIP_VERDE: |
| 669 | case CHIP_BONAIRE: |
| 670 | case CHIP_HAWAII: |
| 671 | case CHIP_TONGA: |
| 672 | case CHIP_FIJI: |
Sonny Jiang | 42e442d | 2015-11-04 16:13:07 -0500 | [diff] [blame] | 673 | case CHIP_POLARIS10: |
| 674 | case CHIP_POLARIS11: |
Marek Olšák | 0608304 | 2015-10-19 02:45:56 +0200 | [diff] [blame] | 675 | sscreen->gs_table_depth = 32; |
| 676 | return true; |
| 677 | default: |
| 678 | return false; |
| 679 | } |
| 680 | } |
| 681 | |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 682 | struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) |
| 683 | { |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 684 | struct si_screen *sscreen = CALLOC_STRUCT(si_screen); |
Michel Dänzer | d64adc3 | 2015-03-26 11:32:59 +0900 | [diff] [blame] | 685 | |
Edward O'Callaghan | 13eb5f5 | 2015-12-04 22:08:22 +1100 | [diff] [blame] | 686 | if (!sscreen) { |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 687 | return NULL; |
| 688 | } |
| 689 | |
Marek Olšák | 09fc5d6 | 2013-09-22 21:47:35 +0200 | [diff] [blame] | 690 | /* Set functions first. */ |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 691 | sscreen->b.b.context_create = si_create_context; |
| 692 | sscreen->b.b.destroy = si_destroy_screen; |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 693 | sscreen->b.b.get_param = si_get_param; |
| 694 | sscreen->b.b.get_shader_param = si_get_shader_param; |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 695 | sscreen->b.b.is_format_supported = si_is_format_supported; |
Tom Stellard | 7b4592a | 2014-01-28 06:51:50 -0800 | [diff] [blame] | 696 | sscreen->b.b.resource_create = r600_resource_create_common; |
Marek Olšák | 09fc5d6 | 2013-09-22 21:47:35 +0200 | [diff] [blame] | 697 | |
Marek Olšák | ec74dee | 2016-02-25 22:32:26 +0100 | [diff] [blame] | 698 | si_init_screen_state_functions(sscreen); |
| 699 | |
Marek Olšák | 955505f | 2014-08-07 21:14:31 +0200 | [diff] [blame] | 700 | if (!r600_common_screen_init(&sscreen->b, ws) || |
Marek Olšák | ff360a5 | 2016-02-11 15:49:34 +0100 | [diff] [blame] | 701 | !si_init_gs_info(sscreen) || |
| 702 | !si_init_shader_cache(sscreen)) { |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 703 | FREE(sscreen); |
Marek Olšák | 1bb77f8 | 2013-09-22 22:12:18 +0200 | [diff] [blame] | 704 | return NULL; |
| 705 | } |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 706 | |
Nicolai Hähnle | ad22006 | 2015-11-25 15:30:03 +0100 | [diff] [blame] | 707 | if (!debug_get_bool_option("RADEON_DISABLE_PERFCOUNTERS", FALSE)) |
| 708 | si_init_perfcounters(sscreen); |
| 709 | |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 710 | sscreen->b.has_cp_dma = true; |
Marek Olšák | a66d934 | 2014-07-08 02:50:57 +0200 | [diff] [blame] | 711 | sscreen->b.has_streamout = true; |
Marek Olšák | 70de433 | 2016-01-27 00:29:53 +0100 | [diff] [blame] | 712 | pipe_mutex_init(sscreen->shader_parts_mutex); |
Marek Olšák | 9aaf28d | 2016-01-28 01:29:59 +0100 | [diff] [blame] | 713 | sscreen->use_monolithic_shaders = |
| 714 | HAVE_LLVM < 0x0308 || |
| 715 | (sscreen->b.debug_flags & DBG_MONOLITHIC_SHADERS) != 0; |
Marek Olšák | bba39d8 | 2013-11-28 15:09:35 +0100 | [diff] [blame] | 716 | |
Marek Olšák | 0cb9de1 | 2013-09-22 15:34:12 +0200 | [diff] [blame] | 717 | if (debug_get_bool_option("RADEON_DUMP_SHADERS", FALSE)) |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 718 | sscreen->b.debug_flags |= DBG_FS | DBG_VS | DBG_GS | DBG_PS | DBG_CS; |
Marek Olšák | 0cb9de1 | 2013-09-22 15:34:12 +0200 | [diff] [blame] | 719 | |
Marek Olšák | b893bbf | 2013-10-03 16:39:50 +0200 | [diff] [blame] | 720 | /* Create the auxiliary context. This must be done last. */ |
Marek Olšák | 0fc21ec | 2015-07-25 18:40:59 +0200 | [diff] [blame] | 721 | sscreen->b.aux_context = sscreen->b.b.context_create(&sscreen->b.b, NULL, 0); |
Marek Olšák | b893bbf | 2013-10-03 16:39:50 +0200 | [diff] [blame] | 722 | |
Marek Olšák | 3af28e5 | 2014-09-05 20:15:16 +0200 | [diff] [blame] | 723 | if (sscreen->b.debug_flags & DBG_TEST_DMA) |
| 724 | r600_test_dma(&sscreen->b); |
| 725 | |
Andreas Hartmetz | aa7ae4f | 2014-01-11 16:01:11 +0100 | [diff] [blame] | 726 | return &sscreen->b.b; |
Tom Stellard | a75c616 | 2012-01-06 17:38:37 -0500 | [diff] [blame] | 727 | } |