Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 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_RS_PROGRAM_FRAGMENT_H |
| 18 | #define ANDROID_RS_PROGRAM_FRAGMENT_H |
| 19 | |
| 20 | #include "rsProgram.h" |
| 21 | |
| 22 | // --------------------------------------------------------------------------- |
| 23 | namespace android { |
| 24 | namespace renderscript { |
| 25 | |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 26 | class ProgramFragmentState; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 27 | |
| 28 | class ProgramFragment : public Program |
| 29 | { |
| 30 | public: |
| 31 | const static uint32_t MAX_TEXTURE = 2; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 32 | |
| 33 | |
| 34 | |
Jason Sams | 25ffcdc | 2009-08-20 16:10:36 -0700 | [diff] [blame^] | 35 | ProgramFragment(Element *in, Element *out, bool pointSpriteEnable); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 36 | virtual ~ProgramFragment(); |
| 37 | |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 38 | virtual void setupGL(ProgramFragmentState *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 | |
| 40 | |
| 41 | |
| 42 | void bindTexture(uint32_t slot, Allocation *); |
| 43 | void bindSampler(uint32_t slot, Sampler *); |
| 44 | void setType(uint32_t slot, const Element *, uint32_t dim); |
| 45 | |
| 46 | void setEnvMode(uint32_t slot, RsTexEnvMode); |
| 47 | void setTexEnable(uint32_t slot, bool); |
| 48 | |
| 49 | |
| 50 | |
| 51 | protected: |
| 52 | // The difference between Textures and Constants is how they are accessed |
| 53 | // Texture lookups go though a sampler which in effect converts normalized |
| 54 | // coordinates into type specific. Multiple samples may also be taken |
| 55 | // and filtered. |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 56 | // |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 57 | // Constants are strictly accessed by programetic loads. |
| 58 | ObjectBaseRef<Allocation> mTextures[MAX_TEXTURE]; |
| 59 | ObjectBaseRef<Sampler> mSamplers[MAX_TEXTURE]; |
| 60 | ObjectBaseRef<const Element> mTextureFormats[MAX_TEXTURE]; |
| 61 | uint32_t mTextureDimensions[MAX_TEXTURE]; |
| 62 | |
| 63 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 64 | // Hacks to create a program for now |
| 65 | RsTexEnvMode mEnvModes[MAX_TEXTURE]; |
| 66 | uint32_t mTextureEnableMask; |
Jason Sams | 25ffcdc | 2009-08-20 16:10:36 -0700 | [diff] [blame^] | 67 | bool mPointSpriteEnable; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 70 | class ProgramFragmentState |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 71 | { |
| 72 | public: |
| 73 | ProgramFragmentState(); |
| 74 | ~ProgramFragmentState(); |
| 75 | |
| 76 | ProgramFragment *mPF; |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 77 | void init(Context *rsc, int32_t w, int32_t h); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 78 | |
| 79 | ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE]; |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 80 | ObjectBaseRef<ProgramFragment> mDefault; |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 81 | Vector<ProgramFragment *> mPrograms; |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 82 | |
| 83 | ObjectBaseRef<ProgramFragment> mLast; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | |
| 87 | } |
| 88 | } |
| 89 | #endif |
| 90 | |
| 91 | |
| 92 | |
| 93 | |