r600_pipe.h revision 9c284b5cae916a083d17d1039d2f2da128b47882
1/* 2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org> 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * on the rights to use, copy, modify, merge, publish, distribute, sub 8 * license, and/or sell copies of the Software, and to permit persons to whom 9 * the Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21 * USE OR OTHER DEALINGS IN THE SOFTWARE. 22 * 23 * Authors: 24 * Jerome Glisse 25 */ 26#ifndef R600_PIPE_H 27#define R600_PIPE_H 28 29#include <pipe/p_state.h> 30#include <pipe/p_screen.h> 31#include <pipe/p_context.h> 32#include <util/u_math.h> 33#include "r600.h" 34#include "r600_shader.h" 35#include "r600_resource.h" 36 37enum r600_pipe_state_id { 38 R600_PIPE_STATE_BLEND = 0, 39 R600_PIPE_STATE_BLEND_COLOR, 40 R600_PIPE_STATE_CONFIG, 41 R600_PIPE_STATE_CLIP, 42 R600_PIPE_STATE_SCISSOR, 43 R600_PIPE_STATE_VIEWPORT, 44 R600_PIPE_STATE_RASTERIZER, 45 R600_PIPE_STATE_VGT, 46 R600_PIPE_STATE_FRAMEBUFFER, 47 R600_PIPE_STATE_DSA, 48 R600_PIPE_STATE_STENCIL_REF, 49 R600_PIPE_STATE_PS_SHADER, 50 R600_PIPE_STATE_VS_SHADER, 51 R600_PIPE_STATE_CONSTANT, 52 R600_PIPE_STATE_SAMPLER, 53 R600_PIPE_STATE_RESOURCE, 54 R600_PIPE_NSTATES 55}; 56 57struct r600_screen { 58 struct pipe_screen screen; 59 struct radeon *radeon; 60}; 61 62struct r600_pipe_sampler_view { 63 struct pipe_sampler_view base; 64 struct r600_pipe_state state; 65}; 66 67struct r600_pipe_rasterizer { 68 struct r600_pipe_state rstate; 69 bool flatshade; 70 unsigned sprite_coord_enable; 71 float offset_units; 72 float offset_scale; 73}; 74 75struct r600_pipe_blend { 76 struct r600_pipe_state rstate; 77 unsigned cb_target_mask; 78}; 79 80struct r600_vertex_element 81{ 82 unsigned count; 83 unsigned refcount; 84 struct pipe_vertex_element elements[32]; 85}; 86 87struct r600_pipe_shader { 88 struct r600_shader shader; 89 struct r600_pipe_state rstate; 90 struct radeon_ws_bo *bo; 91 struct r600_vertex_element vertex_elements; 92}; 93 94 95struct r600_pipe_context { 96 struct pipe_context context; 97 struct blitter_context *blitter; 98 struct pipe_framebuffer_state *pframebuffer; 99 unsigned family; 100 void *custom_dsa_flush; 101 struct list_head query_list; /* fake member for depth remove once merged */ 102 struct r600_screen *screen; 103 struct radeon *radeon; 104 struct r600_pipe_state *states[R600_PIPE_NSTATES]; 105 struct r600_context ctx; 106 struct r600_vertex_element *vertex_elements; 107 struct pipe_framebuffer_state framebuffer; 108 struct pipe_index_buffer index_buffer; 109 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; 110 unsigned nvertex_buffer; 111 unsigned cb_target_mask; 112 /* for saving when using blitter */ 113 struct pipe_stencil_ref stencil_ref; 114 struct pipe_viewport_state viewport; 115 struct pipe_clip_state clip; 116 unsigned vs_nconst; 117 unsigned ps_nconst; 118 struct r600_pipe_state vs_const[256]; 119 struct r600_pipe_state ps_const[256]; 120 struct r600_pipe_state vs_resource[160]; 121 struct r600_pipe_state ps_resource[160]; 122 struct r600_pipe_state config; 123 struct r600_pipe_shader *ps_shader; 124 struct r600_pipe_shader *vs_shader; 125 struct r600_pipe_state vs_const_buffer; 126 struct r600_pipe_state ps_const_buffer; 127 struct r600_pipe_rasterizer *rasterizer; 128 /* shader information */ 129 unsigned sprite_coord_enable; 130 bool flatshade; 131 struct u_upload_mgr *upload_vb; 132 struct u_upload_mgr *upload_ib; 133 unsigned any_user_vbs; 134}; 135 136struct r600_drawl { 137 struct pipe_context *ctx; 138 unsigned mode; 139 unsigned min_index; 140 unsigned max_index; 141 unsigned index_bias; 142 unsigned start; 143 unsigned count; 144 unsigned index_size; 145 unsigned index_buffer_offset; 146 struct pipe_resource *index_buffer; 147}; 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); 156int r600_upload_index_buffer2(struct r600_pipe_context *rctx, struct r600_drawl *draw); 157int r600_upload_user_buffers2(struct r600_pipe_context *rctx); 158void r600_translate_index_buffer2(struct r600_pipe_context *r600, 159 struct pipe_resource **index_buffer, 160 unsigned *index_size, 161 unsigned *start, unsigned count); 162int r600_find_vs_semantic_index2(struct r600_shader *vs, 163 struct r600_shader *ps, int id); 164 165/* evergreen_state.c */ 166void evergreen_init_state_functions2(struct r600_pipe_context *rctx); 167void evergreen_init_config2(struct r600_pipe_context *rctx); 168void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info); 169void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader); 170void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader); 171 172static INLINE u32 S_FIXED(float value, u32 frac_bits) 173{ 174 return value * (1 << frac_bits); 175} 176#define ALIGN_DIVUP(x, y) (((x) + (y) - 1) / (y)) 177 178/* r600_buffer.c */ 179struct pipe_resource *r600_buffer_create(struct pipe_screen *screen, 180 const struct pipe_resource *templ); 181struct pipe_resource *r600_user_buffer_create(struct pipe_screen *screen, 182 void *ptr, unsigned bytes, 183 unsigned bind); 184unsigned r600_buffer_is_referenced_by_cs(struct pipe_context *context, 185 struct pipe_resource *buf, 186 unsigned face, unsigned level); 187struct pipe_resource *r600_buffer_from_handle(struct pipe_screen *screen, 188 struct winsys_handle *whandle); 189 190#endif 191