/* * Direct Rendering Support for SMedia Glamo 336x/337x * * (c) 2009 Thomas White * Roughly based on sis_context.h (c) 2003 Eric Anholt * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __GLAMO_CONTEXT_H #define __GLAMO_CONTEXT_H #include "dri_util.h" #include "utils.h" #include "tnl/t_vertex.h" #include "glamo_screen.h" typedef struct glamo_context glamoContext; typedef struct glamo_context *glamoContextPtr; struct glamo_context { GLcontext *glCtx; /* Must be first in this structure */ int drm_fd; /* DRM fd */ __DRIcontext *driContext; /* DRI context */ __DRIscreen *driScreen; /* DRI screen */ __DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */ glamoScreenPtr glamoScreen; /* Screen private DRI data */ driOptionCache optionCache; uint16_t *cmdq_drm; /* Command queue cache */ uint16_t cmd_burst_base; int cmdq_drm_used; int cmdq_drm_size; int cmdq_obj_used; uint32_t *cmdq_objs; unsigned int *cmdq_obj_pos; /* Information about the current primitive */ struct { GLuint id; uint32_t primitive; /* Current hardware primitive type */ struct glamo_bo *vb_bo; uint8_t *vb; unsigned int start_offset; /* Byte offset of start */ unsigned int current_offset; /* Byte offset of next vertex */ unsigned int count; /* Number of vertices */ } prim; /* Current vertex format and attributes */ int vertex_size; struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; /* State */ GLuint new_state; /* State which must be updated */ uint16_t col_clear; }; #define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx)) #define TAG(x) glamo##x #include "tnl_dd/t_dd_vertex.h" #undef TAG extern GLboolean glamoCreateContext(const __GLcontextModes *glVis, __DRIcontext *driContextPriv, void *sharedContextPrivate); extern void glamoDestroyContext(__DRIcontext *dcp); extern GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv, __DRIdrawable *driDrawPriv, __DRIdrawable *driReadPriv); extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv); extern void glamo_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable); #define GLAMO_PACKCOLOR565(r, g, b) \ ((((r) & 0xf8) << 8) \ | (((g) & 0xfc) << 3) \ | (((b) & 0xf8) >> 3)) extern uint32_t float7s16(GLfloat in); #endif /* __GLAMO_CONTEXT_H */