| 775 | } |
| 776 | |
| 777 | int GetNumMips(GLenum target, GLuint tex, GLuint w, GLuint h, GLuint d) |
| 778 | { |
| 779 | int mips = 1; |
| 780 | |
| 781 | // renderbuffers don't have mips |
| 782 | if(target == eGL_RENDERBUFFER) |
| 783 | return 1; |
| 784 | |
| 785 | GLint immut = 0; |
| 786 | GL.glGetTextureParameterivEXT(tex, target, eGL_TEXTURE_IMMUTABLE_FORMAT, &immut); |
| 787 | |
| 788 | if(immut) |
| 789 | GL.glGetTextureParameterivEXT(tex, target, eGL_TEXTURE_IMMUTABLE_LEVELS, (GLint *)&mips); |
| 790 | else |
| 791 | mips = CalcNumMips(w, h, d); |
| 792 | |
| 793 | GLint maxLevel = 1000; |
| 794 | GL.glGetTextureParameterivEXT(tex, target, eGL_TEXTURE_MAX_LEVEL, &maxLevel); |
| 795 | mips = RDCMIN(mips, maxLevel + 1); |
| 796 | |
| 797 | if(immut == 0) |
| 798 | { |
| 799 | // check to see if all mips are set, or clip the number of mips to those that are |
| 800 | // set. |
| 801 | if(target == eGL_TEXTURE_CUBE_MAP) |
| 802 | target = eGL_TEXTURE_CUBE_MAP_POSITIVE_X; |
| 803 | |
| 804 | for(int i = 0; i < mips; i++) |
| 805 | { |
| 806 | GLint width = 0; |
| 807 | GL.glGetTextureLevelParameterivEXT(tex, target, i, eGL_TEXTURE_WIDTH, &width); |
| 808 | if(width == 0) |
| 809 | { |
| 810 | mips = i; |
| 811 | break; |
| 812 | } |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | return RDCMAX(1, mips); |
| 817 | } |
| 818 | |
| 819 | void GetFramebufferMipAndLayer(GLuint framebuffer, GLenum attachment, GLint *mip, GLint *layer) |
| 820 | { |
no test coverage detected