~ubuntu-branches/ubuntu/raring/mesa/raring-proposed

« back to all changes in this revision

Viewing changes to src/mesa/main/context.c

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2011-06-19 21:26:00 UTC
  • mfrom: (1.6.1 upstream) (3.3.18 sid)
  • mto: (3.3.20 sid)
  • mto: This revision was merged to the branch mainline in revision 145.
  • Revision ID: james.westby@ubuntu.com-20110619212600-rleaapdmnbtstekb
Tags: 7.11~0-2
Thank you sbuild for giving a green light when that's not actually the
case. Fix missing Pre-Depends for the libegl1-mesa-drivers package
(multiarch-support).

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
#include "fbobject.h"
97
97
#include "feedback.h"
98
98
#include "fog.h"
 
99
#include "formats.h"
99
100
#include "framebuffer.h"
100
101
#include "hint.h"
101
102
#include "hash.h"
190
191
 * is acceptable but the actual depth type will be GLushort or GLuint as
191
192
 * needed.
192
193
 * \param stencilBits requested minimum bits per stencil buffer value
193
 
 * \param accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits number of bits per color component in accum buffer.
 
194
 * \param accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits number
 
195
 * of bits per color component in accum buffer.
194
196
 * \param indexBits number of bits per pixel if \p rgbFlag is GL_FALSE
195
197
 * \param redBits number of bits per color component in frame buffer for RGB(A)
196
198
 * mode.  We always use 8 in core Mesa though.
199
201
 * \param alphaBits same as above.
200
202
 * \param numSamples not really used.
201
203
 * 
202
 
 * \return pointer to new struct gl_config or NULL if requested parameters can't be
203
 
 * met.
 
204
 * \return pointer to new struct gl_config or NULL if requested parameters
 
205
 * can't be met.
204
206
 *
205
207
 * \note Need to add params for level and numAuxBuffers (at least)
206
208
 */
417
419
                     MESA_VERSION_STRING, __DATE__, __TIME__);
418
420
      }
419
421
#endif
 
422
 
 
423
#ifdef DEBUG
 
424
      _mesa_test_formats();
 
425
#endif
420
426
   }
421
427
 
422
428
   /* per-API one-time init */
481
487
   prog->MaxTemps = MAX_PROGRAM_TEMPS;
482
488
   prog->MaxEnvParams = MAX_PROGRAM_ENV_PARAMS;
483
489
   prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
484
 
   prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
 
490
   prog->MaxAddressOffset = MAX_PROGRAM_LOCAL_PARAMS;
485
491
 
486
492
   switch (type) {
487
493
   case GL_VERTEX_PROGRAM_ARB:
488
494
      prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS;
489
495
      prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
490
496
      prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
 
497
      prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
491
498
      break;
492
499
   case GL_FRAGMENT_PROGRAM_ARB:
493
500
      prog->MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
494
501
      prog->MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
495
502
      prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
 
503
      prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
496
504
      break;
497
505
   case MESA_GEOMETRY_PROGRAM:
498
506
      prog->MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS;
499
507
      prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
500
508
      prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
501
 
 
502
 
      prog->MaxGeometryTextureImageUnits = MAX_GEOMETRY_TEXTURE_IMAGE_UNITS;
503
 
      prog->MaxGeometryVaryingComponents = MAX_GEOMETRY_VARYING_COMPONENTS;
504
 
      prog->MaxVertexVaryingComponents = MAX_VERTEX_VARYING_COMPONENTS;
505
 
      prog->MaxGeometryUniformComponents = MAX_GEOMETRY_UNIFORM_COMPONENTS;
506
 
      prog->MaxGeometryOutputVertices = MAX_GEOMETRY_OUTPUT_VERTICES;
507
 
      prog->MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS;
 
509
      prog->MaxUniformComponents = MAX_GEOMETRY_UNIFORM_COMPONENTS;
508
510
      break;
509
511
   default:
510
512
      assert(0 && "Bad program type in init_program_limits()");
529
531
   prog->MediumFloat.RangeMax = 127;
530
532
   prog->MediumFloat.Precision = 23;
531
533
   prog->LowFloat = prog->HighFloat = prog->MediumFloat;
532
 
   /* assume ints are stored as floats for now */
533
 
   prog->LowInt = prog->MediumInt = prog->HighInt = prog->MediumFloat;
 
534
 
 
535
   /* Assume ints are stored as floats for now, since this is the least-common
 
536
    * denominator.  The OpenGL ES spec implies (page 132) that the precision
 
537
    * of integer types should be 0.  Practically speaking, IEEE
 
538
    * single-precision floating point values can only store integers in the
 
539
    * range [-0x01000000, 0x01000000] without loss of precision.
 
540
    */
 
541
   prog->MediumInt.RangeMin = 24;
 
542
   prog->MediumInt.RangeMax = 24;
 
543
   prog->MediumInt.Precision = 0;
 
544
   prog->LowInt = prog->HighInt = prog->MediumInt;
534
545
}
535
546
 
536
547
 
557
568
                                     ctx->Const.MaxTextureImageUnits);
558
569
   ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY;
559
570
   ctx->Const.MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS;
 
571
   ctx->Const.MaxTextureBufferSize = 65536;
560
572
   ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
561
573
   ctx->Const.SubPixelBits = SUB_PIXEL_BITS;
562
574
   ctx->Const.MinPointSize = MIN_POINT_SIZE;
604
616
   ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
605
617
   ctx->Const.MaxVarying = MAX_VARYING;
606
618
#endif
 
619
#if FEATURE_ARB_geometry_shader4
 
620
   ctx->Const.MaxGeometryTextureImageUnits = MAX_GEOMETRY_TEXTURE_IMAGE_UNITS;
 
621
   ctx->Const.MaxVertexVaryingComponents = MAX_VERTEX_VARYING_COMPONENTS;
 
622
   ctx->Const.MaxGeometryVaryingComponents = MAX_GEOMETRY_VARYING_COMPONENTS;
 
623
   ctx->Const.MaxGeometryOutputVertices = MAX_GEOMETRY_OUTPUT_VERTICES;
 
624
   ctx->Const.MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS;
 
625
#endif
607
626
 
608
627
   /* Shading language version */
609
628
   if (ctx->API == API_OPENGL) {
639
658
   /** GL_EXT_gpu_shader4 */
640
659
   ctx->Const.MinProgramTexelOffset = -8;
641
660
   ctx->Const.MaxProgramTexelOffset = 7;
 
661
 
 
662
   /* GL_ARB_robustness */
 
663
   ctx->Const.ResetStrategy = GL_NO_RESET_NOTIFICATION_ARB;
642
664
}
643
665
 
644
666
 
774
796
   /* Miscellaneous */
775
797
   ctx->NewState = _NEW_ALL;
776
798
   ctx->ErrorValue = (GLenum) GL_NO_ERROR;
 
799
   ctx->ResetStatus = (GLenum) GL_NO_ERROR;
777
800
   ctx->varying_vp_inputs = ~0;
778
801
 
779
802
   return GL_TRUE;
872
895
 * \param driverContext pointer to driver-specific context data
873
896
 */
874
897
GLboolean
875
 
_mesa_initialize_context_for_api(struct gl_context *ctx,
876
 
                                 gl_api api,
877
 
                                 const struct gl_config *visual,
878
 
                                 struct gl_context *share_list,
879
 
                                 const struct dd_function_table *driverFunctions,
880
 
                                 void *driverContext)
 
898
_mesa_initialize_context(struct gl_context *ctx,
 
899
                         gl_api api,
 
900
                         const struct gl_config *visual,
 
901
                         struct gl_context *share_list,
 
902
                         const struct dd_function_table *driverFunctions,
 
903
                         void *driverContext)
881
904
{
882
905
   struct gl_shared_state *shared;
883
906
   int i;
965
988
      ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
966
989
   }
967
990
 
 
991
   /* Mesa core handles all the formats that mesa core knows about.
 
992
    * Drivers will want to override this list with just the formats
 
993
    * they can handle, and confirm that appropriate fallbacks exist in
 
994
    * _mesa_choose_tex_format().
 
995
    */
 
996
   memset(&ctx->TextureFormatSupported, GL_TRUE,
 
997
          sizeof(ctx->TextureFormatSupported));
 
998
 
968
999
   switch (ctx->API) {
969
1000
   case API_OPENGL:
970
1001
#if FEATURE_dlist
1007
1038
 
1008
1039
 
1009
1040
/**
1010
 
 * Initialize an OpenGL context.
1011
 
 */
1012
 
GLboolean
1013
 
_mesa_initialize_context(struct gl_context *ctx,
1014
 
                         const struct gl_config *visual,
1015
 
                         struct gl_context *share_list,
1016
 
                         const struct dd_function_table *driverFunctions,
1017
 
                         void *driverContext)
1018
 
{
1019
 
   return _mesa_initialize_context_for_api(ctx,
1020
 
                                           API_OPENGL,
1021
 
                                           visual,
1022
 
                                           share_list,
1023
 
                                           driverFunctions,
1024
 
                                           driverContext);
1025
 
}
1026
 
 
1027
 
 
1028
 
/**
1029
1041
 * Allocate and initialize a struct gl_context structure.
1030
1042
 * Note that the driver needs to pass in its dd_function_table here since
1031
1043
 * we need to at least call driverFunctions->NewTextureObject to initialize
1041
1053
 * \return pointer to a new __struct gl_contextRec or NULL if error.
1042
1054
 */
1043
1055
struct gl_context *
1044
 
_mesa_create_context_for_api(gl_api api,
1045
 
                             const struct gl_config *visual,
1046
 
                             struct gl_context *share_list,
1047
 
                             const struct dd_function_table *driverFunctions,
1048
 
                             void *driverContext)
 
1056
_mesa_create_context(gl_api api,
 
1057
                     const struct gl_config *visual,
 
1058
                     struct gl_context *share_list,
 
1059
                     const struct dd_function_table *driverFunctions,
 
1060
                     void *driverContext)
1049
1061
{
1050
1062
   struct gl_context *ctx;
1051
1063
 
1056
1068
   if (!ctx)
1057
1069
      return NULL;
1058
1070
 
1059
 
   if (_mesa_initialize_context_for_api(ctx, api, visual, share_list,
1060
 
                                        driverFunctions, driverContext)) {
 
1071
   if (_mesa_initialize_context(ctx, api, visual, share_list,
 
1072
                                driverFunctions, driverContext)) {
1061
1073
      return ctx;
1062
1074
   }
1063
1075
   else {
1068
1080
 
1069
1081
 
1070
1082
/**
1071
 
 * Create an OpenGL context.
1072
 
 */
1073
 
struct gl_context *
1074
 
_mesa_create_context(const struct gl_config *visual,
1075
 
                     struct gl_context *share_list,
1076
 
                     const struct dd_function_table *driverFunctions,
1077
 
                     void *driverContext)
1078
 
{
1079
 
   return _mesa_create_context_for_api(API_OPENGL, visual,
1080
 
                                       share_list,
1081
 
                                       driverFunctions,
1082
 
                                       driverContext);
1083
 
}
1084
 
 
1085
 
 
1086
 
/**
1087
1083
 * Free the data associated with the given context.
1088
1084
 * 
1089
1085
 * But doesn't free the struct gl_context struct itself.
1195
1191
 * structures.
1196
1192
 */
1197
1193
void
1198
 
_mesa_copy_context( const struct gl_context *src, struct gl_context *dst, GLuint mask )
 
1194
_mesa_copy_context( const struct gl_context *src, struct gl_context *dst,
 
1195
                    GLuint mask )
1199
1196
{
1200
1197
   if (mask & GL_ACCUM_BUFFER_BIT) {
1201
1198
      /* OK to memcpy */
1433
1430
   }
1434
1431
 
1435
1432
   if (curCtx && 
1436
 
      (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && /* make sure this context is valid for flushing */
 
1433
      (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
 
1434
       /* make sure this context is valid for flushing */
1437
1435
      curCtx != newCtx)
1438
1436
      _mesa_flush(curCtx);
1439
1437
 
1448
1446
      _glapi_set_dispatch(newCtx->CurrentDispatch);
1449
1447
 
1450
1448
      if (drawBuffer && readBuffer) {
1451
 
         /* TODO: check if newCtx and buffer's visual match??? */
1452
 
 
1453
1449
         ASSERT(drawBuffer->Name == 0);
1454
1450
         ASSERT(readBuffer->Name == 0);
1455
1451
         _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer);
1460
1456
          * or not bound to a user-created FBO.
1461
1457
          */
1462
1458
         if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
1463
 
            /* KW: merge conflict here, revisit. 
1464
 
             */
1465
 
            /* fix up the fb fields - these will end up wrong otherwise
1466
 
             * if the DRIdrawable changes, and everything relies on them.
1467
 
             * This is a bit messy (same as needed in _mesa_BindFramebufferEXT)
1468
 
             */
1469
 
            unsigned int i;
1470
 
            GLenum buffers[MAX_DRAW_BUFFERS];
1471
 
 
1472
1459
            _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
1473
 
 
1474
 
            for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) {
1475
 
               buffers[i] = newCtx->Color.DrawBuffer[i];
1476
 
            }
1477
 
 
1478
 
            _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers,
1479
 
                              buffers, NULL);
 
1460
            /* Update the FBO's list of drawbuffers/renderbuffers.
 
1461
             * For winsys FBOs this comes from the GL state (which may have
 
1462
             * changed since the last time this FBO was bound).
 
1463
             */
 
1464
            _mesa_update_draw_buffers(newCtx);
1480
1465
         }
1481
1466
         if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
1482
1467
            _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);