debugging the mip not beeing copied correctly on 4.1

This commit is contained in:
samcake 2017-04-26 18:50:28 -07:00
parent 6e6fd608dd
commit 4f8f3a8656
3 changed files with 41 additions and 7 deletions

View file

@ -48,7 +48,7 @@ BackendPointer GLBackend::createBackend() {
// Where the gpuContext is initialized and where the TRUE Backend is created and assigned // Where the gpuContext is initialized and where the TRUE Backend is created and assigned
auto version = QOpenGLContextWrapper::currentContextVersion(); auto version = QOpenGLContextWrapper::currentContextVersion();
std::shared_ptr<GLBackend> result; std::shared_ptr<GLBackend> result;
if (!disableOpenGL45 && version >= 0x0405) { if (false && !disableOpenGL45 && version >= 0x0405) {
qCDebug(gpugllogging) << "Using OpenGL 4.5 backend"; qCDebug(gpugllogging) << "Using OpenGL 4.5 backend";
result = std::make_shared<gpu::gl45::GL45Backend>(); result = std::make_shared<gpu::gl45::GL45Backend>();
} else { } else {

View file

@ -300,7 +300,7 @@ void GL41VariableAllocationTexture::promote() {
// allocate storage for new level // allocate storage for new level
allocateStorage(_allocatedMip - std::min<uint16_t>(_allocatedMip, 2)); allocateStorage(_allocatedMip - std::min<uint16_t>(_allocatedMip, 2));
/*
withPreservedTexture([&] { withPreservedTexture([&] {
GLuint fbo { 0 }; GLuint fbo { 0 };
glGenFramebuffers(1, &fbo); glGenFramebuffers(1, &fbo);
@ -325,7 +325,24 @@ void GL41VariableAllocationTexture::promote() {
glDeleteFramebuffers(1, &fbo); glDeleteFramebuffers(1, &fbo);
syncSampler(); syncSampler();
}); });*/
uint16_t mips = _gpuObject.getNumMips();
// copy pre-existing mips
for (uint16_t mip = _populatedMip; mip < mips; ++mip) {
auto mipDimensions = _gpuObject.evalMipDimensions(mip);
uint16_t targetMip = mip - _allocatedMip;
uint16_t sourceMip = mip - oldAllocatedMip;
auto faces = getFaceCount(_target);
for (uint8_t face = 0; face < faces; ++face) {
glCopyImageSubData(
oldId, _target, sourceMip, 0, 0, face,
_id, _target, targetMip, 0, 0, face,
mipDimensions.x, mipDimensions.y, 1
);
(void)CHECK_GL_ERROR();
}
}
// destroy the old texture // destroy the old texture
glDeleteTextures(1, &oldId); glDeleteTextures(1, &oldId);
@ -343,7 +360,7 @@ void GL41VariableAllocationTexture::demote() {
uint16_t oldAllocatedMip = _allocatedMip; uint16_t oldAllocatedMip = _allocatedMip;
allocateStorage(_allocatedMip + 1); allocateStorage(_allocatedMip + 1);
_populatedMip = std::max(_populatedMip, _allocatedMip); _populatedMip = std::max(_populatedMip, _allocatedMip);
/*
withPreservedTexture([&] { withPreservedTexture([&] {
GLuint fbo { 0 }; GLuint fbo { 0 };
glCreateFramebuffers(1, &fbo); glCreateFramebuffers(1, &fbo);
@ -368,7 +385,24 @@ void GL41VariableAllocationTexture::demote() {
glDeleteFramebuffers(1, &fbo); glDeleteFramebuffers(1, &fbo);
syncSampler(); syncSampler();
}); });*/
// copy pre-existing mips
uint16_t mips = _gpuObject.getNumMips();
for (uint16_t mip = _populatedMip; mip < mips; ++mip) {
auto mipDimensions = _gpuObject.evalMipDimensions(mip);
uint16_t targetMip = mip - _allocatedMip;
uint16_t sourceMip = targetMip + 1;
auto faces = getFaceCount(_target);
for (uint8_t face = 0; face < faces; ++face) {
glCopyImageSubData(
oldId, _target, sourceMip, 0, 0, face,
_id, _target, targetMip, 0, 0, face,
mipDimensions.x, mipDimensions.y, 1
);
(void)CHECK_GL_ERROR();
}
}
// destroy the old texture // destroy the old texture

View file

@ -28,9 +28,9 @@
using namespace gpu; using namespace gpu;
#define CPU_MIPMAPS 1 #define CPU_MIPMAPS 1
#define COMPRESS_COLOR_TEXTURES 0 #define COMPRESS_COLOR_TEXTURES 1
#define COMPRESS_NORMALMAP_TEXTURES 0 // Disable Normalmap compression for now #define COMPRESS_NORMALMAP_TEXTURES 0 // Disable Normalmap compression for now
#define COMPRESS_GRAYSCALE_TEXTURES 0 #define COMPRESS_GRAYSCALE_TEXTURES 1
#define COMPRESS_CUBEMAP_TEXTURES 0 // Disable Cubemap compression for now #define COMPRESS_CUBEMAP_TEXTURES 0 // Disable Cubemap compression for now
static const glm::uvec2 SPARSE_PAGE_SIZE(128); static const glm::uvec2 SPARSE_PAGE_SIZE(128);