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