Texture.h (28047B)
1 // 2 // Copyright 2002 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // Texture.h: Defines the gl::Texture class [OpenGL ES 2.0.24] section 3.7 page 63. 8 9 #ifndef LIBANGLE_TEXTURE_H_ 10 #define LIBANGLE_TEXTURE_H_ 11 12 #include <map> 13 #include <vector> 14 15 #include "angle_gl.h" 16 #include "common/Optional.h" 17 #include "common/debug.h" 18 #include "common/utilities.h" 19 #include "libANGLE/Caps.h" 20 #include "libANGLE/Constants.h" 21 #include "libANGLE/Debug.h" 22 #include "libANGLE/Error.h" 23 #include "libANGLE/FramebufferAttachment.h" 24 #include "libANGLE/Image.h" 25 #include "libANGLE/Observer.h" 26 #include "libANGLE/Stream.h" 27 #include "libANGLE/angletypes.h" 28 #include "libANGLE/formatutils.h" 29 30 namespace egl 31 { 32 class Surface; 33 class Stream; 34 } // namespace egl 35 36 namespace rx 37 { 38 class GLImplFactory; 39 class TextureImpl; 40 class TextureGL; 41 } // namespace rx 42 43 namespace gl 44 { 45 class Framebuffer; 46 class MemoryObject; 47 class Sampler; 48 class State; 49 class Texture; 50 51 constexpr GLuint kInitialMaxLevel = 1000; 52 53 bool IsMipmapFiltered(GLenum minFilterMode); 54 55 // Convert a given filter mode to nearest filtering. 56 GLenum ConvertToNearestFilterMode(GLenum filterMode); 57 58 // Convert a given filter mode to nearest mip filtering. 59 GLenum ConvertToNearestMipFilterMode(GLenum filterMode); 60 61 struct ImageDesc final 62 { 63 ImageDesc(); 64 ImageDesc(const Extents &size, const Format &format, const InitState initState); 65 ImageDesc(const Extents &size, 66 const Format &format, 67 const GLsizei samples, 68 const bool fixedSampleLocations, 69 const InitState initState); 70 71 ImageDesc(const ImageDesc &other) = default; 72 ImageDesc &operator=(const ImageDesc &other) = default; 73 74 GLint getMemorySize() const; 75 76 Extents size; 77 Format format; 78 GLsizei samples; 79 bool fixedSampleLocations; 80 81 // Needed for robust resource initialization. 82 InitState initState; 83 }; 84 85 struct SwizzleState final 86 { 87 SwizzleState(); 88 SwizzleState(GLenum red, GLenum green, GLenum blue, GLenum alpha); 89 SwizzleState(const SwizzleState &other) = default; 90 SwizzleState &operator=(const SwizzleState &other) = default; 91 92 bool swizzleRequired() const; 93 94 bool operator==(const SwizzleState &other) const; 95 bool operator!=(const SwizzleState &other) const; 96 97 GLenum swizzleRed; 98 GLenum swizzleGreen; 99 GLenum swizzleBlue; 100 GLenum swizzleAlpha; 101 }; 102 103 // State from Table 6.9 (state per texture object) in the OpenGL ES 3.0.2 spec. 104 class TextureState final : private angle::NonCopyable 105 { 106 public: 107 TextureState(TextureType type); 108 ~TextureState(); 109 110 bool swizzleRequired() const; 111 GLuint getEffectiveBaseLevel() const; 112 GLuint getEffectiveMaxLevel() const; 113 114 // Returns the value called "q" in the GLES 3.0.4 spec section 3.8.10. 115 GLuint getMipmapMaxLevel() const; 116 117 // Returns true if base level changed. 118 bool setBaseLevel(GLuint baseLevel); 119 GLuint getBaseLevel() const { return mBaseLevel; } 120 bool setMaxLevel(GLuint maxLevel); 121 GLuint getMaxLevel() const { return mMaxLevel; } 122 123 bool isCubeComplete() const; 124 125 ANGLE_INLINE bool compatibleWithSamplerFormatForWebGL(SamplerFormat format, 126 const SamplerState &samplerState) const 127 { 128 if (!mCachedSamplerFormatValid || 129 mCachedSamplerCompareMode != samplerState.getCompareMode()) 130 { 131 mCachedSamplerFormat = computeRequiredSamplerFormat(samplerState); 132 mCachedSamplerCompareMode = samplerState.getCompareMode(); 133 mCachedSamplerFormatValid = true; 134 } 135 // Incomplete textures are compatible with any sampler format. 136 return mCachedSamplerFormat == SamplerFormat::InvalidEnum || format == mCachedSamplerFormat; 137 } 138 139 const ImageDesc &getImageDesc(TextureTarget target, size_t level) const; 140 const ImageDesc &getImageDesc(const ImageIndex &imageIndex) const; 141 142 TextureType getType() const { return mType; } 143 const SwizzleState &getSwizzleState() const { return mSwizzleState; } 144 const SamplerState &getSamplerState() const { return mSamplerState; } 145 GLenum getUsage() const { return mUsage; } 146 bool hasProtectedContent() const { return mHasProtectedContent; } 147 GLenum getDepthStencilTextureMode() const { return mDepthStencilTextureMode; } 148 bool isStencilMode() const { return mDepthStencilTextureMode == GL_STENCIL_INDEX; } 149 150 bool hasBeenBoundAsImage() const { return mHasBeenBoundAsImage; } 151 bool is3DTextureAndHasBeenBoundAs2DImage() const { return mIs3DAndHasBeenBoundAs2DImage; } 152 bool hasBeenBoundAsAttachment() const { return mHasBeenBoundAsAttachment; } 153 154 gl::SrgbOverride getSRGBOverride() const { return mSrgbOverride; } 155 156 // Returns the desc of the base level. Only valid for cube-complete/mip-complete textures. 157 const ImageDesc &getBaseLevelDesc() const; 158 const ImageDesc &getLevelZeroDesc() const; 159 160 // GLES1 emulation: For GL_OES_draw_texture 161 void setCrop(const Rectangle &rect); 162 const Rectangle &getCrop() const; 163 164 // GLES1 emulation: Auto-mipmap generation is a texparameter 165 void setGenerateMipmapHint(GLenum hint); 166 GLenum getGenerateMipmapHint() const; 167 168 // Return the enabled mipmap level count. 169 GLuint getEnabledLevelCount() const; 170 171 bool getImmutableFormat() const { return mImmutableFormat; } 172 GLuint getImmutableLevels() const { return mImmutableLevels; } 173 174 const std::vector<ImageDesc> &getImageDescs() const { return mImageDescs; } 175 176 InitState getInitState() const { return mInitState; } 177 178 const OffsetBindingPointer<Buffer> &getBuffer() const { return mBuffer; } 179 180 const std::string &getLabel() const { return mLabel; } 181 182 private: 183 // Texture needs access to the ImageDesc functions. 184 friend class Texture; 185 friend bool operator==(const TextureState &a, const TextureState &b); 186 187 bool computeSamplerCompleteness(const SamplerState &samplerState, const State &state) const; 188 bool computeSamplerCompletenessForCopyImage(const SamplerState &samplerState, 189 const State &state) const; 190 191 bool computeMipmapCompleteness() const; 192 bool computeLevelCompleteness(TextureTarget target, size_t level) const; 193 SamplerFormat computeRequiredSamplerFormat(const SamplerState &samplerState) const; 194 195 TextureTarget getBaseImageTarget() const; 196 197 void setImageDesc(TextureTarget target, size_t level, const ImageDesc &desc); 198 void setImageDescChain(GLuint baselevel, 199 GLuint maxLevel, 200 Extents baseSize, 201 const Format &format, 202 InitState initState); 203 void setImageDescChainMultisample(Extents baseSize, 204 const Format &format, 205 GLsizei samples, 206 bool fixedSampleLocations, 207 InitState initState); 208 209 void clearImageDesc(TextureTarget target, size_t level); 210 void clearImageDescs(); 211 212 const TextureType mType; 213 214 SwizzleState mSwizzleState; 215 216 SamplerState mSamplerState; 217 218 SrgbOverride mSrgbOverride; 219 220 GLuint mBaseLevel; 221 GLuint mMaxLevel; 222 223 GLenum mDepthStencilTextureMode; 224 225 bool mHasBeenBoundAsImage; 226 bool mIs3DAndHasBeenBoundAs2DImage; 227 bool mHasBeenBoundAsAttachment; 228 229 bool mImmutableFormat; 230 GLuint mImmutableLevels; 231 232 // From GL_ANGLE_texture_usage 233 GLenum mUsage; 234 235 // GL_EXT_protected_textures 236 bool mHasProtectedContent; 237 238 std::vector<ImageDesc> mImageDescs; 239 240 // GLES1 emulation: Texture crop rectangle 241 // For GL_OES_draw_texture 242 Rectangle mCropRect; 243 244 // GLES1 emulation: Generate-mipmap hint per texture 245 GLenum mGenerateMipmapHint; 246 247 // GL_OES_texture_buffer / GLES3.2 248 OffsetBindingPointer<Buffer> mBuffer; 249 250 InitState mInitState; 251 252 mutable SamplerFormat mCachedSamplerFormat; 253 mutable GLenum mCachedSamplerCompareMode; 254 mutable bool mCachedSamplerFormatValid; 255 std::string mLabel; 256 }; 257 258 bool operator==(const TextureState &a, const TextureState &b); 259 bool operator!=(const TextureState &a, const TextureState &b); 260 261 class Texture final : public RefCountObject<TextureID>, 262 public egl::ImageSibling, 263 public LabeledObject 264 { 265 public: 266 Texture(rx::GLImplFactory *factory, TextureID id, TextureType type); 267 ~Texture() override; 268 269 void onDestroy(const Context *context) override; 270 271 angle::Result setLabel(const Context *context, const std::string &label) override; 272 273 const std::string &getLabel() const override; 274 275 TextureType getType() const { return mState.mType; } 276 277 void setSwizzleRed(const Context *context, GLenum swizzleRed); 278 GLenum getSwizzleRed() const; 279 280 void setSwizzleGreen(const Context *context, GLenum swizzleGreen); 281 GLenum getSwizzleGreen() const; 282 283 void setSwizzleBlue(const Context *context, GLenum swizzleBlue); 284 GLenum getSwizzleBlue() const; 285 286 void setSwizzleAlpha(const Context *context, GLenum swizzleAlpha); 287 GLenum getSwizzleAlpha() const; 288 289 void setMinFilter(const Context *context, GLenum minFilter); 290 GLenum getMinFilter() const; 291 292 void setMagFilter(const Context *context, GLenum magFilter); 293 GLenum getMagFilter() const; 294 295 void setWrapS(const Context *context, GLenum wrapS); 296 GLenum getWrapS() const; 297 298 void setWrapT(const Context *context, GLenum wrapT); 299 GLenum getWrapT() const; 300 301 void setWrapR(const Context *context, GLenum wrapR); 302 GLenum getWrapR() const; 303 304 void setMaxAnisotropy(const Context *context, float maxAnisotropy); 305 float getMaxAnisotropy() const; 306 307 void setMinLod(const Context *context, GLfloat minLod); 308 GLfloat getMinLod() const; 309 310 void setMaxLod(const Context *context, GLfloat maxLod); 311 GLfloat getMaxLod() const; 312 313 void setCompareMode(const Context *context, GLenum compareMode); 314 GLenum getCompareMode() const; 315 316 void setCompareFunc(const Context *context, GLenum compareFunc); 317 GLenum getCompareFunc() const; 318 319 void setSRGBDecode(const Context *context, GLenum sRGBDecode); 320 GLenum getSRGBDecode() const; 321 322 void setSRGBOverride(const Context *context, GLenum sRGBOverride); 323 GLenum getSRGBOverride() const; 324 325 const SamplerState &getSamplerState() const; 326 327 angle::Result setBaseLevel(const Context *context, GLuint baseLevel); 328 GLuint getBaseLevel() const; 329 330 void setMaxLevel(const Context *context, GLuint maxLevel); 331 GLuint getMaxLevel() const; 332 333 void setDepthStencilTextureMode(const Context *context, GLenum mode); 334 GLenum getDepthStencilTextureMode() const; 335 336 bool getImmutableFormat() const; 337 338 GLuint getImmutableLevels() const; 339 340 void setUsage(const Context *context, GLenum usage); 341 GLenum getUsage() const; 342 343 void setProtectedContent(Context *context, bool hasProtectedContent); 344 bool hasProtectedContent() const override; 345 346 const TextureState &getState() const { return mState; } 347 348 void setBorderColor(const Context *context, const ColorGeneric &color); 349 const ColorGeneric &getBorderColor() const; 350 351 angle::Result setBuffer(const Context *context, gl::Buffer *buffer, GLenum internalFormat); 352 angle::Result setBufferRange(const Context *context, 353 gl::Buffer *buffer, 354 GLenum internalFormat, 355 GLintptr offset, 356 GLsizeiptr size); 357 const OffsetBindingPointer<Buffer> &getBuffer() const; 358 359 GLint getRequiredTextureImageUnits(const Context *context) const; 360 361 const TextureState &getTextureState() const; 362 363 const Extents &getExtents(TextureTarget target, size_t level) const; 364 size_t getWidth(TextureTarget target, size_t level) const; 365 size_t getHeight(TextureTarget target, size_t level) const; 366 size_t getDepth(TextureTarget target, size_t level) const; 367 GLsizei getSamples(TextureTarget target, size_t level) const; 368 bool getFixedSampleLocations(TextureTarget target, size_t level) const; 369 const Format &getFormat(TextureTarget target, size_t level) const; 370 371 // Returns the value called "q" in the GLES 3.0.4 spec section 3.8.10. 372 GLuint getMipmapMaxLevel() const; 373 374 bool isMipmapComplete() const; 375 376 angle::Result setImage(Context *context, 377 const PixelUnpackState &unpackState, 378 Buffer *unpackBuffer, 379 TextureTarget target, 380 GLint level, 381 GLenum internalFormat, 382 const Extents &size, 383 GLenum format, 384 GLenum type, 385 const uint8_t *pixels); 386 angle::Result setSubImage(Context *context, 387 const PixelUnpackState &unpackState, 388 Buffer *unpackBuffer, 389 TextureTarget target, 390 GLint level, 391 const Box &area, 392 GLenum format, 393 GLenum type, 394 const uint8_t *pixels); 395 396 angle::Result setCompressedImage(Context *context, 397 const PixelUnpackState &unpackState, 398 TextureTarget target, 399 GLint level, 400 GLenum internalFormat, 401 const Extents &size, 402 size_t imageSize, 403 const uint8_t *pixels); 404 angle::Result setCompressedSubImage(const Context *context, 405 const PixelUnpackState &unpackState, 406 TextureTarget target, 407 GLint level, 408 const Box &area, 409 GLenum format, 410 size_t imageSize, 411 const uint8_t *pixels); 412 413 angle::Result copyImage(Context *context, 414 TextureTarget target, 415 GLint level, 416 const Rectangle &sourceArea, 417 GLenum internalFormat, 418 Framebuffer *source); 419 angle::Result copySubImage(Context *context, 420 const ImageIndex &index, 421 const Offset &destOffset, 422 const Rectangle &sourceArea, 423 Framebuffer *source); 424 425 angle::Result copyRenderbufferSubData(Context *context, 426 const gl::Renderbuffer *srcBuffer, 427 GLint srcLevel, 428 GLint srcX, 429 GLint srcY, 430 GLint srcZ, 431 GLint dstLevel, 432 GLint dstX, 433 GLint dstY, 434 GLint dstZ, 435 GLsizei srcWidth, 436 GLsizei srcHeight, 437 GLsizei srcDepth); 438 439 angle::Result copyTextureSubData(Context *context, 440 const gl::Texture *srcTexture, 441 GLint srcLevel, 442 GLint srcX, 443 GLint srcY, 444 GLint srcZ, 445 GLint dstLevel, 446 GLint dstX, 447 GLint dstY, 448 GLint dstZ, 449 GLsizei srcWidth, 450 GLsizei srcHeight, 451 GLsizei srcDepth); 452 453 angle::Result copyTexture(Context *context, 454 TextureTarget target, 455 GLint level, 456 GLenum internalFormat, 457 GLenum type, 458 GLint sourceLevel, 459 bool unpackFlipY, 460 bool unpackPremultiplyAlpha, 461 bool unpackUnmultiplyAlpha, 462 Texture *source); 463 angle::Result copySubTexture(const Context *context, 464 TextureTarget target, 465 GLint level, 466 const Offset &destOffset, 467 GLint sourceLevel, 468 const Box &sourceBox, 469 bool unpackFlipY, 470 bool unpackPremultiplyAlpha, 471 bool unpackUnmultiplyAlpha, 472 Texture *source); 473 angle::Result copyCompressedTexture(Context *context, const Texture *source); 474 475 angle::Result setStorage(Context *context, 476 TextureType type, 477 GLsizei levels, 478 GLenum internalFormat, 479 const Extents &size); 480 481 angle::Result setStorageMultisample(Context *context, 482 TextureType type, 483 GLsizei samplesIn, 484 GLint internalformat, 485 const Extents &size, 486 bool fixedSampleLocations); 487 488 angle::Result setStorageExternalMemory(Context *context, 489 TextureType type, 490 GLsizei levels, 491 GLenum internalFormat, 492 const Extents &size, 493 MemoryObject *memoryObject, 494 GLuint64 offset, 495 GLbitfield createFlags, 496 GLbitfield usageFlags, 497 const void *imageCreateInfoPNext); 498 499 angle::Result setImageExternal(Context *context, 500 TextureTarget target, 501 GLint level, 502 GLenum internalFormat, 503 const Extents &size, 504 GLenum format, 505 GLenum type); 506 507 angle::Result setEGLImageTarget(Context *context, TextureType type, egl::Image *imageTarget); 508 509 angle::Result setStorageEGLImageTarget(Context *context, 510 TextureType type, 511 egl::Image *image, 512 const GLint *attrib_list); 513 514 angle::Result generateMipmap(Context *context); 515 516 void onBindAsImageTexture(); 517 void onBind3DTextureAs2DImage(); 518 519 egl::Surface *getBoundSurface() const; 520 egl::Stream *getBoundStream() const; 521 522 GLint getMemorySize() const; 523 GLint getLevelMemorySize(TextureTarget target, GLint level) const; 524 525 void signalDirtyStorage(InitState initState); 526 527 bool isSamplerComplete(const Context *context, const Sampler *optionalSampler); 528 bool isSamplerCompleteForCopyImage(const Context *context, 529 const Sampler *optionalSampler) const; 530 531 GLenum getImplementationColorReadFormat(const Context *context) const; 532 GLenum getImplementationColorReadType(const Context *context) const; 533 534 bool isCompressedFormatEmulated(const Context *context, 535 TextureTarget target, 536 GLint level) const; 537 538 // We pass the pack buffer and state explicitly so they can be overridden during capture. 539 angle::Result getTexImage(const Context *context, 540 const PixelPackState &packState, 541 Buffer *packBuffer, 542 TextureTarget target, 543 GLint level, 544 GLenum format, 545 GLenum type, 546 void *pixels); 547 548 angle::Result getCompressedTexImage(const Context *context, 549 const PixelPackState &packState, 550 Buffer *packBuffer, 551 TextureTarget target, 552 GLint level, 553 void *pixels); 554 555 rx::TextureImpl *getImplementation() const { return mTexture; } 556 557 // FramebufferAttachmentObject implementation 558 Extents getAttachmentSize(const ImageIndex &imageIndex) const override; 559 Format getAttachmentFormat(GLenum binding, const ImageIndex &imageIndex) const override; 560 GLsizei getAttachmentSamples(const ImageIndex &imageIndex) const override; 561 bool isRenderable(const Context *context, 562 GLenum binding, 563 const ImageIndex &imageIndex) const override; 564 565 bool getAttachmentFixedSampleLocations(const ImageIndex &imageIndex) const; 566 567 // GLES1 emulation 568 void setCrop(const Rectangle &rect); 569 const Rectangle &getCrop() const; 570 void setGenerateMipmapHint(GLenum generate); 571 GLenum getGenerateMipmapHint() const; 572 573 void onAttach(const Context *context, rx::Serial framebufferSerial) override; 574 void onDetach(const Context *context, rx::Serial framebufferSerial) override; 575 576 // Used specifically for FramebufferAttachmentObject. 577 GLuint getId() const override; 578 579 GLuint getNativeID() const; 580 581 // Needed for robust resource init. 582 angle::Result ensureInitialized(const Context *context); 583 InitState initState(GLenum binding, const ImageIndex &imageIndex) const override; 584 InitState initState() const { return mState.mInitState; } 585 void setInitState(GLenum binding, const ImageIndex &imageIndex, InitState initState) override; 586 void setInitState(InitState initState); 587 588 bool isBoundToFramebuffer(rx::Serial framebufferSerial) const 589 { 590 for (size_t index = 0; index < mBoundFramebufferSerials.size(); ++index) 591 { 592 if (mBoundFramebufferSerials[index] == framebufferSerial) 593 return true; 594 } 595 596 return false; 597 } 598 599 bool isDepthOrStencil() const 600 { 601 return mState.getBaseLevelDesc().format.info->isDepthOrStencil(); 602 } 603 604 enum DirtyBitType 605 { 606 // Sampler state 607 DIRTY_BIT_MIN_FILTER, 608 DIRTY_BIT_MAG_FILTER, 609 DIRTY_BIT_WRAP_S, 610 DIRTY_BIT_WRAP_T, 611 DIRTY_BIT_WRAP_R, 612 DIRTY_BIT_MAX_ANISOTROPY, 613 DIRTY_BIT_MIN_LOD, 614 DIRTY_BIT_MAX_LOD, 615 DIRTY_BIT_COMPARE_MODE, 616 DIRTY_BIT_COMPARE_FUNC, 617 DIRTY_BIT_SRGB_DECODE, 618 DIRTY_BIT_SRGB_OVERRIDE, 619 DIRTY_BIT_BORDER_COLOR, 620 621 // Texture state 622 DIRTY_BIT_SWIZZLE_RED, 623 DIRTY_BIT_SWIZZLE_GREEN, 624 DIRTY_BIT_SWIZZLE_BLUE, 625 DIRTY_BIT_SWIZZLE_ALPHA, 626 DIRTY_BIT_BASE_LEVEL, 627 DIRTY_BIT_MAX_LEVEL, 628 DIRTY_BIT_DEPTH_STENCIL_TEXTURE_MODE, 629 630 // Image state 631 DIRTY_BIT_BOUND_AS_IMAGE, 632 DIRTY_BIT_BOUND_AS_ATTACHMENT, 633 634 // Misc 635 DIRTY_BIT_USAGE, 636 DIRTY_BIT_IMPLEMENTATION, 637 638 DIRTY_BIT_COUNT, 639 }; 640 using DirtyBits = angle::BitSet<DIRTY_BIT_COUNT>; 641 642 angle::Result syncState(const Context *context, Command source); 643 bool hasAnyDirtyBit() const { return mDirtyBits.any(); } 644 bool hasAnyDirtyBitExcludingBoundAsAttachmentBit() const 645 { 646 static constexpr DirtyBits kBoundAsAttachment = DirtyBits({DIRTY_BIT_BOUND_AS_ATTACHMENT}); 647 return mDirtyBits.any() && mDirtyBits != kBoundAsAttachment; 648 } 649 650 // ObserverInterface implementation. 651 void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override; 652 653 private: 654 rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override; 655 656 // ANGLE-only method, used internally 657 friend class egl::Surface; 658 angle::Result bindTexImageFromSurface(Context *context, egl::Surface *surface); 659 angle::Result releaseTexImageFromSurface(const Context *context); 660 661 // ANGLE-only methods, used internally 662 friend class egl::Stream; 663 void bindStream(egl::Stream *stream); 664 void releaseStream(); 665 angle::Result acquireImageFromStream(const Context *context, 666 const egl::Stream::GLTextureDescription &desc); 667 angle::Result releaseImageFromStream(const Context *context); 668 669 void invalidateCompletenessCache() const; 670 angle::Result releaseTexImageInternal(Context *context); 671 672 bool doesSubImageNeedInit(const Context *context, 673 const ImageIndex &imageIndex, 674 const Box &area) const; 675 angle::Result ensureSubImageInitialized(const Context *context, 676 const ImageIndex &imageIndex, 677 const Box &area); 678 679 angle::Result handleMipmapGenerationHint(Context *context, int level); 680 681 angle::Result setEGLImageTargetImpl(Context *context, 682 TextureType type, 683 GLuint levels, 684 egl::Image *imageTarget); 685 686 void signalDirtyState(size_t dirtyBit); 687 688 TextureState mState; 689 DirtyBits mDirtyBits; 690 rx::TextureImpl *mTexture; 691 angle::ObserverBinding mImplObserver; 692 // For EXT_texture_buffer, observes buffer changes. 693 angle::ObserverBinding mBufferObserver; 694 695 egl::Surface *mBoundSurface; 696 egl::Stream *mBoundStream; 697 698 // We track all the serials of the Framebuffers this texture is attached to. Note that this 699 // allows duplicates because different ranges of a Texture can be bound to the same Framebuffer. 700 // For the purposes of depth-stencil loops, a simple "isBound" check works fine. For color 701 // attachment Feedback Loop checks we then need to check further to see when a Texture is bound 702 // to mulitple bindings that the bindings don't overlap. 703 static constexpr uint32_t kFastFramebufferSerialCount = 8; 704 angle::FastVector<rx::Serial, kFastFramebufferSerialCount> mBoundFramebufferSerials; 705 706 struct SamplerCompletenessCache 707 { 708 SamplerCompletenessCache(); 709 710 // Context used to generate this cache entry 711 ContextID context; 712 713 // All values that affect sampler completeness that are not stored within 714 // the texture itself 715 SamplerState samplerState; 716 717 // Result of the sampler completeness with the above parameters 718 bool samplerComplete; 719 }; 720 721 mutable SamplerCompletenessCache mCompletenessCache; 722 }; 723 724 inline bool operator==(const TextureState &a, const TextureState &b) 725 { 726 return a.mSwizzleState == b.mSwizzleState && a.mSamplerState == b.mSamplerState && 727 a.mBaseLevel == b.mBaseLevel && a.mMaxLevel == b.mMaxLevel && 728 a.mImmutableFormat == b.mImmutableFormat && a.mImmutableLevels == b.mImmutableLevels && 729 a.mUsage == b.mUsage; 730 } 731 732 inline bool operator!=(const TextureState &a, const TextureState &b) 733 { 734 return !(a == b); 735 } 736 } // namespace gl 737 738 #endif // LIBANGLE_TEXTURE_H_