Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [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 | 330b6c8 | 2012-03-05 15:17:00 +0100 | [diff] [blame] | 23 | #include "r600_pipe.h" |
| 24 | #include "r600_public.h" |
Vadim Girlin | 022122e | 2013-02-01 11:45:35 +0400 | [diff] [blame] | 25 | #include "r600_isa.h" |
Marek Olšák | 2ca73bc | 2013-03-01 15:32:46 +0100 | [diff] [blame] | 26 | #include "evergreen_compute.h" |
Marek Olšák | c77917d | 2013-02-27 21:24:02 +0100 | [diff] [blame] | 27 | #include "r600d.h" |
Marek Olšák | 330b6c8 | 2012-03-05 15:17:00 +0100 | [diff] [blame] | 28 | |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 29 | #include "sb/sb_public.h" |
| 30 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 31 | #include <errno.h> |
Marek Olšák | 330b6c8 | 2012-03-05 15:17:00 +0100 | [diff] [blame] | 32 | #include "pipe/p_shader_tokens.h" |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 33 | #include "util/u_debug.h" |
Marek Olšák | 9f06966 | 2012-12-03 21:31:04 +0100 | [diff] [blame] | 34 | #include "util/u_memory.h" |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 35 | #include "util/u_simple_shaders.h" |
Marek Olšák | 428855e | 2012-04-11 16:00:09 +0200 | [diff] [blame] | 36 | #include "util/u_upload_mgr.h" |
Jerome Glisse | 325422c | 2013-01-07 17:45:59 -0500 | [diff] [blame] | 37 | #include "util/u_math.h" |
Kai Wasserbäch | 8fb7f1a | 2011-08-27 17:51:51 +0200 | [diff] [blame] | 38 | #include "vl/vl_decoder.h" |
| 39 | #include "vl/vl_video_buffer.h" |
Christian König | 7bcfb0b | 2013-10-17 06:21:40 -0600 | [diff] [blame] | 40 | #include "radeon/radeon_video.h" |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 41 | #include "radeon/radeon_uvd.h" |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 42 | #include "os/os_time.h" |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 43 | |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 44 | static const struct debug_named_value r600_debug_options[] = { |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 45 | /* features */ |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 46 | #if defined(R600_USE_LLVM) |
Michel Dänzer | 7286739 | 2014-04-16 15:00:09 +0900 | [diff] [blame] | 47 | { "llvm", DBG_LLVM, "Enable the LLVM shader compiler" }, |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 48 | #endif |
Marek Olšák | e4e655f | 2013-03-05 01:15:45 +0100 | [diff] [blame] | 49 | { "nocpdma", DBG_NO_CP_DMA, "Disable CP DMA" }, |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 50 | |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 51 | /* shader backend */ |
Vadim Girlin | f7217b9 | 2013-08-24 00:54:54 +0400 | [diff] [blame] | 52 | { "nosb", DBG_NO_SB, "Disable sb backend for graphics shaders" }, |
| 53 | { "sbcl", DBG_SB_CS, "Enable sb backend for compute shaders" }, |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 54 | { "sbdry", DBG_SB_DRY_RUN, "Don't use optimized bytecode (just print the dumps)" }, |
| 55 | { "sbstat", DBG_SB_STAT, "Print optimization statistics for shaders" }, |
| 56 | { "sbdump", DBG_SB_DUMP, "Print IR dumps after some optimization passes" }, |
Vadim Girlin | 188c893 | 2013-04-23 10:34:00 +0400 | [diff] [blame] | 57 | { "sbnofallback", DBG_SB_NO_FALLBACK, "Abort on errors instead of fallback" }, |
Vadim Girlin | 4ca67db | 2013-05-03 12:01:20 +0400 | [diff] [blame] | 58 | { "sbdisasm", DBG_SB_DISASM, "Use sb disassembler for shader dumps" }, |
Vadim Girlin | 758ac6f | 2013-06-05 20:55:31 +0400 | [diff] [blame] | 59 | { "sbsafemath", DBG_SB_SAFEMATH, "Disable unsafe math optimizations" }, |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 60 | |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 61 | DEBUG_NAMED_VALUE_END /* must be last */ |
| 62 | }; |
| 63 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 64 | /* |
| 65 | * pipe_context |
| 66 | */ |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 67 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 68 | static void r600_destroy_context(struct pipe_context *context) |
| 69 | { |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 70 | struct r600_context *rctx = (struct r600_context *)context; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 71 | |
Vadim Girlin | 022122e | 2013-02-01 11:45:35 +0400 | [diff] [blame] | 72 | r600_isa_destroy(rctx->isa); |
| 73 | |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 74 | r600_sb_context_destroy(rctx->sb_context); |
| 75 | |
Marek Olšák | 7835401 | 2012-08-26 22:38:35 +0200 | [diff] [blame] | 76 | pipe_resource_reference((struct pipe_resource**)&rctx->dummy_cmask, NULL); |
| 77 | pipe_resource_reference((struct pipe_resource**)&rctx->dummy_fmask, NULL); |
| 78 | |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 79 | if (rctx->dummy_pixel_shader) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 80 | rctx->b.b.delete_fs_state(&rctx->b.b, rctx->dummy_pixel_shader); |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 81 | } |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 82 | if (rctx->custom_dsa_flush) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 83 | rctx->b.b.delete_depth_stencil_alpha_state(&rctx->b.b, rctx->custom_dsa_flush); |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 84 | } |
Marek Olšák | 0f86915 | 2012-08-09 17:21:10 +0200 | [diff] [blame] | 85 | if (rctx->custom_blend_resolve) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 86 | rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_resolve); |
Marek Olšák | 0f86915 | 2012-08-09 17:21:10 +0200 | [diff] [blame] | 87 | } |
Marek Olšák | a3d9d7e | 2012-08-12 20:06:33 +0200 | [diff] [blame] | 88 | if (rctx->custom_blend_decompress) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 89 | rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_decompress); |
Marek Olšák | a3d9d7e | 2012-08-12 20:06:33 +0200 | [diff] [blame] | 90 | } |
Grigori Goronzy | edbbfac | 2013-09-11 01:41:40 +0200 | [diff] [blame] | 91 | if (rctx->custom_blend_fastclear) { |
| 92 | rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_fastclear); |
| 93 | } |
Marek Olšák | c8b06dc | 2012-09-18 19:42:29 +0200 | [diff] [blame] | 94 | util_unreference_framebuffer_state(&rctx->framebuffer.state); |
Tilman Sauerbeck | ecb1b8b | 2010-10-31 12:16:03 +0100 | [diff] [blame] | 95 | |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 96 | if (rctx->blitter) { |
| 97 | util_blitter_destroy(rctx->blitter); |
| 98 | } |
Marek Olšák | d225d07 | 2012-12-09 18:51:31 +0100 | [diff] [blame] | 99 | if (rctx->allocator_fetch_shader) { |
| 100 | u_suballocator_destroy(rctx->allocator_fetch_shader); |
| 101 | } |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 102 | |
Marek Olšák | e363dd5 | 2012-03-05 16:20:05 +0100 | [diff] [blame] | 103 | r600_release_command_buffer(&rctx->start_cs_cmd); |
Marek Olšák | 9670e72 | 2012-02-21 18:08:32 +0100 | [diff] [blame] | 104 | |
Aaron Watry | 3ddabe0 | 2013-11-15 16:09:41 -0600 | [diff] [blame] | 105 | FREE(rctx->start_compute_cs_cmd.buf); |
| 106 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 107 | r600_common_context_cleanup(&rctx->b); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 108 | FREE(rctx); |
| 109 | } |
| 110 | |
Marek Olšák | 0fc21ec | 2015-07-25 18:40:59 +0200 | [diff] [blame] | 111 | static struct pipe_context *r600_create_context(struct pipe_screen *screen, |
| 112 | void *priv, unsigned flags) |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 113 | { |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 114 | struct r600_context *rctx = CALLOC_STRUCT(r600_context); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 115 | struct r600_screen* rscreen = (struct r600_screen *)screen; |
Marek Olšák | dd72c32 | 2014-04-11 22:14:27 +0200 | [diff] [blame] | 116 | struct radeon_winsys *ws = rscreen->b.ws; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 117 | |
| 118 | if (rctx == NULL) |
| 119 | return NULL; |
Marek Olšák | f0b202e | 2011-02-08 17:30:39 +0100 | [diff] [blame] | 120 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 121 | rctx->b.b.screen = screen; |
| 122 | rctx->b.b.priv = priv; |
| 123 | rctx->b.b.destroy = r600_destroy_context; |
Grazvydas Ignotas | 3206d4e | 2015-08-10 00:42:32 +0300 | [diff] [blame] | 124 | rctx->b.set_atom_dirty = (void *)r600_set_atom_dirty; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 125 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 126 | if (!r600_common_context_init(&rctx->b, &rscreen->b)) |
| 127 | goto fail; |
| 128 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 129 | rctx->screen = rscreen; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 130 | rctx->keep_tiling_flags = rscreen->b.info.drm_minor >= 12; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 131 | |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 132 | r600_init_blit_functions(rctx); |
Marek Olšák | f96df32 | 2012-09-10 00:28:46 +0200 | [diff] [blame] | 133 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 134 | if (rscreen->b.info.has_uvd) { |
| 135 | rctx->b.b.create_video_codec = r600_uvd_create_decoder; |
| 136 | rctx->b.b.create_video_buffer = r600_video_buffer_create; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 137 | } else { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 138 | rctx->b.b.create_video_codec = vl_create_decoder; |
| 139 | rctx->b.b.create_video_buffer = vl_video_buffer_create; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 140 | } |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 141 | |
Marek Olšák | f96df32 | 2012-09-10 00:28:46 +0200 | [diff] [blame] | 142 | r600_init_common_state_functions(rctx); |
| 143 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 144 | switch (rctx->b.chip_class) { |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 145 | case R600: |
| 146 | case R700: |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 147 | r600_init_state_functions(rctx); |
Marek Olšák | f126253 | 2012-01-31 10:50:51 +0100 | [diff] [blame] | 148 | r600_init_atom_start_cs(rctx); |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 149 | rctx->custom_dsa_flush = r600_create_db_flush_dsa(rctx); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 150 | rctx->custom_blend_resolve = rctx->b.chip_class == R700 ? r700_create_resolve_blend(rctx) |
Marek Olšák | 7835401 | 2012-08-26 22:38:35 +0200 | [diff] [blame] | 151 | : r600_create_resolve_blend(rctx); |
Marek Olšák | 8698a3b | 2012-08-02 22:31:22 +0200 | [diff] [blame] | 152 | rctx->custom_blend_decompress = r600_create_decompress_blend(rctx); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 153 | rctx->has_vertex_cache = !(rctx->b.family == CHIP_RV610 || |
| 154 | rctx->b.family == CHIP_RV620 || |
| 155 | rctx->b.family == CHIP_RS780 || |
| 156 | rctx->b.family == CHIP_RS880 || |
| 157 | rctx->b.family == CHIP_RV710); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 158 | break; |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 159 | case EVERGREEN: |
| 160 | case CAYMAN: |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 161 | evergreen_init_state_functions(rctx); |
Marek Olšák | f126253 | 2012-01-31 10:50:51 +0100 | [diff] [blame] | 162 | evergreen_init_atom_start_cs(rctx); |
Tom Stellard | 5016fe2 | 2012-06-25 17:56:01 +0000 | [diff] [blame] | 163 | evergreen_init_atom_start_compute_cs(rctx); |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 164 | rctx->custom_dsa_flush = evergreen_create_db_flush_dsa(rctx); |
Marek Olšák | 0f86915 | 2012-08-09 17:21:10 +0200 | [diff] [blame] | 165 | rctx->custom_blend_resolve = evergreen_create_resolve_blend(rctx); |
Marek Olšák | a3d9d7e | 2012-08-12 20:06:33 +0200 | [diff] [blame] | 166 | rctx->custom_blend_decompress = evergreen_create_decompress_blend(rctx); |
Grigori Goronzy | edbbfac | 2013-09-11 01:41:40 +0200 | [diff] [blame] | 167 | rctx->custom_blend_fastclear = evergreen_create_fastclear_blend(rctx); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 168 | rctx->has_vertex_cache = !(rctx->b.family == CHIP_CEDAR || |
| 169 | rctx->b.family == CHIP_PALM || |
| 170 | rctx->b.family == CHIP_SUMO || |
| 171 | rctx->b.family == CHIP_SUMO2 || |
| 172 | rctx->b.family == CHIP_CAICOS || |
| 173 | rctx->b.family == CHIP_CAYMAN || |
| 174 | rctx->b.family == CHIP_ARUBA); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 175 | break; |
| 176 | default: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 177 | R600_ERR("Unsupported chip class %d.\n", rctx->b.chip_class); |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 178 | goto fail; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 179 | } |
| 180 | |
Marek Olšák | 6cc8f6c | 2015-11-07 14:00:30 +0100 | [diff] [blame^] | 181 | rctx->b.gfx.cs = ws->cs_create(rctx->b.ctx, RING_GFX, |
| 182 | r600_context_gfx_flush, rctx, |
| 183 | rscreen->b.trace_bo ? |
| 184 | rscreen->b.trace_bo->cs_buf : NULL); |
| 185 | rctx->b.gfx.flush = r600_context_gfx_flush; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 186 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 187 | rctx->allocator_fetch_shader = u_suballocator_create(&rctx->b.b, 64 * 1024, 256, |
Marek Olšák | c321144 | 2014-02-03 03:42:17 +0100 | [diff] [blame] | 188 | 0, PIPE_USAGE_DEFAULT, FALSE); |
Jerome Glisse | d499ff9 | 2013-01-04 11:46:13 -0500 | [diff] [blame] | 189 | if (!rctx->allocator_fetch_shader) |
| 190 | goto fail; |
Marek Olšák | d225d07 | 2012-12-09 18:51:31 +0100 | [diff] [blame] | 191 | |
Vadim Girlin | 022122e | 2013-02-01 11:45:35 +0400 | [diff] [blame] | 192 | rctx->isa = calloc(1, sizeof(struct r600_isa)); |
| 193 | if (!rctx->isa || r600_isa_init(rctx, rctx->isa)) |
Jerome Glisse | d499ff9 | 2013-01-04 11:46:13 -0500 | [diff] [blame] | 194 | goto fail; |
Marek Olšák | 8df3855 | 2012-12-09 17:56:26 +0100 | [diff] [blame] | 195 | |
Marek Olšák | d13d2fd | 2014-09-06 17:07:50 +0200 | [diff] [blame] | 196 | if (rscreen->b.debug_flags & DBG_FORCE_DMA) |
| 197 | rctx->b.b.resource_copy_region = rctx->b.dma_copy; |
| 198 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 199 | rctx->blitter = util_blitter_create(&rctx->b.b); |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 200 | if (rctx->blitter == NULL) |
| 201 | goto fail; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 202 | util_blitter_set_texture_multisample(rctx->blitter, rscreen->has_msaa); |
Marek Olšák | 187d7fb | 2012-08-24 05:57:22 +0200 | [diff] [blame] | 203 | rctx->blitter->draw_rectangle = r600_draw_rectangle; |
Dave Airlie | d59498b | 2010-10-13 15:22:04 +1000 | [diff] [blame] | 204 | |
Marek Olšák | c383a3c | 2012-09-10 05:56:46 +0200 | [diff] [blame] | 205 | r600_begin_new_cs(rctx); |
Marek Olšák | 4e5c70e | 2014-01-21 18:01:01 +0100 | [diff] [blame] | 206 | r600_query_init_backend_mask(&rctx->b); /* this emits commands and must be last */ |
Marek Olšák | bbad510 | 2011-10-28 22:31:34 +0200 | [diff] [blame] | 207 | |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 208 | rctx->dummy_pixel_shader = |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 209 | util_make_fragment_cloneinput_shader(&rctx->b.b, 0, |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 210 | TGSI_SEMANTIC_GENERIC, |
| 211 | TGSI_INTERPOLATE_CONSTANT); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 212 | rctx->b.b.bind_fs_state(&rctx->b.b, rctx->dummy_pixel_shader); |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 213 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 214 | return &rctx->b.b; |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 215 | |
| 216 | fail: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 217 | r600_destroy_context(&rctx->b.b); |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 218 | return NULL; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | /* |
| 222 | * pipe_screen |
| 223 | */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 224 | |
| 225 | static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param) |
| 226 | { |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 227 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 228 | enum radeon_family family = rscreen->b.family; |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 229 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 230 | switch (param) { |
| 231 | /* Supported features (boolean caps). */ |
| 232 | case PIPE_CAP_NPOT_TEXTURES: |
Ilia Mirkin | 12d39b4 | 2013-10-04 04:32:15 -0400 | [diff] [blame] | 233 | case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 234 | case PIPE_CAP_TWO_SIDED_STENCIL: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 235 | case PIPE_CAP_ANISOTROPIC_FILTER: |
| 236 | case PIPE_CAP_POINT_SPRITE: |
| 237 | case PIPE_CAP_OCCLUSION_QUERY: |
| 238 | case PIPE_CAP_TEXTURE_SHADOW_MAP: |
| 239 | case PIPE_CAP_TEXTURE_MIRROR_CLAMP: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 240 | case PIPE_CAP_BLEND_EQUATION_SEPARATE: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 241 | case PIPE_CAP_TEXTURE_SWIZZLE: |
Marek Olšák | dc4c821 | 2012-01-10 00:19:00 +0100 | [diff] [blame] | 242 | case PIPE_CAP_DEPTH_CLIP_DISABLE: |
Dave Airlie | 39d1feb | 2010-10-06 10:14:33 +1000 | [diff] [blame] | 243 | case PIPE_CAP_SHADER_STENCIL_EXPORT: |
Marek Olšák | 95c7881 | 2011-03-05 16:06:10 +0100 | [diff] [blame] | 244 | case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: |
Marek Olšák | 4a7f013 | 2011-03-29 18:18:05 +0200 | [diff] [blame] | 245 | case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 246 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: |
| 247 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: |
Dave Airlie | 13c9a85 | 2011-06-15 15:15:41 +1000 | [diff] [blame] | 248 | case PIPE_CAP_SM3: |
Marek Olšák | badf033 | 2011-06-19 23:41:02 +0200 | [diff] [blame] | 249 | case PIPE_CAP_SEAMLESS_CUBE_MAP: |
Marek Olšák | 01680ce | 2011-08-16 09:47:16 +0200 | [diff] [blame] | 250 | case PIPE_CAP_PRIMITIVE_RESTART: |
Marek Olšák | 3d13b08 | 2011-09-27 23:08:04 +0200 | [diff] [blame] | 251 | case PIPE_CAP_CONDITIONAL_RENDER: |
Marek Olšák | ba89086 | 2011-09-27 23:18:17 +0200 | [diff] [blame] | 252 | case PIPE_CAP_TEXTURE_BARRIER: |
Marek Olšák | bc1c836 | 2012-01-23 03:11:17 +0100 | [diff] [blame] | 253 | case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: |
Marek Olšák | b0b8121 | 2012-02-16 14:45:35 +0100 | [diff] [blame] | 254 | case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: |
Marek Olšák | 7f1cbf1 | 2012-03-08 12:20:01 +0100 | [diff] [blame] | 255 | case PIPE_CAP_TGSI_INSTANCEID: |
Marek Olšák | 7fe3631 | 2012-04-10 05:14:26 +0200 | [diff] [blame] | 256 | case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: |
| 257 | case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: |
| 258 | case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: |
Marek Olšák | 437ab1d | 2012-04-24 15:19:31 +0200 | [diff] [blame] | 259 | case PIPE_CAP_USER_INDEX_BUFFERS: |
| 260 | case PIPE_CAP_USER_CONSTANT_BUFFERS: |
Fredrik Höglund | af37212 | 2012-06-18 22:50:02 +0200 | [diff] [blame] | 261 | case PIPE_CAP_START_INSTANCE: |
Marek Olšák | 9d699cd | 2012-07-15 03:38:42 +0200 | [diff] [blame] | 262 | case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: |
Dave Airlie | d23aa65 | 2012-12-16 10:31:32 +0000 | [diff] [blame] | 263 | case PIPE_CAP_TEXTURE_BUFFER_OBJECTS: |
Marek Olšák | 3e10ab6 | 2013-03-14 17:18:43 +0100 | [diff] [blame] | 264 | case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: |
Marek Olšák | dfe5367 | 2013-04-10 20:45:01 +0200 | [diff] [blame] | 265 | case PIPE_CAP_QUERY_PIPELINE_STATISTICS: |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 266 | case PIPE_CAP_TEXTURE_MULTISAMPLE: |
Christoph Bumiller | b206f59 | 2014-05-17 01:20:20 +0200 | [diff] [blame] | 267 | case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: |
| 268 | case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION: |
Marek Olšák | 13b9359 | 2014-08-20 19:17:39 +0200 | [diff] [blame] | 269 | case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT: |
Glenn Kennard | a327fa3 | 2014-09-10 11:54:40 +0200 | [diff] [blame] | 270 | case PIPE_CAP_SAMPLE_SHADING: |
Mathias Fröhlich | 5608813 | 2014-09-14 15:17:07 +0200 | [diff] [blame] | 271 | case PIPE_CAP_CLIP_HALFZ: |
Ilia Mirkin | 7c211a1 | 2015-02-01 09:01:50 -0500 | [diff] [blame] | 272 | case PIPE_CAP_POLYGON_OFFSET_CLAMP: |
Edward O'Callaghan | 8254672 | 2015-07-27 11:01:47 +1000 | [diff] [blame] | 273 | case PIPE_CAP_CONDITIONAL_RENDER_INVERTED: |
Marek Olšák | 44dc1d3 | 2015-08-10 19:37:01 +0200 | [diff] [blame] | 274 | case PIPE_CAP_TEXTURE_FLOAT_LINEAR: |
| 275 | case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR: |
Ilia Mirkin | ec3fe42 | 2015-09-10 22:33:34 -0400 | [diff] [blame] | 276 | case PIPE_CAP_TGSI_TXQS: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 277 | return 1; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 278 | |
Marek Olšák | 914365c | 2015-04-29 15:27:50 +0200 | [diff] [blame] | 279 | case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: |
| 280 | return rscreen->b.info.drm_major == 2 && rscreen->b.info.drm_minor >= 43; |
| 281 | |
Marek Olšák | 7713d59 | 2015-02-10 16:02:54 +0100 | [diff] [blame] | 282 | case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: |
| 283 | return !R600_BIG_ENDIAN && rscreen->b.info.has_userptr; |
| 284 | |
Tom Stellard | f61e382 | 2014-02-24 16:51:05 -0500 | [diff] [blame] | 285 | case PIPE_CAP_COMPUTE: |
| 286 | return rscreen->b.chip_class > R700; |
| 287 | |
Christoph Bumiller | 8acaf86 | 2013-03-15 22:11:31 +0100 | [diff] [blame] | 288 | case PIPE_CAP_TGSI_TEXCOORD: |
| 289 | return 0; |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 290 | |
Dave Airlie | 76ba50a | 2013-11-27 19:47:51 +1000 | [diff] [blame] | 291 | case PIPE_CAP_FAKE_SW_MSAA: |
| 292 | return 0; |
| 293 | |
Marek Olšák | 52cb395 | 2013-05-02 03:24:33 +0200 | [diff] [blame] | 294 | case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 295 | return MIN2(rscreen->b.info.vram_size, 0xFFFFFFFF); |
Marek Olšák | 52cb395 | 2013-05-02 03:24:33 +0200 | [diff] [blame] | 296 | |
Marek Olšák | c9f2af3 | 2012-10-28 17:52:48 +0100 | [diff] [blame] | 297 | case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: |
Marek Olšák | d172fa8 | 2012-11-22 22:40:06 +0100 | [diff] [blame] | 298 | return R600_MAP_BUFFER_ALIGNMENT; |
Marek Olšák | c9f2af3 | 2012-10-28 17:52:48 +0100 | [diff] [blame] | 299 | |
Marek Olšák | 1b749dc | 2012-04-24 17:31:17 +0200 | [diff] [blame] | 300 | case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: |
| 301 | return 256; |
| 302 | |
Fredrik Höglund | fb69dbb | 2013-03-22 17:14:43 +0100 | [diff] [blame] | 303 | case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: |
| 304 | return 1; |
| 305 | |
Marek Olšák | 171be75 | 2012-01-24 22:23:01 +0100 | [diff] [blame] | 306 | case PIPE_CAP_GLSL_FEATURE_LEVEL: |
Dave Airlie | 79ea0f4 | 2014-01-30 04:19:57 +0000 | [diff] [blame] | 307 | if (family >= CHIP_CEDAR) |
Glenn Kennard | 24a1a15 | 2015-10-07 17:17:34 +0200 | [diff] [blame] | 308 | return 410; |
Dave Airlie | 79ea0f4 | 2014-01-30 04:19:57 +0000 | [diff] [blame] | 309 | /* pre-evergreen geom shaders need newer kernel */ |
| 310 | if (rscreen->b.info.drm_minor >= 37) |
| 311 | return 330; |
| 312 | return 140; |
Marek Olšák | 171be75 | 2012-01-24 22:23:01 +0100 | [diff] [blame] | 313 | |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 314 | /* Supported except the original R600. */ |
Alex Deucher | d6fea4a | 2011-03-14 17:47:21 -0400 | [diff] [blame] | 315 | case PIPE_CAP_INDEP_BLEND_ENABLE: |
Dave Airlie | de48199 | 2011-04-25 06:55:09 +1000 | [diff] [blame] | 316 | case PIPE_CAP_INDEP_BLEND_FUNC: |
Alex Deucher | d6fea4a | 2011-03-14 17:47:21 -0400 | [diff] [blame] | 317 | /* R600 doesn't support per-MRT blends */ |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 318 | return family == CHIP_R600 ? 0 : 1; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 319 | |
Marek Olšák | d931b0d | 2011-05-02 02:38:20 +0200 | [diff] [blame] | 320 | /* Supported on Evergreen. */ |
Marek Olšák | d931b0d | 2011-05-02 02:38:20 +0200 | [diff] [blame] | 321 | case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: |
Dave Airlie | eb44c36d | 2012-11-03 20:53:33 +1000 | [diff] [blame] | 322 | case PIPE_CAP_CUBE_MAP_ARRAY: |
Glenn Kennard | 3a9278b | 2014-07-20 15:59:16 +0200 | [diff] [blame] | 323 | case PIPE_CAP_TEXTURE_GATHER_SM5: |
Glenn Kennard | a48b615 | 2014-07-23 10:48:17 +0200 | [diff] [blame] | 324 | case PIPE_CAP_TEXTURE_QUERY_LOD: |
Glenn Kennard | afa7df9 | 2014-08-15 10:30:58 +0200 | [diff] [blame] | 325 | case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE: |
Glenn Kennard | c878d61 | 2015-10-16 01:53:47 +0200 | [diff] [blame] | 326 | case PIPE_CAP_SAMPLER_VIEW_TARGET: |
Marek Olšák | d931b0d | 2011-05-02 02:38:20 +0200 | [diff] [blame] | 327 | return family >= CHIP_CEDAR ? 1 : 0; |
Glenn Kennard | 3a9278b | 2014-07-20 15:59:16 +0200 | [diff] [blame] | 328 | case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: |
| 329 | return family >= CHIP_CEDAR ? 4 : 0; |
Glenn Kennard | d80701d | 2015-02-24 15:59:16 +0100 | [diff] [blame] | 330 | case PIPE_CAP_DRAW_INDIRECT: |
| 331 | /* kernel command checker support is also required */ |
| 332 | return family >= CHIP_CEDAR && rscreen->b.info.drm_minor >= 41; |
Marek Olšák | fc8e30e | 2011-04-17 01:57:13 +0200 | [diff] [blame] | 333 | |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 334 | /* Unsupported features. */ |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 335 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: |
| 336 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: |
Marek Olšák | a3bfbcc | 2011-12-17 15:13:23 +0100 | [diff] [blame] | 337 | case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: |
Marek Olšák | bc1c836 | 2012-01-23 03:11:17 +0100 | [diff] [blame] | 338 | case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: |
| 339 | case PIPE_CAP_VERTEX_COLOR_CLAMPED: |
Marek Olšák | 7fe3631 | 2012-04-10 05:14:26 +0200 | [diff] [blame] | 340 | case PIPE_CAP_USER_VERTEX_BUFFERS: |
Ilia Mirkin | d95df4f | 2014-04-26 23:44:57 -0400 | [diff] [blame] | 341 | case PIPE_CAP_TEXTURE_GATHER_OFFSETS: |
Roland Scheidegger | ade8b26 | 2014-12-12 04:13:43 +0100 | [diff] [blame] | 342 | case PIPE_CAP_VERTEXID_NOBASE: |
Marek Olšák | 2622293 | 2015-06-12 14:24:17 +0200 | [diff] [blame] | 343 | case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: |
Marek Olšák | 3b7800e | 2015-08-10 02:11:48 +0200 | [diff] [blame] | 344 | case PIPE_CAP_DEPTH_BOUNDS_TEST: |
Marek Olšák | f3b37e3 | 2015-09-27 19:32:07 +0200 | [diff] [blame] | 345 | case PIPE_CAP_FORCE_PERSAMPLE_INTERP: |
Marek Olšák | d74e7b6 | 2015-09-27 21:02:15 +0200 | [diff] [blame] | 346 | case PIPE_CAP_SHAREABLE_SHADERS: |
Marek Olšák | ce9db16 | 2015-08-24 01:19:35 +0200 | [diff] [blame] | 347 | case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS: |
Ilia Mirkin | 3695b25 | 2015-11-09 13:27:07 -0500 | [diff] [blame] | 348 | case PIPE_CAP_CLEAR_TEXTURE: |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 349 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 350 | |
Marek Olšák | 543b233 | 2011-11-08 21:58:27 +0100 | [diff] [blame] | 351 | /* Stream output. */ |
| 352 | case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: |
Marek Olšák | bba39d8 | 2013-11-28 15:09:35 +0100 | [diff] [blame] | 353 | return rscreen->b.has_streamout ? 4 : 0; |
Marek Olšák | 15146fd | 2012-01-25 03:23:27 +0100 | [diff] [blame] | 354 | case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: |
Marek Olšák | bba39d8 | 2013-11-28 15:09:35 +0100 | [diff] [blame] | 355 | return rscreen->b.has_streamout ? 1 : 0; |
Marek Olšák | 543b233 | 2011-11-08 21:58:27 +0100 | [diff] [blame] | 356 | case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: |
| 357 | case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: |
Marek Olšák | b78b624 | 2012-10-26 18:41:49 +0200 | [diff] [blame] | 358 | return 32*4; |
Marek Olšák | 543b233 | 2011-11-08 21:58:27 +0100 | [diff] [blame] | 359 | |
Grigori Goronzy | d34d5fd | 2014-02-09 22:56:20 +0100 | [diff] [blame] | 360 | /* Geometry shader output. */ |
| 361 | case PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES: |
| 362 | return 1024; |
| 363 | case PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: |
| 364 | return 16384; |
Ilia Mirkin | 746e526 | 2014-06-26 20:01:50 -0400 | [diff] [blame] | 365 | case PIPE_CAP_MAX_VERTEX_STREAMS: |
Glenn Kennard | 3bfa345 | 2015-07-09 16:37:28 +1000 | [diff] [blame] | 366 | return family >= CHIP_CEDAR ? 4 : 1; |
Grigori Goronzy | d34d5fd | 2014-02-09 22:56:20 +0100 | [diff] [blame] | 367 | |
Timothy Arceri | 89e6806 | 2014-08-19 21:09:58 -1000 | [diff] [blame] | 368 | case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE: |
| 369 | return 2047; |
| 370 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 371 | /* Texturing. */ |
| 372 | case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 373 | case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 374 | if (family >= CHIP_CEDAR) |
| 375 | return 15; |
| 376 | else |
| 377 | return 14; |
Marek Olšák | 4f1f323 | 2014-03-09 20:03:57 +0100 | [diff] [blame] | 378 | case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: |
| 379 | /* textures support 8192, but layered rendering supports 2048 */ |
| 380 | return 12; |
Marek Olšák | b37931f | 2011-09-04 04:41:52 +0200 | [diff] [blame] | 381 | case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: |
Marek Olšák | 4f1f323 | 2014-03-09 20:03:57 +0100 | [diff] [blame] | 382 | /* textures support 8192, but layered rendering supports 2048 */ |
| 383 | return rscreen->b.info.drm_minor >= 9 ? 2048 : 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 384 | |
| 385 | /* Render targets. */ |
| 386 | case PIPE_CAP_MAX_RENDER_TARGETS: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 387 | /* XXX some r6xx are buggy and can only do 4 */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 388 | return 8; |
| 389 | |
Marek Olšák | a62cd69 | 2013-09-21 19:45:08 +0200 | [diff] [blame] | 390 | case PIPE_CAP_MAX_VIEWPORTS: |
Alexandre Demers | 7a37d5c | 2015-02-25 01:50:49 -0500 | [diff] [blame] | 391 | return R600_MAX_VIEWPORTS; |
Marek Olšák | a62cd69 | 2013-09-21 19:45:08 +0200 | [diff] [blame] | 392 | |
Mathias Fröhlich | 90c2fd8 | 2011-01-23 22:35:13 +0100 | [diff] [blame] | 393 | /* Timer queries, present when the clock frequency is non zero. */ |
José Fonseca | 9976216 | 2012-12-09 09:50:34 +0000 | [diff] [blame] | 394 | case PIPE_CAP_QUERY_TIME_ELAPSED: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 395 | return rscreen->b.info.r600_clock_crystal_freq != 0; |
Marek Olšák | 44f14eb | 2012-07-05 20:06:41 +0200 | [diff] [blame] | 396 | case PIPE_CAP_QUERY_TIMESTAMP: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 397 | return rscreen->b.info.drm_minor >= 20 && |
| 398 | rscreen->b.info.r600_clock_crystal_freq != 0; |
Mathias Fröhlich | 90c2fd8 | 2011-01-23 22:35:13 +0100 | [diff] [blame] | 399 | |
Ilia Mirkin | c2f9ad5 | 2014-04-09 14:58:53 -0400 | [diff] [blame] | 400 | case PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET: |
Dave Airlie | 0b66610 | 2011-08-29 14:35:16 +0100 | [diff] [blame] | 401 | case PIPE_CAP_MIN_TEXEL_OFFSET: |
| 402 | return -8; |
| 403 | |
Ilia Mirkin | c2f9ad5 | 2014-04-09 14:58:53 -0400 | [diff] [blame] | 404 | case PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET: |
Dave Airlie | 0b66610 | 2011-08-29 14:35:16 +0100 | [diff] [blame] | 405 | case PIPE_CAP_MAX_TEXEL_OFFSET: |
| 406 | return 7; |
Christoph Bumiller | 729abfd | 2013-04-12 13:42:01 +0200 | [diff] [blame] | 407 | |
| 408 | case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: |
| 409 | return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600; |
Tom Stellard | 4e90bc9 | 2013-07-09 21:21:39 -0700 | [diff] [blame] | 410 | case PIPE_CAP_ENDIANNESS: |
| 411 | return PIPE_ENDIAN_LITTLE; |
Emil Velikov | de01443 | 2014-08-14 20:57:29 +0100 | [diff] [blame] | 412 | |
| 413 | case PIPE_CAP_VENDOR_ID: |
| 414 | return 0x1002; |
| 415 | case PIPE_CAP_DEVICE_ID: |
| 416 | return rscreen->b.info.pci_id; |
| 417 | case PIPE_CAP_ACCELERATED: |
| 418 | return 1; |
| 419 | case PIPE_CAP_VIDEO_MEMORY: |
| 420 | return rscreen->b.info.vram_size >> 20; |
| 421 | case PIPE_CAP_UMA: |
| 422 | return 0; |
Axel Davy | eb1c12d | 2015-01-17 14:30:17 +0100 | [diff] [blame] | 423 | case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: |
| 424 | return rscreen->b.chip_class >= R700; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 425 | } |
Marek Olšák | 4ac250c | 2011-11-22 20:44:14 +0100 | [diff] [blame] | 426 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 427 | } |
| 428 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 429 | static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enum pipe_shader_cap param) |
| 430 | { |
Vadim Girlin | 1371d65 | 2013-08-02 06:38:23 +0400 | [diff] [blame] | 431 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
| 432 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 433 | switch(shader) |
| 434 | { |
| 435 | case PIPE_SHADER_FRAGMENT: |
| 436 | case PIPE_SHADER_VERTEX: |
Vadim Girlin | 1371d65 | 2013-08-02 06:38:23 +0400 | [diff] [blame] | 437 | case PIPE_SHADER_COMPUTE: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 438 | break; |
| 439 | case PIPE_SHADER_GEOMETRY: |
Dave Airlie | 79ea0f4 | 2014-01-30 04:19:57 +0000 | [diff] [blame] | 440 | if (rscreen->b.family >= CHIP_CEDAR) |
| 441 | break; |
| 442 | /* pre-evergreen geom shaders need newer kernel */ |
| 443 | if (rscreen->b.info.drm_minor >= 37) |
| 444 | break; |
| 445 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 446 | default: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 447 | /* XXX: support tessellation on Evergreen */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 448 | return 0; |
| 449 | } |
| 450 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 451 | switch (param) { |
| 452 | case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: |
| 453 | case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: |
| 454 | case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: |
| 455 | case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: |
| 456 | return 16384; |
| 457 | case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: |
Marek Olšák | cf37aef | 2013-01-31 19:39:41 +0100 | [diff] [blame] | 458 | return 32; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 459 | case PIPE_SHADER_CAP_MAX_INPUTS: |
Marek Olšák | bb867e2 | 2013-05-02 05:24:27 +0200 | [diff] [blame] | 460 | return shader == PIPE_SHADER_VERTEX ? 16 : 32; |
Marek Olšák | 5f5b83c | 2014-10-01 20:28:17 +0200 | [diff] [blame] | 461 | case PIPE_SHADER_CAP_MAX_OUTPUTS: |
| 462 | return shader == PIPE_SHADER_FRAGMENT ? 8 : 32; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 463 | case PIPE_SHADER_CAP_MAX_TEMPS: |
Henri Verbeet | b2a98c3 | 2011-04-25 13:28:55 +0200 | [diff] [blame] | 464 | return 256; /* Max native temporaries. */ |
Marek Olšák | 04f2c88 | 2014-07-24 20:32:08 +0200 | [diff] [blame] | 465 | case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE: |
Tom Stellard | 72969e0 | 2014-08-07 15:31:17 -0400 | [diff] [blame] | 466 | if (shader == PIPE_SHADER_COMPUTE) { |
| 467 | uint64_t max_const_buffer_size; |
| 468 | pscreen->get_compute_param(pscreen, |
| 469 | PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE, |
| 470 | &max_const_buffer_size); |
| 471 | return max_const_buffer_size; |
| 472 | |
| 473 | } else { |
| 474 | return R600_MAX_CONST_BUFFER_SIZE; |
| 475 | } |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 476 | case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: |
Dave Airlie | 7356579 | 2012-11-06 15:31:41 +1000 | [diff] [blame] | 477 | return R600_MAX_USER_CONST_BUFFERS; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 478 | case PIPE_SHADER_CAP_MAX_PREDS: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 479 | return 0; /* nothing uses this */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 480 | case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: |
| 481 | return 1; |
Brian Paul | 13f3ae5 | 2013-02-01 11:16:54 -0700 | [diff] [blame] | 482 | case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: |
Glenn Kennard | 2fa6d65 | 2014-07-18 09:54:37 +0200 | [diff] [blame] | 483 | return 1; |
Marek Olšák | 5c7127c | 2010-11-12 03:07:05 +0100 | [diff] [blame] | 484 | case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: |
| 485 | case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: |
| 486 | case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: |
| 487 | case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: |
| 488 | return 1; |
Marek Olšák | 9aa089e | 2010-11-14 15:34:59 +0100 | [diff] [blame] | 489 | case PIPE_SHADER_CAP_SUBROUTINES: |
| 490 | return 0; |
Bryan Cain | 17b695e | 2011-05-05 21:10:28 -0500 | [diff] [blame] | 491 | case PIPE_SHADER_CAP_INTEGERS: |
Marek Olšák | 7905108 | 2015-06-05 19:09:21 +0200 | [diff] [blame] | 492 | case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: |
Marek Olšák | 15ca9d1 | 2012-07-14 22:28:26 +0200 | [diff] [blame] | 493 | return 1; |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 494 | case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: |
Roland Scheidegger | 2983c03 | 2013-11-26 02:30:41 +0100 | [diff] [blame] | 495 | case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 496 | return 16; |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 497 | case PIPE_SHADER_CAP_PREFERRED_IR: |
| 498 | if (shader == PIPE_SHADER_COMPUTE) { |
Tom Stellard | fa07f4b | 2014-09-25 18:10:44 -0700 | [diff] [blame] | 499 | #if HAVE_LLVM < 0x0306 |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 500 | return PIPE_SHADER_IR_LLVM; |
Tom Stellard | fa07f4b | 2014-09-25 18:10:44 -0700 | [diff] [blame] | 501 | #else |
| 502 | return PIPE_SHADER_IR_NATIVE; |
| 503 | #endif |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 504 | } else { |
| 505 | return PIPE_SHADER_IR_TGSI; |
| 506 | } |
Tom Stellard | fea996c | 2014-06-17 08:52:34 -0700 | [diff] [blame] | 507 | case PIPE_SHADER_CAP_DOUBLES: |
Glenn Kennard | ce34048 | 2015-09-11 12:42:23 +0200 | [diff] [blame] | 508 | if (rscreen->b.family == CHIP_CYPRESS || |
| 509 | rscreen->b.family == CHIP_CAYMAN || rscreen->b.family == CHIP_ARUBA) |
| 510 | return 1; |
Tom Stellard | fea996c | 2014-06-17 08:52:34 -0700 | [diff] [blame] | 511 | return 0; |
Ilia Mirkin | 899d779 | 2014-07-25 17:03:33 -0400 | [diff] [blame] | 512 | case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: |
Ilia Mirkin | 924ee3f | 2014-07-25 17:48:01 -0400 | [diff] [blame] | 513 | case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: |
Marek Olšák | 216543e | 2015-02-28 00:26:31 +0100 | [diff] [blame] | 514 | case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: |
Ilia Mirkin | 899d779 | 2014-07-25 17:03:33 -0400 | [diff] [blame] | 515 | return 0; |
Marek Olšák | 814f314 | 2015-10-20 18:26:02 +0200 | [diff] [blame] | 516 | case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT: |
| 517 | /* due to a bug in the shader compiler, some loops hang |
| 518 | * if they are not unrolled, see: |
| 519 | * https://bugs.freedesktop.org/show_bug.cgi?id=86720 |
| 520 | */ |
| 521 | return 255; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 522 | } |
Marek Olšák | 4ac250c | 2011-11-22 20:44:14 +0100 | [diff] [blame] | 523 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 524 | } |
| 525 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 526 | static void r600_destroy_screen(struct pipe_screen* pscreen) |
| 527 | { |
| 528 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
| 529 | |
| 530 | if (rscreen == NULL) |
| 531 | return; |
Tilman Sauerbeck | 52ba68d | 2010-10-31 15:51:55 +0100 | [diff] [blame] | 532 | |
Marek Olšák | ac330d4 | 2014-04-09 00:26:32 +0200 | [diff] [blame] | 533 | if (!rscreen->b.ws->unref(rscreen->b.ws)) |
Christian König | 4871128 | 2013-09-25 13:59:56 +0200 | [diff] [blame] | 534 | return; |
| 535 | |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 536 | if (rscreen->global_pool) { |
| 537 | compute_memory_pool_delete(rscreen->global_pool); |
| 538 | } |
| 539 | |
Marek Olšák | ed42e95 | 2014-01-22 02:49:53 +0100 | [diff] [blame] | 540 | r600_destroy_common_screen(&rscreen->b); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 541 | } |
| 542 | |
Marek Olšák | a9ae763 | 2014-01-22 00:58:12 +0100 | [diff] [blame] | 543 | static struct pipe_resource *r600_resource_create(struct pipe_screen *screen, |
| 544 | const struct pipe_resource *templ) |
| 545 | { |
| 546 | if (templ->target == PIPE_BUFFER && |
| 547 | (templ->bind & PIPE_BIND_GLOBAL)) |
| 548 | return r600_compute_global_buffer_create(screen, templ); |
| 549 | |
| 550 | return r600_resource_create_common(screen, templ); |
| 551 | } |
| 552 | |
Marek Olšák | 2ce783d | 2011-08-02 20:25:13 +0200 | [diff] [blame] | 553 | struct pipe_screen *r600_screen_create(struct radeon_winsys *ws) |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 554 | { |
Marek Olšák | 90ce3cd | 2011-09-17 14:10:20 +0200 | [diff] [blame] | 555 | struct r600_screen *rscreen = CALLOC_STRUCT(r600_screen); |
Dave Airlie | e6aad9b | 2012-04-22 08:09:05 +0100 | [diff] [blame] | 556 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 557 | if (rscreen == NULL) { |
| 558 | return NULL; |
| 559 | } |
| 560 | |
Marek Olšák | 68f6dec | 2013-09-22 21:45:23 +0200 | [diff] [blame] | 561 | /* Set functions first. */ |
| 562 | rscreen->b.b.context_create = r600_create_context; |
| 563 | rscreen->b.b.destroy = r600_destroy_screen; |
Marek Olšák | 68f6dec | 2013-09-22 21:45:23 +0200 | [diff] [blame] | 564 | rscreen->b.b.get_param = r600_get_param; |
| 565 | rscreen->b.b.get_shader_param = r600_get_shader_param; |
Marek Olšák | a9ae763 | 2014-01-22 00:58:12 +0100 | [diff] [blame] | 566 | rscreen->b.b.resource_create = r600_resource_create; |
Marek Olšák | 68f6dec | 2013-09-22 21:45:23 +0200 | [diff] [blame] | 567 | |
Marek Olšák | 1bb77f8 | 2013-09-22 22:12:18 +0200 | [diff] [blame] | 568 | if (!r600_common_screen_init(&rscreen->b, ws)) { |
| 569 | FREE(rscreen); |
| 570 | return NULL; |
| 571 | } |
Marek Olšák | 3603d15 | 2011-09-11 14:53:07 +0200 | [diff] [blame] | 572 | |
Marek Olšák | ed42e95 | 2014-01-22 02:49:53 +0100 | [diff] [blame] | 573 | if (rscreen->b.info.chip_class >= EVERGREEN) { |
| 574 | rscreen->b.b.is_format_supported = evergreen_is_format_supported; |
| 575 | } else { |
| 576 | rscreen->b.b.is_format_supported = r600_is_format_supported; |
| 577 | } |
| 578 | |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 579 | rscreen->b.debug_flags |= debug_get_flags_option("R600_DEBUG", r600_debug_options, 0); |
Michel Dänzer | 31009b4 | 2013-03-21 17:56:52 +0100 | [diff] [blame] | 580 | if (debug_get_bool_option("R600_DEBUG_COMPUTE", FALSE)) |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 581 | rscreen->b.debug_flags |= DBG_COMPUTE; |
Michel Dänzer | 31009b4 | 2013-03-21 17:56:52 +0100 | [diff] [blame] | 582 | if (debug_get_bool_option("R600_DUMP_SHADERS", FALSE)) |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 583 | rscreen->b.debug_flags |= DBG_FS | DBG_VS | DBG_GS | DBG_PS | DBG_CS; |
Andreas Boll | 14bdcc6 | 2014-10-23 14:52:55 +0200 | [diff] [blame] | 584 | if (!debug_get_bool_option("R600_HYPERZ", TRUE)) |
| 585 | rscreen->b.debug_flags |= DBG_NO_HYPERZ; |
Michel Dänzer | 7286739 | 2014-04-16 15:00:09 +0900 | [diff] [blame] | 586 | if (debug_get_bool_option("R600_LLVM", FALSE)) |
| 587 | rscreen->b.debug_flags |= DBG_LLVM; |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 588 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 589 | if (rscreen->b.family == CHIP_UNKNOWN) { |
| 590 | fprintf(stderr, "r600: Unknown chipset 0x%04X\n", rscreen->b.info.pci_id); |
Marek Olšák | 518557d | 2011-09-17 13:56:09 +0200 | [diff] [blame] | 591 | FREE(rscreen); |
| 592 | return NULL; |
| 593 | } |
| 594 | |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 595 | /* Figure out streamout kernel support. */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 596 | switch (rscreen->b.chip_class) { |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 597 | case R600: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 598 | if (rscreen->b.family < CHIP_RS780) { |
Marek Olšák | bba39d8 | 2013-11-28 15:09:35 +0100 | [diff] [blame] | 599 | rscreen->b.has_streamout = rscreen->b.info.drm_minor >= 14; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 600 | } else { |
Marek Olšák | bba39d8 | 2013-11-28 15:09:35 +0100 | [diff] [blame] | 601 | rscreen->b.has_streamout = rscreen->b.info.drm_minor >= 23; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 602 | } |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 603 | break; |
| 604 | case R700: |
Marek Olšák | bba39d8 | 2013-11-28 15:09:35 +0100 | [diff] [blame] | 605 | rscreen->b.has_streamout = rscreen->b.info.drm_minor >= 17; |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 606 | break; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 607 | case EVERGREEN: |
| 608 | case CAYMAN: |
Marek Olšák | bba39d8 | 2013-11-28 15:09:35 +0100 | [diff] [blame] | 609 | rscreen->b.has_streamout = rscreen->b.info.drm_minor >= 14; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 610 | break; |
Jerome Glisse | ca474f9 | 2013-01-04 16:34:52 -0500 | [diff] [blame] | 611 | default: |
Marek Olšák | bba39d8 | 2013-11-28 15:09:35 +0100 | [diff] [blame] | 612 | rscreen->b.has_streamout = FALSE; |
Jerome Glisse | ca474f9 | 2013-01-04 16:34:52 -0500 | [diff] [blame] | 613 | break; |
Marek Olšák | 393d741 | 2012-03-27 21:00:49 +0200 | [diff] [blame] | 614 | } |
| 615 | |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 616 | /* MSAA support. */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 617 | switch (rscreen->b.chip_class) { |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 618 | case R600: |
| 619 | case R700: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 620 | rscreen->has_msaa = rscreen->b.info.drm_minor >= 22; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 621 | rscreen->has_compressed_msaa_texturing = false; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 622 | break; |
| 623 | case EVERGREEN: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 624 | rscreen->has_msaa = rscreen->b.info.drm_minor >= 19; |
| 625 | rscreen->has_compressed_msaa_texturing = rscreen->b.info.drm_minor >= 24; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 626 | break; |
| 627 | case CAYMAN: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 628 | rscreen->has_msaa = rscreen->b.info.drm_minor >= 19; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 629 | rscreen->has_compressed_msaa_texturing = true; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 630 | break; |
Jerome Glisse | ca474f9 | 2013-01-04 16:34:52 -0500 | [diff] [blame] | 631 | default: |
| 632 | rscreen->has_msaa = FALSE; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 633 | rscreen->has_compressed_msaa_texturing = false; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 634 | } |
| 635 | |
Marek Olšák | bba39d8 | 2013-11-28 15:09:35 +0100 | [diff] [blame] | 636 | rscreen->b.has_cp_dma = rscreen->b.info.drm_minor >= 27 && |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 637 | !(rscreen->b.debug_flags & DBG_NO_CP_DMA); |
Marek Olšák | 58bd926 | 2013-02-21 17:06:26 +0100 | [diff] [blame] | 638 | |
Tom Stellard | c0f7fe7 | 2012-07-11 16:18:22 +0000 | [diff] [blame] | 639 | rscreen->global_pool = compute_memory_pool_new(rscreen); |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 640 | |
Marek Olšák | b893bbf | 2013-10-03 16:39:50 +0200 | [diff] [blame] | 641 | /* Create the auxiliary context. This must be done last. */ |
Marek Olšák | 0fc21ec | 2015-07-25 18:40:59 +0200 | [diff] [blame] | 642 | rscreen->b.aux_context = rscreen->b.b.context_create(&rscreen->b.b, NULL, 0); |
Marek Olšák | b893bbf | 2013-10-03 16:39:50 +0200 | [diff] [blame] | 643 | |
Marek Olšák | b692076 | 2013-04-21 23:26:52 +0200 | [diff] [blame] | 644 | #if 0 /* This is for testing whether aux_context and buffer clearing work correctly. */ |
| 645 | struct pipe_resource templ = {}; |
| 646 | |
| 647 | templ.width0 = 4; |
| 648 | templ.height0 = 2048; |
| 649 | templ.depth0 = 1; |
| 650 | templ.array_size = 1; |
| 651 | templ.target = PIPE_TEXTURE_2D; |
| 652 | templ.format = PIPE_FORMAT_R8G8B8A8_UNORM; |
Marek Olšák | c321144 | 2014-02-03 03:42:17 +0100 | [diff] [blame] | 653 | templ.usage = PIPE_USAGE_DEFAULT; |
Marek Olšák | b692076 | 2013-04-21 23:26:52 +0200 | [diff] [blame] | 654 | |
| 655 | struct r600_resource *res = r600_resource(rscreen->screen.resource_create(&rscreen->screen, &templ)); |
| 656 | unsigned char *map = ws->buffer_map(res->cs_buf, NULL, PIPE_TRANSFER_WRITE); |
| 657 | |
| 658 | memset(map, 0, 256); |
| 659 | |
| 660 | r600_screen_clear_buffer(rscreen, &res->b.b, 4, 4, 0xCC); |
| 661 | r600_screen_clear_buffer(rscreen, &res->b.b, 8, 4, 0xDD); |
| 662 | r600_screen_clear_buffer(rscreen, &res->b.b, 12, 4, 0xEE); |
| 663 | r600_screen_clear_buffer(rscreen, &res->b.b, 20, 4, 0xFF); |
| 664 | r600_screen_clear_buffer(rscreen, &res->b.b, 32, 20, 0x87); |
| 665 | |
| 666 | ws->buffer_wait(res->buf, RADEON_USAGE_WRITE); |
| 667 | |
| 668 | int i; |
| 669 | for (i = 0; i < 256; i++) { |
| 670 | printf("%02X", map[i]); |
| 671 | if (i % 16 == 15) |
| 672 | printf("\n"); |
| 673 | } |
| 674 | #endif |
| 675 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 676 | return &rscreen->b.b; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 677 | } |