Number of mips should be clamped to MAX_LEVEL+1

* Even this isn't quite enough. We're actually assuming a 'complete'
  texture, i.e. one which has had all mips uploaded/init'd. It's actually
  valid to have a texture that doesn't have all of its mips initialised
  but as long as you don't use them, ie. you bind a point sampler or you
  use it as a framebuffer attachments, it's valid. So REALLY in the
  non-immutable case, we need to iterate over every level and query to see
  if it's been configured, e.g. by fetching its width. Sigh.
This commit is contained in:
baldurk
2014-11-29 01:31:22 +00:00
parent 322c341fa2
commit 87f9a15a3e
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -193,7 +193,7 @@ bool GLResourceManager::Prepare_InitialState(GLResource res)
GLint maxLevel = 1000;
gl.glGetTexParameteriv(details.curType, eGL_TEXTURE_MAX_LEVEL, &maxLevel);
mips = RDCMIN(mips, maxLevel);
mips = RDCMIN(mips, maxLevel+1);
gl.glBindTexture(details.curType, tex);
@@ -421,7 +421,7 @@ bool GLResourceManager::Serialise_InitialState(GLResource res)
GLint maxLevel = 1000;
gl.glGetTexParameteriv(details.curType, eGL_TEXTURE_MAX_LEVEL, &maxLevel);
imgmips = RDCMIN(imgmips, maxLevel);
imgmips = RDCMIN(imgmips, maxLevel+1);
TextureStateInitialData *state = (TextureStateInitialData *)GetInitialContents(Id).blob;
@@ -792,7 +792,7 @@ void GLResourceManager::Apply_InitialState(GLResource live, InitialContentData i
GLint maxLevel = 1000;
gl.glGetTexParameteriv(details.curType, eGL_TEXTURE_MAX_LEVEL, &maxLevel);
mips = RDCMIN(mips, maxLevel);
mips = RDCMIN(mips, maxLevel+1);
// copy over mips
for(int i=0; i < mips; i++)
+1 -1
View File
@@ -517,7 +517,7 @@ void GLReplay::CacheTexture(ResourceId id)
GLuint maxLevel = 1000;
gl.glGetTexParameteriv(target, eGL_TEXTURE_MAX_LEVEL, (GLint *)&maxLevel);
tex.mips = RDCMIN(tex.mips, maxLevel);
tex.mips = RDCMIN(tex.mips, maxLevel+1);
tex.numSubresources = tex.mips*tex.arraysize;