mesa: added gl_program_constants::MaxAddressOffset
[mesa.git] / src / mesa / main / context.c
index f42a566c30228ac7b5d1535cc6aa99dbbde31845..5d581c84002383334699ae9ea3ffea3b6791c35e 100644 (file)
@@ -96,6 +96,7 @@
 #include "fbobject.h"
 #include "feedback.h"
 #include "fog.h"
+#include "formats.h"
 #include "framebuffer.h"
 #include "hint.h"
 #include "hash.h"
@@ -417,6 +418,10 @@ one_time_init( struct gl_context *ctx )
                     MESA_VERSION_STRING, __DATE__, __TIME__);
       }
 #endif
+
+#ifdef DEBUG
+      _mesa_test_formats();
+#endif
    }
 
    /* per-API one-time init */
@@ -482,6 +487,7 @@ init_program_limits(GLenum type, struct gl_program_constants *prog)
    prog->MaxEnvParams = MAX_PROGRAM_ENV_PARAMS;
    prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
    prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
+   prog->MaxAddressOffset = MAX_PROGRAM_LOCAL_PARAMS;
 
    switch (type) {
    case GL_VERTEX_PROGRAM_ARB:
@@ -521,6 +527,25 @@ init_program_limits(GLenum type, struct gl_program_constants *prog)
    prog->MaxNativeTemps = 0;
    prog->MaxNativeAddressRegs = 0;
    prog->MaxNativeParameters = 0;
+
+   /* Set GLSL datatype range/precision info assuming IEEE float values.
+    * Drivers should override these defaults as needed.
+    */
+   prog->MediumFloat.RangeMin = 127;
+   prog->MediumFloat.RangeMax = 127;
+   prog->MediumFloat.Precision = 23;
+   prog->LowFloat = prog->HighFloat = prog->MediumFloat;
+
+   /* Assume ints are stored as floats for now, since this is the least-common
+    * denominator.  The OpenGL ES spec implies (page 132) that the precision
+    * of integer types should be 0.  Practically speaking, IEEE
+    * single-precision floating point values can only store integers in the
+    * range [-0x01000000, 0x01000000] without loss of precision.
+    */
+   prog->MediumInt.RangeMin = 24;
+   prog->MediumInt.RangeMax = 24;
+   prog->MediumInt.Precision = 0;
+   prog->LowInt = prog->HighInt = prog->MediumInt;
 }
 
 
@@ -862,12 +887,12 @@ _mesa_alloc_dispatch_table(int size)
  * \param driverContext pointer to driver-specific context data
  */
 GLboolean
-_mesa_initialize_context_for_api(struct gl_context *ctx,
-                                gl_api api,
-                                const struct gl_config *visual,
-                                struct gl_context *share_list,
-                                const struct dd_function_table *driverFunctions,
-                                void *driverContext)
+_mesa_initialize_context(struct gl_context *ctx,
+                         gl_api api,
+                         const struct gl_config *visual,
+                         struct gl_context *share_list,
+                         const struct dd_function_table *driverFunctions,
+                         void *driverContext)
 {
    struct gl_shared_state *shared;
    int i;
@@ -955,6 +980,14 @@ _mesa_initialize_context_for_api(struct gl_context *ctx,
       ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
    }
 
+   /* Mesa core handles all the formats that mesa core knows about.
+    * Drivers will want to override this list with just the formats
+    * they can handle, and confirm that appropriate fallbacks exist in
+    * _mesa_choose_tex_format().
+    */
+   memset(&ctx->TextureFormatSupported, GL_TRUE,
+         sizeof(ctx->TextureFormatSupported));
+
    switch (ctx->API) {
    case API_OPENGL:
 #if FEATURE_dlist
@@ -996,25 +1029,6 @@ _mesa_initialize_context_for_api(struct gl_context *ctx,
 }
 
 
-/**
- * Initialize an OpenGL context.
- */
-GLboolean
-_mesa_initialize_context(struct gl_context *ctx,
-                         const struct gl_config *visual,
-                         struct gl_context *share_list,
-                         const struct dd_function_table *driverFunctions,
-                         void *driverContext)
-{
-   return _mesa_initialize_context_for_api(ctx,
-                                          API_OPENGL,
-                                          visual,
-                                          share_list,
-                                          driverFunctions,
-                                          driverContext);
-}
-
-
 /**
  * Allocate and initialize a struct gl_context structure.
  * Note that the driver needs to pass in its dd_function_table here since
@@ -1031,11 +1045,11 @@ _mesa_initialize_context(struct gl_context *ctx,
  * \return pointer to a new __struct gl_contextRec or NULL if error.
  */
 struct gl_context *
-_mesa_create_context_for_api(gl_api api,
-                            const struct gl_config *visual,
-                            struct gl_context *share_list,
-                            const struct dd_function_table *driverFunctions,
-                            void *driverContext)
+_mesa_create_context(gl_api api,
+                     const struct gl_config *visual,
+                     struct gl_context *share_list,
+                     const struct dd_function_table *driverFunctions,
+                     void *driverContext)
 {
    struct gl_context *ctx;
 
@@ -1046,8 +1060,8 @@ _mesa_create_context_for_api(gl_api api,
    if (!ctx)
       return NULL;
 
-   if (_mesa_initialize_context_for_api(ctx, api, visual, share_list,
-                                       driverFunctions, driverContext)) {
+   if (_mesa_initialize_context(ctx, api, visual, share_list,
+                                driverFunctions, driverContext)) {
       return ctx;
    }
    else {
@@ -1057,22 +1071,6 @@ _mesa_create_context_for_api(gl_api api,
 }
 
 
-/**
- * Create an OpenGL context.
- */
-struct gl_context *
-_mesa_create_context(const struct gl_config *visual,
-                    struct gl_context *share_list,
-                    const struct dd_function_table *driverFunctions,
-                    void *driverContext)
-{
-   return _mesa_create_context_for_api(API_OPENGL, visual,
-                                      share_list,
-                                      driverFunctions,
-                                      driverContext);
-}
-
-
 /**
  * Free the data associated with the given context.
  *