1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2010 VMware, Inc. 4bf215546Sopenharmony_ci * All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 12bf215546Sopenharmony_ci * the following conditions: 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 16bf215546Sopenharmony_ci * of the Software. 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25bf215546Sopenharmony_ci * 26bf215546Sopenharmony_ci **************************************************************************/ 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#ifndef RBUG_OBJECTS_H 29bf215546Sopenharmony_ci#define RBUG_OBJECTS_H 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include "pipe/p_compiler.h" 33bf215546Sopenharmony_ci#include "pipe/p_state.h" 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#include "rbug_screen.h" 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_cistruct rbug_context; 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_cistruct rbug_resource 41bf215546Sopenharmony_ci{ 42bf215546Sopenharmony_ci struct pipe_resource base; 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_ci struct pipe_resource *resource; 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci struct list_head list; 47bf215546Sopenharmony_ci}; 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_cienum rbug_shader_type 51bf215546Sopenharmony_ci{ 52bf215546Sopenharmony_ci RBUG_SHADER_GEOM, 53bf215546Sopenharmony_ci RBUG_SHADER_VERTEX, 54bf215546Sopenharmony_ci RBUG_SHADER_FRAGMENT, 55bf215546Sopenharmony_ci}; 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_cistruct rbug_shader 58bf215546Sopenharmony_ci{ 59bf215546Sopenharmony_ci struct list_head list; 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_ci void *shader; 62bf215546Sopenharmony_ci void *tokens; 63bf215546Sopenharmony_ci void *replaced_shader; 64bf215546Sopenharmony_ci void *replaced_tokens; 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_ci enum rbug_shader_type type; 67bf215546Sopenharmony_ci bool disabled; 68bf215546Sopenharmony_ci}; 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_cistruct rbug_sampler_view 72bf215546Sopenharmony_ci{ 73bf215546Sopenharmony_ci struct pipe_sampler_view base; 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_ci struct pipe_sampler_view *sampler_view; 76bf215546Sopenharmony_ci}; 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_cistruct rbug_surface 80bf215546Sopenharmony_ci{ 81bf215546Sopenharmony_ci struct pipe_surface base; 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci struct pipe_surface *surface; 84bf215546Sopenharmony_ci}; 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci 87bf215546Sopenharmony_cistruct rbug_transfer 88bf215546Sopenharmony_ci{ 89bf215546Sopenharmony_ci struct pipe_transfer base; 90bf215546Sopenharmony_ci 91bf215546Sopenharmony_ci struct pipe_context *pipe; 92bf215546Sopenharmony_ci struct pipe_transfer *transfer; 93bf215546Sopenharmony_ci}; 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_cistatic inline struct rbug_resource * 97bf215546Sopenharmony_cirbug_resource(struct pipe_resource *_resource) 98bf215546Sopenharmony_ci{ 99bf215546Sopenharmony_ci if (!_resource) 100bf215546Sopenharmony_ci return NULL; 101bf215546Sopenharmony_ci (void)rbug_screen(_resource->screen); 102bf215546Sopenharmony_ci return (struct rbug_resource *)_resource; 103bf215546Sopenharmony_ci} 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_cistatic inline struct rbug_sampler_view * 106bf215546Sopenharmony_cirbug_sampler_view(struct pipe_sampler_view *_sampler_view) 107bf215546Sopenharmony_ci{ 108bf215546Sopenharmony_ci if (!_sampler_view) 109bf215546Sopenharmony_ci return NULL; 110bf215546Sopenharmony_ci (void)rbug_resource(_sampler_view->texture); 111bf215546Sopenharmony_ci return (struct rbug_sampler_view *)_sampler_view; 112bf215546Sopenharmony_ci} 113bf215546Sopenharmony_ci 114bf215546Sopenharmony_cistatic inline struct rbug_surface * 115bf215546Sopenharmony_cirbug_surface(struct pipe_surface *_surface) 116bf215546Sopenharmony_ci{ 117bf215546Sopenharmony_ci if (!_surface) 118bf215546Sopenharmony_ci return NULL; 119bf215546Sopenharmony_ci (void)rbug_resource(_surface->texture); 120bf215546Sopenharmony_ci return (struct rbug_surface *)_surface; 121bf215546Sopenharmony_ci} 122bf215546Sopenharmony_ci 123bf215546Sopenharmony_cistatic inline struct rbug_transfer * 124bf215546Sopenharmony_cirbug_transfer(struct pipe_transfer *_transfer) 125bf215546Sopenharmony_ci{ 126bf215546Sopenharmony_ci if (!_transfer) 127bf215546Sopenharmony_ci return NULL; 128bf215546Sopenharmony_ci (void)rbug_resource(_transfer->resource); 129bf215546Sopenharmony_ci return (struct rbug_transfer *)_transfer; 130bf215546Sopenharmony_ci} 131bf215546Sopenharmony_ci 132bf215546Sopenharmony_cistatic inline struct rbug_shader * 133bf215546Sopenharmony_cirbug_shader(void *_state) 134bf215546Sopenharmony_ci{ 135bf215546Sopenharmony_ci if (!_state) 136bf215546Sopenharmony_ci return NULL; 137bf215546Sopenharmony_ci return (struct rbug_shader *)_state; 138bf215546Sopenharmony_ci} 139bf215546Sopenharmony_ci 140bf215546Sopenharmony_cistatic inline struct pipe_resource * 141bf215546Sopenharmony_cirbug_resource_unwrap(struct pipe_resource *_resource) 142bf215546Sopenharmony_ci{ 143bf215546Sopenharmony_ci if (!_resource) 144bf215546Sopenharmony_ci return NULL; 145bf215546Sopenharmony_ci return rbug_resource(_resource)->resource; 146bf215546Sopenharmony_ci} 147bf215546Sopenharmony_ci 148bf215546Sopenharmony_cistatic inline struct pipe_sampler_view * 149bf215546Sopenharmony_cirbug_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view) 150bf215546Sopenharmony_ci{ 151bf215546Sopenharmony_ci if (!_sampler_view) 152bf215546Sopenharmony_ci return NULL; 153bf215546Sopenharmony_ci return rbug_sampler_view(_sampler_view)->sampler_view; 154bf215546Sopenharmony_ci} 155bf215546Sopenharmony_ci 156bf215546Sopenharmony_cistatic inline struct pipe_surface * 157bf215546Sopenharmony_cirbug_surface_unwrap(struct pipe_surface *_surface) 158bf215546Sopenharmony_ci{ 159bf215546Sopenharmony_ci if (!_surface) 160bf215546Sopenharmony_ci return NULL; 161bf215546Sopenharmony_ci return rbug_surface(_surface)->surface; 162bf215546Sopenharmony_ci} 163bf215546Sopenharmony_ci 164bf215546Sopenharmony_cistatic inline struct pipe_transfer * 165bf215546Sopenharmony_cirbug_transfer_unwrap(struct pipe_transfer *_transfer) 166bf215546Sopenharmony_ci{ 167bf215546Sopenharmony_ci if (!_transfer) 168bf215546Sopenharmony_ci return NULL; 169bf215546Sopenharmony_ci return rbug_transfer(_transfer)->transfer; 170bf215546Sopenharmony_ci} 171bf215546Sopenharmony_ci 172bf215546Sopenharmony_cistatic inline void * 173bf215546Sopenharmony_cirbug_shader_unwrap(void *_state) 174bf215546Sopenharmony_ci{ 175bf215546Sopenharmony_ci struct rbug_shader *shader; 176bf215546Sopenharmony_ci if (!_state) 177bf215546Sopenharmony_ci return NULL; 178bf215546Sopenharmony_ci 179bf215546Sopenharmony_ci shader = rbug_shader(_state); 180bf215546Sopenharmony_ci return shader->replaced_shader ? shader->replaced_shader : shader->shader; 181bf215546Sopenharmony_ci} 182bf215546Sopenharmony_ci 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_cistruct pipe_resource * 185bf215546Sopenharmony_cirbug_resource_create(struct rbug_screen *rb_screen, 186bf215546Sopenharmony_ci struct pipe_resource *resource); 187bf215546Sopenharmony_ci 188bf215546Sopenharmony_civoid 189bf215546Sopenharmony_cirbug_resource_destroy(struct rbug_resource *rb_resource); 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_cistruct pipe_surface * 192bf215546Sopenharmony_cirbug_surface_create(struct rbug_context *rb_context, 193bf215546Sopenharmony_ci struct rbug_resource *rb_resource, 194bf215546Sopenharmony_ci struct pipe_surface *surface); 195bf215546Sopenharmony_ci 196bf215546Sopenharmony_civoid 197bf215546Sopenharmony_cirbug_surface_destroy(struct rbug_context *rb_context, 198bf215546Sopenharmony_ci struct rbug_surface *rb_surface); 199bf215546Sopenharmony_ci 200bf215546Sopenharmony_cistruct pipe_sampler_view * 201bf215546Sopenharmony_cirbug_sampler_view_create(struct rbug_context *rb_context, 202bf215546Sopenharmony_ci struct rbug_resource *rb_resource, 203bf215546Sopenharmony_ci struct pipe_sampler_view *view); 204bf215546Sopenharmony_ci 205bf215546Sopenharmony_civoid 206bf215546Sopenharmony_cirbug_sampler_view_destroy(struct rbug_context *rb_context, 207bf215546Sopenharmony_ci struct rbug_sampler_view *rb_sampler_view); 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_cistruct pipe_transfer * 210bf215546Sopenharmony_cirbug_transfer_create(struct rbug_context *rb_context, 211bf215546Sopenharmony_ci struct rbug_resource *rb_resource, 212bf215546Sopenharmony_ci struct pipe_transfer *transfer); 213bf215546Sopenharmony_ci 214bf215546Sopenharmony_civoid 215bf215546Sopenharmony_cirbug_transfer_destroy(struct rbug_context *rb_context, 216bf215546Sopenharmony_ci struct rbug_transfer *rb_transfer); 217bf215546Sopenharmony_ci 218bf215546Sopenharmony_civoid * 219bf215546Sopenharmony_cirbug_shader_create(struct rbug_context *rb_context, 220bf215546Sopenharmony_ci const struct pipe_shader_state *state, 221bf215546Sopenharmony_ci void *result, enum rbug_shader_type type); 222bf215546Sopenharmony_ci 223bf215546Sopenharmony_civoid 224bf215546Sopenharmony_cirbug_shader_destroy(struct rbug_context *rb_context, 225bf215546Sopenharmony_ci struct rbug_shader *rb_shader); 226bf215546Sopenharmony_ci 227bf215546Sopenharmony_ci 228bf215546Sopenharmony_ci#endif /* RBUG_OBJECTS_H */ 229