diff options
author | Eric Anholt <[email protected]> | 2007-05-18 14:14:12 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2007-05-18 14:14:12 -0700 |
commit | 1bdee1853627e08894bd267b8f0ec176a1b5978f (patch) | |
tree | 78c3b8bb81e866de4544d2621abb633b008095ab /src/mesa/drivers/dri/r300/r300_context.h | |
parent | c085e350df593ab2af60f53b86265db4c3eab38a (diff) | |
parent | 4fca6bfa5d211a093c54b0bbeadaa38081e8c141 (diff) |
Merge branch 'master' into i915-unification
Conflicts:
src/mesa/drivers/dri/common/dri_bufmgr.c
src/mesa/drivers/dri/common/dri_drmpool.c
src/mesa/drivers/dri/i915tex/intel_batchpool.c
src/mesa/drivers/dri/i915tex/intel_buffer_objects.c
src/mesa/drivers/dri/i915tex/intel_regions.c
src/mesa/drivers/dri/i915tex/intel_screen.c
src/mesa/drivers/dri/i915tex/intel_screen.h
Diffstat (limited to 'src/mesa/drivers/dri/r300/r300_context.h')
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.h | 291 |
1 files changed, 115 insertions, 176 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index c8b81d98497..dbcd5d04d6d 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -27,10 +27,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ -/* - * Authors: - * Keith Whitwell <[email protected]> - * Nicolai Haehnle <[email protected]> +/** + * \file + * + * \author Keith Whitwell <[email protected]> + * \author Nicolai Haehnle <[email protected]> */ #ifndef __R300_CONTEXT_H__ @@ -45,19 +46,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "macros.h" #include "mtypes.h" #include "colormac.h" -#include "radeon_context.h" #define USER_BUFFERS -/* KW: Disable this code. Driver should hook into vbo module - * directly, see i965 driver for example. - */ -/* #define RADEON_VTXFMT_A */ -#define HW_VBOS - -/* We don't handle 16 bits elts swapping yet */ -#ifdef MESA_BIG_ENDIAN -#define FORCE_32BITS_ELTS -#endif //#define OPTIMIZE_ELTS @@ -68,13 +58,10 @@ typedef struct r300_context *r300ContextPtr; #include "radeon_lock.h" #include "mm.h" -/* Checkpoint.. for convenience */ -#define CPT { fprintf(stderr, "%s:%s line %d\n", __FILE__, __FUNCTION__, __LINE__); } /* From http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html . I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble with other compilers ... GLUE! */ -#if 1 #define WARN_ONCE(a, ...) { \ static int warn##__LINE__=1; \ if(warn##__LINE__){ \ @@ -86,32 +73,61 @@ typedef struct r300_context *r300ContextPtr; warn##__LINE__=0;\ } \ } -#else -#define WARN_ONCE(a, ...) {} -#endif - /* We should probably change types within vertex_shader - and pixel_shader structure later on */ -#define CARD32 GLuint -#include "vertex_shader.h" +#include "r300_vertprog.h" #include "r300_fragprog.h" -#undef CARD32 +/** + * This function takes a float and packs it into a uint32_t + */ static __inline__ uint32_t r300PackFloat32(float fl) { - union { float fl; uint32_t u; } u; + union { + float fl; + uint32_t u; + } u; u.fl = fl; return u.u; } +/* This is probably wrong for some values, I need to test this + * some more. Range checking would be a good idea also.. + * + * But it works for most things. I'll fix it later if someone + * else with a better clue doesn't + */ +static __inline__ uint32_t r300PackFloat24(float f) +{ + float mantissa; + int exponent; + uint32_t float24 = 0; + + if (f == 0.0) + return 0; + + mantissa = frexpf(f, &exponent); + + /* Handle -ve */ + if (mantissa < 0) { + float24 |= (1 << 23); + mantissa = mantissa * -1.0; + } + /* Handle exponent, bias of 63 */ + exponent += 62; + float24 |= (exponent << 16); + /* Kill 7 LSB of mantissa */ + float24 |= (r300PackFloat32(mantissa) & 0x7FFFFF) >> 7; + + return float24; +} /************ DMA BUFFERS **************/ /* Need refcounting on dma buffers: */ struct r300_dma_buffer { - int refcount; /* the number of retained regions in buf */ + int refcount; /**< the number of retained regions in buf */ drmBufPtr buf; int id; }; @@ -130,10 +146,10 @@ struct r300_dma_region { char *address; /* == buf->address */ int start, end, ptr; /* offsets from start of buf */ - int aos_offset; /* address in GART memory */ - int aos_stride; /* distance between elements, in dwords */ - int aos_size; /* number of components (1-4) */ - int aos_reg; /* VAP register assignment */ + int aos_offset; /* address in GART memory */ + int aos_stride; /* distance between elements, in dwords */ + int aos_size; /* number of components (1-4) */ + int aos_reg; /* VAP register assignment */ }; struct r300_dma { @@ -175,16 +191,15 @@ struct r300_tex_obj { drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS]; /* Six, for the cube faces */ - - GLuint pitch; /* this isn't sent to hardware just used in calculations */ + GLuint pitch; /* this isn't sent to hardware just used in calculations */ /* hardware register values */ /* Note that R200 has 8 registers per texture and R300 only 7 */ GLuint filter; GLuint filter_1; GLuint pitch_reg; - GLuint size; /* npot only */ + GLuint size; /* npot only */ GLuint format; - GLuint offset; /* Image location in the card's address space. + GLuint offset; /* Image location in the card's address space. All cube faces follow. */ GLuint unknown4; GLuint unknown5; @@ -198,10 +213,9 @@ struct r300_tex_obj { GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */ GLuint format_x; - GLboolean border_fallback; - GLuint tile_bits; /* hw texture tile bits used on this texture */ + GLuint tile_bits; /* hw texture tile bits used on this texture */ }; struct r300_texture_env_state { @@ -210,7 +224,6 @@ struct r300_texture_env_state { GLenum envMode; }; - /* The blit width for texture uploads */ #define R300_BLIT_WIDTH_BYTES 1024 @@ -218,7 +231,7 @@ struct r300_texture_env_state { struct r300_texture_state { struct r300_texture_env_state unit[R300_MAX_TEXTURE_UNITS]; - int tc_count; /* number of incoming texture coordinates from VAP */ + int tc_count; /* number of incoming texture coordinates from VAP */ }; /** @@ -230,16 +243,15 @@ struct r300_texture_state { */ struct r300_state_atom { struct r300_state_atom *next, *prev; - const char* name; /* for debug */ + const char *name; /* for debug */ int cmd_size; /* maximum size in dwords */ GLuint idx; /* index in an array (e.g. textures) */ - uint32_t* cmd; + uint32_t *cmd; GLboolean dirty; - int (*check)(r300ContextPtr, struct r300_state_atom* atom); + int (*check) (r300ContextPtr, struct r300_state_atom * atom); }; - #define R300_VPT_CMD_0 0 #define R300_VPT_XSCALE 1 #define R300_VPT_XOFFSET 2 @@ -249,7 +261,7 @@ struct r300_state_atom { #define R300_VPT_ZOFFSET 6 #define R300_VPT_CMDSIZE 7 -#define R300_VIR_CMD_0 0 /* vir is variable size (at least 1) */ +#define R300_VIR_CMD_0 0 /* vir is variable size (at least 1) */ #define R300_VIR_CNTL_0 1 #define R300_VIR_CNTL_1 2 #define R300_VIR_CNTL_2 3 @@ -270,7 +282,6 @@ struct r300_state_atom { #define R300_VOF_CNTL_1 2 #define R300_VOF_CMDSIZE 3 - #define R300_PVS_CMD_0 0 #define R300_PVS_CNTL_1 1 #define R300_PVS_CNTL_2 2 @@ -320,7 +331,7 @@ struct r300_state_atom { #define R300_RI_INTERP_7 8 #define R300_RI_CMDSIZE 9 -#define R300_RR_CMD_0 0 /* rr is variable size (at least 1) */ +#define R300_RR_CMD_0 0 /* rr is variable size (at least 1) */ #define R300_RR_ROUTE_0 1 #define R300_RR_ROUTE_1 2 #define R300_RR_ROUTE_2 3 @@ -402,11 +413,11 @@ struct r300_state_atom { #define R300_VPI_CMD_0 0 #define R300_VPI_INSTR_0 1 -#define R300_VPI_CMDSIZE 1025 /* 256 16 byte instructions */ +#define R300_VPI_CMDSIZE 1025 /* 256 16 byte instructions */ #define R300_VPP_CMD_0 0 #define R300_VPP_PARAM_0 1 -#define R300_VPP_CMDSIZE 1025 /* 256 4-component parameters */ +#define R300_VPP_CMDSIZE 1025 /* 256 4-component parameters */ #define R300_VPS_CMD_0 0 #define R300_VPS_ZERO_0 1 @@ -428,54 +439,54 @@ struct r300_state_atom { struct r300_hw_state { struct r300_state_atom atomlist; - GLboolean is_dirty; - GLboolean all_dirty; - int max_state_size; /* in dwords */ + GLboolean is_dirty; + GLboolean all_dirty; + int max_state_size; /* in dwords */ struct r300_state_atom vpt; /* viewport (1D98) */ struct r300_state_atom vap_cntl; - struct r300_state_atom vof; /* VAP output format register 0x2090 */ + struct r300_state_atom vof; /* VAP output format register 0x2090 */ struct r300_state_atom vte; /* (20B0) */ struct r300_state_atom unk2134; /* (2134) */ struct r300_state_atom vap_cntl_status; struct r300_state_atom vir[2]; /* vap input route (2150/21E0) */ struct r300_state_atom vic; /* vap input control (2180) */ - struct r300_state_atom unk21DC; /* (21DC) */ - struct r300_state_atom unk221C; /* (221C) */ - struct r300_state_atom unk2220; /* (2220) */ - struct r300_state_atom unk2288; /* (2288) */ + struct r300_state_atom unk21DC; /* (21DC) */ + struct r300_state_atom unk221C; /* (221C) */ + struct r300_state_atom unk2220; /* (2220) */ + struct r300_state_atom unk2288; /* (2288) */ struct r300_state_atom pvs; /* pvs_cntl (22D0) */ - struct r300_state_atom gb_enable; /* (4008) */ - struct r300_state_atom gb_misc; /* Multisampling position shifts ? (4010) */ - struct r300_state_atom unk4200; /* (4200) */ - struct r300_state_atom unk4214; /* (4214) */ + struct r300_state_atom gb_enable; /* (4008) */ + struct r300_state_atom gb_misc; /* Multisampling position shifts ? (4010) */ + struct r300_state_atom unk4200; /* (4200) */ + struct r300_state_atom unk4214; /* (4214) */ struct r300_state_atom ps; /* pointsize (421C) */ - struct r300_state_atom unk4230; /* (4230) */ + struct r300_state_atom unk4230; /* (4230) */ struct r300_state_atom lcntl; /* line control */ - struct r300_state_atom unk4260; /* (4260) */ + struct r300_state_atom unk4260; /* (4260) */ struct r300_state_atom shade; struct r300_state_atom polygon_mode; struct r300_state_atom fogp; /* fog parameters (4294) */ - struct r300_state_atom unk429C; /* (429C) */ + struct r300_state_atom unk429C; /* (429C) */ struct r300_state_atom zbias_cntl; struct r300_state_atom zbs; /* zbias (42A4) */ struct r300_state_atom occlusion_cntl; struct r300_state_atom cul; /* cull cntl (42B8) */ - struct r300_state_atom unk42C0; /* (42C0) */ + struct r300_state_atom unk42C0; /* (42C0) */ struct r300_state_atom rc; /* rs control (4300) */ struct r300_state_atom ri; /* rs interpolators (4310) */ struct r300_state_atom rr; /* rs route (4330) */ struct r300_state_atom unk43A4; /* (43A4) */ struct r300_state_atom unk43E8; /* (43E8) */ struct r300_state_atom fp; /* fragment program cntl + nodes (4600) */ - struct r300_state_atom fpt; /* texi - (4620) */ + struct r300_state_atom fpt; /* texi - (4620) */ struct r300_state_atom unk46A4; /* (46A4) */ struct r300_state_atom fpi[4]; /* fp instructions (46C0/47C0/48C0/49C0) */ struct r300_state_atom fogs; /* fog state (4BC0) */ struct r300_state_atom fogc; /* fog color (4BC8) */ struct r300_state_atom at; /* alpha test (4BD4) */ struct r300_state_atom unk4BD8; /* (4BD8) */ - struct r300_state_atom fpp; /* 0x4C00 and following */ + struct r300_state_atom fpp; /* 0x4C00 and following */ struct r300_state_atom unk4E00; /* (4E00) */ struct r300_state_atom bld; /* blending (4E04) */ struct r300_state_atom cmk; /* colormask (4E0C) */ @@ -495,11 +506,11 @@ struct r300_hw_state { struct r300_state_atom vpi; /* vp instructions */ struct r300_state_atom vpp; /* vp parameters */ struct r300_state_atom vps; /* vertex point size (?) */ - /* 8 texture units */ - /* the state is grouped by function and not by - texture unit. This makes single unit updates - really awkward - we are much better off - updating the whole thing at once */ + /* 8 texture units */ + /* the state is grouped by function and not by + texture unit. This makes single unit updates + really awkward - we are much better off + updating the whole thing at once */ struct { struct r300_state_atom filter; struct r300_state_atom filter_1; @@ -509,11 +520,10 @@ struct r300_hw_state { struct r300_state_atom offset; struct r300_state_atom chroma_key; struct r300_state_atom border_color; - } tex; + } tex; struct r300_state_atom txe; /* tex enable (4104) */ }; - /** * This structure holds the command buffer while it is being constructed. * @@ -522,13 +532,12 @@ struct r300_hw_state { * otherwise. */ struct r300_cmdbuf { - int size; /* DWORDs allocated for buffer */ - uint32_t* cmd_buf; - int count_used; /* DWORDs filled so far */ - int count_reemit; /* size of re-emission batch */ + int size; /* DWORDs allocated for buffer */ + uint32_t *cmd_buf; + int count_used; /* DWORDs filled so far */ + int count_reemit; /* size of re-emission batch */ }; - /** * State cache */ @@ -560,9 +569,9 @@ struct r300_vertex_shader_fragment { union { GLuint d[VSF_MAX_FRAGMENT_LENGTH]; float f[VSF_MAX_FRAGMENT_LENGTH]; - VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH/4]; - } body; - }; + VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH / 4]; + } body; +}; #define VSF_DEST_PROGRAM 0x0 #define VSF_DEST_MATRIX0 0x200 @@ -576,24 +585,19 @@ struct r300_vertex_shader_fragment { struct r300_vertex_shader_state { struct r300_vertex_shader_fragment program; - /* a bit of a waste - each uses only a subset of allocated space.. - but easier to program */ - struct r300_vertex_shader_fragment matrix[3]; - struct r300_vertex_shader_fragment vector[2]; - struct r300_vertex_shader_fragment unknown1; struct r300_vertex_shader_fragment unknown2; int program_start; - int unknown_ptr1; /* pointer within program space */ + int unknown_ptr1; /* pointer within program space */ int program_end; int param_offset; int param_count; - int unknown_ptr2; /* pointer within program space */ - int unknown_ptr3; /* pointer within program space */ - }; + int unknown_ptr2; /* pointer within program space */ + int unknown_ptr3; /* pointer within program space */ +}; extern int hw_tcl_on; @@ -603,7 +607,6 @@ extern int hw_tcl_on; /* Should but doesnt work */ //#define CURRENT_VERTEX_SHADER(ctx) (R300_CONTEXT(ctx)->curr_vp) - /* r300_vertex_shader_state and r300_vertex_program should probably be merged together someday. * Keeping them them seperate for now should ensure fixed pipeline keeps functioning properly. */ @@ -621,7 +624,7 @@ struct r300_vertex_program { struct r300_vertex_shader_fragment program; int pos_end; - int num_temporaries; /* Number of temp vars used by program */ + int num_temporaries; /* Number of temp vars used by program */ int wpos_idx; int inputs[VERT_ATTRIB_MAX]; int outputs[VERT_RESULT_MAX]; @@ -631,7 +634,7 @@ struct r300_vertex_program { }; struct r300_vertex_program_cont { - struct gl_vertex_program mesa_program; /* Must be first */ + struct gl_vertex_program mesa_program; /* Must be first */ struct r300_vertex_shader_fragment params; struct r300_vertex_program *progs; }; @@ -644,8 +647,8 @@ struct r300_vertex_program_cont { /* Mapping Mesa registers to R300 temporaries */ struct reg_acc { - int reg; /* Assigned hw temp */ - unsigned int refcount; /* Number of uses by mesa program */ + int reg; /* Assigned hw temp */ + unsigned int refcount; /* Number of uses by mesa program */ }; /** @@ -676,7 +679,6 @@ struct reg_lifetime { int scalar_lastread; }; - /** * Store usage information about an ALU instruction slot during the * compilation of a fragment program. @@ -702,7 +704,7 @@ struct r300_pfs_compile_slot { * Store information during compilation of fragment programs. */ struct r300_pfs_compile_state { - int nrslots; /* number of ALU slots used so far */ + int nrslots; /* number of ALU slots used so far */ /* Track which (parts of) slots are already filled with instructions */ struct r300_pfs_compile_slot slot[PFS_MAX_ALU_INST]; @@ -713,7 +715,7 @@ struct r300_pfs_compile_state { /* Used to map Mesa's inputs/temps onto hardware temps */ int temp_in_use; struct reg_acc temps[PFS_NUM_TEMP_REGS]; - struct reg_acc inputs[32]; /* don't actually need 32... */ + struct reg_acc inputs[32]; /* don't actually need 32... */ /* Track usage of hardware temps, for register allocation, * indirection detection, etc. */ @@ -769,7 +771,7 @@ struct r300_fragment_program { * gl_program_parameter_list::ParameterValues, or a pointer to a * global constant (e.g. for sin/cos-approximation) */ - const GLfloat* constant[PFS_NUM_CONST_REGS]; + const GLfloat *constant[PFS_NUM_CONST_REGS]; int const_nr; int max_temp_idx; @@ -788,41 +790,6 @@ struct r300_fragment_program { #define REG_COLOR0 1 #define REG_TEX0 2 -struct dt { - GLint size; - GLenum type; - GLsizei stride; - void *data; -}; - -struct radeon_vertex_buffer { - int Count; - void *Elts; - int elt_size; - int elt_min, elt_max; /* debug */ - - struct dt AttribPtr[VERT_ATTRIB_MAX]; - - const struct _mesa_prim *Primitive; - GLuint PrimitiveCount; - GLint LockFirst; - GLsizei LockCount; - int lock_uptodate; -}; - -struct r300_aos_rec { - GLuint offset; - int element_size; /* in dwords */ - int stride; /* distance between elements, in dwords */ - - int format; - - int ncomponents; /* number of components - between 1 and 4, inclusive */ - - int reg; /* which register they are assigned to. */ - - }; - struct r300_state { struct r300_depthbuffer_state depth; struct r300_texture_state texture; @@ -831,17 +798,16 @@ struct r300_state { struct r300_pfs_compile_state pfs_compile; struct r300_dma_region aos[R300_MAX_AOS_ARRAYS]; int aos_count; - struct radeon_vertex_buffer VB; GLuint *Elts; struct r300_dma_region elt_dma; - DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for. - They are the same as tnl->render_inputs for fixed pipeline */ + DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for. + They are the same as tnl->render_inputs for fixed pipeline */ struct { - int transform_offset; /* Transform matrix offset, -1 if none */ - } vap_param; /* vertex processor parameter allocation - tells where to write parameters */ + int transform_offset; /* Transform matrix offset, -1 if none */ + } vap_param; /* vertex processor parameter allocation - tells where to write parameters */ struct r300_stencilbuffer_state stencil; @@ -852,10 +818,10 @@ struct r300_state { #define R300_FALLBACK_RAST 2 /** - * R300 context structure. + * \brief R300 context structure. */ struct r300_context { - struct radeon_context radeon; /* parent class, must be first */ + struct radeon_context radeon; /* parent class, must be first */ struct r300_hw_state hw; struct r300_cmdbuf cmdbuf; @@ -882,13 +848,12 @@ struct r300_context { GLuint prefer_gart_client_texturing; #ifdef USER_BUFFERS - struct radeon_memory_manager *rmm; + struct r300_memory_manager *rmm; +#endif + GLvector4f dummy_attrib[_TNL_ATTRIB_MAX]; GLvector4f *temp_attrib[_TNL_ATTRIB_MAX]; -#endif - GLboolean texmicrotile; - GLboolean span_dlocking; GLboolean disable_lowimpact_fallback; }; @@ -899,42 +864,16 @@ struct r300_buffer_object { #define R300_CONTEXT(ctx) ((r300ContextPtr)(ctx->DriverCtx)) -static __inline GLuint r300PackColor( GLuint cpp, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a ) -{ - switch ( cpp ) { - case 2: - return PACK_COLOR_565( r, g, b ); - case 4: - return PACK_COLOR_8888( r, g, b, a ); - default: - return 0; - } -} extern void r300DestroyContext(__DRIcontextPrivate * driContextPriv); extern GLboolean r300CreateContext(const __GLcontextModes * glVisual, __DRIcontextPrivate * driContextPriv, void *sharedContextPrivate); -extern int r300_get_num_verts(r300ContextPtr rmesa, int num_verts, int prim); - -extern void r300_select_vertex_shader(r300ContextPtr r300); +extern void r300SelectVertexShader(r300ContextPtr r300); extern void r300InitShaderFuncs(struct dd_function_table *functions); -extern int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program_cont *vp, float *dst); -extern int r300Fallback(GLcontext *ctx); - -extern void radeon_vb_to_rvb(r300ContextPtr rmesa, struct radeon_vertex_buffer *rvb, struct vertex_buffer *vb); -extern GLboolean r300_run_vb_render(GLcontext *ctx, struct tnl_pipeline_stage *stage); - -#ifdef RADEON_VTXFMT_A -extern void radeon_init_vtxfmt_a(r300ContextPtr rmesa); -#endif - -#ifdef HW_VBOS -extern void r300_init_vbo_funcs(struct dd_function_table *functions); -extern void r300_evict_vbos(GLcontext *ctx, int amount); -#endif +extern int r300VertexProgUpdateParams(GLcontext * ctx, + struct r300_vertex_program_cont *vp, + float *dst); #define RADEON_D_CAPTURE 0 #define RADEON_D_PLAYBACK 1 |