/*
* Authors:
* Gareth Hughes <gareth@valinux.com>
- * Keith Whitwell <keith@tungstengraphics.com>
+ * Keith Whitwell <keithw@vmware.com>
*/
#include "main/glheader.h"
#include "main/light.h"
#include "main/context.h"
#include "main/framebuffer.h"
+#include "main/fbobject.h"
#include "main/simple_list.h"
+#include "main/state.h"
+#include "main/core.h"
+#include "main/stencil.h"
#include "vbo/vbo.h"
#include "tnl/tnl.h"
RADEON_STATECHANGE( rmesa, ctx );
rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = b;
if ( (ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled
- && ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) ) {
+ && ctx->Color.Blend[0].EquationRGB == GL_LOGIC_OP)) ) {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE;
} else {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
~(RADEON_SRC_BLEND_MASK | RADEON_DST_BLEND_MASK);
GLboolean fallback = GL_FALSE;
- switch ( ctx->Color.BlendSrcRGB ) {
+ switch ( ctx->Color.Blend[0].SrcRGB ) {
case GL_ZERO:
b |= RADEON_SRC_BLEND_GL_ZERO;
break;
break;
}
- switch ( ctx->Color.BlendDstRGB ) {
+ switch ( ctx->Color.Blend[0].DstRGB ) {
case GL_ZERO:
b |= RADEON_DST_BLEND_GL_ZERO;
break;
}
}
-static void radeonClearDepth( struct gl_context *ctx, GLclampd d )
-{
- r100ContextPtr rmesa = R100_CONTEXT(ctx);
- GLuint format = (rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &
- RADEON_DEPTH_FORMAT_MASK);
-
- switch ( format ) {
- case RADEON_DEPTH_FORMAT_16BIT_INT_Z:
- rmesa->radeon.state.depth.clear = d * 0x0000ffff;
- break;
- case RADEON_DEPTH_FORMAT_24BIT_INT_Z:
- rmesa->radeon.state.depth.clear = d * 0x00ffffff;
- break;
- }
-}
-
/* =============================================================
* Fog
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
union { int i; float f; } c, d;
- GLchan col[4];
+ GLubyte col[4];
switch (pname) {
case GL_FOG_MODE:
break;
case GL_FOG_COLOR:
RADEON_STATECHANGE( rmesa, ctx );
- UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx->Fog.Color );
+ _mesa_unclamped_float_rgba_to_ubyte(col, ctx->Fog.Color );
rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~RADEON_FOG_COLOR_MASK;
rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |=
radeonPackColor( 4, col[0], col[1], col[2], 0 );
static void radeonFrontFace( struct gl_context *ctx, GLenum mode )
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
+ int cull_face = (mode == GL_CW) ? RADEON_FFACE_CULL_CW : RADEON_FFACE_CULL_CCW;
RADEON_STATECHANGE( rmesa, set );
rmesa->hw.set.cmd[SET_SE_CNTL] &= ~RADEON_FFACE_CULL_DIR_MASK;
rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_CULL_FRONT_IS_CCW;
/* Winding is inverted when rendering to FBO */
- if (ctx->DrawBuffer && ctx->DrawBuffer->Name)
- mode = (mode == GL_CW) ? GL_CCW : GL_CW;
+ if (ctx->DrawBuffer && _mesa_is_user_fbo(ctx->DrawBuffer))
+ cull_face = (mode == GL_CCW) ? RADEON_FFACE_CULL_CW : RADEON_FFACE_CULL_CCW;
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= cull_face;
- switch ( mode ) {
- case GL_CW:
- rmesa->hw.set.cmd[SET_SE_CNTL] |= RADEON_FFACE_CULL_CW;
- break;
- case GL_CCW:
- rmesa->hw.set.cmd[SET_SE_CNTL] |= RADEON_FFACE_CULL_CCW;
+ if ( mode == GL_CCW )
rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_CULL_FRONT_IS_CCW;
- break;
- }
}
rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_CONSTANT] = constant.ui32;
}
-static void radeonPolygonStipplePreKMS( struct gl_context *ctx, const GLubyte *mask )
-{
- r100ContextPtr rmesa = R100_CONTEXT(ctx);
- GLuint i;
- drm_radeon_stipple_t stipple;
-
- /* Must flip pattern upside down.
- */
- for ( i = 0 ; i < 32 ; i++ ) {
- rmesa->state.stipple.mask[31 - i] = ((GLuint *) mask)[i];
- }
-
- /* TODO: push this into cmd mechanism
- */
- radeon_firevertices(&rmesa->radeon);
- LOCK_HARDWARE( &rmesa->radeon );
-
- /* FIXME: Use window x,y offsets into stipple RAM.
- */
- stipple.mask = rmesa->state.stipple.mask;
- drmCommandWrite( rmesa->radeon.dri.fd, DRM_RADEON_STIPPLE,
- &stipple, sizeof(drm_radeon_stipple_t) );
- UNLOCK_HARDWARE( &rmesa->radeon );
-}
-
static void radeonPolygonMode( struct gl_context *ctx, GLenum face, GLenum mode )
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
- GLboolean flag = (ctx->_TriangleCaps & DD_TRI_UNFILLED) != 0;
+ GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL);
/* Can't generally do unfilled via tcl, but some good special
* cases work.
*/
- TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_UNFILLED, flag);
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_UNFILLED, unfilled);
if (rmesa->radeon.TclFallback) {
radeonChooseRenderState( ctx );
radeonChooseVertexState( ctx );
TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_FOGCOORDSPEC, flag);
- if (NEED_SECONDARY_COLOR(ctx)) {
+ if (_mesa_need_secondary_color(ctx)) {
assert( (p & RADEON_SPECULAR_ENABLE) != 0 );
} else {
assert( (p & RADEON_SPECULAR_ENABLE) == 0 );
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
if (ctx->Light.ColorMaterialEnabled &&
- (ctx->Light.ColorMaterialBitmask & BACK_MATERIAL_BITS) !=
- ((ctx->Light.ColorMaterialBitmask & FRONT_MATERIAL_BITS)<<1))
+ (ctx->Light._ColorMaterialBitmask & BACK_MATERIAL_BITS) !=
+ ((ctx->Light._ColorMaterialBitmask & FRONT_MATERIAL_BITS)<<1))
fallback = GL_TRUE;
else {
for (i = MAT_ATTRIB_FRONT_AMBIENT; i < MAT_ATTRIB_FRONT_INDEXES; i+=2)
(3 << RADEON_SPECULAR_SOURCE_SHIFT));
if (ctx->Light.ColorMaterialEnabled) {
- GLuint mask = ctx->Light.ColorMaterialBitmask;
+ GLuint mask = ctx->Light._ColorMaterialBitmask;
if (mask & MAT_BIT_FRONT_EMISSION) {
light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
GLuint mask = ~0;
if (ctx->Light.ColorMaterialEnabled)
- mask &= ~ctx->Light.ColorMaterialBitmask;
+ mask &= ~ctx->Light._ColorMaterialBitmask;
if (RADEON_DEBUG & RADEON_STATE)
fprintf(stderr, "%s\n", __FUNCTION__);
GLint ref, GLuint mask )
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
- GLuint refmask = (((ctx->Stencil.Ref[0] & 0xff) << RADEON_STENCIL_REF_SHIFT) |
+ GLuint refmask = ((_mesa_get_stencil_ref(ctx, 0) << RADEON_STENCIL_REF_SHIFT) |
((ctx->Stencil.ValueMask[0] & 0xff) << RADEON_STENCIL_MASK_SHIFT));
RADEON_STATECHANGE( rmesa, ctx );
}
}
-static void radeonClearStencil( struct gl_context *ctx, GLint s )
-{
- r100ContextPtr rmesa = R100_CONTEXT(ctx);
-
- rmesa->radeon.state.stencil.clear =
- ((GLuint) (ctx->Stencil.Clear & 0xff) |
- (0xff << RADEON_STENCIL_MASK_SHIFT) |
- ((ctx->Stencil.WriteMask[0] & 0xff) << RADEON_STENCIL_WRITEMASK_SHIFT));
-}
/* =============================================================
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
__DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
- GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
- GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
- const GLfloat *v = ctx->Viewport._WindowMap.m;
- const GLboolean render_to_fbo = (ctx->DrawBuffer ? (ctx->DrawBuffer->Name != 0) : 0);
+ GLfloat xoffset = 0.0;
+ GLfloat yoffset = dPriv ? (GLfloat) dPriv->h : 0;
+ const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m;
+ const GLboolean render_to_fbo = (ctx->DrawBuffer ? _mesa_is_user_fbo(ctx->DrawBuffer) : 0);
const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
GLfloat y_scale, y_bias;
}
-static void radeonViewport( struct gl_context *ctx, GLint x, GLint y,
- GLsizei width, GLsizei height )
+static void radeonViewport(struct gl_context *ctx)
{
/* Don't pipeline viewport changes, conflict with window offset
* setting below. Could apply deltas to rescue pipelined viewport
*/
radeonUpdateWindow( ctx );
- radeon_viewport(ctx, x, y, width, height);
+ radeon_viewport(ctx);
}
-static void radeonDepthRange( struct gl_context *ctx, GLclampd nearval,
- GLclampd farval )
+static void radeonDepthRange(struct gl_context *ctx)
{
radeonUpdateWindow( ctx );
}
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
__DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
- GLfloat xoffset = (GLfloat)dPriv->x;
- GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
- const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat xoffset = 0.0;
+ GLfloat yoffset = (GLfloat)dPriv->h;
+ const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m;
float_ui32_type tx;
float_ui32_type ty;
RADEON_STIPPLE_Y_OFFSET_MASK);
/* add magic offsets, then invert */
- stx = 31 - ((dPriv->x - 1) & RADEON_STIPPLE_COORD_MASK);
- sty = 31 - ((dPriv->y + dPriv->h - 1)
+ stx = 31 - ((-1) & RADEON_STIPPLE_COORD_MASK);
+ sty = 31 - ((dPriv->h - 1)
& RADEON_STIPPLE_COORD_MASK);
m |= ((stx << RADEON_STIPPLE_X_OFFSET_SHIFT) |
* Miscellaneous
*/
-static void radeonClearColor( struct gl_context *ctx, const GLfloat color[4] )
-{
- r100ContextPtr rmesa = R100_CONTEXT(ctx);
- GLubyte c[4];
- struct radeon_renderbuffer *rrb;
-
- rrb = radeon_get_colorbuffer(&rmesa->radeon);
- if (!rrb)
- return;
-
- CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
- CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
- CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
- CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
- rmesa->radeon.state.color.clear = radeonPackColor( rrb->cpp,
- c[0], c[1], c[2], c[3] );
-}
-
-
static void radeonRenderMode( struct gl_context *ctx, GLenum mode )
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ALPHA_BLEND_ENABLE;
}
if ( (ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled
- && ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) ) {
+ && ctx->Color.Blend[0].EquationRGB == GL_LOGIC_OP)) ) {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE;
} else {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
*/
if (state) {
ctx->Driver.BlendEquationSeparate( ctx,
- ctx->Color.BlendEquationRGB,
- ctx->Color.BlendEquationA );
- ctx->Driver.BlendFuncSeparate( ctx, ctx->Color.BlendSrcRGB,
- ctx->Color.BlendDstRGB,
- ctx->Color.BlendSrcA,
- ctx->Color.BlendDstA );
+ ctx->Color.Blend[0].EquationRGB,
+ ctx->Color.Blend[0].EquationA );
+ ctx->Driver.BlendFuncSeparate( ctx, ctx->Color.Blend[0].SrcRGB,
+ ctx->Color.Blend[0].DstRGB,
+ ctx->Color.Blend[0].SrcA,
+ ctx->Color.Blend[0].DstA );
}
else {
FALLBACK( rmesa, RADEON_FALLBACK_BLEND_FUNC, GL_FALSE );
case GL_COLOR_LOGIC_OP:
RADEON_STATECHANGE( rmesa, ctx );
if ( (ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled
- && ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) ) {
+ && ctx->Color.Blend[0].EquationRGB == GL_LOGIC_OP)) ) {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE;
} else {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
int idx = TEXMAT_0 + unit;
float *dest = ((float *)RADEON_DB_STATE( mat[idx] )) + MAT_ELT_0;
int i;
- struct gl_texture_unit tUnit = rmesa->radeon.glCtx->Texture.Unit[unit];
+ struct gl_texture_unit tUnit = rmesa->radeon.glCtx.Texture.Unit[unit];
GLfloat *src = rmesa->tmpmat[unit].m;
rmesa->TexMatColSwap &= ~(1 << unit);
- if ((tUnit._ReallyEnabled & (TEXTURE_3D_BIT | TEXTURE_CUBE_BIT)) == 0) {
+ if (!tUnit._Current ||
+ (tUnit._Current->Target != GL_TEXTURE_3D &&
+ tUnit._Current->Target != GL_TEXTURE_CUBE_MAP)) {
if (swapcols) {
rmesa->TexMatColSwap |= 1 << unit;
/* attention some elems are swapped 2 times! */
rmesa->TexMatColSwap = 0;
for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ if (ctx->Texture.Unit[unit]._Current) {
GLboolean needMatrix = GL_FALSE;
if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) {
needMatrix = GL_TRUE;
0, RADEON_GEM_DOMAIN_VRAM);
}
- for (i = 0; i < ctx->Const.MaxTextureImageUnits; ++i) {
+ for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; ++i) {
radeonTexObj *t;
- if (!ctx->Texture.Unit[i]._ReallyEnabled)
+ if (!ctx->Texture.Unit[i]._Current)
continue;
t = rmesa->state.texture.unit[i].texobj;
+
+ if (!t)
+ continue;
if (t->image_override && t->bo)
radeon_cs_space_add_persistent_bo(rmesa->radeon.cmdbuf.cs, t->bo,
RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
* Many of the ctx->Driver functions might have been initialized to
* software defaults in the earlier _mesa_init_driver_functions() call.
*/
-void radeonInitStateFuncs( struct gl_context *ctx , GLboolean dri2 )
+void radeonInitStateFuncs( struct gl_context *ctx )
{
ctx->Driver.UpdateState = radeonInvalidateState;
ctx->Driver.LightingSpaceChange = radeonLightingSpaceChange;
ctx->Driver.ReadBuffer = radeonReadBuffer;
ctx->Driver.CopyPixels = _mesa_meta_CopyPixels;
ctx->Driver.DrawPixels = _mesa_meta_DrawPixels;
- if (dri2)
- ctx->Driver.ReadPixels = radeonReadPixels;
+ ctx->Driver.ReadPixels = radeonReadPixels;
ctx->Driver.AlphaFunc = radeonAlphaFunc;
ctx->Driver.BlendEquationSeparate = radeonBlendEquationSeparate;
ctx->Driver.BlendFuncSeparate = radeonBlendFuncSeparate;
- ctx->Driver.ClearColor = radeonClearColor;
- ctx->Driver.ClearDepth = radeonClearDepth;
- ctx->Driver.ClearStencil = radeonClearStencil;
ctx->Driver.ClipPlane = radeonClipPlane;
ctx->Driver.ColorMask = radeonColorMask;
ctx->Driver.CullFace = radeonCullFace;
ctx->Driver.LogicOpcode = radeonLogicOpCode;
ctx->Driver.PolygonMode = radeonPolygonMode;
ctx->Driver.PolygonOffset = radeonPolygonOffset;
- if (dri2)
- ctx->Driver.PolygonStipple = radeonPolygonStipple;
- else
- ctx->Driver.PolygonStipple = radeonPolygonStipplePreKMS;
+ ctx->Driver.PolygonStipple = radeonPolygonStipple;
ctx->Driver.RenderMode = radeonRenderMode;
ctx->Driver.Scissor = radeonScissor;
ctx->Driver.ShadeModel = radeonShadeModel;