Track Radeon driver symlinks in Git.
[mesa.git] / src / mesa / drivers / dri / r300 / r300_context.c
index f16e5486f67a271ec586c0099cbca6fbddb731d2..6f3aab986d236269f06a2c8ef3a5f57d342b1ef8 100644 (file)
@@ -64,6 +64,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_ioctl.h"
 #include "r300_tex.h"
 #include "r300_emit.h"
+#include "r300_render.h"
 #include "r300_swtcl.h"
 #include "radeon_bocs_wrapper.h"
 
@@ -72,10 +73,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "utils.h"
 #include "xmlpool.h"           /* for symbolic values of enum-type options */
 
-/* hw_tcl_on derives from future_hw_tcl_on when its safe to change it. */
-int future_hw_tcl_on = 1;
-int hw_tcl_on = 1;
-
 #define need_GL_VERSION_2_0
 #define need_GL_ARB_point_parameters
 #define need_GL_ARB_vertex_program
@@ -127,6 +124,8 @@ const struct dri_extension card_extensions[] = {
   {"GL_EXT_texture_lod_bias",          NULL},
   {"GL_EXT_texture_mirror_clamp",      NULL},
   {"GL_EXT_texture_rectangle",         NULL},
+  {"GL_EXT_texture_sRGB",              NULL},
+  {"GL_EXT_vertex_array_bgra",         NULL},
   {"GL_ATI_separate_stencil",          GL_ATI_separate_stencil_functions},
   {"GL_ATI_texture_env_combine3",      NULL},
   {"GL_ATI_texture_mirror_once",       NULL},
@@ -154,16 +153,8 @@ const struct dri_extension gl_20_extension[] = {
   {"GL_VERSION_2_0",                   GL_VERSION_2_0_functions },
 };
 
-
-extern struct tnl_pipeline_stage _r300_render_stage;
-extern const struct tnl_pipeline_stage _r300_tcl_stage;
-
 static const struct tnl_pipeline_stage *r300_pipeline[] = {
 
-       /* Try and go straight to t&l
-        */
-       &_r300_tcl_stage,
-
        /* Catch any t&l fallbacks
         */
        &_tnl_vertex_transform_stage,
@@ -172,6 +163,7 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = {
        &_tnl_fog_coordinate_stage,
        &_tnl_texgen_stage,
        &_tnl_texture_transform_stage,
+       &_tnl_point_attenuation_stage,
        &_tnl_vertex_program_stage,
 
        /* Try again to go to tcl?
@@ -274,13 +266,20 @@ static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
            driQueryOptioni(&r300->radeon.optionCache, "texture_coord_units");
        ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureImageUnits,
                 ctx->Const.MaxTextureCoordUnits);
+
        ctx->Const.MaxTextureMaxAnisotropy = 16.0;
        ctx->Const.MaxTextureLodBias = 16.0;
 
-       if (screen->chip_family >= CHIP_FAMILY_RV515)
+       if (screen->chip_family >= CHIP_FAMILY_RV515) {
                ctx->Const.MaxTextureLevels = 13;
-       else
+               ctx->Const.MaxCubeTextureLevels = 13;
+               ctx->Const.MaxTextureRectSize = 4096;
+       }
+       else {
                ctx->Const.MaxTextureLevels = 12;
+               ctx->Const.MaxCubeTextureLevels = 12;
+               ctx->Const.MaxTextureRectSize = 2048;
+       }
 
        ctx->Const.MinPointSize = 1.0;
        ctx->Const.MinPointSizeAA = 1.0;
@@ -295,7 +294,7 @@ static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
        ctx->Const.MaxDrawBuffers = 1;
 
        /* currently bogus data */
-       if (screen->chip_flags & RADEON_CHIPSET_TCL) {
+       if (r300->options.hw_tcl_enabled) {
                ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
                ctx->Const.VertexProgram.MaxNativeInstructions =
                  VSF_MAX_FRAGMENT_LENGTH / 4;
@@ -307,16 +306,67 @@ static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
                ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
        }
 
-       ctx->Const.FragmentProgram.MaxNativeTemps = PFS_NUM_TEMP_REGS;
-       ctx->Const.FragmentProgram.MaxNativeAttribs = 11;       /* copy i915... */
-       ctx->Const.FragmentProgram.MaxNativeParameters = PFS_NUM_CONST_REGS;
-       ctx->Const.FragmentProgram.MaxNativeAluInstructions = PFS_MAX_ALU_INST;
-       ctx->Const.FragmentProgram.MaxNativeTexInstructions = PFS_MAX_TEX_INST;
-       ctx->Const.FragmentProgram.MaxNativeInstructions =
-           PFS_MAX_ALU_INST + PFS_MAX_TEX_INST;
-       ctx->Const.FragmentProgram.MaxNativeTexIndirections =
-           PFS_MAX_TEX_INDIRECT;
-       ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0;
+       if (screen->chip_family >= CHIP_FAMILY_RV515) {
+               ctx->Const.FragmentProgram.MaxNativeTemps = R500_PFS_NUM_TEMP_REGS;
+               ctx->Const.FragmentProgram.MaxNativeAttribs = 11;       /* copy i915... */
+               ctx->Const.FragmentProgram.MaxNativeParameters = R500_PFS_NUM_CONST_REGS;
+               ctx->Const.FragmentProgram.MaxNativeAluInstructions = R500_PFS_MAX_INST;
+               ctx->Const.FragmentProgram.MaxNativeTexInstructions = R500_PFS_MAX_INST;
+               ctx->Const.FragmentProgram.MaxNativeInstructions = R500_PFS_MAX_INST;
+               ctx->Const.FragmentProgram.MaxNativeTexIndirections = R500_PFS_MAX_INST;
+               ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0;
+       } else {
+               ctx->Const.FragmentProgram.MaxNativeTemps = R300_PFS_NUM_TEMP_REGS;
+               ctx->Const.FragmentProgram.MaxNativeAttribs = 11;       /* copy i915... */
+               ctx->Const.FragmentProgram.MaxNativeParameters = R300_PFS_NUM_CONST_REGS;
+               ctx->Const.FragmentProgram.MaxNativeAluInstructions = R300_PFS_MAX_ALU_INST;
+               ctx->Const.FragmentProgram.MaxNativeTexInstructions = R300_PFS_MAX_TEX_INST;
+               ctx->Const.FragmentProgram.MaxNativeInstructions = R300_PFS_MAX_ALU_INST + R300_PFS_MAX_TEX_INST;
+               ctx->Const.FragmentProgram.MaxNativeTexIndirections = R300_PFS_MAX_TEX_INDIRECT;
+               ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0;
+       }
+}
+
+static void r300ParseOptions(r300ContextPtr r300, radeonScreenPtr screen)
+{
+       struct r300_options options = { 0 };
+
+       driParseConfigFiles(&r300->radeon.optionCache, &screen->optionCache,
+                           screen->driScreen->myNum, "r300");
+
+       r300->radeon.initialMaxAnisotropy = driQueryOptionf(&r300->radeon.optionCache, "def_max_anisotropy");
+
+       options.stencil_two_side_disabled = driQueryOptionb(&r300->radeon.optionCache, "disable_stencil_two_side");
+       options.s3tc_force_enabled = driQueryOptionb(&r300->radeon.optionCache, "force_s3tc_enable");
+       options.s3tc_force_disabled = driQueryOptionb(&r300->radeon.optionCache, "disable_s3tc");
+
+       if (!(screen->chip_flags & RADEON_CHIPSET_TCL) || driQueryOptioni(&r300->radeon.optionCache, "tcl_mode") == DRI_CONF_TCL_SW)
+               options.hw_tcl_enabled = 0;
+       else
+               options.hw_tcl_enabled = 1;
+
+       options.conformance_mode = !driQueryOptionb(&r300->radeon.optionCache, "disable_lowimpact_fallback");
+
+       r300->options = options;
+}
+
+static void r300InitGLExtensions(GLcontext *ctx)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+       driInitExtensions(ctx, card_extensions, GL_TRUE);
+       if (r300->radeon.radeonScreen->kernel_mm)
+               driInitExtensions(ctx, mm_extensions, GL_FALSE);
+
+       if (r300->options.stencil_two_side_disabled)
+               _mesa_disable_extension(ctx, "GL_EXT_stencil_two_side");
+
+       if (ctx->Mesa_DXTn && !r300->options.s3tc_force_enabled) {
+               _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+               _mesa_enable_extension(ctx, "GL_S3_s3tc");
+       } else if (r300->options.s3tc_force_disabled) {
+               _mesa_disable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+       }
 }
 
 /* Create the device specific rendering context.
@@ -330,7 +380,6 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        struct dd_function_table functions;
        r300ContextPtr r300;
        GLcontext *ctx;
-       int tcl_mode;
 
        assert(glVisual);
        assert(driContextPriv);
@@ -340,11 +389,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        if (!r300)
                return GL_FALSE;
 
-       if (!(screen->chip_flags & RADEON_CHIPSET_TCL))
-               hw_tcl_on = future_hw_tcl_on = 0;
-
-       driParseConfigFiles(&r300->radeon.optionCache, &screen->optionCache,
-                           screen->driScreen->myNum, "r300");
+       r300ParseOptions(r300, screen);
 
        r300_init_vtbl(&r300->radeon);
 
@@ -362,10 +407,17 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        }
 
        ctx = r300->radeon.glCtx;
-       r300InitConstValues(ctx, screen);
-       ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
+
+       r300->fallback = 0;
+       if (r300->options.hw_tcl_enabled)
+               ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
+
        ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
 
+       r300InitConstValues(ctx, screen);
+
+       _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
+
        /* Initialize the software rasterizer and helper modules.
         */
        _swrast_CreateContext(ctx);
@@ -373,7 +425,6 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        _tnl_CreateContext(ctx);
        _swsetup_CreateContext(ctx);
        _swsetup_Wakeup(ctx);
-       _ae_create_context(ctx);
 
        /* Install the customized pipeline:
         */
@@ -388,50 +439,24 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        _tnl_allow_pixel_fog(ctx, GL_FALSE);
        _tnl_allow_vertex_fog(ctx, GL_TRUE);
 
+       if (r300->options.hw_tcl_enabled) {
+               r300InitDraw(ctx);
+       } else {
+               r300InitSwtcl(ctx);
+       }
+
        radeon_fbo_init(&r300->radeon);
-       radeonInitSpanFuncs( ctx );
+       radeonInitSpanFuncs( ctx );
        r300InitCmdBuf(r300);
        r300InitState(r300);
-       if (!(screen->chip_flags & RADEON_CHIPSET_TCL))
-               r300InitSwtcl(ctx);
-
-       driInitExtensions(ctx, card_extensions, GL_TRUE);
-       if (r300->radeon.radeonScreen->kernel_mm)
-         driInitExtensions(ctx, mm_extensions, GL_FALSE);
+       r300InitShaderFunctions(r300);
 
-       r300->radeon.initialMaxAnisotropy = driQueryOptionf(&r300->radeon.optionCache,
-                                                    "def_max_anisotropy");
-
-       if (driQueryOptionb(&r300->radeon.optionCache, "disable_stencil_two_side"))
-               _mesa_disable_extension(ctx, "GL_EXT_stencil_two_side");
-
-       if (ctx->Mesa_DXTn && !driQueryOptionb(&r300->radeon.optionCache, "disable_s3tc")) {
-               _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
-               _mesa_enable_extension(ctx, "GL_S3_s3tc");
-       } else if (driQueryOptionb(&r300->radeon.optionCache, "force_s3tc_enable")) {
-               _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+       if (screen->chip_family == CHIP_FAMILY_RS600 || screen->chip_family == CHIP_FAMILY_RS690 ||
+               screen->chip_family == CHIP_FAMILY_RS740) {
+               r300->radeon.texture_row_align = 64;
        }
 
-       r300->disable_lowimpact_fallback =
-                driQueryOptionb(&r300->radeon.optionCache, "disable_lowimpact_fallback");
-
-       tcl_mode = driQueryOptioni(&r300->radeon.optionCache, "tcl_mode");
-       if (driQueryOptionb(&r300->radeon.optionCache, "no_rast")) {
-               fprintf(stderr, "disabling 3D acceleration\n");
-#if R200_MERGED
-               FALLBACK(&r300->radeon, RADEON_FALLBACK_DISABLE, 1);
-#endif
-       }
-       if (tcl_mode == DRI_CONF_TCL_SW ||
-           !(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
-               if (r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
-                       r300->radeon.radeonScreen->chip_flags &=
-                           ~RADEON_CHIPSET_TCL;
-                       fprintf(stderr, "Disabling HW TCL support\n");
-               }
-               TCL_FALLBACK(r300->radeon.glCtx,
-                            RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
-       }
+       r300InitGLExtensions(ctx);
 
        return GL_TRUE;
 }