Path: blob/21.2-virgl/src/gallium/auxiliary/driver_rbug/rbug_objects.h
4561 views
/**************************************************************************1*2* Copyright 2010 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef RBUG_OBJECTS_H28#define RBUG_OBJECTS_H293031#include "pipe/p_compiler.h"32#include "pipe/p_state.h"3334#include "rbug_screen.h"3536struct rbug_context;373839struct rbug_resource40{41struct pipe_resource base;4243struct pipe_resource *resource;4445struct rbug_list list;46};474849enum rbug_shader_type50{51RBUG_SHADER_GEOM,52RBUG_SHADER_VERTEX,53RBUG_SHADER_FRAGMENT,54};5556struct rbug_shader57{58struct rbug_list list;5960void *shader;61void *tokens;62void *replaced_shader;63void *replaced_tokens;6465enum rbug_shader_type type;66bool disabled;67};686970struct rbug_sampler_view71{72struct pipe_sampler_view base;7374struct pipe_sampler_view *sampler_view;75};767778struct rbug_surface79{80struct pipe_surface base;8182struct pipe_surface *surface;83};848586struct rbug_transfer87{88struct pipe_transfer base;8990struct pipe_context *pipe;91struct pipe_transfer *transfer;92};939495static inline struct rbug_resource *96rbug_resource(struct pipe_resource *_resource)97{98if (!_resource)99return NULL;100(void)rbug_screen(_resource->screen);101return (struct rbug_resource *)_resource;102}103104static inline struct rbug_sampler_view *105rbug_sampler_view(struct pipe_sampler_view *_sampler_view)106{107if (!_sampler_view)108return NULL;109(void)rbug_resource(_sampler_view->texture);110return (struct rbug_sampler_view *)_sampler_view;111}112113static inline struct rbug_surface *114rbug_surface(struct pipe_surface *_surface)115{116if (!_surface)117return NULL;118(void)rbug_resource(_surface->texture);119return (struct rbug_surface *)_surface;120}121122static inline struct rbug_transfer *123rbug_transfer(struct pipe_transfer *_transfer)124{125if (!_transfer)126return NULL;127(void)rbug_resource(_transfer->resource);128return (struct rbug_transfer *)_transfer;129}130131static inline struct rbug_shader *132rbug_shader(void *_state)133{134if (!_state)135return NULL;136return (struct rbug_shader *)_state;137}138139static inline struct pipe_resource *140rbug_resource_unwrap(struct pipe_resource *_resource)141{142if (!_resource)143return NULL;144return rbug_resource(_resource)->resource;145}146147static inline struct pipe_sampler_view *148rbug_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view)149{150if (!_sampler_view)151return NULL;152return rbug_sampler_view(_sampler_view)->sampler_view;153}154155static inline struct pipe_surface *156rbug_surface_unwrap(struct pipe_surface *_surface)157{158if (!_surface)159return NULL;160return rbug_surface(_surface)->surface;161}162163static inline struct pipe_transfer *164rbug_transfer_unwrap(struct pipe_transfer *_transfer)165{166if (!_transfer)167return NULL;168return rbug_transfer(_transfer)->transfer;169}170171static inline void *172rbug_shader_unwrap(void *_state)173{174struct rbug_shader *shader;175if (!_state)176return NULL;177178shader = rbug_shader(_state);179return shader->replaced_shader ? shader->replaced_shader : shader->shader;180}181182183struct pipe_resource *184rbug_resource_create(struct rbug_screen *rb_screen,185struct pipe_resource *resource);186187void188rbug_resource_destroy(struct rbug_resource *rb_resource);189190struct pipe_surface *191rbug_surface_create(struct rbug_context *rb_context,192struct rbug_resource *rb_resource,193struct pipe_surface *surface);194195void196rbug_surface_destroy(struct rbug_context *rb_context,197struct rbug_surface *rb_surface);198199struct pipe_sampler_view *200rbug_sampler_view_create(struct rbug_context *rb_context,201struct rbug_resource *rb_resource,202struct pipe_sampler_view *view);203204void205rbug_sampler_view_destroy(struct rbug_context *rb_context,206struct rbug_sampler_view *rb_sampler_view);207208struct pipe_transfer *209rbug_transfer_create(struct rbug_context *rb_context,210struct rbug_resource *rb_resource,211struct pipe_transfer *transfer);212213void214rbug_transfer_destroy(struct rbug_context *rb_context,215struct rbug_transfer *rb_transfer);216217void *218rbug_shader_create(struct rbug_context *rb_context,219const struct pipe_shader_state *state,220void *result, enum rbug_shader_type type);221222void223rbug_shader_destroy(struct rbug_context *rb_context,224struct rbug_shader *rb_shader);225226227#endif /* RBUG_OBJECTS_H */228229230