"Fossies" - the Fresh Open Source Software Archive

Member "mesa-20.1.8/src/gallium/auxiliary/driver_trace/tr_texture.c" (16 Sep 2020, 3385 Bytes) of package /linux/misc/mesa-20.1.8.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "tr_texture.c" see the Fossies "Dox" file reference documentation.

    1 /**************************************************************************
    2  *
    3  * Copyright 2008 VMware, Inc.
    4  * All Rights Reserved.
    5  *
    6  * Permission is hereby granted, free of charge, to any person obtaining a
    7  * copy of this software and associated documentation files (the
    8  * "Software"), to deal in the Software without restriction, including
    9  * without limitation the rights to use, copy, modify, merge, publish,
   10  * distribute, sub license, and/or sell copies of the Software, and to
   11  * permit persons to whom the Software is furnished to do so, subject to
   12  * the following conditions:
   13  *
   14  * The above copyright notice and this permission notice (including the
   15  * next paragraph) shall be included in all copies or substantial portions
   16  * of the Software.
   17  *
   18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
   21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
   22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   25  *
   26  **************************************************************************/
   27 
   28 #include "util/u_inlines.h"
   29 #include "util/u_hash_table.h"
   30 #include "util/u_memory.h"
   31 #include "util/simple_list.h"
   32 
   33 #include "tr_screen.h"
   34 #include "tr_context.h"
   35 #include "tr_texture.h"
   36 
   37 
   38 struct pipe_surface *
   39 trace_surf_create(struct trace_context *tr_ctx,
   40                   struct pipe_resource *res,
   41                   struct pipe_surface *surface)
   42 {
   43    struct trace_surface *tr_surf;
   44 
   45    if (!surface)
   46       goto error;
   47 
   48    assert(surface->texture == res);
   49 
   50    tr_surf = CALLOC_STRUCT(trace_surface);
   51    if (!tr_surf)
   52       goto error;
   53 
   54    memcpy(&tr_surf->base, surface, sizeof(struct pipe_surface));
   55    tr_surf->base.context = &tr_ctx->base;
   56 
   57    pipe_reference_init(&tr_surf->base.reference, 1);
   58    tr_surf->base.texture = NULL;
   59    pipe_resource_reference(&tr_surf->base.texture, res);
   60    tr_surf->surface = surface;
   61 
   62    return &tr_surf->base;
   63 
   64 error:
   65    pipe_surface_reference(&surface, NULL);
   66    return NULL;
   67 }
   68 
   69 
   70 void
   71 trace_surf_destroy(struct trace_surface *tr_surf)
   72 {
   73    trace_context_check(tr_surf->base.context);
   74    pipe_resource_reference(&tr_surf->base.texture, NULL);
   75    pipe_surface_reference(&tr_surf->surface, NULL);
   76    FREE(tr_surf);
   77 }
   78 
   79 
   80 struct pipe_transfer *
   81 trace_transfer_create(struct trace_context *tr_ctx,
   82               struct pipe_resource *res,
   83               struct pipe_transfer *transfer)
   84 {
   85    struct trace_transfer *tr_trans;
   86 
   87    if (!transfer)
   88       goto error;
   89 
   90    assert(transfer->resource == res);
   91 
   92    tr_trans = CALLOC_STRUCT(trace_transfer);
   93    if (!tr_trans)
   94       goto error;
   95 
   96    memcpy(&tr_trans->base, transfer, sizeof(struct pipe_transfer));
   97 
   98    tr_trans->base.resource = NULL;
   99    tr_trans->transfer = transfer;
  100 
  101    pipe_resource_reference(&tr_trans->base.resource, res);
  102    assert(tr_trans->base.resource == res);
  103 
  104    return &tr_trans->base;
  105 
  106 error:
  107    tr_ctx->pipe->transfer_unmap(tr_ctx->pipe, transfer);
  108    return NULL;
  109 }
  110 
  111 
  112 void
  113 trace_transfer_destroy(struct trace_context *tr_context,
  114                        struct trace_transfer *tr_trans)
  115 {
  116    pipe_resource_reference(&tr_trans->base.resource, NULL);
  117    FREE(tr_trans);
  118 }
  119