rbug_objects.h revision 2c3fb4ecce27f4c2468892241216a06fc77143c4
1/************************************************************************** 2 * 3 * Copyright 2010 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#ifndef RBUG_OBJECTS_H 29#define RBUG_OBJECTS_H 30 31 32#include "pipe/p_compiler.h" 33#include "pipe/p_state.h" 34 35#include "rbug_screen.h" 36 37struct rbug_context; 38 39 40struct rbug_resource 41{ 42 struct pipe_resource base; 43 44 struct pipe_resource *resource; 45 46 struct rbug_list list; 47}; 48 49 50struct rbug_shader 51{ 52 struct rbug_list list; 53 54 void *shader; 55 void *tokens; 56 void *replaced_shader; 57 void *replaced_tokens; 58 59 boolean disabled; 60}; 61 62 63struct rbug_sampler_view 64{ 65 struct pipe_sampler_view base; 66 67 struct pipe_sampler_view *sampler_view; 68}; 69 70 71struct rbug_surface 72{ 73 struct pipe_surface base; 74 75 struct pipe_surface *surface; 76}; 77 78 79struct rbug_transfer 80{ 81 struct pipe_transfer base; 82 83 struct pipe_context *pipe; 84 struct pipe_transfer *transfer; 85}; 86 87 88static INLINE struct rbug_resource * 89rbug_resource(struct pipe_resource *_resource) 90{ 91 if (!_resource) 92 return NULL; 93 (void)rbug_screen(_resource->screen); 94 return (struct rbug_resource *)_resource; 95} 96 97static INLINE struct rbug_sampler_view * 98rbug_sampler_view(struct pipe_sampler_view *_sampler_view) 99{ 100 if (!_sampler_view) 101 return NULL; 102 (void)rbug_resource(_sampler_view->texture); 103 return (struct rbug_sampler_view *)_sampler_view; 104} 105 106static INLINE struct rbug_surface * 107rbug_surface(struct pipe_surface *_surface) 108{ 109 if (!_surface) 110 return NULL; 111 (void)rbug_resource(_surface->texture); 112 return (struct rbug_surface *)_surface; 113} 114 115static INLINE struct rbug_transfer * 116rbug_transfer(struct pipe_transfer *_transfer) 117{ 118 if (!_transfer) 119 return NULL; 120 (void)rbug_resource(_transfer->resource); 121 return (struct rbug_transfer *)_transfer; 122} 123 124static INLINE struct rbug_shader * 125rbug_shader(void *_state) 126{ 127 if (!_state) 128 return NULL; 129 return (struct rbug_shader *)_state; 130} 131 132static INLINE struct pipe_resource * 133rbug_resource_unwrap(struct pipe_resource *_resource) 134{ 135 if (!_resource) 136 return NULL; 137 return rbug_resource(_resource)->resource; 138} 139 140static INLINE struct pipe_sampler_view * 141rbug_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view) 142{ 143 if (!_sampler_view) 144 return NULL; 145 return rbug_sampler_view(_sampler_view)->sampler_view; 146} 147 148static INLINE struct pipe_surface * 149rbug_surface_unwrap(struct pipe_surface *_surface) 150{ 151 if (!_surface) 152 return NULL; 153 return rbug_surface(_surface)->surface; 154} 155 156static INLINE struct pipe_transfer * 157rbug_transfer_unwrap(struct pipe_transfer *_transfer) 158{ 159 if (!_transfer) 160 return NULL; 161 return rbug_transfer(_transfer)->transfer; 162} 163 164static INLINE void * 165rbug_shader_unwrap(void *_state) 166{ 167 struct rbug_shader *shader; 168 if (!_state) 169 return NULL; 170 171 shader = rbug_shader(_state); 172 return shader->replaced_shader ? shader->replaced_shader : shader->shader; 173} 174 175 176struct pipe_resource * 177rbug_resource_create(struct rbug_screen *rb_screen, 178 struct pipe_resource *resource); 179 180void 181rbug_resource_destroy(struct rbug_resource *rb_resource); 182 183struct pipe_surface * 184rbug_surface_create(struct rbug_resource *rb_resource, 185 struct pipe_surface *surface); 186 187void 188rbug_surface_destroy(struct rbug_surface *rb_surface); 189 190struct pipe_sampler_view * 191rbug_sampler_view_create(struct rbug_context *rb_context, 192 struct rbug_resource *rb_resource, 193 struct pipe_sampler_view *view); 194 195void 196rbug_sampler_view_destroy(struct rbug_context *rb_context, 197 struct rbug_sampler_view *rb_sampler_view); 198 199struct pipe_transfer * 200rbug_transfer_create(struct rbug_context *rb_context, 201 struct rbug_resource *rb_resource, 202 struct pipe_transfer *transfer); 203 204void 205rbug_transfer_destroy(struct rbug_context *rb_context, 206 struct rbug_transfer *rb_transfer); 207 208 209#endif /* RBUG_OBJECTS_H */ 210