📄 r300_state.c
字号:
{ GLcontext* ctx = r300->radeon.glCtx; if (RADEON_DEBUG & DEBUG_STATE) fprintf(stderr, "%s\n", __FUNCTION__); /* This is a place to initialize registers which have bitfields accessed by different functions and not all bits are used */#if 0 /* initialize similiar to r200 */ r300->hw.zs.cmd[R300_ZS_CNTL_0] = 0; r300->hw.zs.cmd[R300_ZS_CNTL_1] = (R300_ZS_ALWAYS << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | (R300_ZS_KEEP << R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) | (R300_ZS_KEEP << R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT) | (R300_ZS_KEEP << R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT) | (R300_ZS_ALWAYS << R300_RB3D_ZS1_BACK_FUNC_SHIFT) | (R300_ZS_KEEP << R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT) | (R300_ZS_KEEP << R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT) | (R300_ZS_KEEP << R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT); r300->hw.zs.cmd[R300_ZS_CNTL_2] = 0x00ffff00;#endif /* go and compute register values from GL state */ r300UpdateWindow(ctx); r300ColorMask(ctx, ctx->Color.ColorMask[RCOMP], ctx->Color.ColorMask[GCOMP], ctx->Color.ColorMask[BCOMP], ctx->Color.ColorMask[ACOMP]); r300Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test); r300DepthMask(ctx, ctx->Depth.Mask); r300DepthFunc(ctx, ctx->Depth.Func); /* stencil */ r300Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled); r300StencilMaskSeparate(ctx, 0, ctx->Stencil.WriteMask[0]); r300StencilFuncSeparate(ctx, 0, ctx->Stencil.Function[0], ctx->Stencil.Ref[0], ctx->Stencil.ValueMask[0]); r300StencilOpSeparate(ctx, 0, ctx->Stencil.FailFunc[0], ctx->Stencil.ZFailFunc[0], ctx->Stencil.ZPassFunc[0]); r300UpdateCulling(ctx); r300UpdateTextureState(ctx);// r300_setup_routing(ctx, GL_TRUE); #if 0 /* Done in prior to rendering */ if(hw_tcl_on == GL_FALSE){ r300EmitArrays(ctx, GL_TRUE); /* Just do the routing */ r300_setup_textures(ctx); r300_setup_rs_unit(ctx); r300SetupVertexShader(r300); r300SetupPixelShader(r300); }#endif r300_set_blend_state(ctx); r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef); r300Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled); /* Initialize magic registers TODO : learn what they really do, or get rid of those we don't have to touch */ r300->hw.unk2080.cmd[1] = 0x0030045A; //0x0030065a /* Dangerous */ r300->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA | R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA | R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA | R300_VPORT_Z_OFFSET_ENA | R300_VTX_W0_FMT; r300->hw.vte.cmd[2] = 0x00000008; r300->hw.unk2134.cmd[1] = 0x00FFFFFF; r300->hw.unk2134.cmd[2] = 0x00000000;#ifdef MESA_BIG_ENDIAN r300->hw.unk2140.cmd[1] = 0x00000002;#else r300->hw.unk2140.cmd[1] = 0x00000000;#endif#if 0 /* Done in setup routing */ ((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->packet0.count = 1; r300->hw.vir[0].cmd[1] = 0x21030003; ((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->packet0.count = 1; r300->hw.vir[1].cmd[1] = 0xF688F688; r300->hw.vic.cmd[R300_VIR_CNTL_0] = 0x00000001; r300->hw.vic.cmd[R300_VIR_CNTL_1] = 0x00000405;#endif r300->hw.unk21DC.cmd[1] = 0xAAAAAAAA; r300->hw.unk221C.cmd[1] = R300_221C_NORMAL; r300->hw.unk2220.cmd[1] = r300PackFloat32(1.0); r300->hw.unk2220.cmd[2] = r300PackFloat32(1.0); r300->hw.unk2220.cmd[3] = r300PackFloat32(1.0); r300->hw.unk2220.cmd[4] = r300PackFloat32(1.0); /* what about other chips than r300 or rv350??? */ if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300) r300->hw.unk2288.cmd[1] = R300_2288_R300; else r300->hw.unk2288.cmd[1] = R300_2288_RV350;#if 0 r300->hw.vof.cmd[R300_VOF_CNTL_0] = R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT | R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0; /* no textures */ r300->hw.pvs.cmd[R300_PVS_CNTL_1] = 0; r300->hw.pvs.cmd[R300_PVS_CNTL_2] = 0; r300->hw.pvs.cmd[R300_PVS_CNTL_3] = 0;#endif r300->hw.gb_enable.cmd[1] = R300_GB_POINT_STUFF_ENABLE | R300_GB_LINE_STUFF_ENABLE | R300_GB_TRIANGLE_STUFF_ENABLE /*| R300_GB_UNK31*/; r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_0] = 0x66666666; r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_1] = 0x06666666; if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300) || (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R350)) r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_R300 | R300_GB_TILE_SIZE_16; else if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV410) r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_RV410 | R300_GB_TILE_SIZE_16; else if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R420) r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_R420 | R300_GB_TILE_SIZE_16; else r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_RV300 | R300_GB_TILE_SIZE_16; r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = 0x00000000; r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = 0x00000000; /* No antialiasing */ //r300->hw.txe.cmd[R300_TXE_ENABLE] = 0; r300->hw.unk4200.cmd[1] = r300PackFloat32(0.0); r300->hw.unk4200.cmd[2] = r300PackFloat32(0.0); r300->hw.unk4200.cmd[3] = r300PackFloat32(1.0); r300->hw.unk4200.cmd[4] = r300PackFloat32(1.0); r300->hw.unk4214.cmd[1] = 0x00050005; r300PointSize(ctx, 0.0);#if 0 r300->hw.ps.cmd[R300_PS_POINTSIZE] = (6 << R300_POINTSIZE_X_SHIFT) | (6 << R300_POINTSIZE_Y_SHIFT);#endif r300->hw.unk4230.cmd[1] = 0x18000006; r300->hw.unk4230.cmd[2] = 0x00020006; r300->hw.unk4230.cmd[3] = r300PackFloat32(1.0 / 192.0); r300LineWidth(ctx, 0.0); r300->hw.unk4260.cmd[1] = 0; r300->hw.unk4260.cmd[2] = r300PackFloat32(0.0); r300->hw.unk4260.cmd[3] = r300PackFloat32(1.0); r300->hw.unk4274.cmd[1] = 0x00000002; r300ShadeModel(ctx, ctx->Light.ShadeModel); r300->hw.unk4274.cmd[3] = 0x00000000; r300->hw.unk4274.cmd[4] = 0x00000000; r300PolygonMode(ctx, GL_FRONT, ctx->Polygon.FrontMode); r300PolygonMode(ctx, GL_BACK, ctx->Polygon.BackMode); r300->hw.unk4288.cmd[2] = 0x00000001; r300->hw.unk4288.cmd[3] = 0x00000000; r300->hw.unk4288.cmd[4] = 0x00000000; r300->hw.unk4288.cmd[5] = 0x00000000; r300->hw.unk42A0.cmd[1] = 0x00000000; r300PolygonOffset(ctx, ctx->Polygon.OffsetFactor, ctx->Polygon.OffsetUnits); r300Enable(ctx, GL_POLYGON_OFFSET_FILL, ctx->Polygon.OffsetFill); r300->hw.unk42C0.cmd[1] = 0x4B7FFFFF; r300->hw.unk42C0.cmd[2] = 0x00000000; r300->hw.unk43A4.cmd[1] = 0x0000001C; r300->hw.unk43A4.cmd[2] = 0x2DA49525; r300->hw.unk43E8.cmd[1] = 0x00FFFFFF;#if 0 r300->hw.fp.cmd[R300_FP_CNTL0] = 0; r300->hw.fp.cmd[R300_FP_CNTL1] = 0; r300->hw.fp.cmd[R300_FP_CNTL2] = 0; r300->hw.fp.cmd[R300_FP_NODE0] = 0; r300->hw.fp.cmd[R300_FP_NODE1] = 0; r300->hw.fp.cmd[R300_FP_NODE2] = 0; r300->hw.fp.cmd[R300_FP_NODE3] = 0;#endif r300->hw.unk46A4.cmd[1] = 0x00001B01; r300->hw.unk46A4.cmd[2] = 0x00001B0F; r300->hw.unk46A4.cmd[3] = 0x00001B0F; r300->hw.unk46A4.cmd[4] = 0x00001B0F; r300->hw.unk46A4.cmd[5] = 0x00000001;#if 0 for(i = 1; i <= 64; ++i) { /* create NOP instructions */ r300->hw.fpi[0].cmd[i] = FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO)); r300->hw.fpi[1].cmd[i] = FP_SELC(0,XYZ,NO,FP_TMP(0),0,0); r300->hw.fpi[2].cmd[i] = FP_INSTRA(MAD, FP_ARGA(SRC0A), FP_ARGA(ONE), FP_ARGA(ZERO)); r300->hw.fpi[3].cmd[i] = FP_SELA(0,W,NO,FP_TMP(0),0,0); }#endif r300->hw.unk4BC0.cmd[1] = 0; r300->hw.unk4BC8.cmd[1] = 0; r300->hw.unk4BC8.cmd[2] = 0; r300->hw.unk4BC8.cmd[3] = 0; r300->hw.at.cmd[R300_AT_UNKNOWN] = 0; r300->hw.unk4BD8.cmd[1] = 0; r300->hw.unk4E00.cmd[1] = 0;#if 0 r300->hw.bld.cmd[R300_BLD_CBLEND] = 0; r300->hw.bld.cmd[R300_BLD_ABLEND] = 0;#endif r300BlendColor(ctx, ctx->Color.BlendColor); r300->hw.unk4E10.cmd[2] = 0; r300->hw.unk4E10.cmd[3] = 0; /* Again, r300ClearBuffer uses this */ r300->hw.cb.cmd[R300_CB_OFFSET] = r300->radeon.state.color.drawOffset + r300->radeon.radeonScreen->fbLocation; r300->hw.cb.cmd[R300_CB_PITCH] = r300->radeon.state.color.drawPitch; if (r300->radeon.radeonScreen->cpp == 4) r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_ARGB8888; else r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_RGB565; if (r300->radeon.sarea->tiling_enabled) r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_TILE_ENABLE; r300->hw.unk4E50.cmd[1] = 0; r300->hw.unk4E50.cmd[2] = 0; r300->hw.unk4E50.cmd[3] = 0; r300->hw.unk4E50.cmd[4] = 0; r300->hw.unk4E50.cmd[5] = 0; r300->hw.unk4E50.cmd[6] = 0; r300->hw.unk4E50.cmd[7] = 0; r300->hw.unk4E50.cmd[8] = 0; r300->hw.unk4E50.cmd[9] = 0; r300->hw.unk4E88.cmd[1] = 0; r300->hw.unk4EA0.cmd[1] = 0x00000000; r300->hw.unk4EA0.cmd[2] = 0xffffffff; switch (ctx->Visual.depthBits) { case 16: r300->hw.unk4F10.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z; break; case 24: r300->hw.unk4F10.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z; break; default: fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits); exit(-1); } /* z compress? */ //r300->hw.unk4F10.cmd[1] |= R300_DEPTH_FORMAT_UNK32; r300->hw.unk4F10.cmd[3] = 0x00000003; r300->hw.unk4F10.cmd[4] = 0x00000000; r300->hw.zb.cmd[R300_ZB_OFFSET] = r300->radeon.radeonScreen->depthOffset + r300->radeon.radeonScreen->fbLocation; r300->hw.zb.cmd[R300_ZB_PITCH] = r300->radeon.radeonScreen->depthPitch; if (r300->radeon.sarea->tiling_enabled) { /* Turn off when clearing buffers ? */ r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTH_TILE_ENABLE; if (ctx->Visual.depthBits == 24) r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTH_MICROTILE_ENABLE; } r300->hw.unk4F28.cmd[1] = 0; r300->hw.unk4F30.cmd[1] = 0; r300->hw.unk4F30.cmd[2] = 0; r300->hw.unk4F44.cmd[1] = 0; r300->hw.unk4F54.cmd[1] = 0;#if 0 ((drm_r300_cmd_header_t*)r300->hw.vpi.cmd)->vpu.count = 0; for(i = 1; i < R300_VPI_CMDSIZE; i += 4) { /* MOV t0, t0 */ r300->hw.vpi.cmd[i+0] = VP_OUT(ADD,TMP,0,XYZW); r300->hw.vpi.cmd[i+1] = VP_IN(TMP,0); r300->hw.vpi.cmd[i+2] = VP_ZERO(); r300->hw.vpi.cmd[i+3] = VP_ZERO(); } ((drm_r300_cmd_header_t*)r300->hw.vpp.cmd)->vpu.count = 0; for(i = 1; i < R300_VPP_CMDSIZE; ++i) r300->hw.vpp.cmd[i] = 0;#endif r300->hw.vps.cmd[R300_VPS_ZERO_0] = 0; r300->hw.vps.cmd[R300_VPS_ZERO_1] = 0; r300->hw.vps.cmd[R300_VPS_POINTSIZE] = r300PackFloat32(1.0); r300->hw.vps.cmd[R300_VPS_ZERO_3] = 0;//END: TODO r300->hw.all_dirty = GL_TRUE;}/** * Calculate initial hardware state and register state functions. * Assumes that the command buffer and state atoms have been * initialized already. */void r300InitState(r300ContextPtr r300){ GLcontext *ctx = r300->radeon.glCtx; GLuint depth_fmt; radeonInitState(&r300->radeon); switch (ctx->Visual.depthBits) { case 16: r300->state.depth.scale = 1.0 / (GLfloat) 0xffff; depth_fmt = R200_DEPTH_FORMAT_16BIT_INT_Z; r300->state.stencil.clear = 0x00000000; break; case 24: r300->state.depth.scale = 1.0 / (GLfloat) 0xffffff; depth_fmt = R200_DEPTH_FORMAT_24BIT_INT_Z; r300->state.stencil.clear = 0x00ff0000; break; default: fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits); exit(-1); } /* Only have hw stencil when depth buffer is 24 bits deep */ r300->state.stencil.hw_stencil = (ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24); memset(&(r300->state.texture), 0, sizeof(r300->state.texture)); r300ResetHwState(r300);}static void r300RenderMode( GLcontext *ctx, GLenum mode ){ r300ContextPtr rmesa = R300_CONTEXT(ctx); (void)rmesa; (void)mode;}/** * Initialize driver's state callback functions */void r300InitStateFuncs(struct dd_function_table* functions){ radeonInitStateFuncs(functions); functions->UpdateState = r300InvalidateState; functions->AlphaFunc = r300AlphaFunc; functions->BlendColor = r300BlendColor; functions->BlendEquationSeparate = r300BlendEquationSeparate; functions->BlendFuncSeparate = r300BlendFuncSeparate; functions->Enable = r300Enable; functions->ColorMask = r300ColorMask; functions->DepthFunc = r300DepthFunc; functions->DepthMask = r300DepthMask; functions->CullFace = r300CullFace; functions->FrontFace = r300FrontFace; functions->ShadeModel = r300ShadeModel; /* Stencil related */ functions->ClearStencil = r300ClearStencil; functions->StencilFuncSeparate = r300StencilFuncSeparate; functions->StencilMaskSeparate = r300StencilMaskSeparate; functions->StencilOpSeparate = r300StencilOpSeparate; /* Viewport related */ functions->Viewport = r300Viewport; functions->DepthRange = r300DepthRange; functions->PointSize = r300PointSize; functions->LineWidth = r300LineWidth; functions->PolygonOffset = r300PolygonOffset; functions->PolygonMode = r300PolygonMode; functions->RenderMode = r300RenderMode;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -