fixed vrapi swapchain mip level inaccuracy

This commit is contained in:
Jimmy Lee
2017-07-26 02:31:34 -07:00
committed by Baldur Karlsson
parent 310ada841a
commit 517251caee
3 changed files with 27 additions and 13 deletions
+22 -10
View File
@@ -2538,8 +2538,8 @@ void WrappedOpenGL::SwapBuffers(void *windowHandle)
}
}
void WrappedOpenGL::CreateVRAPITextureSwapChain(GLuint tex, GLenum textureType,
GLenum internalformat, GLsizei width, GLsizei height)
void WrappedOpenGL::CreateVRAPITextureSwapChain(GLuint tex, GLenum textureType, GLenum internalformat,
GLsizei width, GLsizei height, GLint levels)
{
GLResource res = TextureRes(GetCtx(), tex);
ResourceId id = GetResourceManager()->RegisterResource(res);
@@ -2559,21 +2559,33 @@ void WrappedOpenGL::CreateVRAPITextureSwapChain(GLuint tex, GLenum textureType,
RDCASSERT(record);
record->AddChunk(chunk);
Common_glTextureParameteriEXT(record, textureType, eGL_TEXTURE_MAX_LEVEL, levels);
}
else
{
GetResourceManager()->AddLiveResource(id, res);
}
if(textureType == eGL_TEXTURE_2D_ARRAY)
for(GLint i = 0; i < levels; ++i)
{
Common_glTextureImage3DEXT(id, eGL_TEXTURE_2D_ARRAY, 0, internalformat, width, height, 2, 0, eGL_RGBA,
eGL_UNSIGNED_BYTE, NULL);
}
else
{
Common_glTextureImage2DEXT(id, eGL_TEXTURE_2D, 0, internalformat, width, height, 0, eGL_RGBA,
eGL_UNSIGNED_BYTE, NULL);
if(textureType == eGL_TEXTURE_2D_ARRAY)
{
Common_glTextureImage3DEXT(id, eGL_TEXTURE_2D_ARRAY, i, internalformat, width, height, 2, 0,
eGL_RGBA, eGL_UNSIGNED_BYTE, NULL);
}
else if(textureType == eGL_TEXTURE_2D)
{
Common_glTextureImage2DEXT(id, eGL_TEXTURE_2D, i, internalformat, width, height, 0, eGL_RGBA,
eGL_UNSIGNED_BYTE, NULL);
}
else
{
RDCERR("Unexpected textureType (%u) in CreateVRAPITextureSwapChain", textureType);
}
width = RDCMAX(1, (width / 2));
height = RDCMAX(1, (height / 2));
}
}
+1 -1
View File
@@ -587,7 +587,7 @@ public:
void WindowSize(void *windowHandle, uint32_t w, uint32_t h);
void SwapBuffers(void *windowHandle);
void CreateVRAPITextureSwapChain(GLuint tex, GLenum textureType, GLenum internalformat,
GLsizei width, GLsizei height);
GLsizei width, GLsizei height, GLint levels);
void FirstFrame(void *ctx, void *wndHandle);
+4 -2
View File
@@ -204,7 +204,8 @@ __attribute__((visibility("default"))) ovrTextureSwapChain *vrapi_CreateTextureS
GLenum internalformat = GetInternalFormat(format);
GLenum textureType = GetTextureType(type);
m_GLDriver->CreateVRAPITextureSwapChain(tex, textureType, internalformat, width, height);
m_GLDriver->CreateVRAPITextureSwapChain(tex, textureType, internalformat, width, height,
levels);
}
}
@@ -236,7 +237,8 @@ __attribute__((visibility("default"))) ovrTextureSwapChain *vrapi_CreateTextureS
GLenum internalformat = GetInternalFormat(format);
GLenum textureType = GetTextureType(type);
m_GLDriver->CreateVRAPITextureSwapChain(tex, textureType, internalformat, width, height);
m_GLDriver->CreateVRAPITextureSwapChain(tex, textureType, internalformat, width, height,
levels);
}
}