| 603 | } |
| 604 | |
| 605 | void GLResourceManager::PrepareTextureInitialContents(ResourceId id, GLResource res) |
| 606 | { |
| 607 | WrappedOpenGL::TextureData &details = m_Driver->m_Textures[id]; |
| 608 | |
| 609 | GLInitialContents initContents; |
| 610 | |
| 611 | initContents.type = eResTexture; |
| 612 | |
| 613 | TextureStateInitialData &state = initContents.tex; |
| 614 | |
| 615 | state.internalformat = details.internalFormat; |
| 616 | state.isView = details.view; |
| 617 | state.width = details.width; |
| 618 | state.height = details.height; |
| 619 | state.depth = details.depth; |
| 620 | state.samples = details.samples; |
| 621 | state.dim = details.dimension; |
| 622 | state.type = details.curType; |
| 623 | state.mips = 1; |
| 624 | |
| 625 | if(details.internalFormat == eGL_NONE) |
| 626 | { |
| 627 | // textures can get here as GL_NONE if they were created and dirtied (by setting lots of |
| 628 | // texture parameters) without ever having storage allocated (via glTexStorage or glTexImage). |
| 629 | // in that case, just ignore as we won't bother with the initial states. |
| 630 | } |
| 631 | else if(details.curType != eGL_TEXTURE_BUFFER) |
| 632 | { |
| 633 | GLenum binding = TextureBinding(details.curType); |
| 634 | |
| 635 | state.mips = GetNumMips(details.curType, res.name, details.width, details.height, details.depth); |
| 636 | |
| 637 | bool ms = (details.curType == eGL_TEXTURE_2D_MULTISAMPLE || |
| 638 | details.curType == eGL_TEXTURE_2D_MULTISAMPLE_ARRAY); |
| 639 | |
| 640 | state.depthMode = eGL_NONE; |
| 641 | if(IsDepthStencilFormat(details.internalFormat)) |
| 642 | { |
| 643 | if(HasExt[ARB_stencil_texturing]) |
| 644 | GL.glGetTextureParameterivEXT(res.name, details.curType, eGL_DEPTH_STENCIL_TEXTURE_MODE, |
| 645 | (GLint *)&state.depthMode); |
| 646 | else |
| 647 | state.depthMode = eGL_DEPTH_COMPONENT; |
| 648 | } |
| 649 | |
| 650 | state.seamless = GL_FALSE; |
| 651 | if((details.curType == eGL_TEXTURE_CUBE_MAP || details.curType == eGL_TEXTURE_CUBE_MAP_ARRAY) && |
| 652 | HasExt[ARB_seamless_cubemap_per_texture]) |
| 653 | GL.glGetTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_CUBE_MAP_SEAMLESS, |
| 654 | (GLint *)&state.seamless); |
| 655 | |
| 656 | if(details.curType != eGL_TEXTURE_RECTANGLE) |
| 657 | { |
| 658 | GL.glGetTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_BASE_LEVEL, |
| 659 | (GLint *)&state.baseLevel); |
| 660 | GL.glGetTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_MAX_LEVEL, |
| 661 | (GLint *)&state.maxLevel); |
| 662 | } |
nothing calls this directly
no test coverage detected