|
1 #include "precompiled.h" |
|
2 // |
|
3 // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. |
|
4 // Use of this source code is governed by a BSD-style license that can be |
|
5 // found in the LICENSE file. |
|
6 // |
|
7 |
|
8 // TextureStorage.cpp: Implements the abstract rx::TextureStorageInterface class and its concrete derived |
|
9 // classes TextureStorageInterface2D and TextureStorageInterfaceCube, which act as the interface to the |
|
10 // GPU-side texture. |
|
11 |
|
12 #include "libGLESv2/renderer/TextureStorage.h" |
|
13 #include "libGLESv2/renderer/Renderer.h" |
|
14 #include "libGLESv2/Renderbuffer.h" |
|
15 #include "libGLESv2/Texture.h" |
|
16 |
|
17 #include "common/debug.h" |
|
18 |
|
19 namespace rx |
|
20 { |
|
21 unsigned int TextureStorageInterface::mCurrentTextureSerial = 1; |
|
22 |
|
23 TextureStorageInterface::TextureStorageInterface() |
|
24 : mTextureSerial(issueTextureSerial()), |
|
25 mInstance(NULL) |
|
26 { |
|
27 } |
|
28 |
|
29 TextureStorageInterface::~TextureStorageInterface() |
|
30 { |
|
31 delete mInstance; |
|
32 } |
|
33 |
|
34 bool TextureStorageInterface::isRenderTarget() const |
|
35 { |
|
36 return mInstance->isRenderTarget(); |
|
37 } |
|
38 |
|
39 |
|
40 bool TextureStorageInterface::isManaged() const |
|
41 { |
|
42 return mInstance->isManaged(); |
|
43 } |
|
44 |
|
45 unsigned int TextureStorageInterface::getTextureSerial() const |
|
46 { |
|
47 return mTextureSerial; |
|
48 } |
|
49 |
|
50 unsigned int TextureStorageInterface::issueTextureSerial() |
|
51 { |
|
52 return mCurrentTextureSerial++; |
|
53 } |
|
54 |
|
55 int TextureStorageInterface::getLodOffset() const |
|
56 { |
|
57 return mInstance->getLodOffset(); |
|
58 } |
|
59 |
|
60 |
|
61 int TextureStorageInterface::levelCount() |
|
62 { |
|
63 return mInstance->levelCount(); |
|
64 } |
|
65 |
|
66 TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, SwapChain *swapchain) |
|
67 : mRenderTargetSerial(gl::RenderbufferStorage::issueSerial()) |
|
68 { |
|
69 mInstance = renderer->createTextureStorage2D(swapchain); |
|
70 } |
|
71 |
|
72 TextureStorageInterface2D::TextureStorageInterface2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height) |
|
73 : mRenderTargetSerial(gl::RenderbufferStorage::issueSerial()) |
|
74 { |
|
75 mInstance = renderer->createTextureStorage2D(levels, internalformat, usage, forceRenderable, width, height); |
|
76 } |
|
77 |
|
78 TextureStorageInterface2D::~TextureStorageInterface2D() |
|
79 { |
|
80 } |
|
81 |
|
82 RenderTarget *TextureStorageInterface2D::getRenderTarget() const |
|
83 { |
|
84 return mInstance->getRenderTarget(); |
|
85 } |
|
86 |
|
87 void TextureStorageInterface2D::generateMipmap(int level) |
|
88 { |
|
89 mInstance->generateMipmap(level); |
|
90 } |
|
91 |
|
92 unsigned int TextureStorageInterface2D::getRenderTargetSerial(GLenum target) const |
|
93 { |
|
94 return mRenderTargetSerial; |
|
95 } |
|
96 |
|
97 TextureStorageInterfaceCube::TextureStorageInterfaceCube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size) |
|
98 : mFirstRenderTargetSerial(gl::RenderbufferStorage::issueCubeSerials()) |
|
99 { |
|
100 mInstance = renderer->createTextureStorageCube(levels, internalformat, usage, forceRenderable, size); |
|
101 } |
|
102 |
|
103 TextureStorageInterfaceCube::~TextureStorageInterfaceCube() |
|
104 { |
|
105 } |
|
106 |
|
107 RenderTarget *TextureStorageInterfaceCube::getRenderTarget(GLenum faceTarget) const |
|
108 { |
|
109 return mInstance->getRenderTarget(faceTarget); |
|
110 } |
|
111 |
|
112 void TextureStorageInterfaceCube::generateMipmap(int face, int level) |
|
113 { |
|
114 mInstance->generateMipmap(face, level); |
|
115 } |
|
116 |
|
117 unsigned int TextureStorageInterfaceCube::getRenderTargetSerial(GLenum target) const |
|
118 { |
|
119 return mFirstRenderTargetSerial + gl::TextureCubeMap::faceIndex(target); |
|
120 } |
|
121 |
|
122 } |