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" |
Kai Wasserbäch | 8fb7f1a | 2011-08-27 17:51:51 +0200 | [diff] [blame] | 35 | #include "util/u_format_s3tc.h" |
Marek Olšák | 9f06966 | 2012-12-03 21:31:04 +0100 | [diff] [blame] | 36 | #include "util/u_memory.h" |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 37 | #include "util/u_simple_shaders.h" |
Marek Olšák | 428855e | 2012-04-11 16:00:09 +0200 | [diff] [blame] | 38 | #include "util/u_upload_mgr.h" |
Jerome Glisse | 325422c | 2013-01-07 17:45:59 -0500 | [diff] [blame] | 39 | #include "util/u_math.h" |
Kai Wasserbäch | 8fb7f1a | 2011-08-27 17:51:51 +0200 | [diff] [blame] | 40 | #include "vl/vl_decoder.h" |
| 41 | #include "vl/vl_video_buffer.h" |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 42 | #include "radeon/radeon_uvd.h" |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 43 | #include "os/os_time.h" |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 44 | |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 45 | static const struct debug_named_value debug_options[] = { |
| 46 | /* logging */ |
| 47 | { "texdepth", DBG_TEX_DEPTH, "Print texture depth info" }, |
| 48 | { "compute", DBG_COMPUTE, "Print compute info" }, |
Marek Olšák | 413ca78 | 2013-04-06 01:33:21 +0200 | [diff] [blame] | 49 | { "vm", DBG_VM, "Print virtual addresses when creating resources" }, |
Jerome Glisse | abb96fd | 2013-04-23 19:22:33 -0400 | [diff] [blame] | 50 | { "trace_cs", DBG_TRACE_CS, "Trace cs and write rlockup_<csid>.c file with faulty cs" }, |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 51 | |
| 52 | /* shaders */ |
| 53 | { "fs", DBG_FS, "Print fetch shaders" }, |
| 54 | { "vs", DBG_VS, "Print vertex shaders" }, |
| 55 | { "gs", DBG_GS, "Print geometry shaders" }, |
| 56 | { "ps", DBG_PS, "Print pixel shaders" }, |
| 57 | { "cs", DBG_CS, "Print compute shaders" }, |
| 58 | |
| 59 | /* features */ |
| 60 | { "nohyperz", DBG_NO_HYPERZ, "Disable Hyper-Z" }, |
| 61 | #if defined(R600_USE_LLVM) |
| 62 | { "nollvm", DBG_NO_LLVM, "Disable the LLVM shader compiler" }, |
| 63 | #endif |
Marek Olšák | e4e655f | 2013-03-05 01:15:45 +0100 | [diff] [blame] | 64 | { "nocpdma", DBG_NO_CP_DMA, "Disable CP DMA" }, |
| 65 | { "nodma", DBG_NO_ASYNC_DMA, "Disable asynchronous DMA" }, |
| 66 | /* GL uses the word INVALIDATE, gallium uses the word DISCARD */ |
| 67 | { "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] | 68 | |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 69 | /* shader backend */ |
Vadim Girlin | f7217b9 | 2013-08-24 00:54:54 +0400 | [diff] [blame] | 70 | { "nosb", DBG_NO_SB, "Disable sb backend for graphics shaders" }, |
| 71 | { "sbcl", DBG_SB_CS, "Enable sb backend for compute shaders" }, |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 72 | { "sbdry", DBG_SB_DRY_RUN, "Don't use optimized bytecode (just print the dumps)" }, |
| 73 | { "sbstat", DBG_SB_STAT, "Print optimization statistics for shaders" }, |
| 74 | { "sbdump", DBG_SB_DUMP, "Print IR dumps after some optimization passes" }, |
Vadim Girlin | 188c893 | 2013-04-23 10:34:00 +0400 | [diff] [blame] | 75 | { "sbnofallback", DBG_SB_NO_FALLBACK, "Abort on errors instead of fallback" }, |
Vadim Girlin | 4ca67db | 2013-05-03 12:01:20 +0400 | [diff] [blame] | 76 | { "sbdisasm", DBG_SB_DISASM, "Use sb disassembler for shader dumps" }, |
Vadim Girlin | 758ac6f | 2013-06-05 20:55:31 +0400 | [diff] [blame] | 77 | { "sbsafemath", DBG_SB_SAFEMATH, "Disable unsafe math optimizations" }, |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 78 | |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 79 | DEBUG_NAMED_VALUE_END /* must be last */ |
| 80 | }; |
| 81 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 82 | /* |
| 83 | * pipe_context |
| 84 | */ |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 85 | static struct r600_fence *r600_create_fence(struct r600_context *rctx) |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 86 | { |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 87 | struct r600_screen *rscreen = rctx->screen; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 88 | struct r600_fence *fence = NULL; |
| 89 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 90 | pipe_mutex_lock(rscreen->fences.mutex); |
| 91 | |
| 92 | if (!rscreen->fences.bo) { |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 93 | /* Create the shared buffer object */ |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 94 | rscreen->fences.bo = (struct r600_resource*) |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 95 | pipe_buffer_create(&rscreen->b.b, PIPE_BIND_CUSTOM, |
Marek Olšák | 6101b6d | 2011-09-11 22:24:38 +0200 | [diff] [blame] | 96 | PIPE_USAGE_STAGING, 4096); |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 97 | if (!rscreen->fences.bo) { |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 98 | R600_ERR("r600: failed to create bo for fence objects\n"); |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 99 | goto out; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 100 | } |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 101 | rscreen->fences.data = r600_buffer_mmap_sync_with_rings(rctx, rscreen->fences.bo, PIPE_TRANSFER_READ_WRITE); |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 102 | } |
| 103 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 104 | if (!LIST_IS_EMPTY(&rscreen->fences.pool)) { |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 105 | struct r600_fence *entry; |
| 106 | |
| 107 | /* Try to find a freed fence that has been signalled */ |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 108 | LIST_FOR_EACH_ENTRY(entry, &rscreen->fences.pool, head) { |
| 109 | if (rscreen->fences.data[entry->index] != 0) { |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 110 | LIST_DELINIT(&entry->head); |
| 111 | fence = entry; |
| 112 | break; |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | if (!fence) { |
| 118 | /* Allocate a new fence */ |
| 119 | struct r600_fence_block *block; |
| 120 | unsigned index; |
| 121 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 122 | if ((rscreen->fences.next_index + 1) >= 1024) { |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 123 | R600_ERR("r600: too many concurrent fences\n"); |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 124 | goto out; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 125 | } |
| 126 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 127 | index = rscreen->fences.next_index++; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 128 | |
| 129 | if (!(index % FENCE_BLOCK_SIZE)) { |
| 130 | /* Allocate a new block */ |
| 131 | block = CALLOC_STRUCT(r600_fence_block); |
| 132 | if (block == NULL) |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 133 | goto out; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 134 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 135 | LIST_ADD(&block->head, &rscreen->fences.blocks); |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 136 | } else { |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 137 | block = LIST_ENTRY(struct r600_fence_block, rscreen->fences.blocks.next, head); |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | fence = &block->fences[index % FENCE_BLOCK_SIZE]; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 141 | fence->index = index; |
| 142 | } |
| 143 | |
| 144 | pipe_reference_init(&fence->reference, 1); |
| 145 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 146 | rscreen->fences.data[fence->index] = 0; |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 147 | r600_context_emit_fence(rctx, rscreen->fences.bo, fence->index, 1); |
Simon Farnsworth | 8cd03b9 | 2012-02-14 12:06:20 +0000 | [diff] [blame] | 148 | |
| 149 | /* Create a dummy BO so that fence_finish without a timeout can sleep waiting for completion */ |
| 150 | fence->sleep_bo = (struct r600_resource*) |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 151 | pipe_buffer_create(&rctx->screen->b.b, PIPE_BIND_CUSTOM, |
Simon Farnsworth | 8cd03b9 | 2012-02-14 12:06:20 +0000 | [diff] [blame] | 152 | PIPE_USAGE_STAGING, 1); |
| 153 | /* Add the fence as a dummy relocation. */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 154 | r600_context_bo_reloc(&rctx->b, &rctx->b.rings.gfx, fence->sleep_bo, RADEON_USAGE_READWRITE); |
Simon Farnsworth | 8cd03b9 | 2012-02-14 12:06:20 +0000 | [diff] [blame] | 155 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 156 | out: |
| 157 | pipe_mutex_unlock(rscreen->fences.mutex); |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 158 | return fence; |
| 159 | } |
| 160 | |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 161 | static void r600_flush(struct pipe_context *ctx, unsigned flags) |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 162 | { |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 163 | struct r600_context *rctx = (struct r600_context *)ctx; |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 164 | struct pipe_query *render_cond = NULL; |
| 165 | unsigned render_cond_mode = 0; |
Roland Scheidegger | 793e8e3 | 2013-06-14 19:48:57 +0200 | [diff] [blame] | 166 | boolean render_cond_cond = FALSE; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 167 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 168 | 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] | 169 | return; |
| 170 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 171 | rctx->b.rings.gfx.flushing = true; |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 172 | /* Disable render condition. */ |
| 173 | if (rctx->current_render_cond) { |
| 174 | render_cond = rctx->current_render_cond; |
Roland Scheidegger | 793e8e3 | 2013-06-14 19:48:57 +0200 | [diff] [blame] | 175 | render_cond_cond = rctx->current_render_cond_cond; |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 176 | render_cond_mode = rctx->current_render_cond_mode; |
Roland Scheidegger | 793e8e3 | 2013-06-14 19:48:57 +0200 | [diff] [blame] | 177 | ctx->render_condition(ctx, NULL, FALSE, 0); |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 178 | } |
| 179 | |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 180 | r600_context_flush(rctx, flags); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 181 | rctx->b.rings.gfx.flushing = false; |
Jerome Glisse | 325422c | 2013-01-07 17:45:59 -0500 | [diff] [blame] | 182 | r600_begin_new_cs(rctx); |
Marek Olšák | 578b211 | 2011-11-10 15:50:06 +0100 | [diff] [blame] | 183 | |
| 184 | /* Re-enable render condition. */ |
| 185 | if (render_cond) { |
Roland Scheidegger | 793e8e3 | 2013-06-14 19:48:57 +0200 | [diff] [blame] | 186 | 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] | 187 | } |
Marek Olšák | 1faa375 | 2013-06-30 18:29:17 +0200 | [diff] [blame] | 188 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 189 | rctx->initial_gfx_cs_size = rctx->b.rings.gfx.cs->cdw; |
Marek Olšák | e2e1dc9 | 2011-08-04 03:38:20 +0200 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | static void r600_flush_from_st(struct pipe_context *ctx, |
Marek Olšák | 598cc1f | 2012-12-21 17:03:22 +0100 | [diff] [blame] | 193 | struct pipe_fence_handle **fence, |
Chia-I Wu | 8c347d4 | 2013-05-02 16:25:15 +0800 | [diff] [blame] | 194 | unsigned flags) |
Marek Olšák | e2e1dc9 | 2011-08-04 03:38:20 +0200 | [diff] [blame] | 195 | { |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 196 | struct r600_context *rctx = (struct r600_context *)ctx; |
| 197 | struct r600_fence **rfence = (struct r600_fence**)fence; |
| 198 | unsigned fflags; |
| 199 | |
| 200 | fflags = flags & PIPE_FLUSH_END_OF_FRAME ? RADEON_FLUSH_END_OF_FRAME : 0; |
| 201 | if (rfence) { |
| 202 | *rfence = r600_create_fence(rctx); |
| 203 | } |
| 204 | /* 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] | 205 | if (rctx->b.rings.dma.cs) { |
| 206 | rctx->b.rings.dma.flush(rctx, fflags); |
Jerome Glisse | 7291669 | 2013-01-28 14:48:46 -0500 | [diff] [blame] | 207 | } |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 208 | rctx->b.rings.gfx.flush(rctx, fflags); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | static void r600_flush_gfx_ring(void *ctx, unsigned flags) |
| 212 | { |
| 213 | r600_flush((struct pipe_context*)ctx, flags); |
| 214 | } |
| 215 | |
| 216 | static void r600_flush_dma_ring(void *ctx, unsigned flags) |
| 217 | { |
| 218 | struct r600_context *rctx = (struct r600_context *)ctx; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 219 | struct radeon_winsys_cs *cs = rctx->b.rings.dma.cs; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 220 | |
Marek Olšák | c77917d | 2013-02-27 21:24:02 +0100 | [diff] [blame] | 221 | if (!cs->cdw) { |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 222 | return; |
| 223 | } |
Marek Olšák | c77917d | 2013-02-27 21:24:02 +0100 | [diff] [blame] | 224 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 225 | rctx->b.rings.dma.flushing = true; |
| 226 | rctx->b.ws->cs_flush(cs, flags, 0); |
| 227 | rctx->b.rings.dma.flushing = false; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | boolean r600_rings_is_buffer_referenced(struct r600_context *ctx, |
| 231 | struct radeon_winsys_cs_handle *buf, |
| 232 | enum radeon_bo_usage usage) |
| 233 | { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 234 | if (ctx->b.ws->cs_is_buffer_referenced(ctx->b.rings.gfx.cs, buf, usage)) { |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 235 | return TRUE; |
| 236 | } |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 237 | if (ctx->b.rings.dma.cs) { |
| 238 | if (ctx->b.ws->cs_is_buffer_referenced(ctx->b.rings.dma.cs, buf, usage)) { |
Jerome Glisse | 7291669 | 2013-01-28 14:48:46 -0500 | [diff] [blame] | 239 | return TRUE; |
| 240 | } |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 241 | } |
| 242 | return FALSE; |
| 243 | } |
| 244 | |
| 245 | void *r600_buffer_mmap_sync_with_rings(struct r600_context *ctx, |
| 246 | struct r600_resource *resource, |
| 247 | unsigned usage) |
| 248 | { |
| 249 | enum radeon_bo_usage rusage = RADEON_USAGE_READWRITE; |
| 250 | unsigned flags = 0; |
| 251 | bool sync_flush = TRUE; |
| 252 | |
| 253 | if (usage & PIPE_TRANSFER_UNSYNCHRONIZED) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 254 | return ctx->b.ws->buffer_map(resource->cs_buf, NULL, usage); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | if (!(usage & PIPE_TRANSFER_WRITE)) { |
| 258 | /* have to wait for pending read */ |
| 259 | rusage = RADEON_USAGE_WRITE; |
| 260 | } |
| 261 | if (usage & PIPE_TRANSFER_DONTBLOCK) { |
| 262 | flags |= RADEON_FLUSH_ASYNC; |
| 263 | } |
| 264 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 265 | if (ctx->b.ws->cs_is_buffer_referenced(ctx->b.rings.gfx.cs, resource->cs_buf, rusage) && ctx->b.rings.gfx.cs->cdw) { |
| 266 | ctx->b.rings.gfx.flush(ctx, flags); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 267 | if (usage & PIPE_TRANSFER_DONTBLOCK) { |
| 268 | return NULL; |
| 269 | } |
| 270 | } |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 271 | if (ctx->b.rings.dma.cs) { |
| 272 | if (ctx->b.ws->cs_is_buffer_referenced(ctx->b.rings.dma.cs, resource->cs_buf, rusage) && ctx->b.rings.dma.cs->cdw) { |
| 273 | ctx->b.rings.dma.flush(ctx, flags); |
Jerome Glisse | 7291669 | 2013-01-28 14:48:46 -0500 | [diff] [blame] | 274 | if (usage & PIPE_TRANSFER_DONTBLOCK) { |
| 275 | return NULL; |
| 276 | } |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | |
| 280 | if (usage & PIPE_TRANSFER_DONTBLOCK) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 281 | if (ctx->b.ws->buffer_is_busy(resource->buf, rusage)) { |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 282 | return NULL; |
| 283 | } |
| 284 | } |
| 285 | if (sync_flush) { |
| 286 | /* Try to avoid busy-waiting in radeon_bo_wait. */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 287 | ctx->b.ws->cs_sync_flush(ctx->b.rings.gfx.cs); |
| 288 | if (ctx->b.rings.dma.cs) { |
| 289 | ctx->b.ws->cs_sync_flush(ctx->b.rings.dma.cs); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 290 | } |
| 291 | } |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 292 | |
| 293 | /* at this point everything is synchronized */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 294 | return ctx->b.ws->buffer_map(resource->cs_buf, NULL, usage); |
Marek Olšák | e2e1dc9 | 2011-08-04 03:38:20 +0200 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | static void r600_flush_from_winsys(void *ctx, unsigned flags) |
| 298 | { |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 299 | struct r600_context *rctx = (struct r600_context *)ctx; |
| 300 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 301 | rctx->b.rings.gfx.flush(rctx, flags); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | static void r600_flush_dma_from_winsys(void *ctx, unsigned flags) |
| 305 | { |
| 306 | struct r600_context *rctx = (struct r600_context *)ctx; |
| 307 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 308 | rctx->b.rings.dma.flush(rctx, flags); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | static void r600_destroy_context(struct pipe_context *context) |
| 312 | { |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 313 | struct r600_context *rctx = (struct r600_context *)context; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 314 | |
Vadim Girlin | 022122e | 2013-02-01 11:45:35 +0400 | [diff] [blame] | 315 | r600_isa_destroy(rctx->isa); |
| 316 | |
Vadim Girlin | ad1df47 | 2013-04-30 20:53:15 +0400 | [diff] [blame] | 317 | r600_sb_context_destroy(rctx->sb_context); |
| 318 | |
Marek Olšák | 7835401 | 2012-08-26 22:38:35 +0200 | [diff] [blame] | 319 | pipe_resource_reference((struct pipe_resource**)&rctx->dummy_cmask, NULL); |
| 320 | pipe_resource_reference((struct pipe_resource**)&rctx->dummy_fmask, NULL); |
| 321 | |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 322 | if (rctx->dummy_pixel_shader) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 323 | 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] | 324 | } |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 325 | if (rctx->custom_dsa_flush) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 326 | 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] | 327 | } |
Marek Olšák | 0f86915 | 2012-08-09 17:21:10 +0200 | [diff] [blame] | 328 | if (rctx->custom_blend_resolve) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 329 | 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] | 330 | } |
Marek Olšák | a3d9d7e | 2012-08-12 20:06:33 +0200 | [diff] [blame] | 331 | if (rctx->custom_blend_decompress) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 332 | 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] | 333 | } |
Grigori Goronzy | edbbfac | 2013-09-11 01:41:40 +0200 | [diff] [blame^] | 334 | if (rctx->custom_blend_fastclear) { |
| 335 | rctx->b.b.delete_blend_state(&rctx->b.b, rctx->custom_blend_fastclear); |
| 336 | } |
Marek Olšák | c8b06dc | 2012-09-18 19:42:29 +0200 | [diff] [blame] | 337 | util_unreference_framebuffer_state(&rctx->framebuffer.state); |
Tilman Sauerbeck | ecb1b8b | 2010-10-31 12:16:03 +0100 | [diff] [blame] | 338 | |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 339 | if (rctx->blitter) { |
| 340 | util_blitter_destroy(rctx->blitter); |
| 341 | } |
Marek Olšák | 428855e | 2012-04-11 16:00:09 +0200 | [diff] [blame] | 342 | if (rctx->uploader) { |
| 343 | u_upload_destroy(rctx->uploader); |
| 344 | } |
Marek Olšák | d225d07 | 2012-12-09 18:51:31 +0100 | [diff] [blame] | 345 | if (rctx->allocator_fetch_shader) { |
| 346 | u_suballocator_destroy(rctx->allocator_fetch_shader); |
| 347 | } |
Marek Olšák | f0b202e | 2011-02-08 17:30:39 +0100 | [diff] [blame] | 348 | util_slab_destroy(&rctx->pool_transfers); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 349 | |
Marek Olšák | e363dd5 | 2012-03-05 16:20:05 +0100 | [diff] [blame] | 350 | r600_release_command_buffer(&rctx->start_cs_cmd); |
Marek Olšák | 9670e72 | 2012-02-21 18:08:32 +0100 | [diff] [blame] | 351 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 352 | if (rctx->b.rings.gfx.cs) { |
| 353 | rctx->b.ws->cs_destroy(rctx->b.rings.gfx.cs); |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 354 | } |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 355 | if (rctx->b.rings.dma.cs) { |
| 356 | rctx->b.ws->cs_destroy(rctx->b.rings.dma.cs); |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 357 | } |
Marek Olšák | 9670e72 | 2012-02-21 18:08:32 +0100 | [diff] [blame] | 358 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 359 | r600_common_context_cleanup(&rctx->b); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 360 | FREE(rctx); |
| 361 | } |
| 362 | |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 363 | 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] | 364 | { |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 365 | struct r600_context *rctx = CALLOC_STRUCT(r600_context); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 366 | struct r600_screen* rscreen = (struct r600_screen *)screen; |
| 367 | |
| 368 | if (rctx == NULL) |
| 369 | return NULL; |
Marek Olšák | f0b202e | 2011-02-08 17:30:39 +0100 | [diff] [blame] | 370 | |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 371 | util_slab_create(&rctx->pool_transfers, |
Marek Olšák | 99c65ba | 2012-02-26 20:37:43 +0100 | [diff] [blame] | 372 | sizeof(struct r600_transfer), 64, |
Marek Olšák | 6a94c9d | 2012-02-21 18:30:18 +0100 | [diff] [blame] | 373 | UTIL_SLAB_SINGLETHREADED); |
| 374 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 375 | rctx->b.b.screen = screen; |
| 376 | rctx->b.b.priv = priv; |
| 377 | rctx->b.b.destroy = r600_destroy_context; |
| 378 | rctx->b.b.flush = r600_flush_from_st; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 379 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 380 | if (!r600_common_context_init(&rctx->b, &rscreen->b)) |
| 381 | goto fail; |
| 382 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 383 | rctx->screen = rscreen; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 384 | rctx->keep_tiling_flags = rscreen->b.info.drm_minor >= 12; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 385 | |
Marek Olšák | 09ec30f | 2012-02-23 23:22:35 +0100 | [diff] [blame] | 386 | LIST_INITHEAD(&rctx->active_nontimer_queries); |
Marek Olšák | e280984 | 2012-02-02 14:01:12 +0100 | [diff] [blame] | 387 | |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 388 | r600_init_blit_functions(rctx); |
Jerome Glisse | 6abd777 | 2010-09-29 15:39:40 -0400 | [diff] [blame] | 389 | r600_init_query_functions(rctx); |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 390 | r600_init_context_resource_functions(rctx); |
Roland Scheidegger | 4c70014 | 2010-12-02 04:33:43 +0100 | [diff] [blame] | 391 | r600_init_surface_functions(rctx); |
Marek Olšák | f96df32 | 2012-09-10 00:28:46 +0200 | [diff] [blame] | 392 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 393 | if (rscreen->b.info.has_uvd) { |
| 394 | rctx->b.b.create_video_codec = r600_uvd_create_decoder; |
| 395 | rctx->b.b.create_video_buffer = r600_video_buffer_create; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 396 | } else { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 397 | rctx->b.b.create_video_codec = vl_create_decoder; |
| 398 | rctx->b.b.create_video_buffer = vl_video_buffer_create; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 399 | } |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 400 | |
Marek Olšák | f96df32 | 2012-09-10 00:28:46 +0200 | [diff] [blame] | 401 | r600_init_common_state_functions(rctx); |
| 402 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 403 | switch (rctx->b.chip_class) { |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 404 | case R600: |
| 405 | case R700: |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 406 | r600_init_state_functions(rctx); |
Marek Olšák | f126253 | 2012-01-31 10:50:51 +0100 | [diff] [blame] | 407 | r600_init_atom_start_cs(rctx); |
Marek Olšák | 1724ef8 | 2013-03-02 17:36:05 +0100 | [diff] [blame] | 408 | rctx->max_db = 4; |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 409 | rctx->custom_dsa_flush = r600_create_db_flush_dsa(rctx); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 410 | 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] | 411 | : r600_create_resolve_blend(rctx); |
Marek Olšák | 8698a3b | 2012-08-02 22:31:22 +0200 | [diff] [blame] | 412 | rctx->custom_blend_decompress = r600_create_decompress_blend(rctx); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 413 | rctx->has_vertex_cache = !(rctx->b.family == CHIP_RV610 || |
| 414 | rctx->b.family == CHIP_RV620 || |
| 415 | rctx->b.family == CHIP_RS780 || |
| 416 | rctx->b.family == CHIP_RS880 || |
| 417 | rctx->b.family == CHIP_RV710); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 418 | break; |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 419 | case EVERGREEN: |
| 420 | case CAYMAN: |
Dave Airlie | dbcd652 | 2010-09-30 09:07:07 +1000 | [diff] [blame] | 421 | evergreen_init_state_functions(rctx); |
Marek Olšák | f126253 | 2012-01-31 10:50:51 +0100 | [diff] [blame] | 422 | evergreen_init_atom_start_cs(rctx); |
Tom Stellard | 5016fe2 | 2012-06-25 17:56:01 +0000 | [diff] [blame] | 423 | evergreen_init_atom_start_compute_cs(rctx); |
Marek Olšák | 1724ef8 | 2013-03-02 17:36:05 +0100 | [diff] [blame] | 424 | rctx->max_db = 8; |
Henri Verbeet | b3b946b | 2011-07-09 17:18:59 +0200 | [diff] [blame] | 425 | rctx->custom_dsa_flush = evergreen_create_db_flush_dsa(rctx); |
Marek Olšák | 0f86915 | 2012-08-09 17:21:10 +0200 | [diff] [blame] | 426 | rctx->custom_blend_resolve = evergreen_create_resolve_blend(rctx); |
Marek Olšák | a3d9d7e | 2012-08-12 20:06:33 +0200 | [diff] [blame] | 427 | rctx->custom_blend_decompress = evergreen_create_decompress_blend(rctx); |
Grigori Goronzy | edbbfac | 2013-09-11 01:41:40 +0200 | [diff] [blame^] | 428 | rctx->custom_blend_fastclear = evergreen_create_fastclear_blend(rctx); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 429 | rctx->has_vertex_cache = !(rctx->b.family == CHIP_CEDAR || |
| 430 | rctx->b.family == CHIP_PALM || |
| 431 | rctx->b.family == CHIP_SUMO || |
| 432 | rctx->b.family == CHIP_SUMO2 || |
| 433 | rctx->b.family == CHIP_CAICOS || |
| 434 | rctx->b.family == CHIP_CAYMAN || |
| 435 | rctx->b.family == CHIP_ARUBA); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 436 | break; |
| 437 | default: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 438 | R600_ERR("Unsupported chip class %d.\n", rctx->b.chip_class); |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 439 | goto fail; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 440 | } |
| 441 | |
Jerome Glisse | abb96fd | 2013-04-23 19:22:33 -0400 | [diff] [blame] | 442 | if (rscreen->trace_bo) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 443 | 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] | 444 | } else { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 445 | 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] | 446 | } |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 447 | rctx->b.rings.gfx.flush = r600_flush_gfx_ring; |
| 448 | rctx->b.ws->cs_set_flush_callback(rctx->b.rings.gfx.cs, r600_flush_from_winsys, rctx); |
| 449 | rctx->b.rings.gfx.flushing = false; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 450 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 451 | rctx->b.rings.dma.cs = NULL; |
| 452 | if (rscreen->b.info.r600_has_dma && !(rscreen->debug_flags & DBG_NO_ASYNC_DMA)) { |
| 453 | rctx->b.rings.dma.cs = rctx->b.ws->cs_create(rctx->b.ws, RING_DMA, NULL); |
| 454 | rctx->b.rings.dma.flush = r600_flush_dma_ring; |
| 455 | rctx->b.ws->cs_set_flush_callback(rctx->b.rings.dma.cs, r600_flush_dma_from_winsys, rctx); |
| 456 | rctx->b.rings.dma.flushing = false; |
Jerome Glisse | bff0763 | 2013-01-07 14:25:11 -0500 | [diff] [blame] | 457 | } |
Marek Olšák | e2e1dc9 | 2011-08-04 03:38:20 +0200 | [diff] [blame] | 458 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 459 | rctx->uploader = u_upload_create(&rctx->b.b, 1024 * 1024, 256, |
Jerome Glisse | d499ff9 | 2013-01-04 11:46:13 -0500 | [diff] [blame] | 460 | PIPE_BIND_INDEX_BUFFER | |
| 461 | PIPE_BIND_CONSTANT_BUFFER); |
| 462 | if (!rctx->uploader) |
| 463 | goto fail; |
Marek Olšák | 428855e | 2012-04-11 16:00:09 +0200 | [diff] [blame] | 464 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 465 | 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] | 466 | 0, PIPE_USAGE_STATIC, FALSE); |
Jerome Glisse | d499ff9 | 2013-01-04 11:46:13 -0500 | [diff] [blame] | 467 | if (!rctx->allocator_fetch_shader) |
| 468 | goto fail; |
Marek Olšák | d225d07 | 2012-12-09 18:51:31 +0100 | [diff] [blame] | 469 | |
Vadim Girlin | 022122e | 2013-02-01 11:45:35 +0400 | [diff] [blame] | 470 | rctx->isa = calloc(1, sizeof(struct r600_isa)); |
| 471 | if (!rctx->isa || r600_isa_init(rctx, rctx->isa)) |
Jerome Glisse | d499ff9 | 2013-01-04 11:46:13 -0500 | [diff] [blame] | 472 | goto fail; |
Marek Olšák | 8df3855 | 2012-12-09 17:56:26 +0100 | [diff] [blame] | 473 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 474 | rctx->blitter = util_blitter_create(&rctx->b.b); |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 475 | if (rctx->blitter == NULL) |
| 476 | goto fail; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 477 | util_blitter_set_texture_multisample(rctx->blitter, rscreen->has_msaa); |
Marek Olšák | 187d7fb | 2012-08-24 05:57:22 +0200 | [diff] [blame] | 478 | rctx->blitter->draw_rectangle = r600_draw_rectangle; |
Dave Airlie | d59498b | 2010-10-13 15:22:04 +1000 | [diff] [blame] | 479 | |
Marek Olšák | c383a3c | 2012-09-10 05:56:46 +0200 | [diff] [blame] | 480 | r600_begin_new_cs(rctx); |
Marek Olšák | e4340c1 | 2012-01-29 23:25:42 +0100 | [diff] [blame] | 481 | 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] | 482 | |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 483 | rctx->dummy_pixel_shader = |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 484 | util_make_fragment_cloneinput_shader(&rctx->b.b, 0, |
Marek Olšák | f71f5ed | 2012-02-24 02:08:32 +0100 | [diff] [blame] | 485 | TGSI_SEMANTIC_GENERIC, |
| 486 | TGSI_INTERPOLATE_CONSTANT); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 487 | 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] | 488 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 489 | return &rctx->b.b; |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 490 | |
| 491 | fail: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 492 | r600_destroy_context(&rctx->b.b); |
Marek Olšák | 04d2828 | 2012-02-21 19:03:14 +0100 | [diff] [blame] | 493 | return NULL; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | /* |
| 497 | * pipe_screen |
| 498 | */ |
| 499 | static const char* r600_get_vendor(struct pipe_screen* pscreen) |
| 500 | { |
| 501 | return "X.Org"; |
| 502 | } |
| 503 | |
Dave Airlie | 4378c17 | 2010-09-30 09:17:20 +1000 | [diff] [blame] | 504 | static const char *r600_get_family_name(enum radeon_family family) |
| 505 | { |
| 506 | switch(family) { |
Henri Verbeet | 9f06411 | 2010-11-07 18:40:12 +0100 | [diff] [blame] | 507 | case CHIP_R600: return "AMD R600"; |
| 508 | case CHIP_RV610: return "AMD RV610"; |
| 509 | case CHIP_RV630: return "AMD RV630"; |
| 510 | case CHIP_RV670: return "AMD RV670"; |
| 511 | case CHIP_RV620: return "AMD RV620"; |
| 512 | case CHIP_RV635: return "AMD RV635"; |
| 513 | case CHIP_RS780: return "AMD RS780"; |
| 514 | case CHIP_RS880: return "AMD RS880"; |
| 515 | case CHIP_RV770: return "AMD RV770"; |
| 516 | case CHIP_RV730: return "AMD RV730"; |
| 517 | case CHIP_RV710: return "AMD RV710"; |
| 518 | case CHIP_RV740: return "AMD RV740"; |
| 519 | case CHIP_CEDAR: return "AMD CEDAR"; |
| 520 | case CHIP_REDWOOD: return "AMD REDWOOD"; |
| 521 | case CHIP_JUNIPER: return "AMD JUNIPER"; |
| 522 | case CHIP_CYPRESS: return "AMD CYPRESS"; |
| 523 | case CHIP_HEMLOCK: return "AMD HEMLOCK"; |
Alex Deucher | 0e4c5f6 | 2010-11-22 17:47:24 -0500 | [diff] [blame] | 524 | case CHIP_PALM: return "AMD PALM"; |
Alex Deucher | 414cd5d | 2011-04-04 12:06:11 -0400 | [diff] [blame] | 525 | case CHIP_SUMO: return "AMD SUMO"; |
| 526 | case CHIP_SUMO2: return "AMD SUMO2"; |
Alex Deucher | f54366b | 2011-01-06 18:05:16 -0500 | [diff] [blame] | 527 | case CHIP_BARTS: return "AMD BARTS"; |
| 528 | case CHIP_TURKS: return "AMD TURKS"; |
| 529 | case CHIP_CAICOS: return "AMD CAICOS"; |
Dave Airlie | 7779f6d | 2011-03-10 12:54:13 +1000 | [diff] [blame] | 530 | case CHIP_CAYMAN: return "AMD CAYMAN"; |
Alex Deucher | b4082f4 | 2012-03-20 19:43:59 -0400 | [diff] [blame] | 531 | case CHIP_ARUBA: return "AMD ARUBA"; |
Henri Verbeet | 9f06411 | 2010-11-07 18:40:12 +0100 | [diff] [blame] | 532 | default: return "AMD unknown"; |
Dave Airlie | 4378c17 | 2010-09-30 09:17:20 +1000 | [diff] [blame] | 533 | } |
| 534 | } |
| 535 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 536 | static const char* r600_get_name(struct pipe_screen* pscreen) |
| 537 | { |
| 538 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 539 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 540 | return r600_get_family_name(rscreen->b.family); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param) |
| 544 | { |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 545 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 546 | enum radeon_family family = rscreen->b.family; |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 547 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 548 | switch (param) { |
| 549 | /* Supported features (boolean caps). */ |
| 550 | case PIPE_CAP_NPOT_TEXTURES: |
| 551 | case PIPE_CAP_TWO_SIDED_STENCIL: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 552 | case PIPE_CAP_ANISOTROPIC_FILTER: |
| 553 | case PIPE_CAP_POINT_SPRITE: |
| 554 | case PIPE_CAP_OCCLUSION_QUERY: |
| 555 | case PIPE_CAP_TEXTURE_SHADOW_MAP: |
| 556 | case PIPE_CAP_TEXTURE_MIRROR_CLAMP: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 557 | case PIPE_CAP_BLEND_EQUATION_SEPARATE: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 558 | case PIPE_CAP_TEXTURE_SWIZZLE: |
Marek Olšák | dc4c821 | 2012-01-10 00:19:00 +0100 | [diff] [blame] | 559 | case PIPE_CAP_DEPTH_CLIP_DISABLE: |
Dave Airlie | 39d1feb | 2010-10-06 10:14:33 +1000 | [diff] [blame] | 560 | case PIPE_CAP_SHADER_STENCIL_EXPORT: |
Marek Olšák | 95c7881 | 2011-03-05 16:06:10 +0100 | [diff] [blame] | 561 | case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: |
Marek Olšák | 4a7f013 | 2011-03-29 18:18:05 +0200 | [diff] [blame] | 562 | case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 563 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: |
| 564 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: |
Dave Airlie | 13c9a85 | 2011-06-15 15:15:41 +1000 | [diff] [blame] | 565 | case PIPE_CAP_SM3: |
Marek Olšák | badf033 | 2011-06-19 23:41:02 +0200 | [diff] [blame] | 566 | case PIPE_CAP_SEAMLESS_CUBE_MAP: |
Marek Olšák | 01680ce | 2011-08-16 09:47:16 +0200 | [diff] [blame] | 567 | case PIPE_CAP_PRIMITIVE_RESTART: |
Marek Olšák | 3d13b08 | 2011-09-27 23:08:04 +0200 | [diff] [blame] | 568 | case PIPE_CAP_CONDITIONAL_RENDER: |
Marek Olšák | ba89086 | 2011-09-27 23:18:17 +0200 | [diff] [blame] | 569 | case PIPE_CAP_TEXTURE_BARRIER: |
Marek Olšák | bc1c836 | 2012-01-23 03:11:17 +0100 | [diff] [blame] | 570 | case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: |
Marek Olšák | b0b8121 | 2012-02-16 14:45:35 +0100 | [diff] [blame] | 571 | case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: |
Marek Olšák | 7f1cbf1 | 2012-03-08 12:20:01 +0100 | [diff] [blame] | 572 | case PIPE_CAP_TGSI_INSTANCEID: |
Marek Olšák | 7fe3631 | 2012-04-10 05:14:26 +0200 | [diff] [blame] | 573 | case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: |
| 574 | case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: |
| 575 | case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: |
Marek Olšák | 437ab1d | 2012-04-24 15:19:31 +0200 | [diff] [blame] | 576 | case PIPE_CAP_USER_INDEX_BUFFERS: |
| 577 | case PIPE_CAP_USER_CONSTANT_BUFFERS: |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 578 | case PIPE_CAP_COMPUTE: |
Fredrik Höglund | af37212 | 2012-06-18 22:50:02 +0200 | [diff] [blame] | 579 | case PIPE_CAP_START_INSTANCE: |
Marek Olšák | 9d699cd | 2012-07-15 03:38:42 +0200 | [diff] [blame] | 580 | case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: |
Dave Airlie | d23aa65 | 2012-12-16 10:31:32 +0000 | [diff] [blame] | 581 | case PIPE_CAP_TEXTURE_BUFFER_OBJECTS: |
Marek Olšák | 3e10ab6 | 2013-03-14 17:18:43 +0100 | [diff] [blame] | 582 | case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: |
Marek Olšák | dfe5367 | 2013-04-10 20:45:01 +0200 | [diff] [blame] | 583 | case PIPE_CAP_QUERY_PIPELINE_STATISTICS: |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 584 | case PIPE_CAP_TEXTURE_MULTISAMPLE: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 585 | return 1; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 586 | |
Christoph Bumiller | 8acaf86 | 2013-03-15 22:11:31 +0100 | [diff] [blame] | 587 | case PIPE_CAP_TGSI_TEXCOORD: |
| 588 | return 0; |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 589 | |
Marek Olšák | 52cb395 | 2013-05-02 03:24:33 +0200 | [diff] [blame] | 590 | case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 591 | return MIN2(rscreen->b.info.vram_size, 0xFFFFFFFF); |
Marek Olšák | 52cb395 | 2013-05-02 03:24:33 +0200 | [diff] [blame] | 592 | |
Marek Olšák | c9f2af3 | 2012-10-28 17:52:48 +0100 | [diff] [blame] | 593 | case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: |
Marek Olšák | d172fa8 | 2012-11-22 22:40:06 +0100 | [diff] [blame] | 594 | return R600_MAP_BUFFER_ALIGNMENT; |
Marek Olšák | c9f2af3 | 2012-10-28 17:52:48 +0100 | [diff] [blame] | 595 | |
Marek Olšák | 1b749dc | 2012-04-24 17:31:17 +0200 | [diff] [blame] | 596 | case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: |
| 597 | return 256; |
| 598 | |
Fredrik Höglund | fb69dbb | 2013-03-22 17:14:43 +0100 | [diff] [blame] | 599 | case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: |
| 600 | return 1; |
| 601 | |
Marek Olšák | 171be75 | 2012-01-24 22:23:01 +0100 | [diff] [blame] | 602 | case PIPE_CAP_GLSL_FEATURE_LEVEL: |
Dave Airlie | d23aa65 | 2012-12-16 10:31:32 +0000 | [diff] [blame] | 603 | return 140; |
Marek Olšák | 171be75 | 2012-01-24 22:23:01 +0100 | [diff] [blame] | 604 | |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 605 | /* Supported except the original R600. */ |
Alex Deucher | d6fea4a | 2011-03-14 17:47:21 -0400 | [diff] [blame] | 606 | case PIPE_CAP_INDEP_BLEND_ENABLE: |
Dave Airlie | de48199 | 2011-04-25 06:55:09 +1000 | [diff] [blame] | 607 | case PIPE_CAP_INDEP_BLEND_FUNC: |
Alex Deucher | d6fea4a | 2011-03-14 17:47:21 -0400 | [diff] [blame] | 608 | /* R600 doesn't support per-MRT blends */ |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 609 | return family == CHIP_R600 ? 0 : 1; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 610 | |
Marek Olšák | d931b0d | 2011-05-02 02:38:20 +0200 | [diff] [blame] | 611 | /* Supported on Evergreen. */ |
Marek Olšák | d931b0d | 2011-05-02 02:38:20 +0200 | [diff] [blame] | 612 | case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: |
Dave Airlie | eb44c36d | 2012-11-03 20:53:33 +1000 | [diff] [blame] | 613 | case PIPE_CAP_CUBE_MAP_ARRAY: |
Marek Olšák | d931b0d | 2011-05-02 02:38:20 +0200 | [diff] [blame] | 614 | return family >= CHIP_CEDAR ? 1 : 0; |
Marek Olšák | fc8e30e | 2011-04-17 01:57:13 +0200 | [diff] [blame] | 615 | |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 616 | /* Unsupported features. */ |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 617 | case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: |
| 618 | case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: |
Marek Olšák | 034e63b | 2011-11-22 20:48:23 +0100 | [diff] [blame] | 619 | case PIPE_CAP_SCALED_RESOLVE: |
Marek Olšák | a3bfbcc | 2011-12-17 15:13:23 +0100 | [diff] [blame] | 620 | case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: |
Marek Olšák | bc1c836 | 2012-01-23 03:11:17 +0100 | [diff] [blame] | 621 | case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: |
| 622 | case PIPE_CAP_VERTEX_COLOR_CLAMPED: |
Marek Olšák | 7fe3631 | 2012-04-10 05:14:26 +0200 | [diff] [blame] | 623 | case PIPE_CAP_USER_VERTEX_BUFFERS: |
Marek Olšák | 93754d8 | 2011-05-03 11:54:40 +0200 | [diff] [blame] | 624 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 625 | |
Marek Olšák | 543b233 | 2011-11-08 21:58:27 +0100 | [diff] [blame] | 626 | /* Stream output. */ |
| 627 | case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 628 | return rscreen->has_streamout ? 4 : 0; |
Marek Olšák | 15146fd | 2012-01-25 03:23:27 +0100 | [diff] [blame] | 629 | case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 630 | return rscreen->has_streamout ? 1 : 0; |
Marek Olšák | 543b233 | 2011-11-08 21:58:27 +0100 | [diff] [blame] | 631 | case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: |
| 632 | case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: |
Marek Olšák | b78b624 | 2012-10-26 18:41:49 +0200 | [diff] [blame] | 633 | return 32*4; |
Marek Olšák | 543b233 | 2011-11-08 21:58:27 +0100 | [diff] [blame] | 634 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 635 | /* Texturing. */ |
| 636 | case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: |
| 637 | case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: |
| 638 | case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 639 | if (family >= CHIP_CEDAR) |
| 640 | return 15; |
| 641 | else |
| 642 | return 14; |
Marek Olšák | b37931f | 2011-09-04 04:41:52 +0200 | [diff] [blame] | 643 | case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 644 | return rscreen->b.info.drm_minor >= 9 ? |
Marek Olšák | b37931f | 2011-09-04 04:41:52 +0200 | [diff] [blame] | 645 | (family >= CHIP_CEDAR ? 16384 : 8192) : 0; |
Marek Olšák | 320adb9 | 2011-05-03 11:54:07 +0200 | [diff] [blame] | 646 | case PIPE_CAP_MAX_COMBINED_SAMPLERS: |
| 647 | return 32; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 648 | |
| 649 | /* Render targets. */ |
| 650 | case PIPE_CAP_MAX_RENDER_TARGETS: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 651 | /* XXX some r6xx are buggy and can only do 4 */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 652 | return 8; |
| 653 | |
Mathias Fröhlich | 90c2fd8 | 2011-01-23 22:35:13 +0100 | [diff] [blame] | 654 | /* Timer queries, present when the clock frequency is non zero. */ |
José Fonseca | 9976216 | 2012-12-09 09:50:34 +0000 | [diff] [blame] | 655 | case PIPE_CAP_QUERY_TIME_ELAPSED: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 656 | return rscreen->b.info.r600_clock_crystal_freq != 0; |
Marek Olšák | 44f14eb | 2012-07-05 20:06:41 +0200 | [diff] [blame] | 657 | case PIPE_CAP_QUERY_TIMESTAMP: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 658 | return rscreen->b.info.drm_minor >= 20 && |
| 659 | rscreen->b.info.r600_clock_crystal_freq != 0; |
Mathias Fröhlich | 90c2fd8 | 2011-01-23 22:35:13 +0100 | [diff] [blame] | 660 | |
Dave Airlie | 0b66610 | 2011-08-29 14:35:16 +0100 | [diff] [blame] | 661 | case PIPE_CAP_MIN_TEXEL_OFFSET: |
| 662 | return -8; |
| 663 | |
| 664 | case PIPE_CAP_MAX_TEXEL_OFFSET: |
| 665 | return 7; |
Christoph Bumiller | 729abfd | 2013-04-12 13:42:01 +0200 | [diff] [blame] | 666 | |
| 667 | case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: |
| 668 | return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600; |
Tom Stellard | 4e90bc9 | 2013-07-09 21:21:39 -0700 | [diff] [blame] | 669 | case PIPE_CAP_ENDIANNESS: |
| 670 | return PIPE_ENDIAN_LITTLE; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 671 | } |
Marek Olšák | 4ac250c | 2011-11-22 20:44:14 +0100 | [diff] [blame] | 672 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 673 | } |
| 674 | |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 675 | static float r600_get_paramf(struct pipe_screen* pscreen, |
| 676 | enum pipe_capf param) |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 677 | { |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 678 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 679 | enum radeon_family family = rscreen->b.family; |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 680 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 681 | switch (param) { |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 682 | case PIPE_CAPF_MAX_LINE_WIDTH: |
| 683 | case PIPE_CAPF_MAX_LINE_WIDTH_AA: |
| 684 | case PIPE_CAPF_MAX_POINT_WIDTH: |
| 685 | case PIPE_CAPF_MAX_POINT_WIDTH_AA: |
Alex Deucher | fae7cb8 | 2010-12-02 16:09:22 -0500 | [diff] [blame] | 686 | if (family >= CHIP_CEDAR) |
| 687 | return 16384.0f; |
| 688 | else |
| 689 | return 8192.0f; |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 690 | case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 691 | return 16.0f; |
Marek Olšák | bb71f92 | 2011-11-19 22:38:22 +0100 | [diff] [blame] | 692 | case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 693 | return 16.0f; |
Marek Olšák | 034e63b | 2011-11-22 20:48:23 +0100 | [diff] [blame] | 694 | case PIPE_CAPF_GUARD_BAND_LEFT: |
| 695 | case PIPE_CAPF_GUARD_BAND_TOP: |
| 696 | case PIPE_CAPF_GUARD_BAND_RIGHT: |
| 697 | case PIPE_CAPF_GUARD_BAND_BOTTOM: |
| 698 | return 0.0f; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 699 | } |
Marek Olšák | 4ac250c | 2011-11-22 20:44:14 +0100 | [diff] [blame] | 700 | return 0.0f; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enum pipe_shader_cap param) |
| 704 | { |
| 705 | switch(shader) |
| 706 | { |
| 707 | case PIPE_SHADER_FRAGMENT: |
| 708 | case PIPE_SHADER_VERTEX: |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 709 | case PIPE_SHADER_COMPUTE: |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 710 | break; |
| 711 | case PIPE_SHADER_GEOMETRY: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 712 | /* XXX: support and enable geometry programs */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 713 | return 0; |
| 714 | default: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 715 | /* XXX: support tessellation on Evergreen */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 716 | return 0; |
| 717 | } |
| 718 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 719 | switch (param) { |
| 720 | case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: |
| 721 | case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: |
| 722 | case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: |
| 723 | case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: |
| 724 | return 16384; |
| 725 | case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: |
Marek Olšák | cf37aef | 2013-01-31 19:39:41 +0100 | [diff] [blame] | 726 | return 32; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 727 | case PIPE_SHADER_CAP_MAX_INPUTS: |
Marek Olšák | 8b63512 | 2012-10-26 17:35:32 +0200 | [diff] [blame] | 728 | return 32; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 729 | case PIPE_SHADER_CAP_MAX_TEMPS: |
Henri Verbeet | b2a98c3 | 2011-04-25 13:28:55 +0200 | [diff] [blame] | 730 | return 256; /* Max native temporaries. */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 731 | case PIPE_SHADER_CAP_MAX_ADDRS: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 732 | /* XXX Isn't this equal to TEMPS? */ |
Henri Verbeet | b2a98c3 | 2011-04-25 13:28:55 +0200 | [diff] [blame] | 733 | return 1; /* Max native address registers */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 734 | case PIPE_SHADER_CAP_MAX_CONSTS: |
Henri Verbeet | eac5029 | 2011-03-07 21:15:03 +0100 | [diff] [blame] | 735 | return R600_MAX_CONST_BUFFER_SIZE; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 736 | case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: |
Dave Airlie | 7356579 | 2012-11-06 15:31:41 +1000 | [diff] [blame] | 737 | return R600_MAX_USER_CONST_BUFFERS; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 738 | case PIPE_SHADER_CAP_MAX_PREDS: |
Marek Olšák | 370c8b5 | 2012-02-24 16:36:05 +0100 | [diff] [blame] | 739 | return 0; /* nothing uses this */ |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 740 | case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: |
| 741 | return 1; |
Brian Paul | 13f3ae5 | 2013-02-01 11:16:54 -0700 | [diff] [blame] | 742 | case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: |
| 743 | return 0; |
Marek Olšák | 5c7127c | 2010-11-12 03:07:05 +0100 | [diff] [blame] | 744 | case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: |
| 745 | case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: |
| 746 | case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: |
| 747 | case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: |
| 748 | return 1; |
Marek Olšák | 9aa089e | 2010-11-14 15:34:59 +0100 | [diff] [blame] | 749 | case PIPE_SHADER_CAP_SUBROUTINES: |
| 750 | return 0; |
Bryan Cain | 17b695e | 2011-05-05 21:10:28 -0500 | [diff] [blame] | 751 | case PIPE_SHADER_CAP_INTEGERS: |
Marek Olšák | 15ca9d1 | 2012-07-14 22:28:26 +0200 | [diff] [blame] | 752 | return 1; |
Marek Olšák | f5bfe54 | 2011-09-27 22:22:06 +0200 | [diff] [blame] | 753 | case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: |
| 754 | return 16; |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 755 | case PIPE_SHADER_CAP_PREFERRED_IR: |
| 756 | if (shader == PIPE_SHADER_COMPUTE) { |
| 757 | return PIPE_SHADER_IR_LLVM; |
| 758 | } else { |
| 759 | return PIPE_SHADER_IR_TGSI; |
| 760 | } |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 761 | } |
Marek Olšák | 4ac250c | 2011-11-22 20:44:14 +0100 | [diff] [blame] | 762 | return 0; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 763 | } |
| 764 | |
Christian König | f265a19 | 2011-07-07 22:51:45 +0200 | [diff] [blame] | 765 | static int r600_get_video_param(struct pipe_screen *screen, |
| 766 | enum pipe_video_profile profile, |
Christian König | a15cbab | 2013-07-15 08:31:25 -0600 | [diff] [blame] | 767 | enum pipe_video_entrypoint entrypoint, |
Christian König | f265a19 | 2011-07-07 22:51:45 +0200 | [diff] [blame] | 768 | enum pipe_video_cap param) |
| 769 | { |
| 770 | switch (param) { |
Christian König | efc7fda | 2011-07-12 00:12:12 +0200 | [diff] [blame] | 771 | case PIPE_VIDEO_CAP_SUPPORTED: |
Christian König | a15cbab | 2013-07-15 08:31:25 -0600 | [diff] [blame] | 772 | return vl_profile_supported(screen, profile, entrypoint); |
Christian König | f265a19 | 2011-07-07 22:51:45 +0200 | [diff] [blame] | 773 | case PIPE_VIDEO_CAP_NPOT_TEXTURES: |
| 774 | return 1; |
Christian König | efc7fda | 2011-07-12 00:12:12 +0200 | [diff] [blame] | 775 | case PIPE_VIDEO_CAP_MAX_WIDTH: |
| 776 | case PIPE_VIDEO_CAP_MAX_HEIGHT: |
| 777 | return vl_video_buffer_max_size(screen); |
Christian König | 9d9afcb | 2012-01-10 14:03:28 +0100 | [diff] [blame] | 778 | case PIPE_VIDEO_CAP_PREFERED_FORMAT: |
| 779 | return PIPE_FORMAT_NV12; |
Christian König | f3f03c6 | 2012-02-01 23:38:45 +0100 | [diff] [blame] | 780 | case PIPE_VIDEO_CAP_PREFERS_INTERLACED: |
| 781 | return false; |
| 782 | case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED: |
| 783 | return false; |
| 784 | case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE: |
| 785 | return true; |
Rico Schüller | d1ba105 | 2013-08-14 13:17:22 +0200 | [diff] [blame] | 786 | case PIPE_VIDEO_CAP_MAX_LEVEL: |
| 787 | return vl_level_supported(screen, profile); |
Christian König | f265a19 | 2011-07-07 22:51:45 +0200 | [diff] [blame] | 788 | default: |
| 789 | return 0; |
| 790 | } |
| 791 | } |
| 792 | |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 793 | const char * r600_llvm_gpu_string(enum radeon_family family) |
| 794 | { |
| 795 | const char * gpu_family; |
| 796 | |
| 797 | switch (family) { |
| 798 | case CHIP_R600: |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 799 | case CHIP_RV630: |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 800 | case CHIP_RV635: |
| 801 | case CHIP_RV670: |
Tom Stellard | ec143dc | 2013-04-29 13:10:09 -0700 | [diff] [blame] | 802 | gpu_family = "r600"; |
| 803 | break; |
| 804 | case CHIP_RV610: |
| 805 | case CHIP_RV620: |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 806 | case CHIP_RS780: |
| 807 | case CHIP_RS880: |
Tom Stellard | ec143dc | 2013-04-29 13:10:09 -0700 | [diff] [blame] | 808 | gpu_family = "rs880"; |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 809 | break; |
| 810 | case CHIP_RV710: |
| 811 | gpu_family = "rv710"; |
| 812 | break; |
| 813 | case CHIP_RV730: |
| 814 | gpu_family = "rv730"; |
| 815 | break; |
| 816 | case CHIP_RV740: |
| 817 | case CHIP_RV770: |
| 818 | gpu_family = "rv770"; |
| 819 | break; |
| 820 | case CHIP_PALM: |
| 821 | case CHIP_CEDAR: |
| 822 | gpu_family = "cedar"; |
| 823 | break; |
| 824 | case CHIP_SUMO: |
| 825 | case CHIP_SUMO2: |
Tom Stellard | ec143dc | 2013-04-29 13:10:09 -0700 | [diff] [blame] | 826 | gpu_family = "sumo"; |
| 827 | break; |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 828 | case CHIP_REDWOOD: |
| 829 | gpu_family = "redwood"; |
| 830 | break; |
| 831 | case CHIP_JUNIPER: |
| 832 | gpu_family = "juniper"; |
| 833 | break; |
| 834 | case CHIP_HEMLOCK: |
| 835 | case CHIP_CYPRESS: |
| 836 | gpu_family = "cypress"; |
| 837 | break; |
| 838 | case CHIP_BARTS: |
| 839 | gpu_family = "barts"; |
| 840 | break; |
| 841 | case CHIP_TURKS: |
| 842 | gpu_family = "turks"; |
| 843 | break; |
| 844 | case CHIP_CAICOS: |
| 845 | gpu_family = "caicos"; |
| 846 | break; |
| 847 | case CHIP_CAYMAN: |
| 848 | case CHIP_ARUBA: |
| 849 | gpu_family = "cayman"; |
| 850 | break; |
| 851 | default: |
| 852 | gpu_family = ""; |
| 853 | fprintf(stderr, "Chip not supported by r600 llvm " |
| 854 | "backend, please file a bug at " PACKAGE_BUGREPORT "\n"); |
| 855 | break; |
| 856 | } |
| 857 | return gpu_family; |
| 858 | } |
| 859 | |
| 860 | |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 861 | static int r600_get_compute_param(struct pipe_screen *screen, |
| 862 | enum pipe_compute_cap param, |
| 863 | void *ret) |
| 864 | { |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 865 | struct r600_screen *rscreen = (struct r600_screen *)screen; |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 866 | //TODO: select these params by asic |
| 867 | switch (param) { |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 868 | case PIPE_COMPUTE_CAP_IR_TARGET: { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 869 | const char *gpu = r600_llvm_gpu_string(rscreen->b.family); |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 870 | if (ret) { |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 871 | sprintf(ret, "%s-r600--", gpu); |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 872 | } |
Tom Stellard | c5e5b34 | 2013-03-07 10:51:25 -0500 | [diff] [blame] | 873 | return (8 + strlen(gpu)) * sizeof(char); |
| 874 | } |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 875 | case PIPE_COMPUTE_CAP_GRID_DIMENSION: |
| 876 | if (ret) { |
| 877 | uint64_t * grid_dimension = ret; |
| 878 | grid_dimension[0] = 3; |
| 879 | } |
| 880 | return 1 * sizeof(uint64_t); |
| 881 | |
| 882 | case PIPE_COMPUTE_CAP_MAX_GRID_SIZE: |
| 883 | if (ret) { |
| 884 | uint64_t * grid_size = ret; |
| 885 | grid_size[0] = 65535; |
| 886 | grid_size[1] = 65535; |
| 887 | grid_size[2] = 1; |
| 888 | } |
| 889 | return 3 * sizeof(uint64_t) ; |
| 890 | |
| 891 | case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE: |
| 892 | if (ret) { |
| 893 | uint64_t * block_size = ret; |
| 894 | block_size[0] = 256; |
| 895 | block_size[1] = 256; |
| 896 | block_size[2] = 256; |
| 897 | } |
| 898 | return 3 * sizeof(uint64_t); |
| 899 | |
| 900 | case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK: |
| 901 | if (ret) { |
| 902 | uint64_t * max_threads_per_block = ret; |
| 903 | *max_threads_per_block = 256; |
| 904 | } |
| 905 | return sizeof(uint64_t); |
| 906 | |
| 907 | case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE: |
| 908 | if (ret) { |
| 909 | uint64_t * max_global_size = ret; |
Tom Stellard | 91ee735 | 2012-09-13 17:09:03 +0000 | [diff] [blame] | 910 | /* XXX: This is what the proprietary driver reports, we |
| 911 | * may want to use a different value. */ |
| 912 | *max_global_size = 201326592; |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 913 | } |
| 914 | return sizeof(uint64_t); |
| 915 | |
| 916 | case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE: |
| 917 | if (ret) { |
| 918 | uint64_t * max_input_size = ret; |
| 919 | *max_input_size = 1024; |
| 920 | } |
| 921 | return sizeof(uint64_t); |
| 922 | |
| 923 | case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE: |
| 924 | if (ret) { |
| 925 | uint64_t * max_local_size = ret; |
| 926 | /* XXX: This is what the proprietary driver reports, we |
| 927 | * may want to use a different value. */ |
| 928 | *max_local_size = 32768; |
| 929 | } |
| 930 | return sizeof(uint64_t); |
| 931 | |
Tom Stellard | 0e3c30c | 2012-09-21 20:19:14 +0000 | [diff] [blame] | 932 | case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE: |
| 933 | if (ret) { |
| 934 | uint64_t max_global_size; |
| 935 | uint64_t * max_mem_alloc_size = ret; |
| 936 | r600_get_compute_param(screen, |
| 937 | PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE, |
| 938 | &max_global_size); |
| 939 | /* OpenCL requres this value be at least |
| 940 | * max(MAX_GLOBAL_SIZE / 4, 128 * 1024 *1024) |
| 941 | * I'm really not sure what value to report here, but |
| 942 | * MAX_GLOBAL_SIZE / 4 seems resonable. |
| 943 | */ |
| 944 | *max_mem_alloc_size = max_global_size / 4; |
| 945 | } |
| 946 | return sizeof(uint64_t); |
| 947 | |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 948 | default: |
| 949 | fprintf(stderr, "unknown PIPE_COMPUTE_CAP %d\n", param); |
| 950 | return 0; |
| 951 | } |
| 952 | } |
| 953 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 954 | static void r600_destroy_screen(struct pipe_screen* pscreen) |
| 955 | { |
| 956 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
| 957 | |
| 958 | if (rscreen == NULL) |
| 959 | return; |
Tilman Sauerbeck | 52ba68d | 2010-10-31 15:51:55 +0100 | [diff] [blame] | 960 | |
Marek Olšák | b692076 | 2013-04-21 23:26:52 +0200 | [diff] [blame] | 961 | pipe_mutex_destroy(rscreen->aux_context_lock); |
| 962 | rscreen->aux_context->destroy(rscreen->aux_context); |
| 963 | |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 964 | if (rscreen->global_pool) { |
| 965 | compute_memory_pool_delete(rscreen->global_pool); |
| 966 | } |
| 967 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 968 | if (rscreen->fences.bo) { |
| 969 | struct r600_fence_block *entry, *tmp; |
| 970 | |
| 971 | LIST_FOR_EACH_ENTRY_SAFE(entry, tmp, &rscreen->fences.blocks, head) { |
| 972 | LIST_DEL(&entry->head); |
| 973 | FREE(entry); |
| 974 | } |
| 975 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 976 | rscreen->b.ws->buffer_unmap(rscreen->fences.bo->cs_buf); |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 977 | pipe_resource_reference((struct pipe_resource**)&rscreen->fences.bo, NULL); |
| 978 | } |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 979 | if (rscreen->trace_bo) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 980 | rscreen->b.ws->buffer_unmap(rscreen->trace_bo->cs_buf); |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 981 | pipe_resource_reference((struct pipe_resource**)&rscreen->trace_bo, NULL); |
| 982 | } |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 983 | pipe_mutex_destroy(rscreen->fences.mutex); |
| 984 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 985 | rscreen->b.ws->destroy(rscreen->b.ws); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 986 | FREE(rscreen); |
| 987 | } |
| 988 | |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 989 | static void r600_fence_reference(struct pipe_screen *pscreen, |
| 990 | struct pipe_fence_handle **ptr, |
| 991 | struct pipe_fence_handle *fence) |
| 992 | { |
| 993 | struct r600_fence **oldf = (struct r600_fence**)ptr; |
| 994 | struct r600_fence *newf = (struct r600_fence*)fence; |
| 995 | |
| 996 | if (pipe_reference(&(*oldf)->reference, &newf->reference)) { |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 997 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
| 998 | pipe_mutex_lock(rscreen->fences.mutex); |
Simon Farnsworth | 8cd03b9 | 2012-02-14 12:06:20 +0000 | [diff] [blame] | 999 | pipe_resource_reference((struct pipe_resource**)&(*oldf)->sleep_bo, NULL); |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 1000 | LIST_ADDTAIL(&(*oldf)->head, &rscreen->fences.pool); |
| 1001 | pipe_mutex_unlock(rscreen->fences.mutex); |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | *ptr = fence; |
| 1005 | } |
| 1006 | |
| 1007 | static boolean r600_fence_signalled(struct pipe_screen *pscreen, |
| 1008 | struct pipe_fence_handle *fence) |
| 1009 | { |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 1010 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 1011 | struct r600_fence *rfence = (struct r600_fence*)fence; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 1012 | |
Marek Olšák | 9f0ddbc | 2013-01-04 12:40:04 +0100 | [diff] [blame] | 1013 | return rscreen->fences.data[rfence->index] != 0; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | static boolean r600_fence_finish(struct pipe_screen *pscreen, |
| 1017 | struct pipe_fence_handle *fence, |
| 1018 | uint64_t timeout) |
| 1019 | { |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 1020 | struct r600_screen *rscreen = (struct r600_screen *)pscreen; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 1021 | struct r600_fence *rfence = (struct r600_fence*)fence; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 1022 | int64_t start_time = 0; |
| 1023 | unsigned spins = 0; |
| 1024 | |
| 1025 | if (timeout != PIPE_TIMEOUT_INFINITE) { |
| 1026 | start_time = os_time_get(); |
| 1027 | |
| 1028 | /* Convert to microseconds. */ |
| 1029 | timeout /= 1000; |
| 1030 | } |
| 1031 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 1032 | while (rscreen->fences.data[rfence->index] == 0) { |
Simon Farnsworth | 8cd03b9 | 2012-02-14 12:06:20 +0000 | [diff] [blame] | 1033 | /* Special-case infinite timeout - wait for the dummy BO to become idle */ |
| 1034 | if (timeout == PIPE_TIMEOUT_INFINITE) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1035 | rscreen->b.ws->buffer_wait(rfence->sleep_bo->buf, RADEON_USAGE_READWRITE); |
Simon Farnsworth | 8cd03b9 | 2012-02-14 12:06:20 +0000 | [diff] [blame] | 1036 | break; |
| 1037 | } |
| 1038 | |
| 1039 | /* The dummy BO will be busy until the CS including the fence has completed, or |
| 1040 | * the GPU is reset. Don't bother continuing to spin when the BO is idle. */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1041 | if (!rscreen->b.ws->buffer_is_busy(rfence->sleep_bo->buf, RADEON_USAGE_READWRITE)) |
Simon Farnsworth | 8cd03b9 | 2012-02-14 12:06:20 +0000 | [diff] [blame] | 1042 | break; |
| 1043 | |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 1044 | if (++spins % 256) |
| 1045 | continue; |
| 1046 | #ifdef PIPE_OS_UNIX |
| 1047 | sched_yield(); |
| 1048 | #else |
| 1049 | os_time_sleep(10); |
| 1050 | #endif |
| 1051 | if (timeout != PIPE_TIMEOUT_INFINITE && |
| 1052 | os_time_get() - start_time >= timeout) { |
Simon Farnsworth | 8cd03b9 | 2012-02-14 12:06:20 +0000 | [diff] [blame] | 1053 | break; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 1054 | } |
| 1055 | } |
| 1056 | |
Simon Farnsworth | 8cd03b9 | 2012-02-14 12:06:20 +0000 | [diff] [blame] | 1057 | return rscreen->fences.data[rfence->index] != 0; |
Fredrik Höglund | 948e1eb | 2011-03-29 19:43:59 +0200 | [diff] [blame] | 1058 | } |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 1059 | |
Marek Olšák | 3603d15 | 2011-09-11 14:53:07 +0200 | [diff] [blame] | 1060 | static int r600_interpret_tiling(struct r600_screen *rscreen, uint32_t tiling_config) |
| 1061 | { |
| 1062 | switch ((tiling_config & 0xe) >> 1) { |
| 1063 | case 0: |
| 1064 | rscreen->tiling_info.num_channels = 1; |
| 1065 | break; |
| 1066 | case 1: |
| 1067 | rscreen->tiling_info.num_channels = 2; |
| 1068 | break; |
| 1069 | case 2: |
| 1070 | rscreen->tiling_info.num_channels = 4; |
| 1071 | break; |
| 1072 | case 3: |
| 1073 | rscreen->tiling_info.num_channels = 8; |
| 1074 | break; |
| 1075 | default: |
| 1076 | return -EINVAL; |
| 1077 | } |
| 1078 | |
| 1079 | switch ((tiling_config & 0x30) >> 4) { |
| 1080 | case 0: |
| 1081 | rscreen->tiling_info.num_banks = 4; |
| 1082 | break; |
| 1083 | case 1: |
| 1084 | rscreen->tiling_info.num_banks = 8; |
| 1085 | break; |
| 1086 | default: |
| 1087 | return -EINVAL; |
| 1088 | |
| 1089 | } |
| 1090 | switch ((tiling_config & 0xc0) >> 6) { |
| 1091 | case 0: |
| 1092 | rscreen->tiling_info.group_bytes = 256; |
| 1093 | break; |
| 1094 | case 1: |
| 1095 | rscreen->tiling_info.group_bytes = 512; |
| 1096 | break; |
| 1097 | default: |
| 1098 | return -EINVAL; |
| 1099 | } |
| 1100 | return 0; |
| 1101 | } |
| 1102 | |
| 1103 | static int evergreen_interpret_tiling(struct r600_screen *rscreen, uint32_t tiling_config) |
| 1104 | { |
| 1105 | switch (tiling_config & 0xf) { |
| 1106 | case 0: |
| 1107 | rscreen->tiling_info.num_channels = 1; |
| 1108 | break; |
| 1109 | case 1: |
| 1110 | rscreen->tiling_info.num_channels = 2; |
| 1111 | break; |
| 1112 | case 2: |
| 1113 | rscreen->tiling_info.num_channels = 4; |
| 1114 | break; |
| 1115 | case 3: |
| 1116 | rscreen->tiling_info.num_channels = 8; |
| 1117 | break; |
| 1118 | default: |
| 1119 | return -EINVAL; |
| 1120 | } |
| 1121 | |
| 1122 | switch ((tiling_config & 0xf0) >> 4) { |
| 1123 | case 0: |
| 1124 | rscreen->tiling_info.num_banks = 4; |
| 1125 | break; |
| 1126 | case 1: |
| 1127 | rscreen->tiling_info.num_banks = 8; |
| 1128 | break; |
| 1129 | case 2: |
| 1130 | rscreen->tiling_info.num_banks = 16; |
| 1131 | break; |
| 1132 | default: |
| 1133 | return -EINVAL; |
| 1134 | } |
| 1135 | |
| 1136 | switch ((tiling_config & 0xf00) >> 8) { |
| 1137 | case 0: |
| 1138 | rscreen->tiling_info.group_bytes = 256; |
| 1139 | break; |
| 1140 | case 1: |
| 1141 | rscreen->tiling_info.group_bytes = 512; |
| 1142 | break; |
| 1143 | default: |
| 1144 | return -EINVAL; |
| 1145 | } |
| 1146 | return 0; |
| 1147 | } |
| 1148 | |
| 1149 | static int r600_init_tiling(struct r600_screen *rscreen) |
| 1150 | { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1151 | uint32_t tiling_config = rscreen->b.info.r600_tiling_config; |
Marek Olšák | 3603d15 | 2011-09-11 14:53:07 +0200 | [diff] [blame] | 1152 | |
| 1153 | /* set default group bytes, overridden by tiling info ioctl */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1154 | if (rscreen->b.chip_class <= R700) { |
Marek Olšák | 3603d15 | 2011-09-11 14:53:07 +0200 | [diff] [blame] | 1155 | rscreen->tiling_info.group_bytes = 256; |
| 1156 | } else { |
| 1157 | rscreen->tiling_info.group_bytes = 512; |
| 1158 | } |
| 1159 | |
| 1160 | if (!tiling_config) |
| 1161 | return 0; |
| 1162 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1163 | if (rscreen->b.chip_class <= R700) { |
Marek Olšák | 3603d15 | 2011-09-11 14:53:07 +0200 | [diff] [blame] | 1164 | return r600_interpret_tiling(rscreen, tiling_config); |
| 1165 | } else { |
| 1166 | return evergreen_interpret_tiling(rscreen, tiling_config); |
| 1167 | } |
| 1168 | } |
| 1169 | |
Marek Olšák | 44f14eb | 2012-07-05 20:06:41 +0200 | [diff] [blame] | 1170 | static uint64_t r600_get_timestamp(struct pipe_screen *screen) |
| 1171 | { |
| 1172 | struct r600_screen *rscreen = (struct r600_screen*)screen; |
| 1173 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1174 | return 1000000 * rscreen->b.ws->query_value(rscreen->b.ws, RADEON_TIMESTAMP) / |
| 1175 | rscreen->b.info.r600_clock_crystal_freq; |
Marek Olšák | 44f14eb | 2012-07-05 20:06:41 +0200 | [diff] [blame] | 1176 | } |
| 1177 | |
Marek Olšák | 2504380 | 2013-03-21 19:44:18 +0100 | [diff] [blame] | 1178 | static int r600_get_driver_query_info(struct pipe_screen *screen, |
| 1179 | unsigned index, |
| 1180 | struct pipe_driver_query_info *info) |
| 1181 | { |
Marek Olšák | 8ddae68 | 2013-03-22 02:39:42 +0100 | [diff] [blame] | 1182 | struct r600_screen *rscreen = (struct r600_screen*)screen; |
Marek Olšák | 2504380 | 2013-03-21 19:44:18 +0100 | [diff] [blame] | 1183 | struct pipe_driver_query_info list[] = { |
| 1184 | {"draw-calls", R600_QUERY_DRAW_CALLS, 0}, |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1185 | {"requested-VRAM", R600_QUERY_REQUESTED_VRAM, rscreen->b.info.vram_size, TRUE}, |
| 1186 | {"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] | 1187 | {"buffer-wait-time", R600_QUERY_BUFFER_WAIT_TIME, 0, FALSE} |
Marek Olšák | 2504380 | 2013-03-21 19:44:18 +0100 | [diff] [blame] | 1188 | }; |
| 1189 | |
| 1190 | if (!info) |
| 1191 | return Elements(list); |
| 1192 | |
| 1193 | if (index >= Elements(list)) |
| 1194 | return 0; |
| 1195 | |
| 1196 | *info = list[index]; |
| 1197 | return 1; |
| 1198 | } |
| 1199 | |
Marek Olšák | 2ce783d | 2011-08-02 20:25:13 +0200 | [diff] [blame] | 1200 | struct pipe_screen *r600_screen_create(struct radeon_winsys *ws) |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 1201 | { |
Marek Olšák | 90ce3cd | 2011-09-17 14:10:20 +0200 | [diff] [blame] | 1202 | struct r600_screen *rscreen = CALLOC_STRUCT(r600_screen); |
Dave Airlie | e6aad9b | 2012-04-22 08:09:05 +0100 | [diff] [blame] | 1203 | |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 1204 | if (rscreen == NULL) { |
| 1205 | return NULL; |
| 1206 | } |
| 1207 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1208 | r600_common_screen_init(&rscreen->b, ws); |
Marek Olšák | 3603d15 | 2011-09-11 14:53:07 +0200 | [diff] [blame] | 1209 | |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 1210 | rscreen->debug_flags = debug_get_flags_option("R600_DEBUG", debug_options, 0); |
Michel Dänzer | 31009b4 | 2013-03-21 17:56:52 +0100 | [diff] [blame] | 1211 | if (debug_get_bool_option("R600_DEBUG_COMPUTE", FALSE)) |
| 1212 | rscreen->debug_flags |= DBG_COMPUTE; |
| 1213 | if (debug_get_bool_option("R600_DUMP_SHADERS", FALSE)) |
| 1214 | rscreen->debug_flags |= DBG_FS | DBG_VS | DBG_GS | DBG_PS | DBG_CS; |
| 1215 | if (!debug_get_bool_option("R600_HYPERZ", TRUE)) |
| 1216 | rscreen->debug_flags |= DBG_NO_HYPERZ; |
| 1217 | if (!debug_get_bool_option("R600_LLVM", TRUE)) |
| 1218 | rscreen->debug_flags |= DBG_NO_LLVM; |
| 1219 | if (debug_get_bool_option("R600_PRINT_TEXDEPTH", FALSE)) |
| 1220 | rscreen->debug_flags |= DBG_TEX_DEPTH; |
Marek Olšák | 4bf0ebd | 2013-03-01 16:31:49 +0100 | [diff] [blame] | 1221 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1222 | if (rscreen->b.family == CHIP_UNKNOWN) { |
| 1223 | 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] | 1224 | FREE(rscreen); |
| 1225 | return NULL; |
| 1226 | } |
| 1227 | |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 1228 | /* Figure out streamout kernel support. */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1229 | switch (rscreen->b.chip_class) { |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 1230 | case R600: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1231 | if (rscreen->b.family < CHIP_RS780) { |
| 1232 | rscreen->has_streamout = rscreen->b.info.drm_minor >= 14; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 1233 | } else { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1234 | rscreen->has_streamout = rscreen->b.info.drm_minor >= 23; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 1235 | } |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 1236 | break; |
| 1237 | case R700: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1238 | rscreen->has_streamout = rscreen->b.info.drm_minor >= 17; |
Marek Olšák | 6e7756d | 2012-06-17 17:54:38 +0200 | [diff] [blame] | 1239 | break; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 1240 | case EVERGREEN: |
| 1241 | case CAYMAN: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1242 | rscreen->has_streamout = rscreen->b.info.drm_minor >= 14; |
Marek Olšák | d063c7b | 2012-09-25 01:43:49 +0200 | [diff] [blame] | 1243 | break; |
Jerome Glisse | ca474f9 | 2013-01-04 16:34:52 -0500 | [diff] [blame] | 1244 | default: |
| 1245 | rscreen->has_streamout = FALSE; |
| 1246 | break; |
Marek Olšák | 393d741 | 2012-03-27 21:00:49 +0200 | [diff] [blame] | 1247 | } |
| 1248 | |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 1249 | /* MSAA support. */ |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1250 | switch (rscreen->b.chip_class) { |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 1251 | case R600: |
| 1252 | case R700: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1253 | rscreen->has_msaa = rscreen->b.info.drm_minor >= 22; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 1254 | rscreen->has_compressed_msaa_texturing = false; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 1255 | break; |
| 1256 | case EVERGREEN: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1257 | rscreen->has_msaa = rscreen->b.info.drm_minor >= 19; |
| 1258 | rscreen->has_compressed_msaa_texturing = rscreen->b.info.drm_minor >= 24; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 1259 | break; |
| 1260 | case CAYMAN: |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1261 | rscreen->has_msaa = rscreen->b.info.drm_minor >= 19; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 1262 | rscreen->has_compressed_msaa_texturing = true; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 1263 | break; |
Jerome Glisse | ca474f9 | 2013-01-04 16:34:52 -0500 | [diff] [blame] | 1264 | default: |
| 1265 | rscreen->has_msaa = FALSE; |
Marek Olšák | 5a3fac4 | 2013-04-11 15:29:41 +0200 | [diff] [blame] | 1266 | rscreen->has_compressed_msaa_texturing = false; |
Marek Olšák | 96ed6c9 | 2012-10-12 18:46:32 +0200 | [diff] [blame] | 1267 | } |
| 1268 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1269 | rscreen->has_cp_dma = rscreen->b.info.drm_minor >= 27 && |
Marek Olšák | e4e655f | 2013-03-05 01:15:45 +0100 | [diff] [blame] | 1270 | !(rscreen->debug_flags & DBG_NO_CP_DMA); |
Marek Olšák | 58bd926 | 2013-02-21 17:06:26 +0100 | [diff] [blame] | 1271 | |
Marek Olšák | 3603d15 | 2011-09-11 14:53:07 +0200 | [diff] [blame] | 1272 | if (r600_init_tiling(rscreen)) { |
Marek Olšák | 3603d15 | 2011-09-11 14:53:07 +0200 | [diff] [blame] | 1273 | FREE(rscreen); |
| 1274 | return NULL; |
| 1275 | } |
| 1276 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1277 | rscreen->b.b.destroy = r600_destroy_screen; |
| 1278 | rscreen->b.b.get_name = r600_get_name; |
| 1279 | rscreen->b.b.get_vendor = r600_get_vendor; |
| 1280 | rscreen->b.b.get_param = r600_get_param; |
| 1281 | rscreen->b.b.get_shader_param = r600_get_shader_param; |
| 1282 | rscreen->b.b.get_paramf = r600_get_paramf; |
| 1283 | rscreen->b.b.get_compute_param = r600_get_compute_param; |
| 1284 | rscreen->b.b.get_timestamp = r600_get_timestamp; |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 1285 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1286 | if (rscreen->b.chip_class >= EVERGREEN) { |
| 1287 | rscreen->b.b.is_format_supported = evergreen_is_format_supported; |
Jerome Glisse | 325422c | 2013-01-07 17:45:59 -0500 | [diff] [blame] | 1288 | rscreen->dma_blit = &evergreen_dma_blit; |
Henri Verbeet | 18cdb9c | 2011-07-05 01:58:46 +0200 | [diff] [blame] | 1289 | } else { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1290 | rscreen->b.b.is_format_supported = r600_is_format_supported; |
Jerome Glisse | 325422c | 2013-01-07 17:45:59 -0500 | [diff] [blame] | 1291 | rscreen->dma_blit = &r600_dma_blit; |
Henri Verbeet | 18cdb9c | 2011-07-05 01:58:46 +0200 | [diff] [blame] | 1292 | } |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1293 | rscreen->b.b.context_create = r600_create_context; |
| 1294 | rscreen->b.b.fence_reference = r600_fence_reference; |
| 1295 | rscreen->b.b.fence_signalled = r600_fence_signalled; |
| 1296 | rscreen->b.b.fence_finish = r600_fence_finish; |
| 1297 | rscreen->b.b.get_driver_query_info = r600_get_driver_query_info; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 1298 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1299 | if (rscreen->b.info.has_uvd) { |
Christian König | 2487324 | 2013-09-09 10:49:55 +0200 | [diff] [blame] | 1300 | rscreen->b.b.get_video_param = ruvd_get_video_param; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1301 | rscreen->b.b.is_video_format_supported = ruvd_is_format_supported; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 1302 | } else { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1303 | rscreen->b.b.get_video_param = r600_get_video_param; |
| 1304 | rscreen->b.b.is_video_format_supported = vl_video_buffer_is_format_supported; |
Christian König | 5b2855b | 2013-04-03 10:18:35 +0200 | [diff] [blame] | 1305 | } |
| 1306 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1307 | r600_init_screen_resource_functions(&rscreen->b.b); |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 1308 | |
Dave Airlie | 8e04379 | 2011-02-11 13:42:52 +1000 | [diff] [blame] | 1309 | util_format_s3tc_init(); |
Dave Airlie | 7b3fa03 | 2010-10-08 11:56:43 +1000 | [diff] [blame] | 1310 | |
Michel Dänzer | 7dd2d29 | 2011-12-30 10:45:31 +0100 | [diff] [blame] | 1311 | rscreen->fences.bo = NULL; |
| 1312 | rscreen->fences.data = NULL; |
| 1313 | rscreen->fences.next_index = 0; |
| 1314 | LIST_INITHEAD(&rscreen->fences.pool); |
| 1315 | LIST_INITHEAD(&rscreen->fences.blocks); |
| 1316 | pipe_mutex_init(rscreen->fences.mutex); |
| 1317 | |
Tom Stellard | c0f7fe7 | 2012-07-11 16:18:22 +0000 | [diff] [blame] | 1318 | rscreen->global_pool = compute_memory_pool_new(rscreen); |
Adam Rak | 6a829a1 | 2011-11-30 22:20:41 +0100 | [diff] [blame] | 1319 | |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 1320 | rscreen->cs_count = 0; |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1321 | if (rscreen->b.info.drm_minor >= 28 && (rscreen->debug_flags & DBG_TRACE_CS)) { |
| 1322 | rscreen->trace_bo = (struct r600_resource*)pipe_buffer_create(&rscreen->b.b, |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 1323 | PIPE_BIND_CUSTOM, |
| 1324 | PIPE_USAGE_STAGING, |
| 1325 | 4096); |
| 1326 | if (rscreen->trace_bo) { |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1327 | 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] | 1328 | PIPE_TRANSFER_UNSYNCHRONIZED); |
| 1329 | } |
| 1330 | } |
Jerome Glisse | e8ca1a5 | 2012-12-19 12:23:50 -0500 | [diff] [blame] | 1331 | |
Marek Olšák | b692076 | 2013-04-21 23:26:52 +0200 | [diff] [blame] | 1332 | /* Create the auxiliary context. */ |
| 1333 | pipe_mutex_init(rscreen->aux_context_lock); |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1334 | rscreen->aux_context = rscreen->b.b.context_create(&rscreen->b.b, NULL); |
Marek Olšák | b692076 | 2013-04-21 23:26:52 +0200 | [diff] [blame] | 1335 | |
| 1336 | #if 0 /* This is for testing whether aux_context and buffer clearing work correctly. */ |
| 1337 | struct pipe_resource templ = {}; |
| 1338 | |
| 1339 | templ.width0 = 4; |
| 1340 | templ.height0 = 2048; |
| 1341 | templ.depth0 = 1; |
| 1342 | templ.array_size = 1; |
| 1343 | templ.target = PIPE_TEXTURE_2D; |
| 1344 | templ.format = PIPE_FORMAT_R8G8B8A8_UNORM; |
| 1345 | templ.usage = PIPE_USAGE_STATIC; |
| 1346 | |
| 1347 | struct r600_resource *res = r600_resource(rscreen->screen.resource_create(&rscreen->screen, &templ)); |
| 1348 | unsigned char *map = ws->buffer_map(res->cs_buf, NULL, PIPE_TRANSFER_WRITE); |
| 1349 | |
| 1350 | memset(map, 0, 256); |
| 1351 | |
| 1352 | r600_screen_clear_buffer(rscreen, &res->b.b, 4, 4, 0xCC); |
| 1353 | r600_screen_clear_buffer(rscreen, &res->b.b, 8, 4, 0xDD); |
| 1354 | r600_screen_clear_buffer(rscreen, &res->b.b, 12, 4, 0xEE); |
| 1355 | r600_screen_clear_buffer(rscreen, &res->b.b, 20, 4, 0xFF); |
| 1356 | r600_screen_clear_buffer(rscreen, &res->b.b, 32, 20, 0x87); |
| 1357 | |
| 1358 | ws->buffer_wait(res->buf, RADEON_USAGE_WRITE); |
| 1359 | |
| 1360 | int i; |
| 1361 | for (i = 0; i < 256; i++) { |
| 1362 | printf("%02X", map[i]); |
| 1363 | if (i % 16 == 15) |
| 1364 | printf("\n"); |
| 1365 | } |
| 1366 | #endif |
| 1367 | |
Marek Olšák | d5b23df | 2013-08-13 21:49:59 +0200 | [diff] [blame] | 1368 | return &rscreen->b.b; |
Jerome Glisse | 1235bec | 2010-09-29 15:05:19 -0400 | [diff] [blame] | 1369 | } |