MCPcopy Create free account
hub / github.com/baldurk/renderdoc / GetNumMips

Function GetNumMips

renderdoc/driver/gl/gl_resources.cpp:777–817  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

775}
776
777int 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
819void GetFramebufferMipAndLayer(GLuint framebuffer, GLenum attachment, GLint *mip, GLint *layer)
820{

Callers 8

CacheTextureMethod · 0.85
GetTextureDataMethod · 0.85
SetProxyTextureDataMethod · 0.85
RenderOverlayMethod · 0.85
Apply_InitialStateMethod · 0.85

Calls 5

CalcNumMipsFunction · 0.85
RDCMINFunction · 0.85
RDCMAXFunction · 0.85

Tested by

no test coverage detected