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" |
Kai Wasserbäch | 8fb7f1a | 2011-08-27 17:51:51 +0200 | [diff] [blame] | 33 | #include "util/u_blitter.h" |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 34 | #include "util/u_debug.h" |
Marek Olšák | 9f06966 | 2012-12-03 21:31:04 +0100 | [diff] [blame] | 35 | #include "util/u_memory.h" |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 36 | #include "util/u_simple_shaders.h" |
Marek Olšák | 428855e | 2012-04-11 16:00:09 +0200 | [diff] [blame] | 37 | #include "util/u_upload_mgr.h" |
Jerome Glisse | 325422c | 2013-01-07 17:45:59 -0500 | [diff] [blame] | 38 | #include "util/u_math.h" |
Kai Wasserbäch | 8fb7f1a | 2011-08-27 17:51:51 +0200 | [diff] [blame] | 39 | #include "vl/vl_decoder.h" |
| 40 | #include "vl/vl_video_buffer.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 */ |
| 46 | { "nohyperz", DBG_NO_HYPERZ, "Disable Hyper-Z" }, |
| 47 | #if defined(R600_USE_LLVM) |
| 48 | { "nollvm", DBG_NO_LLVM, "Disable the LLVM shader compiler" }, |
| 49 | #endif |
Marek Olšák | e4e655f | 2013-03-05 01:15:45 +0100 | [diff] [blame] | 50 | { "nocpdma", DBG_NO_CP_DMA, "Disable CP DMA" }, |
| 51 | { "nodma", DBG_NO_ASYNC_DMA, "Disable asynchronous DMA" }, |
| 52 | /* GL uses the word INVALIDATE, gallium uses the word DISCARD */ |
| 53 | { "noinvalrange", DBG_NO_DISCARD_RANGE, "Disable handling of INVALIDATE_RANGE map flags" }, |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 54 | |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 55 | /* shader backend */ |
Vadim Girlin | f7217b9 | 2013-08-24 00:54:54 +0400 | [diff] [blame] | 56 | { "nosb", DBG_NO_SB, "Disable sb backend for graphics shaders" }, |
| 57 | { "sbcl", DBG_SB_CS, "Enable sb backend for compute shaders" }, |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 58 | { "sbdry", DBG_SB_DRY_RUN, "Don't use optimized bytecode (just print the dumps)" }, |
| 59 | { "sbstat", DBG_SB_STAT, "Print optimization statistics for shaders" }, |
| 60 | { "sbdump", DBG_SB_DUMP, "Print IR dumps after some optimization passes" }, |
Vadim Girlin | 188c893 | 2013-04-23 10:34:00 +0400 | [diff] [blame] | 61 | { "sbnofallback", DBG_SB_NO_FALLBACK, "Abort on errors instead of fallback" }, |
Vadim Girlin | 4ca67db | 2013-05-03 12:01:20 +0400 | [diff] [blame] | 62 | { "sbdisasm", DBG_SB_DISASM, "Use sb disassembler for shader dumps" }, |
Vadim Girlin | 758ac6f | 2013-06-05 20:55:31 +0400 | [diff] [blame] | 63 | { "sbsafemath", DBG_SB_SAFEMATH, "Disable unsafe math optimizations" }, |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 64 | |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 65 | DEBUG_NAMED_VALUE_END /* must be last */ |
| 66 | }; |
| 67 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 68 | /* |
| 69 | * pipe_context |
| 70 | */ |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 71 | |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 72 | static void r600_flush(struct pipe_context *ctx, unsigned flags) |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 73 | { |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 74 | struct r600_context *rctx = (struct r600_context *)ctx; |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 75 | struct pipe_query *render_cond = NULL; |
| 76 | unsigned render_cond_mode = 0; |
Roland Scheidegger | 793e8e3 | 2013-06-14 19:48:57 +0200 | [diff] [blame] | 77 | boolean render_cond_cond = FALSE; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 78 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 79 | if (rctx->b.rings.gfx.cs->cdw == rctx->initial_gfx_cs_size) |
Marek Olšák | 1faa375 | 2013-06-30 18:29:17 +0200 | [diff] [blame] | 80 | return; |
| 81 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 82 | rctx->b.rings.gfx.flushing = true; |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 83 | /* Disable render condition. */ |
| 84 | if (rctx->current_render_cond) { |
| 85 | render_cond = rctx->current_render_cond; |
Roland Scheidegger | 793e8e3 | 2013-06-14 19:48:57 +0200 | [diff] [blame] | 86 | render_cond_cond = rctx->current_render_cond_cond; |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 87 | render_cond_mode = rctx->current_render_cond_mode; |
Roland Scheidegger | 793e8e3 | 2013-06-14 19:48:57 +0200 | [diff] [blame] | 88 | ctx->render_condition(ctx, NULL, FALSE, 0); |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 89 | } |
| 90 | |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 91 | r600_context_flush(rctx, flags); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 92 | rctx->b.rings.gfx.flushing = false; |
Jerome Glisse | 325422c | 2013-01-07 17:45:59 -0500 | [diff] [blame] | 93 | r600_begin_new_cs(rctx); |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 94 | |
| 95 | /* Re-enable render condition. */ |
| 96 | if (render_cond) { |
Roland Scheidegger | 793e8e3 | 2013-06-14 19:48:57 +0200 | [diff] [blame] | 97 | ctx->render_condition(ctx, render_cond, render_cond_cond, render_cond_mode); |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 98 | } |
Marek Olšák | 1faa375 | 2013-06-30 18:29:17 +0200 | [diff] [blame] | 99 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 100 | rctx->initial_gfx_cs_size = rctx->b.rings.gfx.cs->cdw; |
Marek Olšák | e2e1dc9 | 2011-08-04 03:38:20 +0200 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | static void r600_flush_from_st(struct pipe_context *ctx, |
Marek Olšák | 598cc1f | 2012-12-21 17:03:22 +0100 | [diff] [blame] | 104 | struct pipe_fence_handle **fence, |
Chia-I Wu | 8c347d4 | 2013-05-02 16:25:15 +0800 | [diff] [blame] | 105 | unsigned flags) |
Marek Olšák | e2e1dc9 | 2011-08-04 03:38:20 +0200 | [diff] [blame] | 106 | { |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 107 | struct r600_context *rctx = (struct r600_context *)ctx; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 108 | unsigned fflags; |
| 109 | |
| 110 | fflags = flags & PIPE_FLUSH_END_OF_FRAME ? RADEON_FLUSH_END_OF_FRAME : 0; |
Marek Olšák | 9807556 | 2013-10-08 21:50:43 +0200 | [diff] [blame] | 111 | if (fence) { |
| 112 | *fence = rctx->b.ws->cs_create_fence(rctx->b.rings.gfx.cs); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 113 | } |
| 114 | /* flush gfx & dma ring, order does not matter as only one can be live */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 115 | if (rctx->b.rings.dma.cs) { |
| 116 | rctx->b.rings.dma.flush(rctx, fflags); |
Jerome Glisse | 7291669 | 2013-01-28 14:48:46 -0500 | [diff] [blame] | 117 | } |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 118 | rctx->b.rings.gfx.flush(rctx, fflags); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | static void r600_flush_gfx_ring(void *ctx, unsigned flags) |
| 122 | { |
| 123 | r600_flush((struct pipe_context*)ctx, flags); |
| 124 | } |
| 125 | |
| 126 | static void r600_flush_dma_ring(void *ctx, unsigned flags) |
| 127 | { |
| 128 | struct r600_context *rctx = (struct r600_context *)ctx; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 129 | struct radeon_winsys_cs *cs = rctx->b.rings.dma.cs; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 130 | |
Marek Olšák | c77917d | 2013-02-27 21:24:02 +0100 | [diff] [blame] | 131 | if (!cs->cdw) { |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 132 | return; |
| 133 | } |
Marek Olšák | c77917d | 2013-02-27 21:24:02 +0100 | [diff] [blame] | 134 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 135 | rctx->b.rings.dma.flushing = true; |
| 136 | rctx->b.ws->cs_flush(cs, flags, 0); |
| 137 | rctx->b.rings.dma.flushing = false; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 138 | } |
| 139 | |
Marek Olšák | e2e1dc9 | 2011-08-04 03:38:20 +0200 | [diff] [blame] | 140 | static void r600_flush_from_winsys(void *ctx, unsigned flags) |
| 141 | { |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 142 | struct r600_context *rctx = (struct r600_context *)ctx; |
| 143 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 144 | rctx->b.rings.gfx.flush(rctx, flags); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | static void r600_flush_dma_from_winsys(void *ctx, unsigned flags) |
| 148 | { |
| 149 | struct r600_context *rctx = (struct r600_context *)ctx; |
| 150 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 151 | rctx->b.rings.dma.flush(rctx, flags); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | static void r600_destroy_context(struct pipe_context *context) |
| 155 | { |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 156 | struct r600_context *rctx = (struct r600_context *)context; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 157 | |
Vadim Girlin | 022122e | 2013-02-01 11:45:35 +0400 | [diff] [blame] | 158 | r600_isa_destroy(rctx->isa); |
| 159 | |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 160 | r600_sb_context_destroy(rctx->sb_context); |
| 161 | |
Marek Olšák | 7835401 | 2012-08-26 22:38:35 +0200 | [diff] [blame] | 162 | pipe_resource_reference((struct pipe_resource**)&rctx->dummy_cmask, NULL); |
| 163 | pipe_resource_reference((struct pipe_resource**)&rctx->dummy_fmask, NULL); |
| 164 | |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 165 | if (rctx->dummy_pixel_shader) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 166 | 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] | 167 | } |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 168 | if (rctx->custom_dsa_flush) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 169 | 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] | 170 | } |
Marek Olšák | 0f86915 | 2012-08-09 17:21:10 +0200 | [diff] [blame] | 171 | if (rctx->custom_blend_resolve) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 172 | 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] | 173 | } |
Marek Olšák | a3d9d7e | 2012-08-12 20:06:33 +0200 | [diff] [blame] | 174 | if (rctx->custom_blend_decompress) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 175 | 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] | 176 | } |
Grigori Goronzy | edbbfac | 2013-09-11 01:41:40 +0200 | [diff] [blame] | 177 | if (rctx->custom_blend_fastclear) { |
| 178 | rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_fastclear); |
| 179 | } |
Marek Olšák | c8b06dc | 2012-09-18 19:42:29 +0200 | [diff] [blame] | 180 | util_unreference_framebuffer_state(&rctx->framebuffer.state); |
Tilman Sauerbeck | ecb1b8b | 2010-10-31 12:16:03 +0100 | [diff] [blame] | 181 | |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 182 | if (rctx->blitter) { |
| 183 | util_blitter_destroy(rctx->blitter); |
| 184 | } |
Marek Olšák | 428855e | 2012-04-11 16:00:09 +0200 | [diff] [blame] | 185 | if (rctx->uploader) { |
| 186 | u_upload_destroy(rctx->uploader); |
| 187 | } |
Marek Olšák | d225d07 | 2012-12-09 18:51:31 +0100 | [diff] [blame] | 188 | if (rctx->allocator_fetch_shader) { |
| 189 | u_suballocator_destroy(rctx->allocator_fetch_shader); |
| 190 | } |
Marek Olšák | f0b202e | 2011-02-08 17:30:39 +0100 | [diff] [blame] | 191 | util_slab_destroy(&rctx->pool_transfers); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 192 | |
Marek Olšák | e363dd5 | 2012-03-05 16:20:05 +0100 | [diff] [blame] | 193 | r600_release_command_buffer(&rctx->start_cs_cmd); |
Marek Olšák | 9670e72 | 2012-02-21 18:08:32 +0100 | [diff] [blame] | 194 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 195 | if (rctx->b.rings.gfx.cs) { |
| 196 | rctx->b.ws->cs_destroy(rctx->b.rings.gfx.cs); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 197 | } |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 198 | if (rctx->b.rings.dma.cs) { |
| 199 | rctx->b.ws->cs_destroy(rctx->b.rings.dma.cs); |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 200 | } |
Marek Olšák | 9670e72 | 2012-02-21 18:08:32 +0100 | [diff] [blame] | 201 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 202 | r600_common_context_cleanup(&rctx->b); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 203 | FREE(rctx); |
| 204 | } |
| 205 | |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 206 | static struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv) |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 207 | { |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 208 | struct r600_context *rctx = CALLOC_STRUCT(r600_context); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 209 | struct r600_screen* rscreen = (struct r600_screen *)screen; |
| 210 | |
| 211 | if (rctx == NULL) |
| 212 | return NULL; |
Marek Olšák | f0b202e | 2011-02-08 17:30:39 +0100 | [diff] [blame] | 213 | |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 214 | util_slab_create(&rctx->pool_transfers, |
Marek Olšák | 99c65ba | 2012-02-26 20:37:43 +0100 | [diff] [blame] | 215 | sizeof(struct r600_transfer), 64, |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 216 | UTIL_SLAB_SINGLETHREADED); |
| 217 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 218 | rctx->b.b.screen = screen; |
| 219 | rctx->b.b.priv = priv; |
| 220 | rctx->b.b.destroy = r600_destroy_context; |
| 221 | rctx->b.b.flush = r600_flush_from_st; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 222 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 223 | if (!r600_common_context_init(&rctx->b, &rscreen->b)) |
| 224 | goto fail; |
| 225 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 226 | rctx->screen = rscreen; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 227 | rctx->keep_tiling_flags = rscreen->b.info.drm_minor >= 12; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 228 | |
Marek Olšák | 09ec30f | 2012-02-23 23:22:35 +0100 | [diff] [blame] | 229 | LIST_INITHEAD(&rctx->active_nontimer_queries); |
Marek Olšák | e280984 | 2012-02-02 14:01:12 +0100 | [diff] [blame] | 230 | |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 231 | r600_init_blit_functions(rctx); |
Jerome Glisse | 6abd777 | 2010-09-29 15:39:40 -0400 | [diff] [blame] | 232 | r600_init_query_functions(rctx); |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 233 | r600_init_context_resource_functions(rctx); |
Marek Olšák | f96df32 | 2012-09-10 00:28:46 +0200 | [diff] [blame] | 234 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 235 | if (rscreen->b.info.has_uvd) { |
| 236 | rctx->b.b.create_video_codec = r600_uvd_create_decoder; |
| 237 | rctx->b.b.create_video_buffer = r600_video_buffer_create; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 238 | } else { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 239 | rctx->b.b.create_video_codec = vl_create_decoder; |
| 240 | rctx->b.b.create_video_buffer = vl_video_buffer_create; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 241 | } |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 242 | |
Marek Olšák | f96df32 | 2012-09-10 00:28:46 +0200 | [diff] [blame] | 243 | r600_init_common_state_functions(rctx); |
| 244 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 245 | switch (rctx->b.chip_class) { |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 246 | case R600: |
| 247 | case R700: |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 248 | r600_init_state_functions(rctx); |
Marek Olšák | f126253 | 2012-01-31 10:50:51 +0100 | [diff] [blame] | 249 | r600_init_atom_start_cs(rctx); |
Marek Olšák | 1724ef8 | 2013-03-02 17:36:05 +0100 | [diff] [blame] | 250 | rctx->max_db = 4; |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 251 | rctx->custom_dsa_flush = r600_create_db_flush_dsa(rctx); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 252 | 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] | 253 | : r600_create_resolve_blend(rctx); |
Marek Olšák | 8698a3b | 2012-08-02 22:31:22 +0200 | [diff] [blame] | 254 | rctx->custom_blend_decompress = r600_create_decompress_blend(rctx); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 255 | rctx->has_vertex_cache = !(rctx->b.family == CHIP_RV610 || |
| 256 | rctx->b.family == CHIP_RV620 || |
| 257 | rctx->b.family == CHIP_RS780 || |
| 258 | rctx->b.family == CHIP_RS880 || |
| 259 | rctx->b.family == CHIP_RV710); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 260 | break; |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 261 | case EVERGREEN: |
| 262 | case CAYMAN: |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 263 | evergreen_init_state_functions(rctx); |
Marek Olšák | f126253 | 2012-01-31 10:50:51 +0100 | [diff] [blame] | 264 | evergreen_init_atom_start_cs(rctx); |
Tom Stellard | 5016fe2 | 2012-06-25 17:56:01 +0000 | [diff] [blame] | 265 | evergreen_init_atom_start_compute_cs(rctx); |
Marek Olšák | 1724ef8 | 2013-03-02 17:36:05 +0100 | [diff] [blame] | 266 | rctx->max_db = 8; |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 267 | rctx->custom_dsa_flush = evergreen_create_db_flush_dsa(rctx); |
Marek Olšák | 0f86915 | 2012-08-09 17:21:10 +0200 | [diff] [blame] | 268 | rctx->custom_blend_resolve = evergreen_create_resolve_blend(rctx); |
Marek Olšák | a3d9d7e | 2012-08-12 20:06:33 +0200 | [diff] [blame] | 269 | rctx->custom_blend_decompress = evergreen_create_decompress_blend(rctx); |
Grigori Goronzy | edbbfac | 2013-09-11 01:41:40 +0200 | [diff] [blame] | 270 | rctx->custom_blend_fastclear = evergreen_create_fastclear_blend(rctx); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 271 | rctx->has_vertex_cache = !(rctx->b.family == CHIP_CEDAR || |
| 272 | rctx->b.family == CHIP_PALM || |
| 273 | rctx->b.family == CHIP_SUMO || |
| 274 | rctx->b.family == CHIP_SUMO2 || |
| 275 | rctx->b.family == CHIP_CAICOS || |
| 276 | rctx->b.family == CHIP_CAYMAN || |
| 277 | rctx->b.family == CHIP_ARUBA); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 278 | break; |
| 279 | default: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 280 | R600_ERR("Unsupported chip class %d.\n", rctx->b.chip_class); |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 281 | goto fail; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 282 | } |
| 283 | |
Jerome Glisse | abb96fd | 2013-04-23 19:22:33 -0400 | [diff] [blame] | 284 | if (rscreen->trace_bo) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 285 | rctx->b.rings.gfx.cs = rctx->b.ws->cs_create(rctx->b.ws, RING_GFX, rscreen->trace_bo->cs_buf); |
Jerome Glisse | abb96fd | 2013-04-23 19:22:33 -0400 | [diff] [blame] | 286 | } else { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 287 | rctx->b.rings.gfx.cs = rctx->b.ws->cs_create(rctx->b.ws, RING_GFX, NULL); |
Jerome Glisse | abb96fd | 2013-04-23 19:22:33 -0400 | [diff] [blame] | 288 | } |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 289 | rctx->b.rings.gfx.flush = r600_flush_gfx_ring; |
| 290 | rctx->b.ws->cs_set_flush_callback(rctx->b.rings.gfx.cs, r600_flush_from_winsys, rctx); |
| 291 | rctx->b.rings.gfx.flushing = false; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 292 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 293 | rctx->b.rings.dma.cs = NULL; |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 294 | if (rscreen->b.info.r600_has_dma && !(rscreen->b.debug_flags & DBG_NO_ASYNC_DMA)) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 295 | rctx->b.rings.dma.cs = rctx->b.ws->cs_create(rctx->b.ws, RING_DMA, NULL); |
| 296 | rctx->b.rings.dma.flush = r600_flush_dma_ring; |
| 297 | rctx->b.ws->cs_set_flush_callback(rctx->b.rings.dma.cs, r600_flush_dma_from_winsys, rctx); |
| 298 | rctx->b.rings.dma.flushing = false; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 299 | } |
Marek Olšák | e2e1dc9 | 2011-08-04 03:38:20 +0200 | [diff] [blame] | 300 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 301 | rctx->uploader = u_upload_create(&rctx->b.b, 1024 * 1024, 256, |
Jerome Glisse | d499ff9 | 2013-01-04 11:46:13 -0500 | [diff] [blame] | 302 | PIPE_BIND_INDEX_BUFFER | |
| 303 | PIPE_BIND_CONSTANT_BUFFER); |
| 304 | if (!rctx->uploader) |
| 305 | goto fail; |
Marek Olšák | 428855e | 2012-04-11 16:00:09 +0200 | [diff] [blame] | 306 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 307 | rctx->allocator_fetch_shader = u_suballocator_create(&rctx->b.b, 64 * 1024, 256, |
Marek Olšák | d225d07 | 2012-12-09 18:51:31 +0100 | [diff] [blame] | 308 | 0, PIPE_USAGE_STATIC, FALSE); |
Jerome Glisse | d499ff9 | 2013-01-04 11:46:13 -0500 | [diff] [blame] | 309 | if (!rctx->allocator_fetch_shader) |
| 310 | goto fail; |
Marek Olšák | d225d07 | 2012-12-09 18:51:31 +0100 | [diff] [blame] | 311 | |
Vadim Girlin | 022122e | 2013-02-01 11:45:35 +0400 | [diff] [blame] | 312 | rctx->isa = calloc(1, sizeof(struct r600_isa)); |
| 313 | if (!rctx->isa || r600_isa_init(rctx, rctx->isa)) |
Jerome Glisse | d499ff9 | 2013-01-04 11:46:13 -0500 | [diff] [blame] | 314 | goto fail; |
Marek Olšák | 8df3855 | 2012-12-09 17:56:26 +0100 | [diff] [blame] | 315 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 316 | rctx->blitter = util_blitter_create(&rctx->b.b); |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 317 | if (rctx->blitter == NULL) |
| 318 | goto fail; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 319 | util_blitter_set_texture_multisample(rctx->blitter, rscreen->has_msaa); |
Marek Olšák | 187d7fb | 2012-08-24 05:57:22 +0200 | [diff] [blame] | 320 | rctx->blitter->draw_rectangle = r600_draw_rectangle; |
Dave Airlie | d59498b | 2010-10-13 15:22:04 +1000 | [diff] [blame] | 321 | |
Marek Olšák | c383a3c | 2012-09-10 05:56:46 +0200 | [diff] [blame] | 322 | r600_begin_new_cs(rctx); |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 323 | r600_get_backend_mask(rctx); /* this emits commands and must be last */ |
Marek Olšák | bbad510 | 2011-10-28 22:31:34 +0200 | [diff] [blame] | 324 | |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 325 | rctx->dummy_pixel_shader = |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 326 | util_make_fragment_cloneinput_shader(&rctx->b.b, 0, |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 327 | TGSI_SEMANTIC_GENERIC, |
| 328 | TGSI_INTERPOLATE_CONSTANT); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 329 | 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] | 330 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 331 | return &rctx->b.b; |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 332 | |
| 333 | fail: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 334 | r600_destroy_context(&rctx->b.b); |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 335 | return NULL; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | /* |
| 339 | * pipe_screen |
| 340 | */ |
| 341 | static const char* r600_get_vendor(struct pipe_screen* pscreen) |
| 342 | { |
| 343 | return "X.Org"; |
| 344 | } |
| 345 | |
Dave Airlie | 4378c17 | 2010-09-30 09:17:20 +1000 | [diff] [blame] | 346 | static const char *r600_get_family_name(enum radeon_family family) |
| 347 | { |
| 348 | switch(family) { |
Henri Verbeet | 9f06411 | 2010-11-07 18:40:12 +0100 | [diff] [blame] | 349 | case CHIP_R600: return "AMD R600"; |
| 350 | case CHIP_RV610: return "AMD RV610"; |
| 351 | case CHIP_RV630: return "AMD RV630"; |
| 352 | case CHIP_RV670: return "AMD RV670"; |
| 353 | case CHIP_RV620: return "AMD RV620"; |
| 354 | case CHIP_RV635: return "AMD RV635"; |
| 355 | case CHIP_RS780: return "AMD RS780"; |
| 356 | case CHIP_RS880: return "AMD RS880"; |
| 357 | case CHIP_RV770: return "AMD RV770"; |
| 358 | case CHIP_RV730: return "AMD RV730"; |
| 359 | case CHIP_RV710: return "AMD RV710"; |
| 360 | case CHIP_RV740: return "AMD RV740"; |
| 361 | case CHIP_CEDAR: return "AMD CEDAR"; |
| 362 | case CHIP_REDWOOD: return "AMD REDWOOD"; |
| 363 | case CHIP_JUNIPER: return "AMD JUNIPER"; |
| 364 | case CHIP_CYPRESS: return "AMD CYPRESS"; |
| 365 | case CHIP_HEMLOCK: return "AMD HEMLOCK"; |
Alex Deucher | 0e4c5f6 | 2010-11-22 17:47:24 -0500 | [diff] [blame] | 366 | case CHIP_PALM: return "AMD PALM"; |
Alex Deucher | 414cd5d | 2011-04-04 12:06:11 -0400 | [diff] [blame] | 367 | case CHIP_SUMO: return "AMD SUMO"; |
| 368 | case CHIP_SUMO2: return "AMD SUMO2"; |
Alex Deucher | f54366b | 2011-01-06 18:05:16 -0500 | [diff] [blame] | 369 | case CHIP_BARTS: return "AMD BARTS"; |
| 370 | case CHIP_TURKS: return "AMD TURKS"; |
| 371 | case CHIP_CAICOS: return "AMD CAICOS"; |
Dave Airlie | 7779f6d | 2011-03-10 12:54:13 +1000 | [diff] [blame] | 372 | case CHIP_CAYMAN: return "AMD CAYMAN"; |
Alex Deucher | b4082f4 | 2012-03-20 19:43:59 -0400 | [diff] [blame] | 373 | case CHIP_ARUBA: return "AMD ARUBA"; |
Henri Verbeet | 9f06411 | 2010-11-07 18:40:12 +0100 | [diff] [blame] | 374 | default: return "AMD unknown"; |
Dave Airlie | 4378c17 | 2010-09-30 09:17:20 +1000 | [diff] [blame] | 375 | } |
| 376 | } |
| 377 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 378 | static const char* r600_get_name(struct pipe_screen* pscreen) |
| 379 | { |
| 380 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 381 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 382 | return r600_get_family_name(rscreen->b.family); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param) |
| 386 | { |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 387 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 388 | enum radeon_family family = rscreen->b.family; |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 389 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 390 | switch (param) { |
| 391 | /* Supported features (boolean caps). */ |
| 392 | case PIPE_CAP_NPOT_TEXTURES: |
Ilia Mirkin | 12d39b4 | 2013-10-04 04:32:15 -0400 | [diff] [blame^] | 393 | case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 394 | case PIPE_CAP_TWO_SIDED_STENCIL: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 395 | case PIPE_CAP_ANISOTROPIC_FILTER: |
| 396 | case PIPE_CAP_POINT_SPRITE: |
| 397 | case PIPE_CAP_OCCLUSION_QUERY: |
| 398 | case PIPE_CAP_TEXTURE_SHADOW_MAP: |
| 399 | case PIPE_CAP_TEXTURE_MIRROR_CLAMP: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 400 | case PIPE_CAP_BLEND_EQUATION_SEPARATE: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 401 | case PIPE_CAP_TEXTURE_SWIZZLE: |
Marek Olšák | dc4c821 | 2012-01-10 00:19:00 +0100 | [diff] [blame] | 402 | case PIPE_CAP_DEPTH_CLIP_DISABLE: |
Dave Airlie | 39d1feb | 2010-10-06 10:14:33 +1000 | [diff] [blame] | 403 | case PIPE_CAP_SHADER_STENCIL_EXPORT: |
Marek Olšák | 95c7881 | 2011-03-05 16:06:10 +0100 | [diff] [blame] | 404 | case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: |
Marek Olšák | 4a7f013 | 2011-03-29 18:18:05 +0200 | [diff] [blame] | 405 | case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 406 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: |
| 407 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: |
Dave Airlie | 13c9a85 | 2011-06-15 15:15:41 +1000 | [diff] [blame] | 408 | case PIPE_CAP_SM3: |
Marek Olšák | badf033 | 2011-06-19 23:41:02 +0200 | [diff] [blame] | 409 | case PIPE_CAP_SEAMLESS_CUBE_MAP: |
Marek Olšák | 01680ce | 2011-08-16 09:47:16 +0200 | [diff] [blame] | 410 | case PIPE_CAP_PRIMITIVE_RESTART: |
Marek Olšák | 3d13b08 | 2011-09-27 23:08:04 +0200 | [diff] [blame] | 411 | case PIPE_CAP_CONDITIONAL_RENDER: |
Marek Olšák | ba89086 | 2011-09-27 23:18:17 +0200 | [diff] [blame] | 412 | case PIPE_CAP_TEXTURE_BARRIER: |
Marek Olšák | bc1c836 | 2012-01-23 03:11:17 +0100 | [diff] [blame] | 413 | case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: |
Marek Olšák | b0b8121 | 2012-02-16 14:45:35 +0100 | [diff] [blame] | 414 | case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: |
Marek Olšák | 7f1cbf1 | 2012-03-08 12:20:01 +0100 | [diff] [blame] | 415 | case PIPE_CAP_TGSI_INSTANCEID: |
Marek Olšák | 7fe3631 | 2012-04-10 05:14:26 +0200 | [diff] [blame] | 416 | case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: |
| 417 | case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: |
| 418 | case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: |
Marek Olšák | 437ab1d | 2012-04-24 15:19:31 +0200 | [diff] [blame] | 419 | case PIPE_CAP_USER_INDEX_BUFFERS: |
| 420 | case PIPE_CAP_USER_CONSTANT_BUFFERS: |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 421 | case PIPE_CAP_COMPUTE: |
Fredrik Höglund | af37212 | 2012-06-18 22:50:02 +0200 | [diff] [blame] | 422 | case PIPE_CAP_START_INSTANCE: |
Marek Olšák | 9d699cd | 2012-07-15 03:38:42 +0200 | [diff] [blame] | 423 | case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: |
Dave Airlie | d23aa65 | 2012-12-16 10:31:32 +0000 | [diff] [blame] | 424 | case PIPE_CAP_TEXTURE_BUFFER_OBJECTS: |
Marek Olšák | 3e10ab6 | 2013-03-14 17:18:43 +0100 | [diff] [blame] | 425 | case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: |
Marek Olšák | dfe5367 | 2013-04-10 20:45:01 +0200 | [diff] [blame] | 426 | case PIPE_CAP_QUERY_PIPELINE_STATISTICS: |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 427 | case PIPE_CAP_TEXTURE_MULTISAMPLE: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 428 | return 1; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 429 | |
Christoph Bumiller | 8acaf86 | 2013-03-15 22:11:31 +0100 | [diff] [blame] | 430 | case PIPE_CAP_TGSI_TEXCOORD: |
| 431 | return 0; |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 432 | |
Marek Olšák | 52cb395 | 2013-05-02 03:24:33 +0200 | [diff] [blame] | 433 | case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 434 | return MIN2(rscreen->b.info.vram_size, 0xFFFFFFFF); |
Marek Olšák | 52cb395 | 2013-05-02 03:24:33 +0200 | [diff] [blame] | 435 | |
Marek Olšák | c9f2af3 | 2012-10-28 17:52:48 +0100 | [diff] [blame] | 436 | case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: |
Marek Olšák | d172fa8 | 2012-11-22 22:40:06 +0100 | [diff] [blame] | 437 | return R600_MAP_BUFFER_ALIGNMENT; |
Marek Olšák | c9f2af3 | 2012-10-28 17:52:48 +0100 | [diff] [blame] | 438 | |
Marek Olšák | 1b749dc | 2012-04-24 17:31:17 +0200 | [diff] [blame] | 439 | case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: |
| 440 | return 256; |
| 441 | |
Fredrik Höglund | fb69dbb | 2013-03-22 17:14:43 +0100 | [diff] [blame] | 442 | case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: |
| 443 | return 1; |
| 444 | |
Marek Olšák | 171be75 | 2012-01-24 22:23:01 +0100 | [diff] [blame] | 445 | case PIPE_CAP_GLSL_FEATURE_LEVEL: |
Dave Airlie | d23aa65 | 2012-12-16 10:31:32 +0000 | [diff] [blame] | 446 | return 140; |
Marek Olšák | 171be75 | 2012-01-24 22:23:01 +0100 | [diff] [blame] | 447 | |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 448 | /* Supported except the original R600. */ |
Alex Deucher | d6fea4a | 2011-03-14 17:47:21 -0400 | [diff] [blame] | 449 | case PIPE_CAP_INDEP_BLEND_ENABLE: |
Dave Airlie | de48199 | 2011-04-25 06:55:09 +1000 | [diff] [blame] | 450 | case PIPE_CAP_INDEP_BLEND_FUNC: |
Alex Deucher | d6fea4a | 2011-03-14 17:47:21 -0400 | [diff] [blame] | 451 | /* R600 doesn't support per-MRT blends */ |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 452 | return family == CHIP_R600 ? 0 : 1; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 453 | |
Marek Olšák | d931b0d | 2011-05-02 02:38:20 +0200 | [diff] [blame] | 454 | /* Supported on Evergreen. */ |
Marek Olšák | d931b0d | 2011-05-02 02:38:20 +0200 | [diff] [blame] | 455 | case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: |
Dave Airlie | eb44c36d | 2012-11-03 20:53:33 +1000 | [diff] [blame] | 456 | case PIPE_CAP_CUBE_MAP_ARRAY: |
Marek Olšák | d931b0d | 2011-05-02 02:38:20 +0200 | [diff] [blame] | 457 | return family >= CHIP_CEDAR ? 1 : 0; |
Marek Olšák | fc8e30e | 2011-04-17 01:57:13 +0200 | [diff] [blame] | 458 | |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 459 | /* Unsupported features. */ |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 460 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: |
| 461 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: |
Marek Olšák | 034e63b | 2011-11-22 20:48:23 +0100 | [diff] [blame] | 462 | case PIPE_CAP_SCALED_RESOLVE: |
Marek Olšák | a3bfbcc | 2011-12-17 15:13:23 +0100 | [diff] [blame] | 463 | case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: |
Marek Olšák | bc1c836 | 2012-01-23 03:11:17 +0100 | [diff] [blame] | 464 | case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: |
| 465 | case PIPE_CAP_VERTEX_COLOR_CLAMPED: |
Marek Olšák | 7fe3631 | 2012-04-10 05:14:26 +0200 | [diff] [blame] | 466 | case PIPE_CAP_USER_VERTEX_BUFFERS: |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 467 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 468 | |
Marek Olšák | 543b233 | 2011-11-08 21:58:27 +0100 | [diff] [blame] | 469 | /* Stream output. */ |
| 470 | case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 471 | return rscreen->has_streamout ? 4 : 0; |
Marek Olšák | 15146fd | 2012-01-25 03:23:27 +0100 | [diff] [blame] | 472 | case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 473 | return rscreen->has_streamout ? 1 : 0; |
Marek Olšák | 543b233 | 2011-11-08 21:58:27 +0100 | [diff] [blame] | 474 | case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: |
| 475 | case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: |
Marek Olšák | b78b624 | 2012-10-26 18:41:49 +0200 | [diff] [blame] | 476 | return 32*4; |
Marek Olšák | 543b233 | 2011-11-08 21:58:27 +0100 | [diff] [blame] | 477 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 478 | /* Texturing. */ |
| 479 | case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: |
| 480 | case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: |
| 481 | case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 482 | if (family >= CHIP_CEDAR) |
| 483 | return 15; |
| 484 | else |
| 485 | return 14; |
Marek Olšák | b37931f | 2011-09-04 04:41:52 +0200 | [diff] [blame] | 486 | case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 487 | return rscreen->b.info.drm_minor >= 9 ? |
Marek Olšák | b37931f | 2011-09-04 04:41:52 +0200 | [diff] [blame] | 488 | (family >= CHIP_CEDAR ? 16384 : 8192) : 0; |
Marek Olšák | 320adb9 | 2011-05-03 11:54:07 +0200 | [diff] [blame] | 489 | case PIPE_CAP_MAX_COMBINED_SAMPLERS: |
| 490 | return 32; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 491 | |
| 492 | /* Render targets. */ |
| 493 | case PIPE_CAP_MAX_RENDER_TARGETS: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 494 | /* XXX some r6xx are buggy and can only do 4 */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 495 | return 8; |
| 496 | |
Marek Olšák | a62cd69 | 2013-09-21 19:45:08 +0200 | [diff] [blame] | 497 | case PIPE_CAP_MAX_VIEWPORTS: |
| 498 | return 1; |
| 499 | |
Mathias Fröhlich | 90c2fd8 | 2011-01-23 22:35:13 +0100 | [diff] [blame] | 500 | /* Timer queries, present when the clock frequency is non zero. */ |
José Fonseca | 9976216 | 2012-12-09 09:50:34 +0000 | [diff] [blame] | 501 | case PIPE_CAP_QUERY_TIME_ELAPSED: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 502 | return rscreen->b.info.r600_clock_crystal_freq != 0; |
Marek Olšák | 44f14eb | 2012-07-05 20:06:41 +0200 | [diff] [blame] | 503 | case PIPE_CAP_QUERY_TIMESTAMP: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 504 | return rscreen->b.info.drm_minor >= 20 && |
| 505 | rscreen->b.info.r600_clock_crystal_freq != 0; |
Mathias Fröhlich | 90c2fd8 | 2011-01-23 22:35:13 +0100 | [diff] [blame] | 506 | |
Dave Airlie | 0b66610 | 2011-08-29 14:35:16 +0100 | [diff] [blame] | 507 | case PIPE_CAP_MIN_TEXEL_OFFSET: |
| 508 | return -8; |
| 509 | |
| 510 | case PIPE_CAP_MAX_TEXEL_OFFSET: |
| 511 | return 7; |
Christoph Bumiller | 729abfd | 2013-04-12 13:42:01 +0200 | [diff] [blame] | 512 | |
| 513 | case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: |
| 514 | return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600; |
Tom Stellard | 4e90bc9 | 2013-07-09 21:21:39 -0700 | [diff] [blame] | 515 | case PIPE_CAP_ENDIANNESS: |
| 516 | return PIPE_ENDIAN_LITTLE; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 517 | } |
Marek Olšák | 4ac250c | 2011-11-22 20:44:14 +0100 | [diff] [blame] | 518 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 519 | } |
| 520 | |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 521 | static float r600_get_paramf(struct pipe_screen* pscreen, |
| 522 | enum pipe_capf param) |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 523 | { |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 524 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 525 | enum radeon_family family = rscreen->b.family; |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 526 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 527 | switch (param) { |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 528 | case PIPE_CAPF_MAX_LINE_WIDTH: |
| 529 | case PIPE_CAPF_MAX_LINE_WIDTH_AA: |
| 530 | case PIPE_CAPF_MAX_POINT_WIDTH: |
| 531 | case PIPE_CAPF_MAX_POINT_WIDTH_AA: |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 532 | if (family >= CHIP_CEDAR) |
| 533 | return 16384.0f; |
| 534 | else |
| 535 | return 8192.0f; |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 536 | case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 537 | return 16.0f; |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 538 | case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 539 | return 16.0f; |
Marek Olšák | 034e63b | 2011-11-22 20:48:23 +0100 | [diff] [blame] | 540 | case PIPE_CAPF_GUARD_BAND_LEFT: |
| 541 | case PIPE_CAPF_GUARD_BAND_TOP: |
| 542 | case PIPE_CAPF_GUARD_BAND_RIGHT: |
| 543 | case PIPE_CAPF_GUARD_BAND_BOTTOM: |
| 544 | return 0.0f; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 545 | } |
Marek Olšák | 4ac250c | 2011-11-22 20:44:14 +0100 | [diff] [blame] | 546 | return 0.0f; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 547 | } |
| 548 | |
| 549 | static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enum pipe_shader_cap param) |
| 550 | { |
| 551 | switch(shader) |
| 552 | { |
| 553 | case PIPE_SHADER_FRAGMENT: |
| 554 | case PIPE_SHADER_VERTEX: |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 555 | case PIPE_SHADER_COMPUTE: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 556 | break; |
| 557 | case PIPE_SHADER_GEOMETRY: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 558 | /* XXX: support and enable geometry programs */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 559 | return 0; |
| 560 | default: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 561 | /* XXX: support tessellation on Evergreen */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 562 | return 0; |
| 563 | } |
| 564 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 565 | switch (param) { |
| 566 | case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: |
| 567 | case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: |
| 568 | case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: |
| 569 | case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: |
| 570 | return 16384; |
| 571 | case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: |
Marek Olšák | cf37aef | 2013-01-31 19:39:41 +0100 | [diff] [blame] | 572 | return 32; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 573 | case PIPE_SHADER_CAP_MAX_INPUTS: |
Marek Olšák | 8b63512 | 2012-10-26 17:35:32 +0200 | [diff] [blame] | 574 | return 32; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 575 | case PIPE_SHADER_CAP_MAX_TEMPS: |
Henri Verbeet | b2a98c3 | 2011-04-25 13:28:55 +0200 | [diff] [blame] | 576 | return 256; /* Max native temporaries. */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 577 | case PIPE_SHADER_CAP_MAX_ADDRS: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 578 | /* XXX Isn't this equal to TEMPS? */ |
Henri Verbeet | b2a98c3 | 2011-04-25 13:28:55 +0200 | [diff] [blame] | 579 | return 1; /* Max native address registers */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 580 | case PIPE_SHADER_CAP_MAX_CONSTS: |
Henri Verbeet | eac5029 | 2011-03-07 21:15:03 +0100 | [diff] [blame] | 581 | return R600_MAX_CONST_BUFFER_SIZE; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 582 | case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: |
Dave Airlie | 7356579 | 2012-11-06 15:31:41 +1000 | [diff] [blame] | 583 | return R600_MAX_USER_CONST_BUFFERS; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 584 | case PIPE_SHADER_CAP_MAX_PREDS: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 585 | return 0; /* nothing uses this */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 586 | case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: |
| 587 | return 1; |
Brian Paul | 13f3ae5 | 2013-02-01 11:16:54 -0700 | [diff] [blame] | 588 | case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: |
| 589 | return 0; |
Marek Olšák | 5c7127c | 2010-11-12 03:07:05 +0100 | [diff] [blame] | 590 | case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: |
| 591 | case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: |
| 592 | case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: |
| 593 | case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: |
| 594 | return 1; |
Marek Olšák | 9aa089e | 2010-11-14 15:34:59 +0100 | [diff] [blame] | 595 | case PIPE_SHADER_CAP_SUBROUTINES: |
| 596 | return 0; |
Bryan Cain | 17b695e | 2011-05-05 21:10:28 -0500 | [diff] [blame] | 597 | case PIPE_SHADER_CAP_INTEGERS: |
Marek Olšák | 15ca9d1 | 2012-07-14 22:28:26 +0200 | [diff] [blame] | 598 | return 1; |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 599 | case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: |
| 600 | return 16; |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 601 | case PIPE_SHADER_CAP_PREFERRED_IR: |
| 602 | if (shader == PIPE_SHADER_COMPUTE) { |
| 603 | return PIPE_SHADER_IR_LLVM; |
| 604 | } else { |
| 605 | return PIPE_SHADER_IR_TGSI; |
| 606 | } |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 607 | } |
Marek Olšák | 4ac250c | 2011-11-22 20:44:14 +0100 | [diff] [blame] | 608 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 609 | } |
| 610 | |
Christian König | f265a19 | 2011-07-07 22:51:45 +0200 | [diff] [blame] | 611 | static int r600_get_video_param(struct pipe_screen *screen, |
| 612 | enum pipe_video_profile profile, |
Christian König | a15cbab | 2013-07-15 08:31:25 -0600 | [diff] [blame] | 613 | enum pipe_video_entrypoint entrypoint, |
Christian König | f265a19 | 2011-07-07 22:51:45 +0200 | [diff] [blame] | 614 | enum pipe_video_cap param) |
| 615 | { |
| 616 | switch (param) { |
Christian König | efc7fda | 2011-07-12 00:12:12 +0200 | [diff] [blame] | 617 | case PIPE_VIDEO_CAP_SUPPORTED: |
Christian König | a15cbab | 2013-07-15 08:31:25 -0600 | [diff] [blame] | 618 | return vl_profile_supported(screen, profile, entrypoint); |
Christian König | f265a19 | 2011-07-07 22:51:45 +0200 | [diff] [blame] | 619 | case PIPE_VIDEO_CAP_NPOT_TEXTURES: |
| 620 | return 1; |
Christian König | efc7fda | 2011-07-12 00:12:12 +0200 | [diff] [blame] | 621 | case PIPE_VIDEO_CAP_MAX_WIDTH: |
| 622 | case PIPE_VIDEO_CAP_MAX_HEIGHT: |
| 623 | return vl_video_buffer_max_size(screen); |
Christian König | 9d9afcb | 2012-01-10 14:03:28 +0100 | [diff] [blame] | 624 | case PIPE_VIDEO_CAP_PREFERED_FORMAT: |
| 625 | return PIPE_FORMAT_NV12; |
Christian König | f3f03c6 | 2012-02-01 23:38:45 +0100 | [diff] [blame] | 626 | case PIPE_VIDEO_CAP_PREFERS_INTERLACED: |
| 627 | return false; |
| 628 | case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED: |
| 629 | return false; |
| 630 | case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE: |
| 631 | return true; |
Rico Schüller | d1ba105 | 2013-08-14 13:17:22 +0200 | [diff] [blame] | 632 | case PIPE_VIDEO_CAP_MAX_LEVEL: |
| 633 | return vl_level_supported(screen, profile); |
Christian König | f265a19 | 2011-07-07 22:51:45 +0200 | [diff] [blame] | 634 | default: |
| 635 | return 0; |
| 636 | } |
| 637 | } |
| 638 | |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 639 | const char * r600_llvm_gpu_string(enum radeon_family family) |
| 640 | { |
| 641 | const char * gpu_family; |
| 642 | |
| 643 | switch (family) { |
| 644 | case CHIP_R600: |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 645 | case CHIP_RV630: |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 646 | case CHIP_RV635: |
| 647 | case CHIP_RV670: |
Tom Stellard | ec143dc | 2013-04-29 13:10:09 -0700 | [diff] [blame] | 648 | gpu_family = "r600"; |
| 649 | break; |
| 650 | case CHIP_RV610: |
| 651 | case CHIP_RV620: |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 652 | case CHIP_RS780: |
| 653 | case CHIP_RS880: |
Tom Stellard | ec143dc | 2013-04-29 13:10:09 -0700 | [diff] [blame] | 654 | gpu_family = "rs880"; |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 655 | break; |
| 656 | case CHIP_RV710: |
| 657 | gpu_family = "rv710"; |
| 658 | break; |
| 659 | case CHIP_RV730: |
| 660 | gpu_family = "rv730"; |
| 661 | break; |
| 662 | case CHIP_RV740: |
| 663 | case CHIP_RV770: |
| 664 | gpu_family = "rv770"; |
| 665 | break; |
| 666 | case CHIP_PALM: |
| 667 | case CHIP_CEDAR: |
| 668 | gpu_family = "cedar"; |
| 669 | break; |
| 670 | case CHIP_SUMO: |
| 671 | case CHIP_SUMO2: |
Tom Stellard | ec143dc | 2013-04-29 13:10:09 -0700 | [diff] [blame] | 672 | gpu_family = "sumo"; |
| 673 | break; |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 674 | case CHIP_REDWOOD: |
| 675 | gpu_family = "redwood"; |
| 676 | break; |
| 677 | case CHIP_JUNIPER: |
| 678 | gpu_family = "juniper"; |
| 679 | break; |
| 680 | case CHIP_HEMLOCK: |
| 681 | case CHIP_CYPRESS: |
| 682 | gpu_family = "cypress"; |
| 683 | break; |
| 684 | case CHIP_BARTS: |
| 685 | gpu_family = "barts"; |
| 686 | break; |
| 687 | case CHIP_TURKS: |
| 688 | gpu_family = "turks"; |
| 689 | break; |
| 690 | case CHIP_CAICOS: |
| 691 | gpu_family = "caicos"; |
| 692 | break; |
| 693 | case CHIP_CAYMAN: |
| 694 | case CHIP_ARUBA: |
| 695 | gpu_family = "cayman"; |
| 696 | break; |
| 697 | default: |
| 698 | gpu_family = ""; |
| 699 | fprintf(stderr, "Chip not supported by r600 llvm " |
| 700 | "backend, please file a bug at " PACKAGE_BUGREPORT "\n"); |
| 701 | break; |
| 702 | } |
| 703 | return gpu_family; |
| 704 | } |
| 705 | |
| 706 | |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 707 | static int r600_get_compute_param(struct pipe_screen *screen, |
| 708 | enum pipe_compute_cap param, |
| 709 | void *ret) |
| 710 | { |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 711 | struct r600_screen *rscreen = (struct r600_screen *)screen; |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 712 | //TODO: select these params by asic |
| 713 | switch (param) { |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 714 | case PIPE_COMPUTE_CAP_IR_TARGET: { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 715 | const char *gpu = r600_llvm_gpu_string(rscreen->b.family); |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 716 | if (ret) { |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 717 | sprintf(ret, "%s-r600--", gpu); |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 718 | } |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 719 | return (8 + strlen(gpu)) * sizeof(char); |
| 720 | } |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 721 | case PIPE_COMPUTE_CAP_GRID_DIMENSION: |
| 722 | if (ret) { |
| 723 | uint64_t * grid_dimension = ret; |
| 724 | grid_dimension[0] = 3; |
| 725 | } |
| 726 | return 1 * sizeof(uint64_t); |
| 727 | |
| 728 | case PIPE_COMPUTE_CAP_MAX_GRID_SIZE: |
| 729 | if (ret) { |
| 730 | uint64_t * grid_size = ret; |
| 731 | grid_size[0] = 65535; |
| 732 | grid_size[1] = 65535; |
| 733 | grid_size[2] = 1; |
| 734 | } |
| 735 | return 3 * sizeof(uint64_t) ; |
| 736 | |
| 737 | case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE: |
| 738 | if (ret) { |
| 739 | uint64_t * block_size = ret; |
| 740 | block_size[0] = 256; |
| 741 | block_size[1] = 256; |
| 742 | block_size[2] = 256; |
| 743 | } |
| 744 | return 3 * sizeof(uint64_t); |
| 745 | |
| 746 | case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK: |
| 747 | if (ret) { |
| 748 | uint64_t * max_threads_per_block = ret; |
| 749 | *max_threads_per_block = 256; |
| 750 | } |
| 751 | return sizeof(uint64_t); |
| 752 | |
| 753 | case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE: |
| 754 | if (ret) { |
| 755 | uint64_t * max_global_size = ret; |
Tom Stellard | 91ee735 | 2012-09-13 17:09:03 +0000 | [diff] [blame] | 756 | /* XXX: This is what the proprietary driver reports, we |
| 757 | * may want to use a different value. */ |
| 758 | *max_global_size = 201326592; |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 759 | } |
| 760 | return sizeof(uint64_t); |
| 761 | |
| 762 | case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE: |
| 763 | if (ret) { |
| 764 | uint64_t * max_input_size = ret; |
| 765 | *max_input_size = 1024; |
| 766 | } |
| 767 | return sizeof(uint64_t); |
| 768 | |
| 769 | case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE: |
| 770 | if (ret) { |
| 771 | uint64_t * max_local_size = ret; |
| 772 | /* XXX: This is what the proprietary driver reports, we |
| 773 | * may want to use a different value. */ |
| 774 | *max_local_size = 32768; |
| 775 | } |
| 776 | return sizeof(uint64_t); |
| 777 | |
Tom Stellard | 0e3c30c | 2012-09-21 20:19:14 +0000 | [diff] [blame] | 778 | case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE: |
| 779 | if (ret) { |
| 780 | uint64_t max_global_size; |
| 781 | uint64_t * max_mem_alloc_size = ret; |
| 782 | r600_get_compute_param(screen, |
| 783 | PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE, |
| 784 | &max_global_size); |
| 785 | /* OpenCL requres this value be at least |
| 786 | * max(MAX_GLOBAL_SIZE / 4, 128 * 1024 *1024) |
| 787 | * I'm really not sure what value to report here, but |
| 788 | * MAX_GLOBAL_SIZE / 4 seems resonable. |
| 789 | */ |
| 790 | *max_mem_alloc_size = max_global_size / 4; |
| 791 | } |
| 792 | return sizeof(uint64_t); |
| 793 | |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 794 | default: |
| 795 | fprintf(stderr, "unknown PIPE_COMPUTE_CAP %d\n", param); |
| 796 | return 0; |
| 797 | } |
| 798 | } |
| 799 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 800 | static void r600_destroy_screen(struct pipe_screen* pscreen) |
| 801 | { |
| 802 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
| 803 | |
| 804 | if (rscreen == NULL) |
| 805 | return; |
Tilman Sauerbeck | 52ba68d | 2010-10-31 15:51:55 +0100 | [diff] [blame] | 806 | |
Christian König | 4871128 | 2013-09-25 13:59:56 +0200 | [diff] [blame] | 807 | if (!radeon_winsys_unref(rscreen->b.ws)) |
| 808 | return; |
| 809 | |
Marek Olšák | 68f6dec | 2013-09-22 21:45:23 +0200 | [diff] [blame] | 810 | r600_common_screen_cleanup(&rscreen->b); |
Marek Olšák | b692076 | 2013-04-21 23:26:52 +0200 | [diff] [blame] | 811 | |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 812 | if (rscreen->global_pool) { |
| 813 | compute_memory_pool_delete(rscreen->global_pool); |
| 814 | } |
| 815 | |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 816 | if (rscreen->trace_bo) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 817 | rscreen->b.ws->buffer_unmap(rscreen->trace_bo->cs_buf); |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 818 | pipe_resource_reference((struct pipe_resource**)&rscreen->trace_bo, NULL); |
| 819 | } |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 820 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 821 | rscreen->b.ws->destroy(rscreen->b.ws); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 822 | FREE(rscreen); |
| 823 | } |
| 824 | |
Marek Olšák | 44f14eb | 2012-07-05 20:06:41 +0200 | [diff] [blame] | 825 | static uint64_t r600_get_timestamp(struct pipe_screen *screen) |
| 826 | { |
| 827 | struct r600_screen *rscreen = (struct r600_screen*)screen; |
| 828 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 829 | return 1000000 * rscreen->b.ws->query_value(rscreen->b.ws, RADEON_TIMESTAMP) / |
| 830 | rscreen->b.info.r600_clock_crystal_freq; |
Marek Olšák | 44f14eb | 2012-07-05 20:06:41 +0200 | [diff] [blame] | 831 | } |
| 832 | |
Marek Olšák | 2504380 | 2013-03-21 19:44:18 +0100 | [diff] [blame] | 833 | static int r600_get_driver_query_info(struct pipe_screen *screen, |
| 834 | unsigned index, |
| 835 | struct pipe_driver_query_info *info) |
| 836 | { |
Marek Olšák | 8ddae68 | 2013-03-22 02:39:42 +0100 | [diff] [blame] | 837 | struct r600_screen *rscreen = (struct r600_screen*)screen; |
Marek Olšák | 2504380 | 2013-03-21 19:44:18 +0100 | [diff] [blame] | 838 | struct pipe_driver_query_info list[] = { |
| 839 | {"draw-calls", R600_QUERY_DRAW_CALLS, 0}, |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 840 | {"requested-VRAM", R600_QUERY_REQUESTED_VRAM, rscreen->b.info.vram_size, TRUE}, |
| 841 | {"requested-GTT", R600_QUERY_REQUESTED_GTT, rscreen->b.info.gart_size, TRUE}, |
Marek Olšák | 05fa359 | 2013-04-05 02:43:26 +0200 | [diff] [blame] | 842 | {"buffer-wait-time", R600_QUERY_BUFFER_WAIT_TIME, 0, FALSE} |
Marek Olšák | 2504380 | 2013-03-21 19:44:18 +0100 | [diff] [blame] | 843 | }; |
| 844 | |
| 845 | if (!info) |
| 846 | return Elements(list); |
| 847 | |
| 848 | if (index >= Elements(list)) |
| 849 | return 0; |
| 850 | |
| 851 | *info = list[index]; |
| 852 | return 1; |
| 853 | } |
| 854 | |
Marek Olšák | 2ce783d | 2011-08-02 20:25:13 +0200 | [diff] [blame] | 855 | struct pipe_screen *r600_screen_create(struct radeon_winsys *ws) |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 856 | { |
Marek Olšák | 90ce3cd | 2011-09-17 14:10:20 +0200 | [diff] [blame] | 857 | struct r600_screen *rscreen = CALLOC_STRUCT(r600_screen); |
Dave Airlie | e6aad9b | 2012-04-22 08:09:05 +0100 | [diff] [blame] | 858 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 859 | if (rscreen == NULL) { |
| 860 | return NULL; |
| 861 | } |
| 862 | |
Marek Olšák | 7b25f52 | 2013-09-30 12:57:51 +0200 | [diff] [blame] | 863 | ws->query_info(ws, &rscreen->b.info); |
| 864 | |
Marek Olšák | 68f6dec | 2013-09-22 21:45:23 +0200 | [diff] [blame] | 865 | /* Set functions first. */ |
| 866 | rscreen->b.b.context_create = r600_create_context; |
| 867 | rscreen->b.b.destroy = r600_destroy_screen; |
| 868 | rscreen->b.b.get_name = r600_get_name; |
| 869 | rscreen->b.b.get_vendor = r600_get_vendor; |
| 870 | rscreen->b.b.get_param = r600_get_param; |
| 871 | rscreen->b.b.get_shader_param = r600_get_shader_param; |
| 872 | rscreen->b.b.get_paramf = r600_get_paramf; |
| 873 | rscreen->b.b.get_compute_param = r600_get_compute_param; |
| 874 | rscreen->b.b.get_timestamp = r600_get_timestamp; |
Marek Olšák | 7b25f52 | 2013-09-30 12:57:51 +0200 | [diff] [blame] | 875 | if (rscreen->b.info.chip_class >= EVERGREEN) { |
Marek Olšák | 68f6dec | 2013-09-22 21:45:23 +0200 | [diff] [blame] | 876 | rscreen->b.b.is_format_supported = evergreen_is_format_supported; |
| 877 | } else { |
| 878 | rscreen->b.b.is_format_supported = r600_is_format_supported; |
| 879 | } |
Marek Olšák | 68f6dec | 2013-09-22 21:45:23 +0200 | [diff] [blame] | 880 | rscreen->b.b.get_driver_query_info = r600_get_driver_query_info; |
| 881 | if (rscreen->b.info.has_uvd) { |
| 882 | rscreen->b.b.get_video_param = ruvd_get_video_param; |
| 883 | rscreen->b.b.is_video_format_supported = ruvd_is_format_supported; |
| 884 | } else { |
| 885 | rscreen->b.b.get_video_param = r600_get_video_param; |
| 886 | rscreen->b.b.is_video_format_supported = vl_video_buffer_is_format_supported; |
| 887 | } |
| 888 | r600_init_screen_resource_functions(&rscreen->b.b); |
| 889 | |
Marek Olšák | 1bb77f8 | 2013-09-22 22:12:18 +0200 | [diff] [blame] | 890 | if (!r600_common_screen_init(&rscreen->b, ws)) { |
| 891 | FREE(rscreen); |
| 892 | return NULL; |
| 893 | } |
Marek Olšák | 3603d15 | 2011-09-11 14:53:07 +0200 | [diff] [blame] | 894 | |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 895 | 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] | 896 | if (debug_get_bool_option("R600_DEBUG_COMPUTE", FALSE)) |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 897 | rscreen->b.debug_flags |= DBG_COMPUTE; |
Michel Dänzer | 31009b4 | 2013-03-21 17:56:52 +0100 | [diff] [blame] | 898 | if (debug_get_bool_option("R600_DUMP_SHADERS", FALSE)) |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 899 | rscreen->b.debug_flags |= DBG_FS | DBG_VS | DBG_GS | DBG_PS | DBG_CS; |
Michel Dänzer | 31009b4 | 2013-03-21 17:56:52 +0100 | [diff] [blame] | 900 | if (!debug_get_bool_option("R600_HYPERZ", TRUE)) |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 901 | rscreen->b.debug_flags |= DBG_NO_HYPERZ; |
Michel Dänzer | 31009b4 | 2013-03-21 17:56:52 +0100 | [diff] [blame] | 902 | if (!debug_get_bool_option("R600_LLVM", TRUE)) |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 903 | rscreen->b.debug_flags |= DBG_NO_LLVM; |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 904 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 905 | if (rscreen->b.family == CHIP_UNKNOWN) { |
| 906 | 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] | 907 | FREE(rscreen); |
| 908 | return NULL; |
| 909 | } |
| 910 | |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 911 | /* Figure out streamout kernel support. */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 912 | switch (rscreen->b.chip_class) { |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 913 | case R600: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 914 | if (rscreen->b.family < CHIP_RS780) { |
| 915 | rscreen->has_streamout = rscreen->b.info.drm_minor >= 14; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 916 | } else { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 917 | rscreen->has_streamout = rscreen->b.info.drm_minor >= 23; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 918 | } |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 919 | break; |
| 920 | case R700: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 921 | rscreen->has_streamout = rscreen->b.info.drm_minor >= 17; |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 922 | break; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 923 | case EVERGREEN: |
| 924 | case CAYMAN: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 925 | rscreen->has_streamout = rscreen->b.info.drm_minor >= 14; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 926 | break; |
Jerome Glisse | ca474f9 | 2013-01-04 16:34:52 -0500 | [diff] [blame] | 927 | default: |
| 928 | rscreen->has_streamout = FALSE; |
| 929 | break; |
Marek Olšák | 393d741 | 2012-03-27 21:00:49 +0200 | [diff] [blame] | 930 | } |
| 931 | |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 932 | /* MSAA support. */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 933 | switch (rscreen->b.chip_class) { |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 934 | case R600: |
| 935 | case R700: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 936 | rscreen->has_msaa = rscreen->b.info.drm_minor >= 22; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 937 | rscreen->has_compressed_msaa_texturing = false; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 938 | break; |
| 939 | case EVERGREEN: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 940 | rscreen->has_msaa = rscreen->b.info.drm_minor >= 19; |
| 941 | rscreen->has_compressed_msaa_texturing = rscreen->b.info.drm_minor >= 24; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 942 | break; |
| 943 | case CAYMAN: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 944 | rscreen->has_msaa = rscreen->b.info.drm_minor >= 19; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 945 | rscreen->has_compressed_msaa_texturing = true; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 946 | break; |
Jerome Glisse | ca474f9 | 2013-01-04 16:34:52 -0500 | [diff] [blame] | 947 | default: |
| 948 | rscreen->has_msaa = FALSE; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 949 | rscreen->has_compressed_msaa_texturing = false; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 950 | } |
| 951 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 952 | rscreen->has_cp_dma = rscreen->b.info.drm_minor >= 27 && |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 953 | !(rscreen->b.debug_flags & DBG_NO_CP_DMA); |
Marek Olšák | 58bd926 | 2013-02-21 17:06:26 +0100 | [diff] [blame] | 954 | |
Tom Stellard | c0f7fe7 | 2012-07-11 16:18:22 +0000 | [diff] [blame] | 955 | rscreen->global_pool = compute_memory_pool_new(rscreen); |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 956 | |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 957 | rscreen->cs_count = 0; |
Marek Olšák | ba650cc | 2013-09-22 15:18:11 +0200 | [diff] [blame] | 958 | if (rscreen->b.info.drm_minor >= 28 && (rscreen->b.debug_flags & DBG_TRACE_CS)) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 959 | rscreen->trace_bo = (struct r600_resource*)pipe_buffer_create(&rscreen->b.b, |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 960 | PIPE_BIND_CUSTOM, |
| 961 | PIPE_USAGE_STAGING, |
| 962 | 4096); |
| 963 | if (rscreen->trace_bo) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 964 | rscreen->trace_ptr = rscreen->b.ws->buffer_map(rscreen->trace_bo->cs_buf, NULL, |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 965 | PIPE_TRANSFER_UNSYNCHRONIZED); |
| 966 | } |
| 967 | } |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 968 | |
Marek Olšák | b893bbf | 2013-10-03 16:39:50 +0200 | [diff] [blame] | 969 | /* Create the auxiliary context. This must be done last. */ |
| 970 | rscreen->b.aux_context = rscreen->b.b.context_create(&rscreen->b.b, NULL); |
| 971 | |
Marek Olšák | b692076 | 2013-04-21 23:26:52 +0200 | [diff] [blame] | 972 | #if 0 /* This is for testing whether aux_context and buffer clearing work correctly. */ |
| 973 | struct pipe_resource templ = {}; |
| 974 | |
| 975 | templ.width0 = 4; |
| 976 | templ.height0 = 2048; |
| 977 | templ.depth0 = 1; |
| 978 | templ.array_size = 1; |
| 979 | templ.target = PIPE_TEXTURE_2D; |
| 980 | templ.format = PIPE_FORMAT_R8G8B8A8_UNORM; |
| 981 | templ.usage = PIPE_USAGE_STATIC; |
| 982 | |
| 983 | struct r600_resource *res = r600_resource(rscreen->screen.resource_create(&rscreen->screen, &templ)); |
| 984 | unsigned char *map = ws->buffer_map(res->cs_buf, NULL, PIPE_TRANSFER_WRITE); |
| 985 | |
| 986 | memset(map, 0, 256); |
| 987 | |
| 988 | r600_screen_clear_buffer(rscreen, &res->b.b, 4, 4, 0xCC); |
| 989 | r600_screen_clear_buffer(rscreen, &res->b.b, 8, 4, 0xDD); |
| 990 | r600_screen_clear_buffer(rscreen, &res->b.b, 12, 4, 0xEE); |
| 991 | r600_screen_clear_buffer(rscreen, &res->b.b, 20, 4, 0xFF); |
| 992 | r600_screen_clear_buffer(rscreen, &res->b.b, 32, 20, 0x87); |
| 993 | |
| 994 | ws->buffer_wait(res->buf, RADEON_USAGE_WRITE); |
| 995 | |
| 996 | int i; |
| 997 | for (i = 0; i < 256; i++) { |
| 998 | printf("%02X", map[i]); |
| 999 | if (i % 16 == 15) |
| 1000 | printf("\n"); |
| 1001 | } |
| 1002 | #endif |
| 1003 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1004 | return &rscreen->b.b; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 1005 | } |