1 // 2 // Copyright 2014 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 // TextureD3D.h: Implementations of the Texture interfaces shared betweeen the D3D backends. 8 9 #ifndef LIBANGLE_RENDERER_D3D_TEXTURED3D_H_ 10 #define LIBANGLE_RENDERER_D3D_TEXTURED3D_H_ 11 12 #include "common/Color.h" 13 #include "libANGLE/Constants.h" 14 #include "libANGLE/Stream.h" 15 #include "libANGLE/angletypes.h" 16 #include "libANGLE/renderer/TextureImpl.h" 17 #include "libANGLE/renderer/d3d/TextureStorage.h" 18 19 namespace gl 20 { 21 class Framebuffer; 22 } 23 24 namespace rx 25 { 26 class EGLImageD3D; 27 class ImageD3D; 28 class RendererD3D; 29 class RenderTargetD3D; 30 class TextureStorage; 31 32 class TextureD3D : public TextureImpl, public angle::ObserverInterface 33 { 34 public: 35 TextureD3D(const gl::TextureState &data, RendererD3D *renderer); 36 ~TextureD3D() override; 37 38 void onDestroy(const gl::Context *context) override; 39 40 angle::Result getNativeTexture(const gl::Context *context, TextureStorage **outStorage); 41 hasDirtyImages()42 bool hasDirtyImages() const { return mDirtyImages; } resetDirty()43 void resetDirty() { mDirtyImages = false; } 44 45 virtual ImageD3D *getImage(const gl::ImageIndex &index) const = 0; 46 virtual GLsizei getLayerCount(int level) const = 0; 47 48 angle::Result getImageAndSyncFromStorage(const gl::Context *context, 49 const gl::ImageIndex &index, 50 ImageD3D **outImage); 51 52 GLint getBaseLevelWidth() const; 53 GLint getBaseLevelHeight() const; 54 GLenum getBaseLevelInternalFormat() const; 55 56 angle::Result setStorage(const gl::Context *context, 57 gl::TextureType type, 58 size_t levels, 59 GLenum internalFormat, 60 const gl::Extents &size) override; 61 62 angle::Result setStorageMultisample(const gl::Context *context, 63 gl::TextureType type, 64 GLsizei samples, 65 GLint internalformat, 66 const gl::Extents &size, 67 bool fixedSampleLocations) override; 68 69 angle::Result setStorageExternalMemory(const gl::Context *context, 70 gl::TextureType type, 71 size_t levels, 72 GLenum internalFormat, 73 const gl::Extents &size, 74 gl::MemoryObject *memoryObject, 75 GLuint64 offset) override; 76 isImmutable()77 bool isImmutable() const { return mImmutable; } 78 79 virtual angle::Result getRenderTarget(const gl::Context *context, 80 const gl::ImageIndex &index, 81 GLsizei samples, 82 RenderTargetD3D **outRT) = 0; 83 84 // Returns an iterator over all "Images" for this particular Texture. 85 virtual gl::ImageIndexIterator imageIterator() const = 0; 86 87 // Returns an ImageIndex for a particular "Image". 3D Textures do not have images for 88 // slices of their depth texures, so 3D textures ignore the layer parameter. 89 virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const = 0; 90 virtual bool isValidIndex(const gl::ImageIndex &index) const = 0; 91 92 angle::Result setImageExternal(const gl::Context *context, 93 gl::TextureType type, 94 egl::Stream *stream, 95 const egl::Stream::GLTextureDescription &desc) override; 96 angle::Result generateMipmap(const gl::Context *context) override; hasStorage()97 bool hasStorage() const { return mTexStorage != nullptr; } 98 TextureStorage *getStorage(); 99 ImageD3D *getBaseLevelImage() const; 100 101 angle::Result getAttachmentRenderTarget(const gl::Context *context, 102 GLenum binding, 103 const gl::ImageIndex &imageIndex, 104 GLsizei samples, 105 FramebufferAttachmentRenderTarget **rtOut) override; 106 107 angle::Result setBaseLevel(const gl::Context *context, GLuint baseLevel) override; 108 109 angle::Result syncState(const gl::Context *context, 110 const gl::Texture::DirtyBits &dirtyBits) override; 111 112 angle::Result initializeContents(const gl::Context *context, 113 const gl::ImageIndex &imageIndex) override; 114 115 GLsizei getRenderToTextureSamples(); 116 117 // ObserverInterface implementation. 118 void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override; 119 120 protected: 121 angle::Result setImageImpl(const gl::Context *context, 122 const gl::ImageIndex &index, 123 GLenum type, 124 const gl::PixelUnpackState &unpack, 125 gl::Buffer *unpackBuffer, 126 const uint8_t *pixels, 127 ptrdiff_t layerOffset); 128 angle::Result subImage(const gl::Context *context, 129 const gl::ImageIndex &index, 130 const gl::Box &area, 131 GLenum format, 132 GLenum type, 133 const gl::PixelUnpackState &unpack, 134 gl::Buffer *unpackBuffer, 135 const uint8_t *pixels, 136 ptrdiff_t layerOffset); 137 angle::Result setCompressedImageImpl(const gl::Context *context, 138 const gl::ImageIndex &index, 139 const gl::PixelUnpackState &unpack, 140 const uint8_t *pixels, 141 ptrdiff_t layerOffset); 142 angle::Result subImageCompressed(const gl::Context *context, 143 const gl::ImageIndex &index, 144 const gl::Box &area, 145 GLenum format, 146 const gl::PixelUnpackState &unpack, 147 const uint8_t *pixels, 148 ptrdiff_t layerOffset); 149 bool isFastUnpackable(const gl::Buffer *unpackBuffer, GLenum sizedInternalFormat); 150 angle::Result fastUnpackPixels(const gl::Context *context, 151 const gl::PixelUnpackState &unpack, 152 gl::Buffer *unpackBuffer, 153 const uint8_t *pixels, 154 const gl::Box &destArea, 155 GLenum sizedInternalFormat, 156 GLenum type, 157 RenderTargetD3D *destRenderTarget); 158 159 GLint getLevelZeroWidth() const; 160 GLint getLevelZeroHeight() const; 161 virtual GLint getLevelZeroDepth() const; 162 163 GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const; 164 virtual angle::Result initMipmapImages(const gl::Context *context) = 0; 165 bool isBaseImageZeroSize() const; 166 virtual bool isImageComplete(const gl::ImageIndex &index) const = 0; 167 168 bool canCreateRenderTargetForImage(const gl::ImageIndex &index) const; 169 angle::Result ensureRenderTarget(const gl::Context *context); 170 171 virtual angle::Result createCompleteStorage(bool renderTarget, 172 TexStoragePointer *outTexStorage) const = 0; 173 virtual angle::Result setCompleteTexStorage(const gl::Context *context, 174 TextureStorage *newCompleteTexStorage) = 0; 175 angle::Result commitRegion(const gl::Context *context, 176 const gl::ImageIndex &index, 177 const gl::Box ®ion); 178 179 angle::Result releaseTexStorage(const gl::Context *context); 180 getBaseLevel()181 GLuint getBaseLevel() const { return mBaseLevel; } 182 183 virtual void markAllImagesDirty() = 0; 184 185 GLint getBaseLevelDepth() const; 186 187 RendererD3D *mRenderer; 188 189 bool mDirtyImages; 190 191 bool mImmutable; 192 TextureStorage *mTexStorage; 193 angle::ObserverBinding mTexStorageObserverBinding; 194 195 private: 196 virtual angle::Result initializeStorage(const gl::Context *context, bool renderTarget) = 0; 197 198 virtual angle::Result updateStorage(const gl::Context *context) = 0; 199 200 bool shouldUseSetData(const ImageD3D *image) const; 201 202 angle::Result generateMipmapUsingImages(const gl::Context *context, const GLuint maxLevel); 203 204 GLuint mBaseLevel; 205 }; 206 207 class TextureD3D_2D : public TextureD3D 208 { 209 public: 210 TextureD3D_2D(const gl::TextureState &data, RendererD3D *renderer); 211 ~TextureD3D_2D() override; 212 213 void onDestroy(const gl::Context *context) override; 214 215 ImageD3D *getImage(int level, int layer) const; 216 ImageD3D *getImage(const gl::ImageIndex &index) const override; 217 GLsizei getLayerCount(int level) const override; 218 219 GLsizei getWidth(GLint level) const; 220 GLsizei getHeight(GLint level) const; 221 GLenum getInternalFormat(GLint level) const; 222 bool isDepth(GLint level) const; 223 bool isSRGB(GLint level) const; 224 225 angle::Result setImage(const gl::Context *context, 226 const gl::ImageIndex &index, 227 GLenum internalFormat, 228 const gl::Extents &size, 229 GLenum format, 230 GLenum type, 231 const gl::PixelUnpackState &unpack, 232 gl::Buffer *unpackBuffer, 233 const uint8_t *pixels) override; 234 angle::Result setSubImage(const gl::Context *context, 235 const gl::ImageIndex &index, 236 const gl::Box &area, 237 GLenum format, 238 GLenum type, 239 const gl::PixelUnpackState &unpack, 240 gl::Buffer *unpackBuffer, 241 const uint8_t *pixels) override; 242 243 angle::Result setCompressedImage(const gl::Context *context, 244 const gl::ImageIndex &index, 245 GLenum internalFormat, 246 const gl::Extents &size, 247 const gl::PixelUnpackState &unpack, 248 size_t imageSize, 249 const uint8_t *pixels) override; 250 angle::Result setCompressedSubImage(const gl::Context *context, 251 const gl::ImageIndex &index, 252 const gl::Box &area, 253 GLenum format, 254 const gl::PixelUnpackState &unpack, 255 size_t imageSize, 256 const uint8_t *pixels) override; 257 258 angle::Result copyImage(const gl::Context *context, 259 const gl::ImageIndex &index, 260 const gl::Rectangle &sourceArea, 261 GLenum internalFormat, 262 gl::Framebuffer *source) override; 263 angle::Result copySubImage(const gl::Context *context, 264 const gl::ImageIndex &index, 265 const gl::Offset &destOffset, 266 const gl::Rectangle &sourceArea, 267 gl::Framebuffer *source) override; 268 269 angle::Result copyTexture(const gl::Context *context, 270 const gl::ImageIndex &index, 271 GLenum internalFormat, 272 GLenum type, 273 size_t sourceLevel, 274 bool unpackFlipY, 275 bool unpackPremultiplyAlpha, 276 bool unpackUnmultiplyAlpha, 277 const gl::Texture *source) override; 278 angle::Result copySubTexture(const gl::Context *context, 279 const gl::ImageIndex &index, 280 const gl::Offset &destOffset, 281 size_t sourceLevel, 282 const gl::Box &sourceBox, 283 bool unpackFlipY, 284 bool unpackPremultiplyAlpha, 285 bool unpackUnmultiplyAlpha, 286 const gl::Texture *source) override; 287 angle::Result copyCompressedTexture(const gl::Context *context, 288 const gl::Texture *source) override; 289 290 angle::Result setStorage(const gl::Context *context, 291 gl::TextureType type, 292 size_t levels, 293 GLenum internalFormat, 294 const gl::Extents &size) override; 295 296 angle::Result bindTexImage(const gl::Context *context, egl::Surface *surface) override; 297 angle::Result releaseTexImage(const gl::Context *context) override; 298 299 angle::Result setEGLImageTarget(const gl::Context *context, 300 gl::TextureType type, 301 egl::Image *image) override; 302 303 angle::Result getRenderTarget(const gl::Context *context, 304 const gl::ImageIndex &index, 305 GLsizei samples, 306 RenderTargetD3D **outRT) override; 307 308 gl::ImageIndexIterator imageIterator() const override; 309 gl::ImageIndex getImageIndex(GLint mip, GLint layer) const override; 310 bool isValidIndex(const gl::ImageIndex &index) const override; 311 312 protected: 313 void markAllImagesDirty() override; 314 315 private: 316 angle::Result initializeStorage(const gl::Context *context, bool renderTarget) override; 317 angle::Result createCompleteStorage(bool renderTarget, 318 TexStoragePointer *outTexStorage) const override; 319 angle::Result setCompleteTexStorage(const gl::Context *context, 320 TextureStorage *newCompleteTexStorage) override; 321 322 angle::Result updateStorage(const gl::Context *context) override; 323 angle::Result initMipmapImages(const gl::Context *context) override; 324 325 bool isValidLevel(int level) const; 326 bool isLevelComplete(int level) const; 327 bool isImageComplete(const gl::ImageIndex &index) const override; 328 329 angle::Result updateStorageLevel(const gl::Context *context, int level); 330 331 angle::Result redefineImage(const gl::Context *context, 332 size_t level, 333 GLenum internalformat, 334 const gl::Extents &size, 335 bool forceRelease); 336 337 bool mEGLImageTarget; 338 gl::TexLevelArray<std::unique_ptr<ImageD3D>> mImageArray; 339 }; 340 341 class TextureD3D_Cube : public TextureD3D 342 { 343 public: 344 TextureD3D_Cube(const gl::TextureState &data, RendererD3D *renderer); 345 ~TextureD3D_Cube() override; 346 347 void onDestroy(const gl::Context *context) override; 348 349 ImageD3D *getImage(int level, int layer) const; 350 ImageD3D *getImage(const gl::ImageIndex &index) const override; 351 GLsizei getLayerCount(int level) const override; 352 353 GLenum getInternalFormat(GLint level, GLint layer) const; 354 bool isDepth(GLint level, GLint layer) const; 355 bool isSRGB(GLint level, GLint layer) const; 356 357 angle::Result setImage(const gl::Context *context, 358 const gl::ImageIndex &index, 359 GLenum internalFormat, 360 const gl::Extents &size, 361 GLenum format, 362 GLenum type, 363 const gl::PixelUnpackState &unpack, 364 gl::Buffer *unpackBuffer, 365 const uint8_t *pixels) override; 366 angle::Result setSubImage(const gl::Context *context, 367 const gl::ImageIndex &index, 368 const gl::Box &area, 369 GLenum format, 370 GLenum type, 371 const gl::PixelUnpackState &unpack, 372 gl::Buffer *unpackBuffer, 373 const uint8_t *pixels) override; 374 375 angle::Result setCompressedImage(const gl::Context *context, 376 const gl::ImageIndex &index, 377 GLenum internalFormat, 378 const gl::Extents &size, 379 const gl::PixelUnpackState &unpack, 380 size_t imageSize, 381 const uint8_t *pixels) override; 382 angle::Result setCompressedSubImage(const gl::Context *context, 383 const gl::ImageIndex &index, 384 const gl::Box &area, 385 GLenum format, 386 const gl::PixelUnpackState &unpack, 387 size_t imageSize, 388 const uint8_t *pixels) override; 389 390 angle::Result copyImage(const gl::Context *context, 391 const gl::ImageIndex &index, 392 const gl::Rectangle &sourceArea, 393 GLenum internalFormat, 394 gl::Framebuffer *source) override; 395 angle::Result copySubImage(const gl::Context *context, 396 const gl::ImageIndex &index, 397 const gl::Offset &destOffset, 398 const gl::Rectangle &sourceArea, 399 gl::Framebuffer *source) override; 400 401 angle::Result copyTexture(const gl::Context *context, 402 const gl::ImageIndex &index, 403 GLenum internalFormat, 404 GLenum type, 405 size_t sourceLevel, 406 bool unpackFlipY, 407 bool unpackPremultiplyAlpha, 408 bool unpackUnmultiplyAlpha, 409 const gl::Texture *source) override; 410 angle::Result copySubTexture(const gl::Context *context, 411 const gl::ImageIndex &index, 412 const gl::Offset &destOffset, 413 size_t sourceLevel, 414 const gl::Box &sourceBox, 415 bool unpackFlipY, 416 bool unpackPremultiplyAlpha, 417 bool unpackUnmultiplyAlpha, 418 const gl::Texture *source) override; 419 420 angle::Result setStorage(const gl::Context *context, 421 gl::TextureType type, 422 size_t levels, 423 GLenum internalFormat, 424 const gl::Extents &size) override; 425 426 angle::Result bindTexImage(const gl::Context *context, egl::Surface *surface) override; 427 angle::Result releaseTexImage(const gl::Context *context) override; 428 429 angle::Result setEGLImageTarget(const gl::Context *context, 430 gl::TextureType type, 431 egl::Image *image) override; 432 433 angle::Result getRenderTarget(const gl::Context *context, 434 const gl::ImageIndex &index, 435 GLsizei samples, 436 RenderTargetD3D **outRT) override; 437 438 gl::ImageIndexIterator imageIterator() const override; 439 gl::ImageIndex getImageIndex(GLint mip, GLint layer) const override; 440 bool isValidIndex(const gl::ImageIndex &index) const override; 441 442 protected: 443 void markAllImagesDirty() override; 444 445 private: 446 angle::Result initializeStorage(const gl::Context *context, bool renderTarget) override; 447 angle::Result createCompleteStorage(bool renderTarget, 448 TexStoragePointer *outTexStorage) const override; 449 angle::Result setCompleteTexStorage(const gl::Context *context, 450 TextureStorage *newCompleteTexStorage) override; 451 452 angle::Result updateStorage(const gl::Context *context) override; 453 angle::Result initMipmapImages(const gl::Context *context) override; 454 455 bool isValidFaceLevel(int faceIndex, int level) const; 456 bool isFaceLevelComplete(int faceIndex, int level) const; 457 bool isCubeComplete() const; 458 bool isImageComplete(const gl::ImageIndex &index) const override; 459 angle::Result updateStorageFaceLevel(const gl::Context *context, int faceIndex, int level); 460 461 angle::Result redefineImage(const gl::Context *context, 462 int faceIndex, 463 GLint level, 464 GLenum internalformat, 465 const gl::Extents &size, 466 bool forceRelease); 467 468 std::array<gl::TexLevelArray<std::unique_ptr<ImageD3D>>, 6> mImageArray; 469 }; 470 471 class TextureD3D_3D : public TextureD3D 472 { 473 public: 474 TextureD3D_3D(const gl::TextureState &data, RendererD3D *renderer); 475 ~TextureD3D_3D() override; 476 477 void onDestroy(const gl::Context *context) override; 478 479 ImageD3D *getImage(int level, int layer) const; 480 ImageD3D *getImage(const gl::ImageIndex &index) const override; 481 GLsizei getLayerCount(int level) const override; 482 483 GLsizei getWidth(GLint level) const; 484 GLsizei getHeight(GLint level) const; 485 GLsizei getDepth(GLint level) const; 486 GLenum getInternalFormat(GLint level) const; 487 bool isDepth(GLint level) const; 488 bool isSRGB(GLint level) const; 489 490 angle::Result setImage(const gl::Context *context, 491 const gl::ImageIndex &index, 492 GLenum internalFormat, 493 const gl::Extents &size, 494 GLenum format, 495 GLenum type, 496 const gl::PixelUnpackState &unpack, 497 gl::Buffer *unpackBuffer, 498 const uint8_t *pixels) override; 499 angle::Result setSubImage(const gl::Context *context, 500 const gl::ImageIndex &index, 501 const gl::Box &area, 502 GLenum format, 503 GLenum type, 504 const gl::PixelUnpackState &unpack, 505 gl::Buffer *unpackBuffer, 506 const uint8_t *pixels) override; 507 508 angle::Result setCompressedImage(const gl::Context *context, 509 const gl::ImageIndex &index, 510 GLenum internalFormat, 511 const gl::Extents &size, 512 const gl::PixelUnpackState &unpack, 513 size_t imageSize, 514 const uint8_t *pixels) override; 515 angle::Result setCompressedSubImage(const gl::Context *context, 516 const gl::ImageIndex &index, 517 const gl::Box &area, 518 GLenum format, 519 const gl::PixelUnpackState &unpack, 520 size_t imageSize, 521 const uint8_t *pixels) override; 522 523 angle::Result copyImage(const gl::Context *context, 524 const gl::ImageIndex &index, 525 const gl::Rectangle &sourceArea, 526 GLenum internalFormat, 527 gl::Framebuffer *source) override; 528 angle::Result copySubImage(const gl::Context *context, 529 const gl::ImageIndex &index, 530 const gl::Offset &destOffset, 531 const gl::Rectangle &sourceArea, 532 gl::Framebuffer *source) override; 533 534 angle::Result copyTexture(const gl::Context *context, 535 const gl::ImageIndex &index, 536 GLenum internalFormat, 537 GLenum type, 538 size_t sourceLevel, 539 bool unpackFlipY, 540 bool unpackPremultiplyAlpha, 541 bool unpackUnmultiplyAlpha, 542 const gl::Texture *source) override; 543 angle::Result copySubTexture(const gl::Context *context, 544 const gl::ImageIndex &index, 545 const gl::Offset &destOffset, 546 size_t sourceLevel, 547 const gl::Box &sourceBox, 548 bool unpackFlipY, 549 bool unpackPremultiplyAlpha, 550 bool unpackUnmultiplyAlpha, 551 const gl::Texture *source) override; 552 553 angle::Result setStorage(const gl::Context *context, 554 gl::TextureType type, 555 size_t levels, 556 GLenum internalFormat, 557 const gl::Extents &size) override; 558 559 angle::Result bindTexImage(const gl::Context *context, egl::Surface *surface) override; 560 angle::Result releaseTexImage(const gl::Context *context) override; 561 562 angle::Result setEGLImageTarget(const gl::Context *context, 563 gl::TextureType type, 564 egl::Image *image) override; 565 566 angle::Result getRenderTarget(const gl::Context *context, 567 const gl::ImageIndex &index, 568 GLsizei samples, 569 RenderTargetD3D **outRT) override; 570 571 gl::ImageIndexIterator imageIterator() const override; 572 gl::ImageIndex getImageIndex(GLint mip, GLint layer) const override; 573 bool isValidIndex(const gl::ImageIndex &index) const override; 574 575 protected: 576 void markAllImagesDirty() override; 577 GLint getLevelZeroDepth() const override; 578 579 private: 580 angle::Result initializeStorage(const gl::Context *context, bool renderTarget) override; 581 angle::Result createCompleteStorage(bool renderTarget, 582 TexStoragePointer *outStorage) const override; 583 angle::Result setCompleteTexStorage(const gl::Context *context, 584 TextureStorage *newCompleteTexStorage) override; 585 586 angle::Result updateStorage(const gl::Context *context) override; 587 angle::Result initMipmapImages(const gl::Context *context) override; 588 589 bool isValidLevel(int level) const; 590 bool isLevelComplete(int level) const; 591 bool isImageComplete(const gl::ImageIndex &index) const override; 592 angle::Result updateStorageLevel(const gl::Context *context, int level); 593 594 angle::Result redefineImage(const gl::Context *context, 595 GLint level, 596 GLenum internalformat, 597 const gl::Extents &size, 598 bool forceRelease); 599 600 gl::TexLevelArray<std::unique_ptr<ImageD3D>> mImageArray; 601 }; 602 603 class TextureD3D_2DArray : public TextureD3D 604 { 605 public: 606 TextureD3D_2DArray(const gl::TextureState &data, RendererD3D *renderer); 607 ~TextureD3D_2DArray() override; 608 609 void onDestroy(const gl::Context *context) override; 610 611 virtual ImageD3D *getImage(int level, int layer) const; 612 ImageD3D *getImage(const gl::ImageIndex &index) const override; 613 GLsizei getLayerCount(int level) const override; 614 615 GLsizei getWidth(GLint level) const; 616 GLsizei getHeight(GLint level) const; 617 GLenum getInternalFormat(GLint level) const; 618 bool isDepth(GLint level) const; 619 620 angle::Result setImage(const gl::Context *context, 621 const gl::ImageIndex &index, 622 GLenum internalFormat, 623 const gl::Extents &size, 624 GLenum format, 625 GLenum type, 626 const gl::PixelUnpackState &unpack, 627 gl::Buffer *unpackBuffer, 628 const uint8_t *pixels) override; 629 angle::Result setSubImage(const gl::Context *context, 630 const gl::ImageIndex &index, 631 const gl::Box &area, 632 GLenum format, 633 GLenum type, 634 const gl::PixelUnpackState &unpack, 635 gl::Buffer *unpackBuffer, 636 const uint8_t *pixels) override; 637 638 angle::Result setCompressedImage(const gl::Context *context, 639 const gl::ImageIndex &index, 640 GLenum internalFormat, 641 const gl::Extents &size, 642 const gl::PixelUnpackState &unpack, 643 size_t imageSize, 644 const uint8_t *pixels) override; 645 angle::Result setCompressedSubImage(const gl::Context *context, 646 const gl::ImageIndex &index, 647 const gl::Box &area, 648 GLenum format, 649 const gl::PixelUnpackState &unpack, 650 size_t imageSize, 651 const uint8_t *pixels) override; 652 653 angle::Result copyImage(const gl::Context *context, 654 const gl::ImageIndex &index, 655 const gl::Rectangle &sourceArea, 656 GLenum internalFormat, 657 gl::Framebuffer *source) override; 658 angle::Result copySubImage(const gl::Context *context, 659 const gl::ImageIndex &index, 660 const gl::Offset &destOffset, 661 const gl::Rectangle &sourceArea, 662 gl::Framebuffer *source) override; 663 664 angle::Result copyTexture(const gl::Context *context, 665 const gl::ImageIndex &index, 666 GLenum internalFormat, 667 GLenum type, 668 size_t sourceLevel, 669 bool unpackFlipY, 670 bool unpackPremultiplyAlpha, 671 bool unpackUnmultiplyAlpha, 672 const gl::Texture *source) override; 673 angle::Result copySubTexture(const gl::Context *context, 674 const gl::ImageIndex &index, 675 const gl::Offset &destOffset, 676 size_t sourceLevel, 677 const gl::Box &sourceBox, 678 bool unpackFlipY, 679 bool unpackPremultiplyAlpha, 680 bool unpackUnmultiplyAlpha, 681 const gl::Texture *source) override; 682 683 angle::Result setStorage(const gl::Context *context, 684 gl::TextureType type, 685 size_t levels, 686 GLenum internalFormat, 687 const gl::Extents &size) override; 688 689 angle::Result bindTexImage(const gl::Context *context, egl::Surface *surface) override; 690 angle::Result releaseTexImage(const gl::Context *context) override; 691 692 angle::Result setEGLImageTarget(const gl::Context *context, 693 gl::TextureType type, 694 egl::Image *image) override; 695 696 angle::Result getRenderTarget(const gl::Context *context, 697 const gl::ImageIndex &index, 698 GLsizei samples, 699 RenderTargetD3D **outRT) override; 700 701 gl::ImageIndexIterator imageIterator() const override; 702 gl::ImageIndex getImageIndex(GLint mip, GLint layer) const override; 703 bool isValidIndex(const gl::ImageIndex &index) const override; 704 705 protected: 706 void markAllImagesDirty() override; 707 708 private: 709 angle::Result initializeStorage(const gl::Context *context, bool renderTarget) override; 710 angle::Result createCompleteStorage(bool renderTarget, 711 TexStoragePointer *outStorage) const override; 712 angle::Result setCompleteTexStorage(const gl::Context *context, 713 TextureStorage *newCompleteTexStorage) override; 714 715 angle::Result updateStorage(const gl::Context *context) override; 716 angle::Result initMipmapImages(const gl::Context *context) override; 717 718 bool isValidLevel(int level) const; 719 bool isLevelComplete(int level) const; 720 bool isImageComplete(const gl::ImageIndex &index) const override; 721 bool isSRGB(GLint level) const; 722 angle::Result updateStorageLevel(const gl::Context *context, int level); 723 724 void deleteImages(); 725 angle::Result redefineImage(const gl::Context *context, 726 GLint level, 727 GLenum internalformat, 728 const gl::Extents &size, 729 bool forceRelease); 730 731 // Storing images as an array of single depth textures since D3D11 treats each array level of a 732 // Texture2D object as a separate subresource. Each layer would have to be looped over 733 // to update all the texture layers since they cannot all be updated at once and it makes the 734 // most sense for the Image class to not have to worry about layer subresource as well as mip 735 // subresources. 736 GLsizei mLayerCounts[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; 737 ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; 738 }; 739 740 // Base class for immutable textures. These don't support manipulation of individual texture images. 741 class TextureD3DImmutableBase : public TextureD3D 742 { 743 public: 744 TextureD3DImmutableBase(const gl::TextureState &data, RendererD3D *renderer); 745 ~TextureD3DImmutableBase() override; 746 747 ImageD3D *getImage(const gl::ImageIndex &index) const override; 748 angle::Result setImage(const gl::Context *context, 749 const gl::ImageIndex &index, 750 GLenum internalFormat, 751 const gl::Extents &size, 752 GLenum format, 753 GLenum type, 754 const gl::PixelUnpackState &unpack, 755 gl::Buffer *unpackBuffer, 756 const uint8_t *pixels) override; 757 angle::Result setSubImage(const gl::Context *context, 758 const gl::ImageIndex &index, 759 const gl::Box &area, 760 GLenum format, 761 GLenum type, 762 const gl::PixelUnpackState &unpack, 763 gl::Buffer *unpackBuffer, 764 const uint8_t *pixels) override; 765 766 angle::Result setCompressedImage(const gl::Context *context, 767 const gl::ImageIndex &index, 768 GLenum internalFormat, 769 const gl::Extents &size, 770 const gl::PixelUnpackState &unpack, 771 size_t imageSize, 772 const uint8_t *pixels) override; 773 angle::Result setCompressedSubImage(const gl::Context *context, 774 const gl::ImageIndex &index, 775 const gl::Box &area, 776 GLenum format, 777 const gl::PixelUnpackState &unpack, 778 size_t imageSize, 779 const uint8_t *pixels) override; 780 781 angle::Result copyImage(const gl::Context *context, 782 const gl::ImageIndex &index, 783 const gl::Rectangle &sourceArea, 784 GLenum internalFormat, 785 gl::Framebuffer *source) override; 786 angle::Result copySubImage(const gl::Context *context, 787 const gl::ImageIndex &index, 788 const gl::Offset &destOffset, 789 const gl::Rectangle &sourceArea, 790 gl::Framebuffer *source) override; 791 792 angle::Result bindTexImage(const gl::Context *context, egl::Surface *surface) override; 793 angle::Result releaseTexImage(const gl::Context *context) override; 794 }; 795 796 class TextureD3D_External : public TextureD3DImmutableBase 797 { 798 public: 799 TextureD3D_External(const gl::TextureState &data, RendererD3D *renderer); 800 ~TextureD3D_External() override; 801 802 GLsizei getLayerCount(int level) const override; 803 804 angle::Result setImageExternal(const gl::Context *context, 805 gl::TextureType type, 806 egl::Stream *stream, 807 const egl::Stream::GLTextureDescription &desc) override; 808 809 angle::Result setEGLImageTarget(const gl::Context *context, 810 gl::TextureType type, 811 egl::Image *image) override; 812 813 angle::Result getRenderTarget(const gl::Context *context, 814 const gl::ImageIndex &index, 815 GLsizei samples, 816 RenderTargetD3D **outRT) override; 817 818 gl::ImageIndexIterator imageIterator() const override; 819 gl::ImageIndex getImageIndex(GLint mip, GLint layer) const override; 820 bool isValidIndex(const gl::ImageIndex &index) const override; 821 822 protected: 823 void markAllImagesDirty() override; 824 825 private: 826 angle::Result initializeStorage(const gl::Context *context, bool renderTarget) override; 827 angle::Result createCompleteStorage(bool renderTarget, 828 TexStoragePointer *outTexStorage) const override; 829 angle::Result setCompleteTexStorage(const gl::Context *context, 830 TextureStorage *newCompleteTexStorage) override; 831 832 angle::Result updateStorage(const gl::Context *context) override; 833 angle::Result initMipmapImages(const gl::Context *context) override; 834 835 bool isImageComplete(const gl::ImageIndex &index) const override; 836 }; 837 838 class TextureD3D_2DMultisample : public TextureD3DImmutableBase 839 { 840 public: 841 TextureD3D_2DMultisample(const gl::TextureState &data, RendererD3D *renderer); 842 ~TextureD3D_2DMultisample() override; 843 844 angle::Result setStorageMultisample(const gl::Context *context, 845 gl::TextureType type, 846 GLsizei samples, 847 GLint internalformat, 848 const gl::Extents &size, 849 bool fixedSampleLocations) override; 850 851 angle::Result setEGLImageTarget(const gl::Context *context, 852 gl::TextureType type, 853 egl::Image *image) override; 854 855 angle::Result getRenderTarget(const gl::Context *context, 856 const gl::ImageIndex &index, 857 GLsizei samples, 858 RenderTargetD3D **outRT) override; 859 860 gl::ImageIndexIterator imageIterator() const override; 861 gl::ImageIndex getImageIndex(GLint mip, GLint layer) const override; 862 bool isValidIndex(const gl::ImageIndex &index) const override; 863 864 GLsizei getLayerCount(int level) const override; 865 866 protected: 867 void markAllImagesDirty() override; 868 869 angle::Result setCompleteTexStorage(const gl::Context *context, 870 TextureStorage *newCompleteTexStorage) override; 871 872 angle::Result updateStorage(const gl::Context *context) override; 873 874 private: 875 angle::Result initializeStorage(const gl::Context *context, bool renderTarget) override; 876 angle::Result createCompleteStorage(bool renderTarget, 877 TexStoragePointer *outTexStorage) const override; 878 angle::Result initMipmapImages(const gl::Context *context) override; 879 880 bool isImageComplete(const gl::ImageIndex &index) const override; 881 }; 882 883 class TextureD3D_2DMultisampleArray : public TextureD3DImmutableBase 884 { 885 public: 886 TextureD3D_2DMultisampleArray(const gl::TextureState &data, RendererD3D *renderer); 887 ~TextureD3D_2DMultisampleArray() override; 888 889 angle::Result setStorageMultisample(const gl::Context *context, 890 gl::TextureType type, 891 GLsizei samples, 892 GLint internalformat, 893 const gl::Extents &size, 894 bool fixedSampleLocations) override; 895 896 angle::Result setEGLImageTarget(const gl::Context *context, 897 gl::TextureType type, 898 egl::Image *image) override; 899 900 angle::Result getRenderTarget(const gl::Context *context, 901 const gl::ImageIndex &index, 902 GLsizei samples, 903 RenderTargetD3D **outRT) override; 904 905 gl::ImageIndexIterator imageIterator() const override; 906 gl::ImageIndex getImageIndex(GLint mip, GLint layer) const override; 907 bool isValidIndex(const gl::ImageIndex &index) const override; 908 909 GLsizei getLayerCount(int level) const override; 910 911 protected: 912 void markAllImagesDirty() override; 913 914 angle::Result setCompleteTexStorage(const gl::Context *context, 915 TextureStorage *newCompleteTexStorage) override; 916 917 angle::Result updateStorage(const gl::Context *context) override; 918 919 private: 920 angle::Result initializeStorage(const gl::Context *context, bool renderTarget) override; 921 angle::Result createCompleteStorage(bool renderTarget, 922 TexStoragePointer *outTexStorage) const override; 923 angle::Result initMipmapImages(const gl::Context *context) override; 924 925 bool isImageComplete(const gl::ImageIndex &index) const override; 926 927 GLsizei mLayerCount; 928 }; 929 } // namespace rx 930 931 #endif // LIBANGLE_RENDERER_D3D_TEXTURED3D_H_ 932