【发布时间】:2015-03-19 05:15:30
【问题描述】:
我有一个非常随机的崩溃发生,大约十分之一的时候我会在nvoglv32.dll 中遇到崩溃。它并不总是发生在完全相同的地方,但它确实发生在距离同一个地方大约 10 行的范围内。
我添加了使用 glTexSubImage2D() 更新纹理的功能,现在我遇到了这些间歇性崩溃。
void UpdateTexture(const GLuint textureID, const CaffApp::Dev::Format format, const CaffApp::Dev::TextureD dimention, const uint32_t offsetX, const uint32_t offsetY, const uint32_t width, const uint32_t height, void *data)
{
using namespace CaffApp::Dev;
const auto externalFormat = format == Format::DEV ? GL_RGBA32F : GL_RGBA ;
const auto internalFormat = GL_RGBA;
const auto formatType = format == Format::R8G8B8 ? GL_UNSIGNED_BYTE : GL_FLOAT;
const auto glDimention = GetDimentionTarget(dimention);
assert(CaffMath::IsPOW2(texWidth));
assert(CaffMath::IsPOW2(texHeight));
glBindTexture(glDimention, textureID);
switch(glDimention)
{
case(GL_TEXTURE_1D):
{
glTexSubImage1D(GL_TEXTURE_1D, offsetX, 0, texWidth, internalFormat, formatType, data);
break;
}
case(GL_TEXTURE_2D):
{
glTexSubImage2D(GL_TEXTURE_2D, 0, offsetX, offsetY, texWidth, texHeight, internalFormat, formatType, data);
break;
}
};
glBindTexture(glDimention, 0);
GL_ERROR("Updating texture.")
}
void Texture::updateSubset(const std::vector<float> &data, const uint32_t offsetX, const uint32_t offsetY)
{
assert(m_textureID);
uint32_t sizeX = m_width;
uint32_t sizeY = m_height;
if(sizeX == 0 || sizeY == 0)
{
SetTextureDimentionFromDataSize(m_dimention, data.size(), sizeX, sizeY);
}
UpdateTexture(m_textureID, m_format, m_dimention, offsetX, offsetY, sizeX, sizeY, (void*)data.data());
GL_ERROR("Updating texture.")
}
如果崩溃发生,它只会在第一次调用 glTexSubImage... 时发生。否则很好。
我确实看到了一些关于顶点属性设置不正确的问题,但我真的看不出那里有什么问题,而且代码在 2 年左右没有改变,所以在这里考虑一下。
有什么想法吗?
【问题讨论】: