~mmach/netext73/mesa_2004

« back to all changes in this revision

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

  • Committer: mmach
  • Date: 2021-03-12 20:48:59 UTC
  • Revision ID: netbit73@gmail.com-20210312204859-i194ujlcu82pq61p
21

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
valid_filter_for_float(const struct gl_context *ctx,
68
68
                       const struct gl_texture_object *obj)
69
69
{
70
 
   switch (obj->Sampler.MagFilter) {
 
70
   switch (obj->Sampler.Attrib.MagFilter) {
71
71
   case GL_LINEAR:
72
72
      if (obj->_IsHalfFloat && !ctx->Extensions.OES_texture_half_float_linear) {
73
73
         return false;
74
74
      } else if (obj->_IsFloat && !ctx->Extensions.OES_texture_float_linear) {
75
75
         return false;
76
76
      }
 
77
      FALLTHROUGH;
77
78
   case GL_NEAREST:
78
79
   case GL_NEAREST_MIPMAP_NEAREST:
79
80
      break;
81
82
      unreachable("Invalid mag filter");
82
83
   }
83
84
 
84
 
   switch (obj->Sampler.MinFilter) {
 
85
   switch (obj->Sampler.Attrib.MinFilter) {
85
86
   case GL_LINEAR:
86
87
   case GL_NEAREST_MIPMAP_LINEAR:
87
88
   case GL_LINEAR_MIPMAP_NEAREST:
91
92
      } else if (obj->_IsFloat && !ctx->Extensions.OES_texture_float_linear) {
92
93
         return false;
93
94
      }
 
95
      FALLTHROUGH;
94
96
   case GL_NEAREST:
95
97
   case GL_NEAREST_MIPMAP_NEAREST:
96
98
      break;
321
323
   else {
322
324
      obj->TargetIndex = NUM_TEXTURE_TARGETS; /* invalid/error value */
323
325
   }
324
 
   obj->Priority = 1.0F;
325
 
   obj->BaseLevel = 0;
326
 
   obj->MaxLevel = 1000;
 
326
   obj->Attrib.Priority = 1.0F;
 
327
   obj->Attrib.BaseLevel = 0;
 
328
   obj->Attrib.MaxLevel = 1000;
327
329
 
328
330
   /* must be one; no support for (YUV) planes in separate buffers */
329
331
   obj->RequiredTextureImageUnits = 1;
331
333
   /* sampler state */
332
334
   if (target == GL_TEXTURE_RECTANGLE_NV ||
333
335
       target == GL_TEXTURE_EXTERNAL_OES) {
334
 
      obj->Sampler.WrapS = GL_CLAMP_TO_EDGE;
335
 
      obj->Sampler.WrapT = GL_CLAMP_TO_EDGE;
336
 
      obj->Sampler.WrapR = GL_CLAMP_TO_EDGE;
337
 
      obj->Sampler.MinFilter = GL_LINEAR;
 
336
      obj->Sampler.Attrib.WrapS = GL_CLAMP_TO_EDGE;
 
337
      obj->Sampler.Attrib.WrapT = GL_CLAMP_TO_EDGE;
 
338
      obj->Sampler.Attrib.WrapR = GL_CLAMP_TO_EDGE;
 
339
      obj->Sampler.Attrib.MinFilter = GL_LINEAR;
338
340
   }
339
341
   else {
340
 
      obj->Sampler.WrapS = GL_REPEAT;
341
 
      obj->Sampler.WrapT = GL_REPEAT;
342
 
      obj->Sampler.WrapR = GL_REPEAT;
343
 
      obj->Sampler.MinFilter = GL_NEAREST_MIPMAP_LINEAR;
 
342
      obj->Sampler.Attrib.WrapS = GL_REPEAT;
 
343
      obj->Sampler.Attrib.WrapT = GL_REPEAT;
 
344
      obj->Sampler.Attrib.WrapR = GL_REPEAT;
 
345
      obj->Sampler.Attrib.MinFilter = GL_NEAREST_MIPMAP_LINEAR;
344
346
   }
345
 
   obj->Sampler.MagFilter = GL_LINEAR;
346
 
   obj->Sampler.MinLod = -1000.0;
347
 
   obj->Sampler.MaxLod = 1000.0;
348
 
   obj->Sampler.LodBias = 0.0;
349
 
   obj->Sampler.MaxAnisotropy = 1.0;
350
 
   obj->Sampler.CompareMode = GL_NONE;         /* ARB_shadow */
351
 
   obj->Sampler.CompareFunc = GL_LEQUAL;       /* ARB_shadow */
352
 
   obj->DepthMode = ctx->API == API_OPENGL_CORE ? GL_RED : GL_LUMINANCE;
353
 
   obj->StencilSampling = false;
354
 
   obj->Sampler.CubeMapSeamless = GL_FALSE;
 
347
   obj->Sampler.Attrib.MagFilter = GL_LINEAR;
 
348
   obj->Sampler.Attrib.MinLod = -1000.0;
 
349
   obj->Sampler.Attrib.MaxLod = 1000.0;
 
350
   obj->Sampler.Attrib.LodBias = 0.0;
 
351
   obj->Sampler.Attrib.MaxAnisotropy = 1.0;
 
352
   obj->Sampler.Attrib.CompareMode = GL_NONE;         /* ARB_shadow */
 
353
   obj->Sampler.Attrib.CompareFunc = GL_LEQUAL;       /* ARB_shadow */
 
354
   obj->Attrib.DepthMode = ctx->API == API_OPENGL_CORE ? GL_RED : GL_LUMINANCE;
 
355
   obj->Attrib.StencilSampling = false;
 
356
   obj->Sampler.Attrib.CubeMapSeamless = GL_FALSE;
355
357
   obj->Sampler.HandleAllocated = GL_FALSE;
356
 
   obj->Swizzle[0] = GL_RED;
357
 
   obj->Swizzle[1] = GL_GREEN;
358
 
   obj->Swizzle[2] = GL_BLUE;
359
 
   obj->Swizzle[3] = GL_ALPHA;
360
 
   obj->_Swizzle = SWIZZLE_NOOP;
361
 
   obj->Sampler.sRGBDecode = GL_DECODE_EXT;
 
358
   obj->Attrib.Swizzle[0] = GL_RED;
 
359
   obj->Attrib.Swizzle[1] = GL_GREEN;
 
360
   obj->Attrib.Swizzle[2] = GL_BLUE;
 
361
   obj->Attrib.Swizzle[3] = GL_ALPHA;
 
362
   obj->Attrib._Swizzle = SWIZZLE_NOOP;
 
363
   obj->Sampler.Attrib.sRGBDecode = GL_DECODE_EXT;
362
364
   obj->BufferObjectFormat = GL_R8;
363
365
   obj->_BufferObjectFormat = MESA_FORMAT_R_UNORM8;
364
366
   obj->ImageFormatCompatibilityType = GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE;
387
389
      case GL_TEXTURE_2D_MULTISAMPLE:
388
390
      case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
389
391
         filter = GL_NEAREST;
390
 
         /* fallthrough */
 
392
         FALLTHROUGH;
391
393
 
392
394
      case GL_TEXTURE_RECTANGLE_NV:
393
395
      case GL_TEXTURE_EXTERNAL_OES:
394
396
         /* have to init wrap and filter state here - kind of klunky */
395
 
         obj->Sampler.WrapS = GL_CLAMP_TO_EDGE;
396
 
         obj->Sampler.WrapT = GL_CLAMP_TO_EDGE;
397
 
         obj->Sampler.WrapR = GL_CLAMP_TO_EDGE;
398
 
         obj->Sampler.MinFilter = filter;
399
 
         obj->Sampler.MagFilter = filter;
 
397
         obj->Sampler.Attrib.WrapS = GL_CLAMP_TO_EDGE;
 
398
         obj->Sampler.Attrib.WrapT = GL_CLAMP_TO_EDGE;
 
399
         obj->Sampler.Attrib.WrapR = GL_CLAMP_TO_EDGE;
 
400
         obj->Sampler.Attrib.MinFilter = filter;
 
401
         obj->Sampler.Attrib.MagFilter = filter;
400
402
         if (ctx->Driver.TexParameter) {
401
403
            /* XXX we probably don't need to make all these calls */
402
404
            ctx->Driver.TexParameter(ctx, obj, GL_TEXTURE_WRAP_S);
458
460
 
459
461
 
460
462
/**
461
 
 * Copy texture object state from one texture object to another.
462
 
 * Use for glPush/PopAttrib.
463
 
 *
464
 
 * \param dest destination texture object.
465
 
 * \param src source texture object.
466
 
 */
467
 
void
468
 
_mesa_copy_texture_object( struct gl_texture_object *dest,
469
 
                           const struct gl_texture_object *src )
470
 
{
471
 
   dest->Target = src->Target;
472
 
   dest->TargetIndex = src->TargetIndex;
473
 
   dest->Name = src->Name;
474
 
   dest->Priority = src->Priority;
475
 
   dest->Sampler.BorderColor.f[0] = src->Sampler.BorderColor.f[0];
476
 
   dest->Sampler.BorderColor.f[1] = src->Sampler.BorderColor.f[1];
477
 
   dest->Sampler.BorderColor.f[2] = src->Sampler.BorderColor.f[2];
478
 
   dest->Sampler.BorderColor.f[3] = src->Sampler.BorderColor.f[3];
479
 
   dest->Sampler.WrapS = src->Sampler.WrapS;
480
 
   dest->Sampler.WrapT = src->Sampler.WrapT;
481
 
   dest->Sampler.WrapR = src->Sampler.WrapR;
482
 
   dest->Sampler.MinFilter = src->Sampler.MinFilter;
483
 
   dest->Sampler.MagFilter = src->Sampler.MagFilter;
484
 
   dest->Sampler.MinLod = src->Sampler.MinLod;
485
 
   dest->Sampler.MaxLod = src->Sampler.MaxLod;
486
 
   dest->Sampler.LodBias = src->Sampler.LodBias;
487
 
   dest->BaseLevel = src->BaseLevel;
488
 
   dest->MaxLevel = src->MaxLevel;
489
 
   dest->Sampler.MaxAnisotropy = src->Sampler.MaxAnisotropy;
490
 
   dest->Sampler.CompareMode = src->Sampler.CompareMode;
491
 
   dest->Sampler.CompareFunc = src->Sampler.CompareFunc;
492
 
   dest->Sampler.CubeMapSeamless = src->Sampler.CubeMapSeamless;
493
 
   dest->DepthMode = src->DepthMode;
494
 
   dest->StencilSampling = src->StencilSampling;
495
 
   dest->Sampler.sRGBDecode = src->Sampler.sRGBDecode;
496
 
   dest->_MaxLevel = src->_MaxLevel;
497
 
   dest->_MaxLambda = src->_MaxLambda;
498
 
   dest->GenerateMipmap = src->GenerateMipmap;
499
 
   dest->_BaseComplete = src->_BaseComplete;
500
 
   dest->_MipmapComplete = src->_MipmapComplete;
501
 
   COPY_4V(dest->Swizzle, src->Swizzle);
502
 
   dest->_Swizzle = src->_Swizzle;
503
 
   dest->_IsHalfFloat = src->_IsHalfFloat;
504
 
   dest->_IsFloat = src->_IsFloat;
505
 
 
506
 
   dest->RequiredTextureImageUnits = src->RequiredTextureImageUnits;
507
 
}
508
 
 
509
 
 
510
 
/**
511
463
 * Free all texture images of the given texture objectm, except for
512
464
 * \p retainTexImage.
513
465
 *
680
632
_mesa_test_texobj_completeness( const struct gl_context *ctx,
681
633
                                struct gl_texture_object *t )
682
634
{
683
 
   const GLint baseLevel = t->BaseLevel;
 
635
   const GLint baseLevel = t->Attrib.BaseLevel;
684
636
   const struct gl_texture_image *baseImage;
685
637
   GLint maxLevels = 0;
686
638
 
704
656
      return;
705
657
   }
706
658
 
707
 
   if (t->MaxLevel < baseLevel) {
 
659
   if (t->Attrib.MaxLevel < baseLevel) {
708
660
      incomplete(t, MIPMAP, "MAX_LEVEL (%d) < BASE_LEVEL (%d)",
709
 
                 t->MaxLevel, baseLevel);
 
661
                 t->Attrib.MaxLevel, baseLevel);
710
662
      return;
711
663
   }
712
664
 
748
700
 
749
701
   assert(maxLevels > 0);
750
702
 
751
 
   t->_MaxLevel = MIN3(t->MaxLevel,
 
703
   t->_MaxLevel = MIN3(t->Attrib.MaxLevel,
752
704
                       /* 'p' in the GL spec */
753
705
                       (int) (baseLevel + baseImage->MaxNumLevels - 1),
754
706
                       /* 'q' in the GL spec */
924
876
GLboolean
925
877
_mesa_cube_complete(const struct gl_texture_object *texObj)
926
878
{
927
 
   return _mesa_cube_level_complete(texObj, texObj->BaseLevel);
 
879
   return _mesa_cube_level_complete(texObj, texObj->Attrib.BaseLevel);
928
880
}
929
881
 
930
882
/**
1032
984
         return NULL;
1033
985
 
1034
986
      assert(texObj->RefCount == 1);
1035
 
      texObj->Sampler.MinFilter = GL_NEAREST;
1036
 
      texObj->Sampler.MagFilter = GL_NEAREST;
 
987
      texObj->Sampler.Attrib.MinFilter = GL_NEAREST;
 
988
      texObj->Sampler.Attrib.MagFilter = GL_NEAREST;
1037
989
 
1038
990
      texFormat = ctx->Driver.ChooseTextureFormat(ctx, target,
1039
991
                                                  GL_RGBA, GL_RGBA,
1170
1122
    *     of the maximum texture width, height, or depth, the error
1171
1123
    *     INVALID_VALUE is generated."
1172
1124
    */
1173
 
   if (level < 0 || level > t->MaxLevel) {
 
1125
   if (level < 0 || level > t->Attrib.MaxLevel) {
1174
1126
      _mesa_error(ctx, GL_INVALID_VALUE, "%s(level)", name);
1175
1127
      return NULL;
1176
1128
   }
2087
2039
      if (texName[i] > 0) {
2088
2040
         struct gl_texture_object *t = _mesa_lookup_texture(ctx, texName[i]);
2089
2041
         if (t) {
2090
 
            t->Priority = CLAMP( priorities[i], 0.0F, 1.0F );
 
2042
            t->Attrib.Priority = CLAMP( priorities[i], 0.0F, 1.0F );
2091
2043
         }
2092
2044
      }
2093
2045
   }
2193
2145
void
2194
2146
_mesa_lock_context_textures( struct gl_context *ctx )
2195
2147
{
2196
 
   mtx_lock(&ctx->Shared->TexMutex);
 
2148
   if (!ctx->TexturesLocked)
 
2149
      mtx_lock(&ctx->Shared->TexMutex);
2197
2150
 
2198
2151
   if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) {
2199
2152
      ctx->NewState |= _NEW_TEXTURE_OBJECT;
2206
2159
_mesa_unlock_context_textures( struct gl_context *ctx )
2207
2160
{
2208
2161
   assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp);
2209
 
   mtx_unlock(&ctx->Shared->TexMutex);
 
2162
   if (!ctx->TexturesLocked)
 
2163
      mtx_unlock(&ctx->Shared->TexMutex);
2210
2164
}
2211
2165
 
2212
2166