📄 i830_state.c
字号:
I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_IALPHAB] = iab; i830->state.Ctx[I830_CTXREG_STATE1] = s1; } /* This will catch a logicop blend equation. It will also ensure * independant alpha blend is really in the correct state (either enabled * or disabled) if blending is already enabled. */ i830EvalLogicOpBlendState(ctx); if (0) { fprintf(stderr, "[%s:%u] STATE1: 0x%08x IALPHAB: 0x%08x blend is %sabled\n", __FUNCTION__, __LINE__, i830->state.Ctx[I830_CTXREG_STATE1], i830->state.Ctx[I830_CTXREG_IALPHAB], (ctx->Color.BlendEnabled) ? "en" : "dis"); }}static voidi830BlendEquationSeparate(GLcontext * ctx, GLenum modeRGB, GLenum modeA){ DBG("%s -> %s, %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(modeRGB), _mesa_lookup_enum_by_nr(modeA)); (void) modeRGB; (void) modeA; i830_set_blend_state(ctx);}static voidi830BlendFuncSeparate(GLcontext * ctx, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA){ DBG("%s -> RGB(%s, %s) A(%s, %s)\n", __FUNCTION__, _mesa_lookup_enum_by_nr(sfactorRGB), _mesa_lookup_enum_by_nr(dfactorRGB), _mesa_lookup_enum_by_nr(sfactorA), _mesa_lookup_enum_by_nr(dfactorA)); (void) sfactorRGB; (void) dfactorRGB; (void) sfactorA; (void) dfactorA; i830_set_blend_state(ctx);}static voidi830DepthFunc(GLcontext * ctx, GLenum func){ struct i830_context *i830 = i830_context(ctx); int test = intel_translate_compare_func(func); DBG("%s\n", __FUNCTION__); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK; i830->state.Ctx[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC | DEPTH_TEST_FUNC(test));}static voidi830DepthMask(GLcontext * ctx, GLboolean flag){ struct i830_context *i830 = i830_context(ctx); DBG("%s flag (%d)\n", __FUNCTION__, flag); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK; if (flag && ctx->Depth.Test) i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DEPTH_WRITE; else i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;}/* ============================================================= * Polygon stipple * * The i830 supports a 4x4 stipple natively, GL wants 32x32. * Fortunately stipple is usually a repeating pattern. */static voidi830PolygonStipple(GLcontext * ctx, const GLubyte * mask){ struct i830_context *i830 = i830_context(ctx); const GLubyte *m = mask; GLubyte p[4]; int i, j, k; int active = (ctx->Polygon.StippleFlag && i830->intel.reduced_primitive == GL_TRIANGLES); GLuint newMask; if (active) { I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE); i830->state.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE; } p[0] = mask[12] & 0xf; p[0] |= p[0] << 4; p[1] = mask[8] & 0xf; p[1] |= p[1] << 4; p[2] = mask[4] & 0xf; p[2] |= p[2] << 4; p[3] = mask[0] & 0xf; p[3] |= p[3] << 4; for (k = 0; k < 8; k++) for (j = 3; j >= 0; j--) for (i = 0; i < 4; i++, m++) if (*m != p[j]) { i830->intel.hw_stipple = 0; return; } newMask = (((p[0] & 0xf) << 0) | ((p[1] & 0xf) << 4) | ((p[2] & 0xf) << 8) | ((p[3] & 0xf) << 12)); if (newMask == 0xffff || newMask == 0x0) { /* this is needed to make conform pass */ i830->intel.hw_stipple = 0; return; } i830->state.Stipple[I830_STPREG_ST1] &= ~0xffff; i830->state.Stipple[I830_STPREG_ST1] |= newMask; i830->intel.hw_stipple = 1; if (active) i830->state.Stipple[I830_STPREG_ST1] |= ST1_ENABLE;}/* ============================================================= * Hardware clipping */static voidi830Scissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h){ struct i830_context *i830 = i830_context(ctx); int x1, y1, x2, y2; if (!ctx->DrawBuffer) return; DBG("%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h); if (ctx->DrawBuffer->Name == 0) { x1 = x; y1 = ctx->DrawBuffer->Height - (y + h); x2 = x + w - 1; y2 = y1 + h - 1; DBG("%s %d..%d,%d..%d (inverted)\n", __FUNCTION__, x1, x2, y1, y2); } else { /* FBO - not inverted */ x1 = x; y1 = y; x2 = x + w - 1; y2 = y + h - 1; DBG("%s %d..%d,%d..%d (not inverted)\n", __FUNCTION__, x1, x2, y1, y2); } x1 = CLAMP(x1, 0, ctx->DrawBuffer->Width - 1); y1 = CLAMP(y1, 0, ctx->DrawBuffer->Height - 1); x2 = CLAMP(x2, 0, ctx->DrawBuffer->Width - 1); y2 = CLAMP(y2, 0, ctx->DrawBuffer->Height - 1); DBG("%s %d..%d,%d..%d (clamped)\n", __FUNCTION__, x1, x2, y1, y2); I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS); i830->state.Buffer[I830_DESTREG_SR1] = (y1 << 16) | (x1 & 0xffff); i830->state.Buffer[I830_DESTREG_SR2] = (y2 << 16) | (x2 & 0xffff);}static voidi830LogicOp(GLcontext * ctx, GLenum opcode){ struct i830_context *i830 = i830_context(ctx); int tmp = intel_translate_logic_op(opcode); DBG("%s\n", __FUNCTION__); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE4] &= ~LOGICOP_MASK; i830->state.Ctx[I830_CTXREG_STATE4] |= LOGIC_OP_FUNC(tmp);}static voidi830CullFaceFrontFace(GLcontext * ctx, GLenum unused){ struct i830_context *i830 = i830_context(ctx); GLuint mode; DBG("%s\n", __FUNCTION__); if (!ctx->Polygon.CullFlag) { mode = CULLMODE_NONE; } else if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) { mode = CULLMODE_CW; if (ctx->Polygon.CullFaceMode == GL_FRONT) mode ^= (CULLMODE_CW ^ CULLMODE_CCW); if (ctx->Polygon.FrontFace != GL_CCW) mode ^= (CULLMODE_CW ^ CULLMODE_CCW); } else { mode = CULLMODE_BOTH; } I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE3] &= ~CULLMODE_MASK; i830->state.Ctx[I830_CTXREG_STATE3] |= ENABLE_CULL_MODE | mode;}static voidi830LineWidth(GLcontext * ctx, GLfloat widthf){ struct i830_context *i830 = i830_context(ctx); int width; int state5; DBG("%s\n", __FUNCTION__); width = (int) (widthf * 2); CLAMP_SELF(width, 1, 15); state5 = i830->state.Ctx[I830_CTXREG_STATE5] & ~FIXED_LINE_WIDTH_MASK; state5 |= (ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(width)); if (state5 != i830->state.Ctx[I830_CTXREG_STATE5]) { I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE5] = state5; }}static voidi830PointSize(GLcontext * ctx, GLfloat size){ struct i830_context *i830 = i830_context(ctx); GLint point_size = (int) size; DBG("%s\n", __FUNCTION__); CLAMP_SELF(point_size, 1, 256); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_STATE5] &= ~FIXED_POINT_WIDTH_MASK; i830->state.Ctx[I830_CTXREG_STATE5] |= (ENABLE_FIXED_POINT_WIDTH | FIXED_POINT_WIDTH(point_size));}/* ============================================================= * Color masks */static voidi830ColorMask(GLcontext * ctx, GLboolean r, GLboolean g, GLboolean b, GLboolean a){ struct i830_context *i830 = i830_context(ctx); GLuint tmp = 0; DBG("%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a); tmp = ((i830->state.Ctx[I830_CTXREG_ENABLES_2] & ~WRITEMASK_MASK) | ENABLE_COLOR_MASK | ENABLE_COLOR_WRITE | ((!r) << WRITEMASK_RED_SHIFT) | ((!g) << WRITEMASK_GREEN_SHIFT) | ((!b) << WRITEMASK_BLUE_SHIFT) | ((!a) << WRITEMASK_ALPHA_SHIFT)); if (tmp != i830->state.Ctx[I830_CTXREG_ENABLES_2]) { I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_2] = tmp; }}static voidupdate_specular(GLcontext * ctx){ struct i830_context *i830 = i830_context(ctx); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK; if (NEED_SECONDARY_COLOR(ctx)) i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_SPEC_ADD; else i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_SPEC_ADD;}static voidi830LightModelfv(GLcontext * ctx, GLenum pname, const GLfloat * param){ DBG("%s\n", __FUNCTION__); if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) { update_specular(ctx); }}/* In Mesa 3.5 we can reliably do native flatshading. */static voidi830ShadeModel(GLcontext * ctx, GLenum mode){ struct i830_context *i830 = i830_context(ctx); I830_STATECHANGE(i830, I830_UPLOAD_CTX);#define SHADE_MODE_MASK ((1<<10)|(1<<8)|(1<<6)|(1<<4)) i830->state.Ctx[I830_CTXREG_STATE3] &= ~SHADE_MODE_MASK; if (mode == GL_FLAT) { i830->state.Ctx[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_FLAT) | FOG_SHADE_MODE(SHADE_MODE_FLAT) | SPEC_SHADE_MODE(SHADE_MODE_FLAT) | COLOR_SHADE_MODE(SHADE_MODE_FLAT)); } else { i830->state.Ctx[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) | FOG_SHADE_MODE(SHADE_MODE_LINEAR) | SPEC_SHADE_MODE(SHADE_MODE_LINEAR) | COLOR_SHADE_MODE(SHADE_MODE_LINEAR)); }}/* ============================================================= * Fog */static voidi830Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param){ struct i830_context *i830 = i830_context(ctx); DBG("%s\n", __FUNCTION__); if (pname == GL_FOG_COLOR) { GLuint color = (((GLubyte) (ctx->Fog.Color[0] * 255.0F) << 16) | ((GLubyte) (ctx->Fog.Color[1] * 255.0F) << 8) | ((GLubyte) (ctx->Fog.Color[2] * 255.0F) << 0)); I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_FOGCOLOR] = (_3DSTATE_FOG_COLOR_CMD | color);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -