|
| 1 | +/* |
| 2 | + * Geforce NV2A PGRAPH OpenGL Renderer debug routines |
| 3 | + * |
| 4 | + * Copyright (c) 2025 Matt Borgerson |
| 5 | + * |
| 6 | + * This library is free software; you can redistribute it and/or |
| 7 | + * modify it under the terms of the GNU Lesser General Public |
| 8 | + * License as published by the Free Software Foundation; either |
| 9 | + * version 2 of the License, or (at your option) any later version. |
| 10 | + * |
| 11 | + * This library is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | + * Lesser General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Lesser General Public |
| 17 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | + |
| 20 | +#include "hw/xbox/nv2a/debug_gl.h" |
| 21 | + |
| 22 | +#include <stdio.h> |
| 23 | + |
| 24 | +#include "qemu/osdep.h" |
| 25 | + |
| 26 | +#ifdef XEMU_DEBUG_BUILD |
| 27 | + |
| 28 | +static GLenum framebuffer_attachments[] = { GL_COLOR_ATTACHMENT0, |
| 29 | + GL_DEPTH_ATTACHMENT, |
| 30 | + GL_STENCIL_ATTACHMENT, |
| 31 | + GL_DEPTH_STENCIL_ATTACHMENT }; |
| 32 | + |
| 33 | +void gl_debug_assert_framebuffer_complete(const char *source_file, int line) |
| 34 | +{ |
| 35 | + GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); |
| 36 | + if (status == GL_FRAMEBUFFER_COMPLETE) { |
| 37 | + return; |
| 38 | + } |
| 39 | + |
| 40 | + fprintf(stderr, |
| 41 | + "OpenGL framebuffer status: 0x%X (%d) != " |
| 42 | + "GL_FRAMEBUFFER_COMPLETE at %s:%d\n", |
| 43 | + status, status, source_file, line); |
| 44 | + |
| 45 | + GLint objectType, objectName; |
| 46 | + for (int i = 0; i < ARRAY_SIZE(framebuffer_attachments); ++i) { |
| 47 | + GLenum attachment = framebuffer_attachments[i]; |
| 48 | + |
| 49 | + glGetFramebufferAttachmentParameteriv( |
| 50 | + GL_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, |
| 51 | + &objectType); |
| 52 | + |
| 53 | + if (objectType == GL_NONE) { |
| 54 | + fprintf(stderr, "\t0x%X: GL_NONE\n", attachment); |
| 55 | + } else { |
| 56 | + glGetFramebufferAttachmentParameteriv( |
| 57 | + GL_FRAMEBUFFER, attachment, |
| 58 | + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &objectName); |
| 59 | + |
| 60 | + fprintf(stderr, "\t0x%X: type=%d, name=%d\n", attachment, |
| 61 | + objectType, objectName); |
| 62 | + |
| 63 | + if (objectType == GL_TEXTURE) { |
| 64 | + GLint width, height, internalFormat; |
| 65 | + glBindTexture(GL_TEXTURE_2D, objectName); |
| 66 | + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, |
| 67 | + &width); |
| 68 | + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, |
| 69 | + &height); |
| 70 | + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, |
| 71 | + GL_TEXTURE_INTERNAL_FORMAT, |
| 72 | + &internalFormat); |
| 73 | + fprintf(stderr, "\t\tTexture: %dx%d, format=0x%X\n", width, |
| 74 | + height, internalFormat); |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + assert(!"OpenGL GL_FRAMEBUFFER status != GL_FRAMEBUFFER_COMPLETE"); |
| 80 | +} |
| 81 | + |
| 82 | +#endif // ifdef XEMU_DEBUG_BUILD |
0 commit comments