Merge remote-tracking branch 'origin/master' into pipe-video
[mesa.git] / src / mesa / drivers / dri / r300 / r300_context.c
index 364e0ba6b6147f07e7c36b716a87b196f7a6b41e..213d3c060a689bfe980ed1e8a16534ec7e235e6a 100644 (file)
@@ -43,6 +43,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/extensions.h"
 #include "main/bufferobj.h"
 #include "main/texobj.h"
+#include "main/mfeatures.h"
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
@@ -61,6 +62,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_state.h"
 #include "r300_tex.h"
 #include "r300_emit.h"
+#include "r300_render.h"
 #include "r300_swtcl.h"
 #include "radeon_bocs_wrapper.h"
 #include "radeon_buffer_objects.h"
@@ -85,6 +87,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_EXT_stencil_two_side
 #define need_GL_ATI_separate_stencil
 #define need_GL_NV_vertex_program
+#define need_GL_OES_EGL_image
 
 #include "main/remap_helper.h"
 
@@ -130,10 +133,11 @@ static const struct dri_extension card_extensions[] = {
   {"GL_ATI_texture_mirror_once",       NULL},
   {"GL_MESA_pack_invert",              NULL},
   {"GL_MESA_ycbcr_texture",            NULL},
-  {"GL_MESAX_texture_float",           NULL},
   {"GL_NV_blend_square",               NULL},
   {"GL_NV_vertex_program",             GL_NV_vertex_program_functions},
-  {"GL_SGIS_generate_mipmap",          NULL},
+#if FEATURE_OES_EGL_image
+  {"GL_OES_EGL_image",                  GL_OES_EGL_image_functions },
+#endif
   {NULL,                               NULL}
   /* *INDENT-ON* */
 };
@@ -219,13 +223,15 @@ static void r300_vtbl_pre_emit_atoms(radeonContextPtr radeon)
        end_3d(radeon);
 }
 
-static void r300_fallback(GLcontext *ctx, GLuint bit, GLboolean mode)
+static void r300_fallback(struct gl_context *ctx, GLuint bit, GLboolean mode)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        if (mode)
                r300->radeon.Fallback |= bit;
        else
                r300->radeon.Fallback &= ~bit;
+
+       r300SwitchFallback(ctx, R300_FALLBACK_RADEON_COMMON, mode);
 }
 
 static void r300_emit_query_finish(radeonContextPtr radeon)
@@ -329,7 +335,7 @@ static void r300_init_vtbl(radeonContextPtr radeon)
        }
 }
 
-static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
+static void r300InitConstValues(struct gl_context *ctx, radeonScreenPtr screen)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
 
@@ -373,13 +379,12 @@ static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
        ctx->Const.MaxDrawBuffers = 1;
        ctx->Const.MaxColorAttachments = 1;
 
-       /* currently bogus data */
        if (r300->options.hw_tcl_enabled) {
-               ctx->Const.VertexProgram.MaxNativeInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
-               ctx->Const.VertexProgram.MaxNativeAluInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
-               ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */
+               ctx->Const.VertexProgram.MaxNativeInstructions = 255;
+               ctx->Const.VertexProgram.MaxNativeAluInstructions = 255;
+               ctx->Const.VertexProgram.MaxNativeAttribs = 16;
                ctx->Const.VertexProgram.MaxNativeTemps = 32;
-               ctx->Const.VertexProgram.MaxNativeParameters = 256;     /* r420 */
+               ctx->Const.VertexProgram.MaxNativeParameters = 256;
                ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
        }
 
@@ -438,7 +443,7 @@ static void r300ParseOptions(r300ContextPtr r300, radeonScreenPtr screen)
        r300->options = options;
 }
 
-static void r300InitGLExtensions(GLcontext *ctx)
+static void r300InitGLExtensions(struct gl_context *ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
 
@@ -459,7 +464,7 @@ static void r300InitGLExtensions(GLcontext *ctx)
        if (!r300->radeon.radeonScreen->drmSupportsOcclusionQueries) {
                _mesa_disable_extension(ctx, "GL_ARB_occlusion_query");
        }
-       if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV350)
+        if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_R420)
                _mesa_enable_extension(ctx, "GL_ARB_half_float_vertex");
 
        if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
@@ -475,7 +480,8 @@ static void r300InitIoctlFuncs(struct dd_function_table *functions)
 
 /* Create the device specific rendering context.
  */
-GLboolean r300CreateContext(const __GLcontextModes * glVisual,
+GLboolean r300CreateContext(gl_api api,
+                           const struct gl_config * glVisual,
                            __DRIcontext * driContextPriv,
                            void *sharedContextPrivate)
 {
@@ -483,7 +489,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
        struct dd_function_table functions;
        r300ContextPtr r300;
-       GLcontext *ctx;
+       struct gl_context *ctx;
 
        assert(glVisual);
        assert(driContextPriv);
@@ -500,7 +506,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
 
        _mesa_init_driver_functions(&functions);
        r300InitIoctlFuncs(&functions);
-       r300InitStateFuncs(&functions);
+       r300InitStateFuncs(&r300->radeon, &functions);
        r300InitTextureFuncs(&r300->radeon, &functions);
        r300InitShaderFuncs(&functions);
        radeonInitQueryObjFunctions(&functions);