/* * Direct Rendering Support for SMedia Glamo 336x/337x * * (c) 2009 Thomas White * Roughly based on sis_state.c (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. * * * Also partially based on intel_fbo.c, to which the following notice applies: * * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * * 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, sub license, 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 (including the * next paragraph) 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 NON-INFRINGEMENT. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. */ #include "main/context.h" #include "main/framebuffer.h" #include "glamo_fbo.h" #include "glamo_state.h" #include "glamo_context.h" #include "glamo_cmdq.h" #include "glamo_regs.h" static void glamoResizeBuffers(GLcontext *ctx, struct gl_framebuffer *fb, GLuint width, GLuint height) { struct glamo_framebuffer *glamo_fb = (struct glamo_framebuffer *)fb; int i; _mesa_resize_framebuffer(ctx, fb, width, height); fb->Initialized = GL_TRUE; /* XXX remove someday */ if (fb->Name != 0) { return; } /* Make sure all window system renderbuffers are up to date */ for (i = 0; i < 2; i++) { struct gl_renderbuffer *rb = &glamo_fb->color_rb[i]->base; /* only resize if size is changing */ if (rb && (rb->Width != width || rb->Height != height)) { rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height); } } } static void glamoClear(GLcontext *ctx, GLbitfield mask) { glamoContext *gCtx; struct gl_framebuffer *fb; int i; gCtx = GLAMO_CONTEXT(ctx); fb = ctx->DrawBuffer; printf("glamoClear (%f %f %f %f)\n", ctx->Color.ClearColor[0], ctx->Color.ClearColor[1], ctx->Color.ClearColor[2], ctx->Color.ClearColor[3]); fflush(stdout); for (i = 0; i < fb->_NumColorDrawBuffers; i++) { struct glamo_renderbuffer *grb; grb = glamo_renderbuffer(fb->_ColorDrawBuffers[i]); GlamoDRMAddCommandBO(gCtx, GLAMO_REG_2D_DST_ADDRL, grb->bo); GlamoDRMAddCommand(gCtx, GLAMO_REG_2D_DST_PITCH, grb->width & 0x7ff); GlamoDRMAddCommand(gCtx, GLAMO_REG_2D_DST_HEIGHT, grb->height); GlamoDRMAddCommand(gCtx, GLAMO_REG_2D_PAT_FG, 0xabcd); GlamoDRMAddCommand(gCtx, GLAMO_REG_2D_COMMAND2, 0xff); /* set */ GlamoDRMAddCommand(gCtx, GLAMO_REG_2D_DST_X, fb->_Xmin); GlamoDRMAddCommand(gCtx, GLAMO_REG_2D_DST_Y, fb->_Ymin); GlamoDRMAddCommand(gCtx, GLAMO_REG_2D_RECT_WIDTH, fb->_Xmax-fb->_Xmin); GlamoDRMAddCommand(gCtx, GLAMO_REG_2D_RECT_HEIGHT, fb->_Ymax-fb->_Ymin); GlamoDRMAddCommand(gCtx, GLAMO_REG_2D_COMMAND3, 0); } } static void glamoClearColor(GLcontext *ctx, const GLfloat color[4]) { printf("glamoClearColor (%f %f %f %f)\n", color[0], color[1], color[2], color[3]); fflush(stdout); } static void glamoShadeModel(GLcontext *ctx, GLenum mode) { printf("glamoShadeModel\n"); fflush(stdout); } static void glamoViewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height ) { printf("glamoViewport\n"); fflush(stdout); } static void glamoUpdateState(GLcontext *ctx, GLbitfield new_state) { printf("glamoUpdateState\n"); } static void glamoFlush(GLcontext *ctx) { printf("glamoFlush\n"); } void glamoInitStateFuncs(GLcontext *ctx) { ctx->Driver.UpdateState = glamoUpdateState; ctx->Driver.Clear = glamoClear; ctx->Driver.ClearColor = glamoClearColor; ctx->Driver.ClearDepth = NULL; ctx->Driver.ClearStencil = NULL; ctx->Driver.AlphaFunc = NULL; ctx->Driver.BlendFuncSeparate = NULL; ctx->Driver.ColorMask = NULL; ctx->Driver.CullFace = NULL; ctx->Driver.DepthMask = NULL; ctx->Driver.DepthFunc = NULL; ctx->Driver.DepthRange = NULL; ctx->Driver.DrawBuffer = NULL; ctx->Driver.Enable = NULL; ctx->Driver.FrontFace = NULL; ctx->Driver.Fogfv = NULL; ctx->Driver.Hint = NULL; ctx->Driver.Lightfv = NULL; ctx->Driver.LogicOpcode = NULL; ctx->Driver.PolygonMode = NULL; ctx->Driver.PolygonStipple = NULL; ctx->Driver.ReadBuffer = NULL; ctx->Driver.RenderMode = NULL; ctx->Driver.Scissor = NULL; ctx->Driver.ShadeModel = glamoShadeModel; ctx->Driver.LightModelfv = NULL; ctx->Driver.Viewport = glamoViewport; ctx->Driver.ResizeBuffers = glamoResizeBuffers; ctx->Driver.Flush = glamoFlush; }