2 // Copyright (c) 2002-2013 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.
7 // TextureStorage.cpp: Shared members of abstract rx::TextureStorage class.
9 #include "libGLESv2/renderer/d3d/TextureStorage.h"
10 #include "libGLESv2/renderer/d3d/TextureD3D.h"
11 #include "libGLESv2/renderer/Renderer.h"
12 #include "libGLESv2/Renderbuffer.h"
13 #include "libGLESv2/Texture.h"
15 #include "common/debug.h"
16 #include "common/mathutil.h"
21 unsigned int TextureStorage::mCurrentTextureSerial = 1;
23 TextureStorage::TextureStorage()
24 : mTextureSerial(issueTextureSerial()),
25 mFirstRenderTargetSerial(0),
26 mRenderTargetSerialsLayerStride(0)
29 void TextureStorage::initializeSerials(unsigned int rtSerialsToReserve, unsigned int rtSerialsLayerStride)
31 mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(rtSerialsToReserve);
32 mRenderTargetSerialsLayerStride = rtSerialsLayerStride;
35 unsigned int TextureStorage::getRenderTargetSerial(const gl::ImageIndex &index) const
37 unsigned int layerOffset = (index.hasLayer() ? (static_cast<unsigned int>(index.layerIndex) * mRenderTargetSerialsLayerStride) : 0);
38 return mFirstRenderTargetSerial + static_cast<unsigned int>(index.mipIndex) + layerOffset;
41 unsigned int TextureStorage::getTextureSerial() const
43 return mTextureSerial;
46 unsigned int TextureStorage::issueTextureSerial()
48 return mCurrentTextureSerial++;