Home | History | Annotate | Download | only in d3d
      1 //
      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.
      5 //
      6 
      7 // TextureStorage.cpp: Shared members of abstract rx::TextureStorage class.
      8 
      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"
     14 
     15 #include "common/debug.h"
     16 #include "common/mathutil.h"
     17 
     18 namespace rx
     19 {
     20 
     21 unsigned int TextureStorage::mCurrentTextureSerial = 1;
     22 
     23 TextureStorage::TextureStorage()
     24     : mTextureSerial(issueTextureSerial()),
     25       mFirstRenderTargetSerial(0),
     26       mRenderTargetSerialsLayerStride(0)
     27 {}
     28 
     29 void TextureStorage::initializeSerials(unsigned int rtSerialsToReserve, unsigned int rtSerialsLayerStride)
     30 {
     31     mFirstRenderTargetSerial = gl::RenderbufferStorage::issueSerials(rtSerialsToReserve);
     32     mRenderTargetSerialsLayerStride = rtSerialsLayerStride;
     33 }
     34 
     35 unsigned int TextureStorage::getRenderTargetSerial(const gl::ImageIndex &index) const
     36 {
     37     unsigned int layerOffset = (index.hasLayer() ? (static_cast<unsigned int>(index.layerIndex) * mRenderTargetSerialsLayerStride) : 0);
     38     return mFirstRenderTargetSerial + static_cast<unsigned int>(index.mipIndex) + layerOffset;
     39 }
     40 
     41 unsigned int TextureStorage::getTextureSerial() const
     42 {
     43     return mTextureSerial;
     44 }
     45 
     46 unsigned int TextureStorage::issueTextureSerial()
     47 {
     48     return mCurrentTextureSerial++;
     49 }
     50 
     51 }
     52