r600_pipe.h revision 1235becaa1cf7e29f580900592563c3329d326de
1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen/* 23345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * Copyright 2010 Jerome Glisse <glisse@freedesktop.org> 33345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * 43345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * Permission is hereby granted, free of charge, to any person obtaining a 53345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * copy of this software and associated documentation files (the "Software"), 6ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen * to deal in the Software without restriction, including without limitation 73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * on the rights to use, copy, modify, merge, publish, distribute, sub 83345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * license, and/or sell copies of the Software, and to permit persons to whom 93345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * the Software is furnished to do so, subject to the following conditions: 103345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * 113345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * The above copyright notice and this permission notice (including the next 123345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * paragraph) shall be included in all copies or substantial portions of the 133345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * Software. 143345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * 153345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 163345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 173345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 183345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 193345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 203345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 213345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * USE OR OTHER DEALINGS IN THE SOFTWARE. 223345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * 233345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * Authors: 243345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick * Jerome Glisse 253345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick */ 263345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#ifndef R600_PIPE_H 273345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#define R600_PIPE_H 283345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 293345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include <pipe/p_state.h> 303345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include <pipe/p_screen.h> 313345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include <pipe/p_context.h> 323345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include <util/u_math.h> 333345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "r600.h" 343345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "r600_shader.h" 353345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "r600_resource.h" 363345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 373345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickenum r600_pipe_state_id { 383345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_BLEND = 0, 393345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_BLEND_COLOR, 403345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_CONFIG, 413345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_CLIP, 423345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_SCISSOR, 433345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_VIEWPORT, 443345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_RASTERIZER, 453345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_VGT, 463345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_FRAMEBUFFER, 473345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_DSA, 483345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_STENCIL_REF, 493345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_PS_SHADER, 503345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_VS_SHADER, 513345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_CONSTANT, 523345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_SAMPLER, 533345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_STATE_RESOURCE, 543345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick R600_PIPE_NSTATES 553345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick}; 563345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 573345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickstruct r600_screen { 583345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_screen screen; 593345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct radeon *radeon; 603345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick}; 613345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 623345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickstruct r600_pipe_sampler_view { 633345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_sampler_view base; 643345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state state; 653345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick}; 663345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 673345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickstruct r600_pipe_rasterizer { 683345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state rstate; 693345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick bool flatshade; 703345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned sprite_coord_enable; 713345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick float offset_units; 723345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick float offset_scale; 733345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick}; 743345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 753345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickstruct r600_pipe_blend { 763345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state rstate; 773345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned cb_target_mask; 783345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick}; 793345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 803345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickstruct r600_vertex_element 813345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick{ 823345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned count; 833345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned refcount; 843345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_vertex_element elements[32]; 853345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick}; 863345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 873345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickstruct r600_pipe_shader { 883345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_shader shader; 893345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state rstate; 903345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct radeon_ws_bo *bo; 913345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_vertex_element vertex_elements; 923345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick}; 933345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 943345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 953345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickstruct r600_pipe_context { 963345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_context context; 973345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct blitter_context *blitter; 983345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_framebuffer_state *pframebuffer; 993345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned family; 1003345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick void *custom_dsa_flush; 1013345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct list_head query_list; /* fake member for depth remove once merged */ 1023345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_screen *screen; 1033345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct radeon *radeon; 1043345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state *states[R600_PIPE_NSTATES]; 1053345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_context ctx; 1063345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_vertex_element *vertex_elements; 1073345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_framebuffer_state framebuffer; 1083345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_index_buffer index_buffer; 1093345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; 1103345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned nvertex_buffer; 1113345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned cb_target_mask; 1123345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick /* for saving when using blitter */ 1133345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_stencil_ref stencil_ref; 1143345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_viewport_state viewport; 1153345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_clip_state clip; 1163345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned vs_nconst; 1173345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned ps_nconst; 1183345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state vs_const[256]; 1193345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state ps_const[256]; 1203345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state vs_resource[160]; 1213345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state ps_resource[160]; 1223345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state config; 1233345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_shader *ps_shader; 1243345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_shader *vs_shader; 1253345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state vs_const_buffer; 1263345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_state ps_const_buffer; 1273345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct r600_pipe_rasterizer *rasterizer; 1283345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick /* shader information */ 1293345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned sprite_coord_enable; 1303345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick bool flatshade; 1313345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct u_upload_mgr *upload_vb; 1323345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct u_upload_mgr *upload_ib; 1333345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned any_user_vbs; 1343345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick}; 1353345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 1363345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickstruct r600_drawl { 1373345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_context *ctx; 1383345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned mode; 1393345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned min_index; 1403345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned max_index; 1413345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned index_bias; 1423345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned start; 1433345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned count; 1443345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned index_size; 1453345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick unsigned index_buffer_offset; 1463345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct pipe_resource *index_buffer; 1473345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick}; 148 149uint32_t r600_translate_texformat(enum pipe_format format, 150 const unsigned char *swizzle_view, 151 uint32_t *word4_p, uint32_t *yuv_format_p); 152 153/* r600_state2.c */ 154int r600_pipe_shader_update2(struct pipe_context *ctx, struct r600_pipe_shader *shader); 155int r600_pipe_shader_create2(struct pipe_context *ctx, struct r600_pipe_shader *shader, const struct tgsi_token *tokens); 156void r600_translate_index_buffer2(struct r600_pipe_context *r600, 157 struct pipe_resource **index_buffer, 158 unsigned *index_size, 159 unsigned *start, unsigned count); 160int r600_find_vs_semantic_index2(struct r600_shader *vs, 161 struct r600_shader *ps, int id); 162 163/* evergreen_state.c */ 164void evergreen_init_state_functions2(struct r600_pipe_context *rctx); 165void evergreen_init_config2(struct r600_pipe_context *rctx); 166void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info); 167void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader); 168void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader); 169 170static INLINE u32 S_FIXED(float value, u32 frac_bits) 171{ 172 return value * (1 << frac_bits); 173} 174#define ALIGN_DIVUP(x, y) (((x) + (y) - 1) / (y)) 175 176/* r600_blit.c */ 177void r600_init_blit_functions2(struct r600_pipe_context *rctx); 178int r600_blit_uncompress_depth2(struct pipe_context *ctx, struct r600_resource_texture *texture); 179 180/* r600_buffer.c */ 181struct pipe_resource *r600_buffer_create(struct pipe_screen *screen, 182 const struct pipe_resource *templ); 183struct pipe_resource *r600_user_buffer_create(struct pipe_screen *screen, 184 void *ptr, unsigned bytes, 185 unsigned bind); 186unsigned r600_buffer_is_referenced_by_cs(struct pipe_context *context, 187 struct pipe_resource *buf, 188 unsigned face, unsigned level); 189struct pipe_resource *r600_buffer_from_handle(struct pipe_screen *screen, 190 struct winsys_handle *whandle); 191int r600_upload_index_buffer(struct r600_pipe_context *rctx, struct r600_drawl *draw); 192int r600_upload_user_buffers(struct r600_pipe_context *rctx); 193 194/* r600_query.c */ 195void r600_init_query_functions2(struct r600_pipe_context *rctx); 196 197/* r600_resource.c */ 198void r600_init_context_resource_functions2(struct r600_pipe_context *r600); 199 200/* r600_state.c */ 201void r600_init_state_functions2(struct r600_pipe_context *rctx); 202void r600_draw_vbo2(struct pipe_context *ctx, const struct pipe_draw_info *info); 203void r600_init_config2(struct r600_pipe_context *rctx); 204 205/* r600_helper.h */ 206int r600_conv_pipe_prim(unsigned pprim, unsigned *prim); 207 208/* r600_texture.c */ 209void r600_init_screen_texture_functions(struct pipe_screen *screen); 210 211#endif 212