1a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell/************************************************************************** 2a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * 3877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca * Copyright 2008 VMware, Inc. 4a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * All Rights Reserved. 5a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * 6a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 7a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * copy of this software and associated documentation files (the 8a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * "Software"), to deal in the Software without restriction, including 9a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * without limitation the rights to use, copy, modify, merge, publish, 10a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * distribute, sub license, and/or sell copies of the Software, and to 11a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * permit persons to whom the Software is furnished to do so, subject to 12a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * the following conditions: 13a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * 14a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * The above copyright notice and this permission notice (including the 15a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * next paragraph) shall be included in all copies or substantial portions 16a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * of the Software. 17a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * 18a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * 26a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell **************************************************************************/ 27a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 284f25420bdd834e81a3e22733304efc5261c2998aBrian Paul#include "util/u_memory.h" 29c6b3c2f34b5fdc30e679068d4e6130ba30efc1e4Keith Whitwell#include "util/u_math.h" 30784026139cc15db384bed858e7be943b79772aa4Dave Airlie#include "util/u_format.h" 31a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell#include "draw/draw_context.h" 32a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell#include "draw/draw_private.h" 33a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell#include "draw/draw_pt.h" 34a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell#include "translate/translate.h" 355fcd84ab39318a371253b1a7285bc657fb82efedZack Rusin#include "translate/translate_cache.h" 36a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 37a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 38a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwellstruct pt_fetch { 39a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell struct draw_context *draw; 40a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 41a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell struct translate *translate; 42f088b53769aacbee20135d912c33d688b6002011Zack Rusin 43a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell unsigned vertex_size; 44f088b53769aacbee20135d912c33d688b6002011Zack Rusin 455fcd84ab39318a371253b1a7285bc657fb82efedZack Rusin struct translate_cache *cache; 46a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell}; 47a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 48a0127b6ced257919180ba3a1bf534b68d9c750beRoland Scheidegger 49994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul/** 50994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul * Perform the fetch from API vertex elements & vertex buffers, to a 51a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * contiguous set of float[4] attributes as required for the 52a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * vertex_shader->run_linear() method. 53a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * 54a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * This is used in all cases except pure passthrough 55a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * (draw_pt_fetch_emit.c) which has its own version to translate 56a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * directly to hw vertices. 57a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell * 58a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell */ 59994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paulvoid 60994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Pauldraw_pt_fetch_prepare(struct pt_fetch *fetch, 61994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul unsigned vs_input_count, 62994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul unsigned vertex_size, 63994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul unsigned instance_id_index) 64a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell{ 65a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell struct draw_context *draw = fetch->draw; 66c6b3c2f34b5fdc30e679068d4e6130ba30efc1e4Keith Whitwell unsigned nr_inputs; 67543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol unsigned i, nr = 0, ei = 0; 68a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell unsigned dst_offset = 0; 69543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol unsigned num_extra_inputs = 0; 70a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell struct translate_key key; 71a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 72a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell fetch->vertex_size = vertex_size; 73a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 746c2c1e0ffeb265aa508e0ce8e552e10b0b5c5962Roland Scheidegger /* Leave the clipmask/edgeflags/pad/vertex_id, 756c2c1e0ffeb265aa508e0ce8e552e10b0b5c5962Roland Scheidegger * clip[] and whatever else in the header untouched. 76a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell */ 776c2c1e0ffeb265aa508e0ce8e552e10b0b5c5962Roland Scheidegger dst_offset = offsetof(struct vertex_header, data); 78a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 79543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol if (instance_id_index != ~0) { 80543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol num_extra_inputs++; 81543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol } 82543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol 83543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol assert(draw->pt.nr_vertex_elements + num_extra_inputs >= vs_input_count); 84543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol 85543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol nr_inputs = MIN2(vs_input_count, draw->pt.nr_vertex_elements + num_extra_inputs); 86c6b3c2f34b5fdc30e679068d4e6130ba30efc1e4Keith Whitwell 87c6b3c2f34b5fdc30e679068d4e6130ba30efc1e4Keith Whitwell for (i = 0; i < nr_inputs; i++) { 88543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol if (i == instance_id_index) { 89543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol key.element[nr].type = TRANSLATE_ELEMENT_INSTANCE_ID; 9076ff89d2de3807f316954aa97ffdbb51bb3b6966Michal Krol key.element[nr].input_format = PIPE_FORMAT_R32_USCALED; 9176ff89d2de3807f316954aa97ffdbb51bb3b6966Michal Krol key.element[nr].output_format = PIPE_FORMAT_R32_USCALED; 9276ff89d2de3807f316954aa97ffdbb51bb3b6966Michal Krol key.element[nr].output_offset = dst_offset; 9376ff89d2de3807f316954aa97ffdbb51bb3b6966Michal Krol 9476ff89d2de3807f316954aa97ffdbb51bb3b6966Michal Krol dst_offset += sizeof(uint); 9517707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie } else if (util_format_is_pure_sint(draw->pt.vertex_element[i].src_format)) { 9617707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].type = TRANSLATE_ELEMENT_NORMAL; 9717707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].input_format = draw->pt.vertex_element[ei].src_format; 9817707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].input_buffer = draw->pt.vertex_element[ei].vertex_buffer_index; 9917707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].input_offset = draw->pt.vertex_element[ei].src_offset; 10017707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].instance_divisor = draw->pt.vertex_element[ei].instance_divisor; 10117707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].output_format = PIPE_FORMAT_R32G32B32A32_SINT; 10217707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].output_offset = dst_offset; 10317707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie 10417707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie ei++; 10517707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie dst_offset += 4 * sizeof(int); 10617707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie } else if (util_format_is_pure_uint(draw->pt.vertex_element[i].src_format)) { 10717707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].type = TRANSLATE_ELEMENT_NORMAL; 10817707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].input_format = draw->pt.vertex_element[ei].src_format; 10917707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].input_buffer = draw->pt.vertex_element[ei].vertex_buffer_index; 11017707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].input_offset = draw->pt.vertex_element[ei].src_offset; 11117707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].instance_divisor = draw->pt.vertex_element[ei].instance_divisor; 11217707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].output_format = PIPE_FORMAT_R32G32B32A32_UINT; 11317707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie key.element[nr].output_offset = dst_offset; 11417707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie 11517707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie ei++; 11617707d89f438d7f52a3918f9b351e1419314cb17Dave Airlie dst_offset += 4 * sizeof(unsigned); 117543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol } else { 118543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol key.element[nr].type = TRANSLATE_ELEMENT_NORMAL; 119543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol key.element[nr].input_format = draw->pt.vertex_element[ei].src_format; 120543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol key.element[nr].input_buffer = draw->pt.vertex_element[ei].vertex_buffer_index; 121543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol key.element[nr].input_offset = draw->pt.vertex_element[ei].src_offset; 122543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol key.element[nr].instance_divisor = draw->pt.vertex_element[ei].instance_divisor; 12376ff89d2de3807f316954aa97ffdbb51bb3b6966Michal Krol key.element[nr].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT; 12476ff89d2de3807f316954aa97ffdbb51bb3b6966Michal Krol key.element[nr].output_offset = dst_offset; 12576ff89d2de3807f316954aa97ffdbb51bb3b6966Michal Krol 126543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol ei++; 12776ff89d2de3807f316954aa97ffdbb51bb3b6966Michal Krol dst_offset += 4 * sizeof(float); 128543b9566bdaa48fea2df1866fa1310c1cdbcde27Michal Krol } 129a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 130a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell nr++; 131a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell } 132a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 133a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell assert(dst_offset <= vertex_size); 134a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 135a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell key.nr_elements = nr; 136a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell key.output_stride = vertex_size; 137a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 138a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell if (!fetch->translate || 1397ddb925b8bc6c18eba953e34d2b630a3a6593f05Keith Whitwell translate_key_compare(&fetch->translate->key, &key) != 0) 140a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell { 1417ddb925b8bc6c18eba953e34d2b630a3a6593f05Keith Whitwell translate_key_sanitize(&key); 1425fcd84ab39318a371253b1a7285bc657fb82efedZack Rusin fetch->translate = translate_cache_find(fetch->cache, &key); 143a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell } 144a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell} 145a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 146a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 147994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paulvoid 148994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Pauldraw_pt_fetch_run(struct pt_fetch *fetch, 149994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul const unsigned *elts, 150994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul unsigned count, 151994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul char *verts) 152a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell{ 153a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell struct draw_context *draw = fetch->draw; 154a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell struct translate *translate = fetch->translate; 155a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell unsigned i; 156a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 1577d72607e142c0412b88183b849fd701e698b8f79Keith Whitwell for (i = 0; i < draw->pt.nr_vertex_buffers; i++) { 158994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul translate->set_buffer(translate, 159994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul i, 16029853ab7b8656cee9b92a53bec43f6e9f1e49691Zack Rusin ((char *)draw->pt.user.vbuffer[i].map + 1617d72607e142c0412b88183b849fd701e698b8f79Keith Whitwell draw->pt.vertex_buffer[i].buffer_offset), 1622a30d3d74a0b87f8066659952628ccd072a4e2b0José Fonseca draw->pt.vertex_buffer[i].stride, 1633733da31e8b4405b65e1b6ca3b6599ecc5af5fe7José Fonseca draw->pt.max_index); 164a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell } 165a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 166a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell translate->run_elts( translate, 167994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul elts, 168a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell count, 1691c2e5c223da28cdffe156b6b430fcdf638909021Zack Rusin draw->start_instance, 1705007e39f76c897b8f3aa4acf6086c8b7ac30bdefMichal Krol draw->instance_id, 171a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell verts ); 172a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell} 173a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 174a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 175994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paulvoid 176994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Pauldraw_pt_fetch_run_linear(struct pt_fetch *fetch, 177994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul unsigned start, 178994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul unsigned count, 179994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul char *verts) 180abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin{ 181abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin struct draw_context *draw = fetch->draw; 182abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin struct translate *translate = fetch->translate; 183abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin unsigned i; 184abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin 185abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin for (i = 0; i < draw->pt.nr_vertex_buffers; i++) { 186abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin translate->set_buffer(translate, 187abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin i, 18829853ab7b8656cee9b92a53bec43f6e9f1e49691Zack Rusin ((char *)draw->pt.user.vbuffer[i].map + 189abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin draw->pt.vertex_buffer[i].buffer_offset), 1902a30d3d74a0b87f8066659952628ccd072a4e2b0José Fonseca draw->pt.vertex_buffer[i].stride, 1917da3a947c72111dfb605781be6c0d61423b56e76José Fonseca draw->pt.max_index); 192abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin } 193abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin 194abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin translate->run( translate, 195abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin start, 196abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin count, 1971c2e5c223da28cdffe156b6b430fcdf638909021Zack Rusin draw->start_instance, 1987ca0ce38340144794267609646048b3820d594abMichal Krol draw->instance_id, 199abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin verts ); 200abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin} 201abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin 202abb08e9335b5d7cb004dc9e6cec390ab6968abe5Zack Rusin 203994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paulstruct pt_fetch * 204994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Pauldraw_pt_fetch_create(struct draw_context *draw) 205a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell{ 206a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell struct pt_fetch *fetch = CALLOC_STRUCT(pt_fetch); 207a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell if (!fetch) 208a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell return NULL; 209f088b53769aacbee20135d912c33d688b6002011Zack Rusin 210a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell fetch->draw = draw; 2115fcd84ab39318a371253b1a7285bc657fb82efedZack Rusin fetch->cache = translate_cache_create(); 21295f8f8863a80ce1e584160d4d085213a9bbaef12Zack Rusin if (!fetch->cache) { 21395f8f8863a80ce1e584160d4d085213a9bbaef12Zack Rusin FREE(fetch); 21495f8f8863a80ce1e584160d4d085213a9bbaef12Zack Rusin return NULL; 21595f8f8863a80ce1e584160d4d085213a9bbaef12Zack Rusin } 21695f8f8863a80ce1e584160d4d085213a9bbaef12Zack Rusin 217a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell return fetch; 218a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell} 219a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell 220994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paul 221994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Paulvoid 222994c33db875c6af2f5b535a7a173ff3bfa24fc32Brian Pauldraw_pt_fetch_destroy(struct pt_fetch *fetch) 223a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell{ 224501be9c7dd0cc5f985c708fa0e5f35d7fd20deb4Keith Whitwell if (fetch->cache) 225501be9c7dd0cc5f985c708fa0e5f35d7fd20deb4Keith Whitwell translate_cache_destroy(fetch->cache); 226e406ad5912985920a0d796f1ada58b40316590edKeith Whitwell 227a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell FREE(fetch); 228a773f06e969a3992451dd7fe6fd55ea96b2774faKeith Whitwell} 229