1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2010 Red Hat Inc. 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the "Software"), 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to deal in the Software without restriction, including without limitation 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * on the rights to use, copy, modify, merge, publish, distribute, sub 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * license, and/or sell copies of the Software, and to permit persons to whom 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the Software is furnished to do so, subject to the following conditions: 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the next 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * paragraph) shall be included in all copies or substantial portions of the 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Software. 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * USE OR OTHER DEALINGS IN THE SOFTWARE. 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Authors: Dave Airlie <airlied@redhat.com> 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_index_modify.h" 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_upload_mgr.h" 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "radeonsi_pipe.h" 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid r600_translate_index_buffer(struct r600_context *r600, 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct pipe_index_buffer *ib, 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned count) 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct pipe_resource *out_buffer = NULL; 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned out_offset; 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void *ptr; 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (ib->index_size) { 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case 1: 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org u_upload_alloc(r600->uploader, 0, count * 2, 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org &out_offset, &out_buffer, &ptr); 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org util_shorten_ubyte_elts_to_userptr( 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org &r600->context, ib, 0, ib->offset, count, ptr); 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org pipe_resource_reference(&ib->buffer, NULL); 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ib->buffer = out_buffer; 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ib->offset = out_offset; 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ib->index_size = 2; 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 54