11235becaa1cf7e29f580900592563c3329d326deJerome Glisse/* 21235becaa1cf7e29f580900592563c3329d326deJerome Glisse * Copyright 2010 Jerome Glisse <glisse@freedesktop.org> 31235becaa1cf7e29f580900592563c3329d326deJerome Glisse * 41235becaa1cf7e29f580900592563c3329d326deJerome Glisse * Permission is hereby granted, free of charge, to any person obtaining a 51235becaa1cf7e29f580900592563c3329d326deJerome Glisse * copy of this software and associated documentation files (the "Software"), 61235becaa1cf7e29f580900592563c3329d326deJerome Glisse * to deal in the Software without restriction, including without limitation 71235becaa1cf7e29f580900592563c3329d326deJerome Glisse * on the rights to use, copy, modify, merge, publish, distribute, sub 81235becaa1cf7e29f580900592563c3329d326deJerome Glisse * license, and/or sell copies of the Software, and to permit persons to whom 91235becaa1cf7e29f580900592563c3329d326deJerome Glisse * the Software is furnished to do so, subject to the following conditions: 101235becaa1cf7e29f580900592563c3329d326deJerome Glisse * 111235becaa1cf7e29f580900592563c3329d326deJerome Glisse * The above copyright notice and this permission notice (including the next 121235becaa1cf7e29f580900592563c3329d326deJerome Glisse * paragraph) shall be included in all copies or substantial portions of the 131235becaa1cf7e29f580900592563c3329d326deJerome Glisse * Software. 141235becaa1cf7e29f580900592563c3329d326deJerome Glisse * 151235becaa1cf7e29f580900592563c3329d326deJerome Glisse * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161235becaa1cf7e29f580900592563c3329d326deJerome Glisse * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171235becaa1cf7e29f580900592563c3329d326deJerome Glisse * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 181235becaa1cf7e29f580900592563c3329d326deJerome Glisse * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 191235becaa1cf7e29f580900592563c3329d326deJerome Glisse * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 201235becaa1cf7e29f580900592563c3329d326deJerome Glisse * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 211235becaa1cf7e29f580900592563c3329d326deJerome Glisse * USE OR OTHER DEALINGS IN THE SOFTWARE. 221235becaa1cf7e29f580900592563c3329d326deJerome Glisse */ 23330b6c85c961b32f704ce8ec7dbf8cb7fc0b80a8Marek Olšák#include "r600_pipe.h" 24330b6c85c961b32f704ce8ec7dbf8cb7fc0b80a8Marek Olšák#include "r600_public.h" 25330b6c85c961b32f704ce8ec7dbf8cb7fc0b80a8Marek Olšák 261235becaa1cf7e29f580900592563c3329d326deJerome Glisse#include <errno.h> 27330b6c85c961b32f704ce8ec7dbf8cb7fc0b80a8Marek Olšák#include "pipe/p_shader_tokens.h" 288fb7f1a8a4cbab5365491b4b41e50ff3f03306c8Kai Wasserbäch#include "util/u_blitter.h" 298fb7f1a8a4cbab5365491b4b41e50ff3f03306c8Kai Wasserbäch#include "util/u_format_s3tc.h" 30f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák#include "util/u_simple_shaders.h" 31428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák#include "util/u_upload_mgr.h" 328fb7f1a8a4cbab5365491b4b41e50ff3f03306c8Kai Wasserbäch#include "vl/vl_decoder.h" 338fb7f1a8a4cbab5365491b4b41e50ff3f03306c8Kai Wasserbäch#include "vl/vl_video_buffer.h" 34948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund#include "os/os_time.h" 351235becaa1cf7e29f580900592563c3329d326deJerome Glisse 361235becaa1cf7e29f580900592563c3329d326deJerome Glisse/* 371235becaa1cf7e29f580900592563c3329d326deJerome Glisse * pipe_context 381235becaa1cf7e29f580900592563c3329d326deJerome Glisse */ 39e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšákstatic struct r600_fence *r600_create_fence(struct r600_context *rctx) 40948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund{ 41e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák struct r600_screen *rscreen = rctx->screen; 42948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct r600_fence *fence = NULL; 43948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 447dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer pipe_mutex_lock(rscreen->fences.mutex); 457dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer 467dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer if (!rscreen->fences.bo) { 47948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund /* Create the shared buffer object */ 487dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer rscreen->fences.bo = (struct r600_resource*) 497dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer pipe_buffer_create(&rscreen->screen, PIPE_BIND_CUSTOM, 506101b6d442b06a347c001fe85848d636ab7df260Marek Olšák PIPE_USAGE_STAGING, 4096); 517dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer if (!rscreen->fences.bo) { 52948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund R600_ERR("r600: failed to create bo for fence objects\n"); 537dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer goto out; 54948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 550a6120244e66494db070ce875c0a464fbc5b15a1Marek Olšák rscreen->fences.data = rctx->ws->buffer_map(rscreen->fences.bo->cs_buf, 56e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák rctx->cs, 577dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer PIPE_TRANSFER_READ_WRITE); 58948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 59948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 607dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer if (!LIST_IS_EMPTY(&rscreen->fences.pool)) { 61948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct r600_fence *entry; 62948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 63948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund /* Try to find a freed fence that has been signalled */ 647dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer LIST_FOR_EACH_ENTRY(entry, &rscreen->fences.pool, head) { 657dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer if (rscreen->fences.data[entry->index] != 0) { 66948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund LIST_DELINIT(&entry->head); 67948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund fence = entry; 68948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund break; 69948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 70948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 71948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 72948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 73948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund if (!fence) { 74948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund /* Allocate a new fence */ 75948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct r600_fence_block *block; 76948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund unsigned index; 77948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 787dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer if ((rscreen->fences.next_index + 1) >= 1024) { 79948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund R600_ERR("r600: too many concurrent fences\n"); 807dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer goto out; 81948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 82948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 837dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer index = rscreen->fences.next_index++; 84948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 85948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund if (!(index % FENCE_BLOCK_SIZE)) { 86948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund /* Allocate a new block */ 87948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund block = CALLOC_STRUCT(r600_fence_block); 88948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund if (block == NULL) 897dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer goto out; 90948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 917dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer LIST_ADD(&block->head, &rscreen->fences.blocks); 92948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } else { 937dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer block = LIST_ENTRY(struct r600_fence_block, rscreen->fences.blocks.next, head); 94948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 95948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 96948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund fence = &block->fences[index % FENCE_BLOCK_SIZE]; 97948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund fence->index = index; 98948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 99948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 100948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund pipe_reference_init(&fence->reference, 1); 101948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 1027dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer rscreen->fences.data[fence->index] = 0; 103e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák r600_context_emit_fence(rctx, rscreen->fences.bo, fence->index, 1); 1048cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth 1058cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth /* Create a dummy BO so that fence_finish without a timeout can sleep waiting for completion */ 1068cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth fence->sleep_bo = (struct r600_resource*) 1078cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth pipe_buffer_create(&rctx->screen->screen, PIPE_BIND_CUSTOM, 1088cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth PIPE_USAGE_STAGING, 1); 1098cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth /* Add the fence as a dummy relocation. */ 1108cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth r600_context_bo_reloc(rctx, fence->sleep_bo, RADEON_USAGE_READWRITE); 1118cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth 1127dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzerout: 1137dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer pipe_mutex_unlock(rscreen->fences.mutex); 114948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund return fence; 115948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund} 116948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 117e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák 118c79e9f0ed59d561849a0a4fbaafe87d5064d3e8cMarek Olšákvoid r600_flush(struct pipe_context *ctx, struct pipe_fence_handle **fence, 119c79e9f0ed59d561849a0a4fbaafe87d5064d3e8cMarek Olšák unsigned flags) 1201235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 121e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák struct r600_context *rctx = (struct r600_context *)ctx; 122948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct r600_fence **rfence = (struct r600_fence**)fence; 123578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák struct pipe_query *render_cond = NULL; 124578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák unsigned render_cond_mode = 0; 125948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 126948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund if (rfence) 127948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund *rfence = r600_create_fence(rctx); 128948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 129578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák /* Disable render condition. */ 130578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák if (rctx->current_render_cond) { 131578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák render_cond = rctx->current_render_cond; 132578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák render_cond_mode = rctx->current_render_cond_mode; 133578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák ctx->render_condition(ctx, NULL, 0); 134578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák } 135578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák 136e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák r600_context_flush(rctx, flags); 137578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák 138578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák /* Re-enable render condition. */ 139578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák if (render_cond) { 140578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák ctx->render_condition(ctx, render_cond, render_cond_mode); 141578b211be6a1466eea00fc4a8fc5d4efa4bfd62cMarek Olšák } 142e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák} 143e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák 144e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšákstatic void r600_flush_from_st(struct pipe_context *ctx, 145e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák struct pipe_fence_handle **fence) 146e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák{ 147e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák r600_flush(ctx, fence, 0); 148e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák} 149e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák 150e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšákstatic void r600_flush_from_winsys(void *ctx, unsigned flags) 151e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák{ 152e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák r600_flush((struct pipe_context*)ctx, NULL, flags); 1531235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 1541235becaa1cf7e29f580900592563c3329d326deJerome Glisse 1551235becaa1cf7e29f580900592563c3329d326deJerome Glissestatic void r600_destroy_context(struct pipe_context *context) 1561235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 157e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák struct r600_context *rctx = (struct r600_context *)context; 1581235becaa1cf7e29f580900592563c3329d326deJerome Glisse 15978354011f99c4103345f8f32e10b0b4b884ebdafMarek Olšák pipe_resource_reference((struct pipe_resource**)&rctx->dummy_cmask, NULL); 16078354011f99c4103345f8f32e10b0b4b884ebdafMarek Olšák pipe_resource_reference((struct pipe_resource**)&rctx->dummy_fmask, NULL); 16178354011f99c4103345f8f32e10b0b4b884ebdafMarek Olšák 1628d1a9a984f33d8e45f932a9f47cdd57da617a919Vadim Girlin if (rctx->no_blend) { 1638d1a9a984f33d8e45f932a9f47cdd57da617a919Vadim Girlin rctx->context.delete_blend_state(&rctx->context, rctx->no_blend); 1648d1a9a984f33d8e45f932a9f47cdd57da617a919Vadim Girlin } 165f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák if (rctx->dummy_pixel_shader) { 166f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák rctx->context.delete_fs_state(&rctx->context, rctx->dummy_pixel_shader); 167f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák } 1686a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák if (rctx->custom_dsa_flush) { 1696a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák rctx->context.delete_depth_stencil_alpha_state(&rctx->context, rctx->custom_dsa_flush); 1706a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák } 1710f86915c5322b096b7154b6c84e21288074b775dMarek Olšák if (rctx->custom_blend_resolve) { 1720f86915c5322b096b7154b6c84e21288074b775dMarek Olšák rctx->context.delete_blend_state(&rctx->context, rctx->custom_blend_resolve); 1730f86915c5322b096b7154b6c84e21288074b775dMarek Olšák } 174a3d9d7ec79d6f7205fab2324e47d8ea185431de0Marek Olšák if (rctx->custom_blend_decompress) { 175a3d9d7ec79d6f7205fab2324e47d8ea185431de0Marek Olšák rctx->context.delete_blend_state(&rctx->context, rctx->custom_blend_decompress); 176a3d9d7ec79d6f7205fab2324e47d8ea185431de0Marek Olšák } 17709eff39a58885bb3b8507d02920b53b4e81a66eaHenri Verbeet util_unreference_framebuffer_state(&rctx->framebuffer); 178ecb1b8b98f7b2464e29e56a1f1bf87f74129ac08Tilman Sauerbeck 179e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák r600_context_fini(rctx); 18001b39b053b0cb6c7493b560b26734f3c4fa52efaJosé Fonseca 1816a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák if (rctx->blitter) { 1826a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák util_blitter_destroy(rctx->blitter); 1836a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák } 1841235becaa1cf7e29f580900592563c3329d326deJerome Glisse for (int i = 0; i < R600_PIPE_NSTATES; i++) { 1851235becaa1cf7e29f580900592563c3329d326deJerome Glisse free(rctx->states[i]); 1861235becaa1cf7e29f580900592563c3329d326deJerome Glisse } 1871235becaa1cf7e29f580900592563c3329d326deJerome Glisse 188428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák if (rctx->uploader) { 189428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák u_upload_destroy(rctx->uploader); 190428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák } 191f0b202ec73855bd9e1b29909c8ac90393043cb8bMarek Olšák util_slab_destroy(&rctx->pool_transfers); 1921235becaa1cf7e29f580900592563c3329d326deJerome Glisse 193e363dd5c7d8ba40984d937ad7487abbb5be439bcMarek Olšák r600_release_command_buffer(&rctx->start_cs_cmd); 1949670e72f6ef85f0e6f6c9afe136dc67c017e3faeMarek Olšák 1956a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák if (rctx->cs) { 1966a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák rctx->ws->cs_destroy(rctx->cs); 1976a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák } 1989670e72f6ef85f0e6f6c9afe136dc67c017e3faeMarek Olšák 1999670e72f6ef85f0e6f6c9afe136dc67c017e3faeMarek Olšák FREE(rctx->range); 2001235becaa1cf7e29f580900592563c3329d326deJerome Glisse FREE(rctx); 2011235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 2021235becaa1cf7e29f580900592563c3329d326deJerome Glisse 203dbcd6526021c50770c3e5e04b04dc64c70298124Dave Airliestatic struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv) 2041235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 205e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák struct r600_context *rctx = CALLOC_STRUCT(r600_context); 2061235becaa1cf7e29f580900592563c3329d326deJerome Glisse struct r600_screen* rscreen = (struct r600_screen *)screen; 2078d1a9a984f33d8e45f932a9f47cdd57da617a919Vadim Girlin struct pipe_blend_state no_blend = {}; 2081235becaa1cf7e29f580900592563c3329d326deJerome Glisse 2091235becaa1cf7e29f580900592563c3329d326deJerome Glisse if (rctx == NULL) 2101235becaa1cf7e29f580900592563c3329d326deJerome Glisse return NULL; 211f0b202ec73855bd9e1b29909c8ac90393043cb8bMarek Olšák 2126a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák util_slab_create(&rctx->pool_transfers, 21399c65bac341f808279a8a847158ace4f058aa72eMarek Olšák sizeof(struct r600_transfer), 64, 2146a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák UTIL_SLAB_SINGLETHREADED); 2156a94c9dde0d62b5ccfcbe3dbafdadeab37fd48a6Marek Olšák 2161235becaa1cf7e29f580900592563c3329d326deJerome Glisse rctx->context.screen = screen; 2171235becaa1cf7e29f580900592563c3329d326deJerome Glisse rctx->context.priv = priv; 2181235becaa1cf7e29f580900592563c3329d326deJerome Glisse rctx->context.destroy = r600_destroy_context; 219e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák rctx->context.flush = r600_flush_from_st; 2201235becaa1cf7e29f580900592563c3329d326deJerome Glisse 2211235becaa1cf7e29f580900592563c3329d326deJerome Glisse /* Easy accessing of screen/winsys. */ 2221235becaa1cf7e29f580900592563c3329d326deJerome Glisse rctx->screen = rscreen; 2236101b6d442b06a347c001fe85848d636ab7df260Marek Olšák rctx->ws = rscreen->ws; 224518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák rctx->family = rscreen->family; 225518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák rctx->chip_class = rscreen->chip_class; 2261235becaa1cf7e29f580900592563c3329d326deJerome Glisse 227e2809849ecac69615ece294a55ee355afaac33d3Marek Olšák LIST_INITHEAD(&rctx->dirty_states); 22809ec30f02830b3cbf9d6ac04d9497634dca86846Marek Olšák LIST_INITHEAD(&rctx->active_timer_queries); 22909ec30f02830b3cbf9d6ac04d9497634dca86846Marek Olšák LIST_INITHEAD(&rctx->active_nontimer_queries); 2309670e72f6ef85f0e6f6c9afe136dc67c017e3faeMarek Olšák LIST_INITHEAD(&rctx->dirty); 2319670e72f6ef85f0e6f6c9afe136dc67c017e3faeMarek Olšák LIST_INITHEAD(&rctx->enable_list); 2329670e72f6ef85f0e6f6c9afe136dc67c017e3faeMarek Olšák 2339670e72f6ef85f0e6f6c9afe136dc67c017e3faeMarek Olšák rctx->range = CALLOC(NUM_RANGES, sizeof(struct r600_range)); 23404d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák if (!rctx->range) 23504d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák goto fail; 236e2809849ecac69615ece294a55ee355afaac33d3Marek Olšák 237dbcd6526021c50770c3e5e04b04dc64c70298124Dave Airlie r600_init_blit_functions(rctx); 2386abd7771c6ab2c733b20835e211060dd18fd847dJerome Glisse r600_init_query_functions(rctx); 239dbcd6526021c50770c3e5e04b04dc64c70298124Dave Airlie r600_init_context_resource_functions(rctx); 2404c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger r600_init_surface_functions(rctx); 2412d7738eb2bee41656953d1173926f546c6711badMarek Olšák rctx->context.draw_vbo = r600_draw_vbo; 242ea78480029450c019287c2a94d7c42a6a1d12dc3Christian König 243ea78480029450c019287c2a94d7c42a6a1d12dc3Christian König rctx->context.create_video_decoder = vl_create_decoder; 2444e837f557bf5f5afb286e1f2244ed69c0092c2d6Christian König rctx->context.create_video_buffer = vl_video_buffer_create; 2451235becaa1cf7e29f580900592563c3329d326deJerome Glisse 2460813e58a3e41faf6f2072d034dfdc6198a3a1feeMarek Olšák r600_init_common_atoms(rctx); 2470813e58a3e41faf6f2072d034dfdc6198a3a1feeMarek Olšák 248b3b946b0ab88c1d7edeab183d8ad5125ba223392Henri Verbeet switch (rctx->chip_class) { 249b3b946b0ab88c1d7edeab183d8ad5125ba223392Henri Verbeet case R600: 250b3b946b0ab88c1d7edeab183d8ad5125ba223392Henri Verbeet case R700: 251dbcd6526021c50770c3e5e04b04dc64c70298124Dave Airlie r600_init_state_functions(rctx); 252f126253040654d52db134063a69ebaf0c417d410Marek Olšák r600_init_atom_start_cs(rctx); 25304d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák if (r600_context_init(rctx)) 25404d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák goto fail; 255b3b946b0ab88c1d7edeab183d8ad5125ba223392Henri Verbeet rctx->custom_dsa_flush = r600_create_db_flush_dsa(rctx); 25678354011f99c4103345f8f32e10b0b4b884ebdafMarek Olšák rctx->custom_blend_resolve = rctx->chip_class == R700 ? r700_create_resolve_blend(rctx) 25778354011f99c4103345f8f32e10b0b4b884ebdafMarek Olšák : r600_create_resolve_blend(rctx); 2588698a3b85dd89c5d2fa473e7942b7dc8d25f3c8fMarek Olšák rctx->custom_blend_decompress = r600_create_decompress_blend(rctx); 259bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->has_vertex_cache = !(rctx->family == CHIP_RV610 || 260bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_RV620 || 261bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_RS780 || 262bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_RS880 || 263bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_RV710); 2641235becaa1cf7e29f580900592563c3329d326deJerome Glisse break; 265b3b946b0ab88c1d7edeab183d8ad5125ba223392Henri Verbeet case EVERGREEN: 266b3b946b0ab88c1d7edeab183d8ad5125ba223392Henri Verbeet case CAYMAN: 267dbcd6526021c50770c3e5e04b04dc64c70298124Dave Airlie evergreen_init_state_functions(rctx); 268f126253040654d52db134063a69ebaf0c417d410Marek Olšák evergreen_init_atom_start_cs(rctx); 2695016fe2d47a08ce2cd7c597e67862086e7d63b64Tom Stellard evergreen_init_atom_start_compute_cs(rctx); 27004d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák if (evergreen_context_init(rctx)) 27104d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák goto fail; 272b3b946b0ab88c1d7edeab183d8ad5125ba223392Henri Verbeet rctx->custom_dsa_flush = evergreen_create_db_flush_dsa(rctx); 2730f86915c5322b096b7154b6c84e21288074b775dMarek Olšák rctx->custom_blend_resolve = evergreen_create_resolve_blend(rctx); 274a3d9d7ec79d6f7205fab2324e47d8ea185431de0Marek Olšák rctx->custom_blend_decompress = evergreen_create_decompress_blend(rctx); 275bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->has_vertex_cache = !(rctx->family == CHIP_CEDAR || 276bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_PALM || 277bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_SUMO || 278bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_SUMO2 || 279bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_CAICOS || 280bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_CAYMAN || 281bc95152f1d3bf0dbf79d81e6b9956fd60198e3dfMarek Olšák rctx->family == CHIP_ARUBA); 2821235becaa1cf7e29f580900592563c3329d326deJerome Glisse break; 2831235becaa1cf7e29f580900592563c3329d326deJerome Glisse default: 284b3b946b0ab88c1d7edeab183d8ad5125ba223392Henri Verbeet R600_ERR("Unsupported chip class %d.\n", rctx->chip_class); 28504d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák goto fail; 2861235becaa1cf7e29f580900592563c3329d326deJerome Glisse } 2871235becaa1cf7e29f580900592563c3329d326deJerome Glisse 2889670e72f6ef85f0e6f6c9afe136dc67c017e3faeMarek Olšák rctx->cs = rctx->ws->cs_create(rctx->ws); 289e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák rctx->ws->cs_set_flush_callback(rctx->cs, r600_flush_from_winsys, rctx); 290e363dd5c7d8ba40984d937ad7487abbb5be439bcMarek Olšák r600_emit_atom(rctx, &rctx->start_cs_cmd.atom); 291e2e1dc9e66ff348caa97b7b35e558d75c6cc6899Marek Olšák 292428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák rctx->uploader = u_upload_create(&rctx->context, 1024 * 1024, 256, 293428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák PIPE_BIND_INDEX_BUFFER | 294428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák PIPE_BIND_CONSTANT_BUFFER); 295428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák if (!rctx->uploader) 296428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák goto fail; 297428855eea3e99d94474df6df0cb8dfc4a8819702Marek Olšák 2981235becaa1cf7e29f580900592563c3329d326deJerome Glisse rctx->blitter = util_blitter_create(&rctx->context); 29904d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák if (rctx->blitter == NULL) 30004d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák goto fail; 301187d7fb2fec7da889f25366696faaac4c2e8f9c4Marek Olšák rctx->blitter->draw_rectangle = r600_draw_rectangle; 302d59498b78041b8a7a046ac2c892e7a1896f59ca2Dave Airlie 303e4340c1908a6a3b09e1a15d5195f6da7d00494d0Marek Olšák r600_get_backend_mask(rctx); /* this emits commands and must be last */ 304bbad5103e61806ef6d6a0d5e53abc4b9e77a7fe9Marek Olšák 305aacd653834264b70a2537aff7914762b39f0683fMarek Olšák if (rctx->chip_class == R600) 306aacd653834264b70a2537aff7914762b39f0683fMarek Olšák r600_set_max_scissor(rctx); 307aacd653834264b70a2537aff7914762b39f0683fMarek Olšák 308f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák rctx->dummy_pixel_shader = 309f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák util_make_fragment_cloneinput_shader(&rctx->context, 0, 310f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák TGSI_SEMANTIC_GENERIC, 311f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák TGSI_INTERPOLATE_CONSTANT); 312f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák rctx->context.bind_fs_state(&rctx->context, rctx->dummy_pixel_shader); 313f71f5edf78572ae87b9efb897df49efab1a53558Marek Olšák 3148d1a9a984f33d8e45f932a9f47cdd57da617a919Vadim Girlin no_blend.rt[0].colormask = 0xF; 3158d1a9a984f33d8e45f932a9f47cdd57da617a919Vadim Girlin rctx->no_blend = rctx->context.create_blend_state(&rctx->context, &no_blend); 3168d1a9a984f33d8e45f932a9f47cdd57da617a919Vadim Girlin 3171235becaa1cf7e29f580900592563c3329d326deJerome Glisse return &rctx->context; 31804d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák 31904d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšákfail: 32004d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák r600_destroy_context(&rctx->context); 32104d2828b03a75963a469f2fb008c3595948cfcfcMarek Olšák return NULL; 3221235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 3231235becaa1cf7e29f580900592563c3329d326deJerome Glisse 3241235becaa1cf7e29f580900592563c3329d326deJerome Glisse/* 3251235becaa1cf7e29f580900592563c3329d326deJerome Glisse * pipe_screen 3261235becaa1cf7e29f580900592563c3329d326deJerome Glisse */ 3271235becaa1cf7e29f580900592563c3329d326deJerome Glissestatic const char* r600_get_vendor(struct pipe_screen* pscreen) 3281235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 3291235becaa1cf7e29f580900592563c3329d326deJerome Glisse return "X.Org"; 3301235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 3311235becaa1cf7e29f580900592563c3329d326deJerome Glisse 3324378c17c88c6d1fb046f53ef83955fd7fbd992dbDave Airliestatic const char *r600_get_family_name(enum radeon_family family) 3334378c17c88c6d1fb046f53ef83955fd7fbd992dbDave Airlie{ 3344378c17c88c6d1fb046f53ef83955fd7fbd992dbDave Airlie switch(family) { 3359f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_R600: return "AMD R600"; 3369f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RV610: return "AMD RV610"; 3379f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RV630: return "AMD RV630"; 3389f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RV670: return "AMD RV670"; 3399f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RV620: return "AMD RV620"; 3409f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RV635: return "AMD RV635"; 3419f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RS780: return "AMD RS780"; 3429f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RS880: return "AMD RS880"; 3439f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RV770: return "AMD RV770"; 3449f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RV730: return "AMD RV730"; 3459f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RV710: return "AMD RV710"; 3469f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_RV740: return "AMD RV740"; 3479f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_CEDAR: return "AMD CEDAR"; 3489f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_REDWOOD: return "AMD REDWOOD"; 3499f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_JUNIPER: return "AMD JUNIPER"; 3509f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_CYPRESS: return "AMD CYPRESS"; 3519f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet case CHIP_HEMLOCK: return "AMD HEMLOCK"; 3520e4c5f63b9023b292b88b2f0d5d0f6154e8ad263Alex Deucher case CHIP_PALM: return "AMD PALM"; 353414cd5df50435f475d92b02c229453d037369c0fAlex Deucher case CHIP_SUMO: return "AMD SUMO"; 354414cd5df50435f475d92b02c229453d037369c0fAlex Deucher case CHIP_SUMO2: return "AMD SUMO2"; 355f54366bcf61a414885abb9f7f47e897598a80859Alex Deucher case CHIP_BARTS: return "AMD BARTS"; 356f54366bcf61a414885abb9f7f47e897598a80859Alex Deucher case CHIP_TURKS: return "AMD TURKS"; 357f54366bcf61a414885abb9f7f47e897598a80859Alex Deucher case CHIP_CAICOS: return "AMD CAICOS"; 3587779f6d1dffde2c0501e44adc342e52803de08d4Dave Airlie case CHIP_CAYMAN: return "AMD CAYMAN"; 359b4082f492b4b55df4c636445e47b97d1f1e4b5b2Alex Deucher case CHIP_ARUBA: return "AMD ARUBA"; 3609f064116458ff68b92f179a19be4615f003eaa3eHenri Verbeet default: return "AMD unknown"; 3614378c17c88c6d1fb046f53ef83955fd7fbd992dbDave Airlie } 3624378c17c88c6d1fb046f53ef83955fd7fbd992dbDave Airlie} 3634378c17c88c6d1fb046f53ef83955fd7fbd992dbDave Airlie 3641235becaa1cf7e29f580900592563c3329d326deJerome Glissestatic const char* r600_get_name(struct pipe_screen* pscreen) 3651235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 3661235becaa1cf7e29f580900592563c3329d326deJerome Glisse struct r600_screen *rscreen = (struct r600_screen *)pscreen; 3671235becaa1cf7e29f580900592563c3329d326deJerome Glisse 368518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák return r600_get_family_name(rscreen->family); 3691235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 3701235becaa1cf7e29f580900592563c3329d326deJerome Glisse 3711235becaa1cf7e29f580900592563c3329d326deJerome Glissestatic int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param) 3721235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 373fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher struct r600_screen *rscreen = (struct r600_screen *)pscreen; 374518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák enum radeon_family family = rscreen->family; 375fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher 3761235becaa1cf7e29f580900592563c3329d326deJerome Glisse switch (param) { 3771235becaa1cf7e29f580900592563c3329d326deJerome Glisse /* Supported features (boolean caps). */ 3781235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_NPOT_TEXTURES: 3791235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_TWO_SIDED_STENCIL: 3801235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_ANISOTROPIC_FILTER: 3811235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_POINT_SPRITE: 3821235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_OCCLUSION_QUERY: 3831235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_TEXTURE_SHADOW_MAP: 3841235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_TEXTURE_MIRROR_CLAMP: 3851235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_BLEND_EQUATION_SEPARATE: 3861235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_TEXTURE_SWIZZLE: 3871235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: 388dc4c821f0817a3db716f965692fb701079f66340Marek Olšák case PIPE_CAP_DEPTH_CLIP_DISABLE: 38939d1feb51e9dac794751e72f48faf26409a84b1cDave Airlie case PIPE_CAP_SHADER_STENCIL_EXPORT: 39095c7881ac8240fa369e33db411bbd165d0f61948Marek Olšák case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: 3914a7f013f9db793dab8dbc9f71646dab49f12ed2fMarek Olšák case PIPE_CAP_MIXED_COLORBUFFER_FORMATS: 39293754d8499934a4c38e9a934d0a934c1484b707cMarek Olšák case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: 39393754d8499934a4c38e9a934d0a934c1484b707cMarek Olšák case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: 39413c9a8552bc83b1ad91442caacf847cb6cead2b5Dave Airlie case PIPE_CAP_SM3: 395badf0335ef70223204fbae3e8fdef718cdb3ad19Marek Olšák case PIPE_CAP_SEAMLESS_CUBE_MAP: 39601680ce2f350f44073e8f1adf3b36d48424d21faMarek Olšák case PIPE_CAP_PRIMITIVE_RESTART: 3973d13b081c72626acba6b9a25baec740c60dfafe1Marek Olšák case PIPE_CAP_CONDITIONAL_RENDER: 398ba89086e79b22bd9578ea642846108de624c91e9Marek Olšák case PIPE_CAP_TEXTURE_BARRIER: 399bc1c8369384b5e16547c5bf9728aa78f8dfd66ccMarek Olšák case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: 400b0b81218132b6952de987dca21b9750d8d51b7f0Marek Olšák case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: 4017f1cbf12bc883090734983bdd98e5158b9a194a0Marek Olšák case PIPE_CAP_TGSI_INSTANCEID: 4027fe3631a7a0ad7602b4e947ac87ef86875c8bb3fMarek Olšák case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: 4037fe3631a7a0ad7602b4e947ac87ef86875c8bb3fMarek Olšák case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: 4047fe3631a7a0ad7602b4e947ac87ef86875c8bb3fMarek Olšák case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: 405437ab1d6df7282770ee869180446db36c2dbdfa8Marek Olšák case PIPE_CAP_USER_INDEX_BUFFERS: 406437ab1d6df7282770ee869180446db36c2dbdfa8Marek Olšák case PIPE_CAP_USER_CONSTANT_BUFFERS: 4076a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_CAP_COMPUTE: 408af372129e5c1722a3d53dd1fc2f3409207c12f7eFredrik Höglund case PIPE_CAP_START_INSTANCE: 4099d699cd845f3544fa6e149fa4ffb1d131d32b482Marek Olšák case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: 4101235becaa1cf7e29f580900592563c3329d326deJerome Glisse return 1; 41193754d8499934a4c38e9a934d0a934c1484b707cMarek Olšák 4121b749dc34f8d83cf3dfa863279b1fe2b356d34b2Marek Olšák case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: 4131b749dc34f8d83cf3dfa863279b1fe2b356d34b2Marek Olšák return 256; 4141b749dc34f8d83cf3dfa863279b1fe2b356d34b2Marek Olšák 415171be755223d99f8cc5cc1bdaf8bd7b4caa04b4fMarek Olšák case PIPE_CAP_GLSL_FEATURE_LEVEL: 41615ca9d159e50815b0bfe60df8873f48c32a59ca5Marek Olšák return 130; 417171be755223d99f8cc5cc1bdaf8bd7b4caa04b4fMarek Olšák 41893754d8499934a4c38e9a934d0a934c1484b707cMarek Olšák /* Supported except the original R600. */ 419d6fea4a9856598961dd0f69436df749e5aa8d077Alex Deucher case PIPE_CAP_INDEP_BLEND_ENABLE: 420de48199693484fc903627ce53b007901af2e37a8Dave Airlie case PIPE_CAP_INDEP_BLEND_FUNC: 421d6fea4a9856598961dd0f69436df749e5aa8d077Alex Deucher /* R600 doesn't support per-MRT blends */ 42293754d8499934a4c38e9a934d0a934c1484b707cMarek Olšák return family == CHIP_R600 ? 0 : 1; 4231235becaa1cf7e29f580900592563c3329d326deJerome Glisse 424d931b0d8b360fc0222d295eca38aaee3e4e5d0beMarek Olšák /* Supported on Evergreen. */ 425d931b0d8b360fc0222d295eca38aaee3e4e5d0beMarek Olšák case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: 426d931b0d8b360fc0222d295eca38aaee3e4e5d0beMarek Olšák return family >= CHIP_CEDAR ? 1 : 0; 427fc8e30edbcc802aac61a3562a3be42bb18b5dcd5Marek Olšák 42893754d8499934a4c38e9a934d0a934c1484b707cMarek Olšák /* Unsupported features. */ 42993754d8499934a4c38e9a934d0a934c1484b707cMarek Olšák case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: 43093754d8499934a4c38e9a934d0a934c1484b707cMarek Olšák case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: 431034e63b9f8ee23cfac769b1a2c431bdd2307a6c4Marek Olšák case PIPE_CAP_SCALED_RESOLVE: 432a3bfbccd0a97ccaa9d07317d9681a350d02ee456Marek Olšák case PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS: 433a3bfbccd0a97ccaa9d07317d9681a350d02ee456Marek Olšák case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: 434bc1c8369384b5e16547c5bf9728aa78f8dfd66ccMarek Olšák case PIPE_CAP_FRAGMENT_COLOR_CLAMPED: 435bc1c8369384b5e16547c5bf9728aa78f8dfd66ccMarek Olšák case PIPE_CAP_VERTEX_COLOR_CLAMPED: 4367fe3631a7a0ad7602b4e947ac87ef86875c8bb3fMarek Olšák case PIPE_CAP_USER_VERTEX_BUFFERS: 43793754d8499934a4c38e9a934d0a934c1484b707cMarek Olšák return 0; 4381235becaa1cf7e29f580900592563c3329d326deJerome Glisse 439543b2331d7b45a29ccd3530daa2389e87e65d89bMarek Olšák /* Stream output. */ 440543b2331d7b45a29ccd3530daa2389e87e65d89bMarek Olšák case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: 4416e7756db14c362ede6fdc97454267a32b8eab1d4Marek Olšák return rscreen->has_streamout ? 4 : 0; 44215146fd1bcbb08e44a1cbb984440ee1a5de63d48Marek Olšák case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: 4436e7756db14c362ede6fdc97454267a32b8eab1d4Marek Olšák return rscreen->has_streamout ? 1 : 0; 444543b2331d7b45a29ccd3530daa2389e87e65d89bMarek Olšák case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: 445543b2331d7b45a29ccd3530daa2389e87e65d89bMarek Olšák case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: 446b55c98ea4124f63a6a4b5ecf349ae80404449695Marek Olšák return 32*4; 447543b2331d7b45a29ccd3530daa2389e87e65d89bMarek Olšák 4481235becaa1cf7e29f580900592563c3329d326deJerome Glisse /* Texturing. */ 4491235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: 4501235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: 4511235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: 452fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher if (family >= CHIP_CEDAR) 453fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher return 15; 454fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher else 455fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher return 14; 456b37931f69b7885ec9cdcaea8aec10db777d7e60aMarek Olšák case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: 4571a532ca79a4a87bb86c641a6ca22da0301dc1f62Marek Olšák return rscreen->info.drm_minor >= 9 ? 458b37931f69b7885ec9cdcaea8aec10db777d7e60aMarek Olšák (family >= CHIP_CEDAR ? 16384 : 8192) : 0; 459320adb93a137a733da4b44f41e2d8ba01f164568Marek Olšák case PIPE_CAP_MAX_COMBINED_SAMPLERS: 460320adb93a137a733da4b44f41e2d8ba01f164568Marek Olšák return 32; 4611235becaa1cf7e29f580900592563c3329d326deJerome Glisse 4621235becaa1cf7e29f580900592563c3329d326deJerome Glisse /* Render targets. */ 4631235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_CAP_MAX_RENDER_TARGETS: 464370c8b5ee7666f4f515d63603afe8282b1b3c682Marek Olšák /* XXX some r6xx are buggy and can only do 4 */ 4651235becaa1cf7e29f580900592563c3329d326deJerome Glisse return 8; 4661235becaa1cf7e29f580900592563c3329d326deJerome Glisse 46790c2fd86407999475ff6accecf36e5a2c75feb9bMathias Fröhlich /* Timer queries, present when the clock frequency is non zero. */ 46890c2fd86407999475ff6accecf36e5a2c75feb9bMathias Fröhlich case PIPE_CAP_TIMER_QUERY: 4691a532ca79a4a87bb86c641a6ca22da0301dc1f62Marek Olšák return rscreen->info.r600_clock_crystal_freq != 0; 47044f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák case PIPE_CAP_QUERY_TIMESTAMP: 47144f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák return rscreen->info.drm_minor >= 20 && 47244f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák rscreen->info.r600_clock_crystal_freq != 0; 47390c2fd86407999475ff6accecf36e5a2c75feb9bMathias Fröhlich 4740b666106c5f75b581ef1ebeb354c29a00400404fDave Airlie case PIPE_CAP_MIN_TEXEL_OFFSET: 4750b666106c5f75b581ef1ebeb354c29a00400404fDave Airlie return -8; 4760b666106c5f75b581ef1ebeb354c29a00400404fDave Airlie 4770b666106c5f75b581ef1ebeb354c29a00400404fDave Airlie case PIPE_CAP_MAX_TEXEL_OFFSET: 4780b666106c5f75b581ef1ebeb354c29a00400404fDave Airlie return 7; 4791235becaa1cf7e29f580900592563c3329d326deJerome Glisse } 4804ac250c9d594898ad02323dbf02aab8792366d11Marek Olšák return 0; 4811235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 4821235becaa1cf7e29f580900592563c3329d326deJerome Glisse 483bb71f9249a66b9a4921a878766c0a2d87624c369Marek Olšákstatic float r600_get_paramf(struct pipe_screen* pscreen, 484bb71f9249a66b9a4921a878766c0a2d87624c369Marek Olšák enum pipe_capf param) 4851235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 486fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher struct r600_screen *rscreen = (struct r600_screen *)pscreen; 487518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák enum radeon_family family = rscreen->family; 488fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher 4891235becaa1cf7e29f580900592563c3329d326deJerome Glisse switch (param) { 490bb71f9249a66b9a4921a878766c0a2d87624c369Marek Olšák case PIPE_CAPF_MAX_LINE_WIDTH: 491bb71f9249a66b9a4921a878766c0a2d87624c369Marek Olšák case PIPE_CAPF_MAX_LINE_WIDTH_AA: 492bb71f9249a66b9a4921a878766c0a2d87624c369Marek Olšák case PIPE_CAPF_MAX_POINT_WIDTH: 493bb71f9249a66b9a4921a878766c0a2d87624c369Marek Olšák case PIPE_CAPF_MAX_POINT_WIDTH_AA: 494fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher if (family >= CHIP_CEDAR) 495fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher return 16384.0f; 496fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher else 497fae7cb8ed83d43b28a7837acdb4912714a955217Alex Deucher return 8192.0f; 498bb71f9249a66b9a4921a878766c0a2d87624c369Marek Olšák case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: 4991235becaa1cf7e29f580900592563c3329d326deJerome Glisse return 16.0f; 500bb71f9249a66b9a4921a878766c0a2d87624c369Marek Olšák case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: 5011235becaa1cf7e29f580900592563c3329d326deJerome Glisse return 16.0f; 502034e63b9f8ee23cfac769b1a2c431bdd2307a6c4Marek Olšák case PIPE_CAPF_GUARD_BAND_LEFT: 503034e63b9f8ee23cfac769b1a2c431bdd2307a6c4Marek Olšák case PIPE_CAPF_GUARD_BAND_TOP: 504034e63b9f8ee23cfac769b1a2c431bdd2307a6c4Marek Olšák case PIPE_CAPF_GUARD_BAND_RIGHT: 505034e63b9f8ee23cfac769b1a2c431bdd2307a6c4Marek Olšák case PIPE_CAPF_GUARD_BAND_BOTTOM: 506034e63b9f8ee23cfac769b1a2c431bdd2307a6c4Marek Olšák return 0.0f; 5071235becaa1cf7e29f580900592563c3329d326deJerome Glisse } 5084ac250c9d594898ad02323dbf02aab8792366d11Marek Olšák return 0.0f; 5091235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 5101235becaa1cf7e29f580900592563c3329d326deJerome Glisse 5111235becaa1cf7e29f580900592563c3329d326deJerome Glissestatic int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enum pipe_shader_cap param) 5121235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 5131235becaa1cf7e29f580900592563c3329d326deJerome Glisse switch(shader) 5141235becaa1cf7e29f580900592563c3329d326deJerome Glisse { 5151235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_FRAGMENT: 5161235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_VERTEX: 5176a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_SHADER_COMPUTE: 5181235becaa1cf7e29f580900592563c3329d326deJerome Glisse break; 5191235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_GEOMETRY: 520370c8b5ee7666f4f515d63603afe8282b1b3c682Marek Olšák /* XXX: support and enable geometry programs */ 5211235becaa1cf7e29f580900592563c3329d326deJerome Glisse return 0; 5221235becaa1cf7e29f580900592563c3329d326deJerome Glisse default: 523370c8b5ee7666f4f515d63603afe8282b1b3c682Marek Olšák /* XXX: support tessellation on Evergreen */ 5241235becaa1cf7e29f580900592563c3329d326deJerome Glisse return 0; 5251235becaa1cf7e29f580900592563c3329d326deJerome Glisse } 5261235becaa1cf7e29f580900592563c3329d326deJerome Glisse 527370c8b5ee7666f4f515d63603afe8282b1b3c682Marek Olšák /* XXX: all these should be fixed, since r600 surely supports much more! */ 5281235becaa1cf7e29f580900592563c3329d326deJerome Glisse switch (param) { 5291235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 5301235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 5311235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 5321235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 5331235becaa1cf7e29f580900592563c3329d326deJerome Glisse return 16384; 5341235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 535370c8b5ee7666f4f515d63603afe8282b1b3c682Marek Olšák return 8; /* XXX */ 5361235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_INPUTS: 5371235becaa1cf7e29f580900592563c3329d326deJerome Glisse if(shader == PIPE_SHADER_FRAGMENT) 5381e5cef96d184b00eb588b48ecd02386998077d82Marek Olšák return 34; 5391235becaa1cf7e29f580900592563c3329d326deJerome Glisse else 5401e5cef96d184b00eb588b48ecd02386998077d82Marek Olšák return 32; 5411235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_TEMPS: 542b2a98c3531c276b76024bb9b10fdd6c3360cb0c9Henri Verbeet return 256; /* Max native temporaries. */ 5431235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_ADDRS: 544370c8b5ee7666f4f515d63603afe8282b1b3c682Marek Olšák /* XXX Isn't this equal to TEMPS? */ 545b2a98c3531c276b76024bb9b10fdd6c3360cb0c9Henri Verbeet return 1; /* Max native address registers */ 5461235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_CONSTS: 547eac50295fccb983281423e825e57ab4a2a5bbbfbHenri Verbeet return R600_MAX_CONST_BUFFER_SIZE; 5481235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 54954e8dcaad65cbe3603730414fd8d76ac53f89a86Vadim Girlin return R600_MAX_CONST_BUFFERS-1; 5501235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_MAX_PREDS: 551370c8b5ee7666f4f515d63603afe8282b1b3c682Marek Olšák return 0; /* nothing uses this */ 5521235becaa1cf7e29f580900592563c3329d326deJerome Glisse case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: 5531235becaa1cf7e29f580900592563c3329d326deJerome Glisse return 1; 5545c7127c07c3933662bc5447ce4a83b4e8af3b473Marek Olšák case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: 5555c7127c07c3933662bc5447ce4a83b4e8af3b473Marek Olšák case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: 5565c7127c07c3933662bc5447ce4a83b4e8af3b473Marek Olšák case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 5575c7127c07c3933662bc5447ce4a83b4e8af3b473Marek Olšák case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 5585c7127c07c3933662bc5447ce4a83b4e8af3b473Marek Olšák return 1; 5599aa089eac05ebefafb6610b4a7e209b2fd1e93f6Marek Olšák case PIPE_SHADER_CAP_SUBROUTINES: 5609aa089eac05ebefafb6610b4a7e209b2fd1e93f6Marek Olšák return 0; 56117b695e6e7dd730497fb60a8e161935b23fa0e9cBryan Cain case PIPE_SHADER_CAP_INTEGERS: 56215ca9d159e50815b0bfe60df8873f48c32a59ca5Marek Olšák return 1; 563f5bfe54a34d9c8cd5de2b096d0e8486fe0d990a7Marek Olšák case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 564f5bfe54a34d9c8cd5de2b096d0e8486fe0d990a7Marek Olšák return 16; 5656a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_SHADER_CAP_PREFERRED_IR: 5666a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (shader == PIPE_SHADER_COMPUTE) { 5676a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return PIPE_SHADER_IR_LLVM; 5686a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } else { 5696a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return PIPE_SHADER_IR_TGSI; 5706a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 5711235becaa1cf7e29f580900592563c3329d326deJerome Glisse } 5724ac250c9d594898ad02323dbf02aab8792366d11Marek Olšák return 0; 5731235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 5741235becaa1cf7e29f580900592563c3329d326deJerome Glisse 575f265a194263bb2a3fa204947a9c98f472835f121Christian Königstatic int r600_get_video_param(struct pipe_screen *screen, 576f265a194263bb2a3fa204947a9c98f472835f121Christian König enum pipe_video_profile profile, 577f265a194263bb2a3fa204947a9c98f472835f121Christian König enum pipe_video_cap param) 578f265a194263bb2a3fa204947a9c98f472835f121Christian König{ 579f265a194263bb2a3fa204947a9c98f472835f121Christian König switch (param) { 580efc7fda4627919b5355952d955ee4a2c98505e56Christian König case PIPE_VIDEO_CAP_SUPPORTED: 581efc7fda4627919b5355952d955ee4a2c98505e56Christian König return vl_profile_supported(screen, profile); 582f265a194263bb2a3fa204947a9c98f472835f121Christian König case PIPE_VIDEO_CAP_NPOT_TEXTURES: 583f265a194263bb2a3fa204947a9c98f472835f121Christian König return 1; 584efc7fda4627919b5355952d955ee4a2c98505e56Christian König case PIPE_VIDEO_CAP_MAX_WIDTH: 585efc7fda4627919b5355952d955ee4a2c98505e56Christian König case PIPE_VIDEO_CAP_MAX_HEIGHT: 586efc7fda4627919b5355952d955ee4a2c98505e56Christian König return vl_video_buffer_max_size(screen); 5879d9afcb5bac2931d4b8e6d1aa571e941c5110c90Christian König case PIPE_VIDEO_CAP_PREFERED_FORMAT: 5889d9afcb5bac2931d4b8e6d1aa571e941c5110c90Christian König return PIPE_FORMAT_NV12; 589f3f03c67e90f962f67e7b58b7c7baff3be251cb1Christian König case PIPE_VIDEO_CAP_PREFERS_INTERLACED: 590f3f03c67e90f962f67e7b58b7c7baff3be251cb1Christian König return false; 591f3f03c67e90f962f67e7b58b7c7baff3be251cb1Christian König case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED: 592f3f03c67e90f962f67e7b58b7c7baff3be251cb1Christian König return false; 593f3f03c67e90f962f67e7b58b7c7baff3be251cb1Christian König case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE: 594f3f03c67e90f962f67e7b58b7c7baff3be251cb1Christian König return true; 595f265a194263bb2a3fa204947a9c98f472835f121Christian König default: 596f265a194263bb2a3fa204947a9c98f472835f121Christian König return 0; 597f265a194263bb2a3fa204947a9c98f472835f121Christian König } 598f265a194263bb2a3fa204947a9c98f472835f121Christian König} 599f265a194263bb2a3fa204947a9c98f472835f121Christian König 6006a829a1b724ca0d960decee217d260b4de8a5463Adam Rakstatic int r600_get_compute_param(struct pipe_screen *screen, 6016a829a1b724ca0d960decee217d260b4de8a5463Adam Rak enum pipe_compute_cap param, 6026a829a1b724ca0d960decee217d260b4de8a5463Adam Rak void *ret) 6036a829a1b724ca0d960decee217d260b4de8a5463Adam Rak{ 6046a829a1b724ca0d960decee217d260b4de8a5463Adam Rak //TODO: select these params by asic 6056a829a1b724ca0d960decee217d260b4de8a5463Adam Rak switch (param) { 6066a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_COMPUTE_CAP_IR_TARGET: 6076a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (ret) { 6086a829a1b724ca0d960decee217d260b4de8a5463Adam Rak strcpy(ret, "r600--"); 6096a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6106a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return 7 * sizeof(char); 6116a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6126a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_COMPUTE_CAP_GRID_DIMENSION: 6136a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (ret) { 6146a829a1b724ca0d960decee217d260b4de8a5463Adam Rak uint64_t * grid_dimension = ret; 6156a829a1b724ca0d960decee217d260b4de8a5463Adam Rak grid_dimension[0] = 3; 6166a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6176a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return 1 * sizeof(uint64_t); 6186a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6196a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_COMPUTE_CAP_MAX_GRID_SIZE: 6206a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (ret) { 6216a829a1b724ca0d960decee217d260b4de8a5463Adam Rak uint64_t * grid_size = ret; 6226a829a1b724ca0d960decee217d260b4de8a5463Adam Rak grid_size[0] = 65535; 6236a829a1b724ca0d960decee217d260b4de8a5463Adam Rak grid_size[1] = 65535; 6246a829a1b724ca0d960decee217d260b4de8a5463Adam Rak grid_size[2] = 1; 6256a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6266a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return 3 * sizeof(uint64_t) ; 6276a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6286a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE: 6296a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (ret) { 6306a829a1b724ca0d960decee217d260b4de8a5463Adam Rak uint64_t * block_size = ret; 6316a829a1b724ca0d960decee217d260b4de8a5463Adam Rak block_size[0] = 256; 6326a829a1b724ca0d960decee217d260b4de8a5463Adam Rak block_size[1] = 256; 6336a829a1b724ca0d960decee217d260b4de8a5463Adam Rak block_size[2] = 256; 6346a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6356a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return 3 * sizeof(uint64_t); 6366a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6376a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK: 6386a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (ret) { 6396a829a1b724ca0d960decee217d260b4de8a5463Adam Rak uint64_t * max_threads_per_block = ret; 6406a829a1b724ca0d960decee217d260b4de8a5463Adam Rak *max_threads_per_block = 256; 6416a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6426a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return sizeof(uint64_t); 6436a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6446a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE: 6456a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (ret) { 6466a829a1b724ca0d960decee217d260b4de8a5463Adam Rak uint64_t * max_global_size = ret; 647c0f7fe7b79afa9b95b1af56dce9eb881575b1cdeTom Stellard /* XXX: This is 64kb for now until we get the 648c0f7fe7b79afa9b95b1af56dce9eb881575b1cdeTom Stellard * compute memory pool working correctly. 649c0f7fe7b79afa9b95b1af56dce9eb881575b1cdeTom Stellard */ 650c0f7fe7b79afa9b95b1af56dce9eb881575b1cdeTom Stellard *max_global_size = 1024 * 16 * 4; 6516a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6526a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return sizeof(uint64_t); 6536a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6546a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE: 6556a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (ret) { 6566a829a1b724ca0d960decee217d260b4de8a5463Adam Rak uint64_t * max_input_size = ret; 6576a829a1b724ca0d960decee217d260b4de8a5463Adam Rak *max_input_size = 1024; 6586a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6596a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return sizeof(uint64_t); 6606a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6616a829a1b724ca0d960decee217d260b4de8a5463Adam Rak case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE: 6626a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (ret) { 6636a829a1b724ca0d960decee217d260b4de8a5463Adam Rak uint64_t * max_local_size = ret; 6646a829a1b724ca0d960decee217d260b4de8a5463Adam Rak /* XXX: This is what the proprietary driver reports, we 6656a829a1b724ca0d960decee217d260b4de8a5463Adam Rak * may want to use a different value. */ 6666a829a1b724ca0d960decee217d260b4de8a5463Adam Rak *max_local_size = 32768; 6676a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6686a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return sizeof(uint64_t); 6696a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6706a829a1b724ca0d960decee217d260b4de8a5463Adam Rak default: 6716a829a1b724ca0d960decee217d260b4de8a5463Adam Rak fprintf(stderr, "unknown PIPE_COMPUTE_CAP %d\n", param); 6726a829a1b724ca0d960decee217d260b4de8a5463Adam Rak return 0; 6736a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6746a829a1b724ca0d960decee217d260b4de8a5463Adam Rak} 6756a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6761235becaa1cf7e29f580900592563c3329d326deJerome Glissestatic void r600_destroy_screen(struct pipe_screen* pscreen) 6771235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 6781235becaa1cf7e29f580900592563c3329d326deJerome Glisse struct r600_screen *rscreen = (struct r600_screen *)pscreen; 6791235becaa1cf7e29f580900592563c3329d326deJerome Glisse 6801235becaa1cf7e29f580900592563c3329d326deJerome Glisse if (rscreen == NULL) 6811235becaa1cf7e29f580900592563c3329d326deJerome Glisse return; 68252ba68d0b071620c891122d8049ec77568aa8d19Tilman Sauerbeck 6836a829a1b724ca0d960decee217d260b4de8a5463Adam Rak if (rscreen->global_pool) { 6846a829a1b724ca0d960decee217d260b4de8a5463Adam Rak compute_memory_pool_delete(rscreen->global_pool); 6856a829a1b724ca0d960decee217d260b4de8a5463Adam Rak } 6866a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 6877dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer if (rscreen->fences.bo) { 6887dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer struct r600_fence_block *entry, *tmp; 6897dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer 6907dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer LIST_FOR_EACH_ENTRY_SAFE(entry, tmp, &rscreen->fences.blocks, head) { 6917dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer LIST_DEL(&entry->head); 6927dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer FREE(entry); 6937dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer } 6947dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer 6950a6120244e66494db070ce875c0a464fbc5b15a1Marek Olšák rscreen->ws->buffer_unmap(rscreen->fences.bo->cs_buf); 6967dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer pipe_resource_reference((struct pipe_resource**)&rscreen->fences.bo, NULL); 6977dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer } 6987dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer pipe_mutex_destroy(rscreen->fences.mutex); 6997dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer 7002ce783d8ddec1b1fcadc0798af0ebb045bba1cc4Marek Olšák rscreen->ws->destroy(rscreen->ws); 7011235becaa1cf7e29f580900592563c3329d326deJerome Glisse FREE(rscreen); 7021235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 7031235becaa1cf7e29f580900592563c3329d326deJerome Glisse 704948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglundstatic void r600_fence_reference(struct pipe_screen *pscreen, 705948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct pipe_fence_handle **ptr, 706948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct pipe_fence_handle *fence) 707948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund{ 708948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct r600_fence **oldf = (struct r600_fence**)ptr; 709948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct r600_fence *newf = (struct r600_fence*)fence; 710948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 711948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund if (pipe_reference(&(*oldf)->reference, &newf->reference)) { 7127dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer struct r600_screen *rscreen = (struct r600_screen *)pscreen; 7137dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer pipe_mutex_lock(rscreen->fences.mutex); 7148cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth pipe_resource_reference((struct pipe_resource**)&(*oldf)->sleep_bo, NULL); 7157dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer LIST_ADDTAIL(&(*oldf)->head, &rscreen->fences.pool); 7167dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer pipe_mutex_unlock(rscreen->fences.mutex); 717948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 718948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 719948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund *ptr = fence; 720948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund} 721948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 722948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglundstatic boolean r600_fence_signalled(struct pipe_screen *pscreen, 723948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct pipe_fence_handle *fence) 724948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund{ 7257dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer struct r600_screen *rscreen = (struct r600_screen *)pscreen; 726948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct r600_fence *rfence = (struct r600_fence*)fence; 727948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 728cd95b673479f8a8ac3d5aabf387d33f705e156e9Marek Olšák return rscreen->fences.data[rfence->index] != 0; 729948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund} 730948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 731948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglundstatic boolean r600_fence_finish(struct pipe_screen *pscreen, 732948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct pipe_fence_handle *fence, 733948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund uint64_t timeout) 734948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund{ 7357dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer struct r600_screen *rscreen = (struct r600_screen *)pscreen; 736948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund struct r600_fence *rfence = (struct r600_fence*)fence; 737948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund int64_t start_time = 0; 738948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund unsigned spins = 0; 739948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 740948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund if (timeout != PIPE_TIMEOUT_INFINITE) { 741948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund start_time = os_time_get(); 742948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 743948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund /* Convert to microseconds. */ 744948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund timeout /= 1000; 745948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 746948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 7477dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer while (rscreen->fences.data[rfence->index] == 0) { 7488cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth /* Special-case infinite timeout - wait for the dummy BO to become idle */ 7498cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth if (timeout == PIPE_TIMEOUT_INFINITE) { 7508cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth rscreen->ws->buffer_wait(rfence->sleep_bo->buf, RADEON_USAGE_READWRITE); 7518cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth break; 7528cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth } 7538cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth 7548cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth /* The dummy BO will be busy until the CS including the fence has completed, or 7558cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth * the GPU is reset. Don't bother continuing to spin when the BO is idle. */ 7568cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth if (!rscreen->ws->buffer_is_busy(rfence->sleep_bo->buf, RADEON_USAGE_READWRITE)) 7578cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth break; 7588cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth 759948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund if (++spins % 256) 760948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund continue; 761948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund#ifdef PIPE_OS_UNIX 762948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund sched_yield(); 763948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund#else 764948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund os_time_sleep(10); 765948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund#endif 766948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund if (timeout != PIPE_TIMEOUT_INFINITE && 767948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund os_time_get() - start_time >= timeout) { 7688cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth break; 769948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 770948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund } 771948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund 7728cd03b933cf868ff867e2db4a0937005a02fd0e4Simon Farnsworth return rscreen->fences.data[rfence->index] != 0; 773948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund} 7741235becaa1cf7e29f580900592563c3329d326deJerome Glisse 7753603d157889544230f1787bbdc4915ccd7461c59Marek Olšákstatic int r600_interpret_tiling(struct r600_screen *rscreen, uint32_t tiling_config) 7763603d157889544230f1787bbdc4915ccd7461c59Marek Olšák{ 7773603d157889544230f1787bbdc4915ccd7461c59Marek Olšák switch ((tiling_config & 0xe) >> 1) { 7783603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 0: 7793603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_channels = 1; 7803603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 7813603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 1: 7823603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_channels = 2; 7833603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 7843603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 2: 7853603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_channels = 4; 7863603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 7873603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 3: 7883603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_channels = 8; 7893603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 7903603d157889544230f1787bbdc4915ccd7461c59Marek Olšák default: 7913603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return -EINVAL; 7923603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } 7933603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 7943603d157889544230f1787bbdc4915ccd7461c59Marek Olšák switch ((tiling_config & 0x30) >> 4) { 7953603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 0: 7963603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_banks = 4; 7973603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 7983603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 1: 7993603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_banks = 8; 8003603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8013603d157889544230f1787bbdc4915ccd7461c59Marek Olšák default: 8023603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return -EINVAL; 8033603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 8043603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } 8053603d157889544230f1787bbdc4915ccd7461c59Marek Olšák switch ((tiling_config & 0xc0) >> 6) { 8063603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 0: 8073603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.group_bytes = 256; 8083603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8093603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 1: 8103603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.group_bytes = 512; 8113603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8123603d157889544230f1787bbdc4915ccd7461c59Marek Olšák default: 8133603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return -EINVAL; 8143603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } 8153603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return 0; 8163603d157889544230f1787bbdc4915ccd7461c59Marek Olšák} 8173603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 8183603d157889544230f1787bbdc4915ccd7461c59Marek Olšákstatic int evergreen_interpret_tiling(struct r600_screen *rscreen, uint32_t tiling_config) 8193603d157889544230f1787bbdc4915ccd7461c59Marek Olšák{ 8203603d157889544230f1787bbdc4915ccd7461c59Marek Olšák switch (tiling_config & 0xf) { 8213603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 0: 8223603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_channels = 1; 8233603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8243603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 1: 8253603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_channels = 2; 8263603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8273603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 2: 8283603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_channels = 4; 8293603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8303603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 3: 8313603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_channels = 8; 8323603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8333603d157889544230f1787bbdc4915ccd7461c59Marek Olšák default: 8343603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return -EINVAL; 8353603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } 8363603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 8373603d157889544230f1787bbdc4915ccd7461c59Marek Olšák switch ((tiling_config & 0xf0) >> 4) { 8383603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 0: 8393603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_banks = 4; 8403603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8413603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 1: 8423603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_banks = 8; 8433603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8443603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 2: 8453603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.num_banks = 16; 8463603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8473603d157889544230f1787bbdc4915ccd7461c59Marek Olšák default: 8483603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return -EINVAL; 8493603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } 8503603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 8513603d157889544230f1787bbdc4915ccd7461c59Marek Olšák switch ((tiling_config & 0xf00) >> 8) { 8523603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 0: 8533603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.group_bytes = 256; 8543603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8553603d157889544230f1787bbdc4915ccd7461c59Marek Olšák case 1: 8563603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.group_bytes = 512; 8573603d157889544230f1787bbdc4915ccd7461c59Marek Olšák break; 8583603d157889544230f1787bbdc4915ccd7461c59Marek Olšák default: 8593603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return -EINVAL; 8603603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } 8613603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return 0; 8623603d157889544230f1787bbdc4915ccd7461c59Marek Olšák} 8633603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 8643603d157889544230f1787bbdc4915ccd7461c59Marek Olšákstatic int r600_init_tiling(struct r600_screen *rscreen) 8653603d157889544230f1787bbdc4915ccd7461c59Marek Olšák{ 8663603d157889544230f1787bbdc4915ccd7461c59Marek Olšák uint32_t tiling_config = rscreen->info.r600_tiling_config; 8673603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 8683603d157889544230f1787bbdc4915ccd7461c59Marek Olšák /* set default group bytes, overridden by tiling info ioctl */ 869518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák if (rscreen->chip_class <= R700) { 8703603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.group_bytes = 256; 8713603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } else { 8723603d157889544230f1787bbdc4915ccd7461c59Marek Olšák rscreen->tiling_info.group_bytes = 512; 8733603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } 8743603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 8753603d157889544230f1787bbdc4915ccd7461c59Marek Olšák if (!tiling_config) 8763603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return 0; 8773603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 878518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák if (rscreen->chip_class <= R700) { 8793603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return r600_interpret_tiling(rscreen, tiling_config); 8803603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } else { 8813603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return evergreen_interpret_tiling(rscreen, tiling_config); 8823603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } 8833603d157889544230f1787bbdc4915ccd7461c59Marek Olšák} 8843603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 885518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšákstatic unsigned radeon_family_from_device(unsigned device) 886518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák{ 887518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák switch (device) { 888518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák#define CHIPSET(pciid, name, family) case pciid: return CHIP_##family; 889518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák#include "pci_ids/r600_pci_ids.h" 890518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák#undef CHIPSET 891518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák default: 892518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák return CHIP_UNKNOWN; 893518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák } 894518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák} 895518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák 89644f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšákstatic uint64_t r600_get_timestamp(struct pipe_screen *screen) 89744f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák{ 89844f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák struct r600_screen *rscreen = (struct r600_screen*)screen; 89944f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák 90044f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák return 1000000 * rscreen->ws->query_timestamp(rscreen->ws) / 90144f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák rscreen->info.r600_clock_crystal_freq; 90244f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák} 90344f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák 9042ce783d8ddec1b1fcadc0798af0ebb045bba1cc4Marek Olšákstruct pipe_screen *r600_screen_create(struct radeon_winsys *ws) 9051235becaa1cf7e29f580900592563c3329d326deJerome Glisse{ 90690ce3cdde9fb2dd507b4e21c5456a3371f5996bcMarek Olšák struct r600_screen *rscreen = CALLOC_STRUCT(r600_screen); 907e6aad9ba04fb914a2484241f74ed0557fd1d59daDave Airlie 9081235becaa1cf7e29f580900592563c3329d326deJerome Glisse if (rscreen == NULL) { 9091235becaa1cf7e29f580900592563c3329d326deJerome Glisse return NULL; 9101235becaa1cf7e29f580900592563c3329d326deJerome Glisse } 9111235becaa1cf7e29f580900592563c3329d326deJerome Glisse 9122ce783d8ddec1b1fcadc0798af0ebb045bba1cc4Marek Olšák rscreen->ws = ws; 9133603d157889544230f1787bbdc4915ccd7461c59Marek Olšák ws->query_info(ws, &rscreen->info); 9143603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 915518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák rscreen->family = radeon_family_from_device(rscreen->info.pci_id); 916518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák if (rscreen->family == CHIP_UNKNOWN) { 917518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák fprintf(stderr, "r600: Unknown chipset 0x%04X\n", rscreen->info.pci_id); 918518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák FREE(rscreen); 919518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák return NULL; 920518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák } 921518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák 922518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák /* setup class */ 923b4082f492b4b55df4c636445e47b97d1f1e4b5b2Alex Deucher if (rscreen->family >= CHIP_CAYMAN) { 924518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák rscreen->chip_class = CAYMAN; 925518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák } else if (rscreen->family >= CHIP_CEDAR) { 926518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák rscreen->chip_class = EVERGREEN; 927518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák } else if (rscreen->family >= CHIP_RV770) { 928518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák rscreen->chip_class = R700; 929518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák } else { 930518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák rscreen->chip_class = R600; 931518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák } 932518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák 9336e7756db14c362ede6fdc97454267a32b8eab1d4Marek Olšák /* Figure out streamout kernel support. */ 9346e7756db14c362ede6fdc97454267a32b8eab1d4Marek Olšák switch (rscreen->chip_class) { 9356e7756db14c362ede6fdc97454267a32b8eab1d4Marek Olšák case R600: 9361106bbc7d6cd024d1e20573e281ea4c48c5eaf19Marek Olšák if (rscreen->family < CHIP_RS780) { 9371106bbc7d6cd024d1e20573e281ea4c48c5eaf19Marek Olšák rscreen->has_streamout = rscreen->info.drm_minor >= 14; 9381106bbc7d6cd024d1e20573e281ea4c48c5eaf19Marek Olšák } else { 9391106bbc7d6cd024d1e20573e281ea4c48c5eaf19Marek Olšák rscreen->has_streamout = rscreen->info.drm_minor >= 23; 9401106bbc7d6cd024d1e20573e281ea4c48c5eaf19Marek Olšák } 9416e7756db14c362ede6fdc97454267a32b8eab1d4Marek Olšák break; 9426e7756db14c362ede6fdc97454267a32b8eab1d4Marek Olšák case R700: 9436e7756db14c362ede6fdc97454267a32b8eab1d4Marek Olšák rscreen->has_streamout = rscreen->info.drm_minor >= 17; 9446e7756db14c362ede6fdc97454267a32b8eab1d4Marek Olšák break; 9451106bbc7d6cd024d1e20573e281ea4c48c5eaf19Marek Olšák case EVERGREEN: 9461106bbc7d6cd024d1e20573e281ea4c48c5eaf19Marek Olšák case CAYMAN: 9471106bbc7d6cd024d1e20573e281ea4c48c5eaf19Marek Olšák rscreen->has_streamout = rscreen->info.drm_minor >= 14; 9481106bbc7d6cd024d1e20573e281ea4c48c5eaf19Marek Olšák break; 949393d741788fa82896d4b1c9fd02402a83053afcfMarek Olšák } 950393d741788fa82896d4b1c9fd02402a83053afcfMarek Olšák 9513603d157889544230f1787bbdc4915ccd7461c59Marek Olšák if (r600_init_tiling(rscreen)) { 9523603d157889544230f1787bbdc4915ccd7461c59Marek Olšák FREE(rscreen); 9533603d157889544230f1787bbdc4915ccd7461c59Marek Olšák return NULL; 9543603d157889544230f1787bbdc4915ccd7461c59Marek Olšák } 9553603d157889544230f1787bbdc4915ccd7461c59Marek Olšák 9561235becaa1cf7e29f580900592563c3329d326deJerome Glisse rscreen->screen.destroy = r600_destroy_screen; 9571235becaa1cf7e29f580900592563c3329d326deJerome Glisse rscreen->screen.get_name = r600_get_name; 9581235becaa1cf7e29f580900592563c3329d326deJerome Glisse rscreen->screen.get_vendor = r600_get_vendor; 9591235becaa1cf7e29f580900592563c3329d326deJerome Glisse rscreen->screen.get_param = r600_get_param; 9601235becaa1cf7e29f580900592563c3329d326deJerome Glisse rscreen->screen.get_shader_param = r600_get_shader_param; 9611235becaa1cf7e29f580900592563c3329d326deJerome Glisse rscreen->screen.get_paramf = r600_get_paramf; 962f265a194263bb2a3fa204947a9c98f472835f121Christian König rscreen->screen.get_video_param = r600_get_video_param; 9636a829a1b724ca0d960decee217d260b4de8a5463Adam Rak rscreen->screen.get_compute_param = r600_get_compute_param; 96444f14ebd7b9ba7186342039d2602fdd6ea5077f5Marek Olšák rscreen->screen.get_timestamp = r600_get_timestamp; 9656a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 966518557d74abd4ce035dae079ff6eb1b08cc639d0Marek Olšák if (rscreen->chip_class >= EVERGREEN) { 96718cdb9c8abfb5d9f009fcb36ab788f48792207e4Henri Verbeet rscreen->screen.is_format_supported = evergreen_is_format_supported; 96818cdb9c8abfb5d9f009fcb36ab788f48792207e4Henri Verbeet } else { 96918cdb9c8abfb5d9f009fcb36ab788f48792207e4Henri Verbeet rscreen->screen.is_format_supported = r600_is_format_supported; 97018cdb9c8abfb5d9f009fcb36ab788f48792207e4Henri Verbeet } 9717eca76952b6726be9459375dde7478a01789577eChristian König rscreen->screen.is_video_format_supported = vl_video_buffer_is_format_supported; 972dbcd6526021c50770c3e5e04b04dc64c70298124Dave Airlie rscreen->screen.context_create = r600_create_context; 973948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund rscreen->screen.fence_reference = r600_fence_reference; 974948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund rscreen->screen.fence_signalled = r600_fence_signalled; 975948e1eb8e9c166ad5b74abc630d0760768ce78c9Fredrik Höglund rscreen->screen.fence_finish = r600_fence_finish; 9761235becaa1cf7e29f580900592563c3329d326deJerome Glisse r600_init_screen_resource_functions(&rscreen->screen); 9771235becaa1cf7e29f580900592563c3329d326deJerome Glisse 9788e0437914bb786d0b05be8f95e4ff37bf5a19f44Dave Airlie util_format_s3tc_init(); 9797b3fa038830663de9bceded1b0dd2d64b8cf39c4Dave Airlie 9807dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer rscreen->fences.bo = NULL; 9817dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer rscreen->fences.data = NULL; 9827dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer rscreen->fences.next_index = 0; 9837dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer LIST_INITHEAD(&rscreen->fences.pool); 9847dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer LIST_INITHEAD(&rscreen->fences.blocks); 9857dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer pipe_mutex_init(rscreen->fences.mutex); 9867dd2d29a560a53d42d15f9ac06ba2ee7cd312ed9Michel Dänzer 987c0f7fe7b79afa9b95b1af56dce9eb881575b1cdeTom Stellard rscreen->global_pool = compute_memory_pool_new(rscreen); 9886a829a1b724ca0d960decee217d260b4de8a5463Adam Rak 9891235becaa1cf7e29f580900592563c3329d326deJerome Glisse return &rscreen->screen; 9901235becaa1cf7e29f580900592563c3329d326deJerome Glisse} 991