rsdShaderCache.h revision 326e0ddf89e8df2837752fbfd7a014814b32082c
1/* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef ANDROID_STRUCTURED_TYPE_H 18#define ANDROID_STRUCTURED_TYPE_H 19 20#include "rsElement.h" 21 22// --------------------------------------------------------------------------- 23namespace android { 24namespace renderscript { 25 26 27class Type : public ObjectBase 28{ 29public: 30 Type(); 31 virtual ~Type(); 32 33 Type * createTex2D(const Element *, size_t w, size_t h, bool mip); 34 35 36 size_t getOffsetForFace(uint32_t face) const; 37 38 size_t getSizeBytes() const {return mTotalSizeBytes;} 39 size_t getElementSizeBytes() const {return mElement->getSizeBytes();} 40 const Element * getElement() const {return mElement.get();} 41 42 uint32_t getDimX() const {return mDimX;} 43 uint32_t getDimY() const {return mDimY;} 44 uint32_t getDimZ() const {return mDimZ;} 45 uint32_t getDimLOD() const {return mDimLOD;} 46 bool getDimFaces() const {return mFaces;} 47 48 uint32_t getLODDimX(uint32_t lod) const {rsAssert(lod < mLODCount); return mLODs[lod].mX;} 49 uint32_t getLODDimY(uint32_t lod) const {rsAssert(lod < mLODCount); return mLODs[lod].mY;} 50 uint32_t getLODDimZ(uint32_t lod) const {rsAssert(lod < mLODCount); return mLODs[lod].mZ;} 51 uint32_t getLODOffset(uint32_t lod) const {rsAssert(lod < mLODCount); return mLODs[lod].mOffset;} 52 53 uint32_t getLODOffset(uint32_t lod, uint32_t x) const; 54 uint32_t getLODOffset(uint32_t lod, uint32_t x, uint32_t y) const; 55 uint32_t getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) const; 56 57 uint32_t getLODCount() const {return mLODCount;} 58 59 60 void setElement(const Element *e) {mElement.set(e);} 61 void setDimX(uint32_t v) {mDimX = v;} 62 void setDimY(uint32_t v) {mDimY = v;} 63 void setDimZ(uint32_t v) {mDimZ = v;} 64 void setDimFaces(bool v) {mFaces = v;} 65 void setDimLOD(bool v) {mDimLOD = v;} 66 67 void clear(); 68 void compute(); 69 70 71protected: 72 struct LOD { 73 size_t mX; 74 size_t mY; 75 size_t mZ; 76 size_t mOffset; 77 }; 78 79 void makeLODTable(); 80 81 // Internal structure from most to least significant. 82 // * Array dimensions 83 // * Faces 84 // * Mipmaps 85 // * xyz 86 87 ObjectBaseRef<const Element> mElement; 88 89 // Size of the structure in the various dimensions. A missing Dimension is 90 // specified as a 0 and not a 1. 91 size_t mDimX; 92 size_t mDimY; 93 size_t mDimZ; 94 bool mDimLOD; 95 bool mFaces; 96 97 // A list of array dimensions. The count is the number of array dimensions and the 98 // sizes is a per array size. 99 //Vector<size_t> mDimArraysSizes; 100 101 // count of mipmap levels, 0 indicates no mipmapping 102 103 size_t mMipChainSizeBytes; 104 size_t mTotalSizeBytes; 105 LOD *mLODs; 106 uint32_t mLODCount; 107 108private: 109 Type(const Type &); 110}; 111 112 113class TypeState { 114public: 115 TypeState(); 116 ~TypeState(); 117 118 Vector<Type *> mAllTypes; 119 120 size_t mX; 121 size_t mY; 122 size_t mZ; 123 uint32_t mLOD; 124 bool mFaces; 125 ObjectBaseRef<const Element> mElement; 126 127 128 129}; 130 131 132} 133} 134#endif //ANDROID_STRUCTURED_TYPE 135