LibGL: Simplify glDrawPixels checks and reduce debug spam

This commit is contained in:
Jelle Raaijmakers 2021-12-21 14:42:25 +01:00 committed by Brian Gianforcaro
parent a1fb16e89c
commit 7fa2e792a8
Notes: sideshowbarker 2024-07-17 22:28:16 +09:00
2 changed files with 14 additions and 45 deletions

View file

@ -170,9 +170,6 @@ extern "C" {
// Format enums
#define GL_COLOR_INDEX 0x1900
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
#define GL_BITMAP 0x1A00
#define GL_STENCIL_INDEX 0x1901
#define GL_DEPTH_COMPONENT 0x1902
#define GL_RED 0x1903
@ -181,6 +178,11 @@ extern "C" {
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
#define GL_BGR 0x190B
#define GL_BGRA 0x190C
#define GL_BITMAP 0x1A00
// Lighting related defines
#define GL_LIGHTING 0x0B50
@ -208,12 +210,6 @@ extern "C" {
#define GL_LINE 0x1B01
#define GL_FILL 0x1B02
// Pixel formats
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_BGR 0x190B
#define GL_BGRA 0x190C
// Source pixel data format
#define GL_UNSIGNED_BYTE 0x1401
#define GL_UNSIGNED_BYTE_3_3_2 0x8032

View file

@ -2064,41 +2064,11 @@ void SoftwareGLContext::gl_draw_pixels(GLsizei width, GLsizei height, GLenum for
{
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_draw_pixels, width, height, format, type, data);
RETURN_WITH_ERROR_IF(!(format == GL_COLOR_INDEX
|| format == GL_STENCIL_INDEX
|| format == GL_DEPTH_COMPONENT
|| format == GL_RGBA
|| format == GL_BGRA
|| format == GL_RED
|| format == GL_GREEN
|| format == GL_BLUE
|| format == GL_ALPHA
|| format == GL_RGB
|| format == GL_BGR
|| format == GL_LUMINANCE
|| format == GL_LUMINANCE_ALPHA),
GL_INVALID_ENUM);
RETURN_WITH_ERROR_IF(format < GL_COLOR_INDEX || format > GL_BGRA, GL_INVALID_ENUM);
RETURN_WITH_ERROR_IF(!(type == GL_UNSIGNED_BYTE
|| type == GL_BYTE
|| type == GL_BITMAP
|| type == GL_UNSIGNED_SHORT
|| type == GL_SHORT
|| type == GL_UNSIGNED_INT
|| type == GL_INT
|| type == GL_FLOAT
|| type == GL_UNSIGNED_BYTE_3_3_2
|| type == GL_UNSIGNED_BYTE_2_3_3_REV
|| type == GL_UNSIGNED_SHORT_5_6_5
|| type == GL_UNSIGNED_SHORT_5_6_5_REV
|| type == GL_UNSIGNED_SHORT_4_4_4_4
|| type == GL_UNSIGNED_SHORT_4_4_4_4_REV
|| type == GL_UNSIGNED_SHORT_5_5_5_1
|| type == GL_UNSIGNED_SHORT_1_5_5_5_REV
|| type == GL_UNSIGNED_INT_8_8_8_8
|| type == GL_UNSIGNED_INT_8_8_8_8_REV
|| type == GL_UNSIGNED_INT_10_10_10_2
|| type == GL_UNSIGNED_INT_2_10_10_10_REV),
RETURN_WITH_ERROR_IF((type < GL_BYTE || type > GL_FLOAT)
&& (type < GL_UNSIGNED_BYTE_3_3_2 || type > GL_UNSIGNED_INT_10_10_10_2)
&& (type < GL_UNSIGNED_BYTE_2_3_3_REV || type > GL_UNSIGNED_INT_2_10_10_10_REV),
GL_INVALID_ENUM);
RETURN_WITH_ERROR_IF(type == GL_BITMAP && !(format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX), GL_INVALID_ENUM);
@ -2139,8 +2109,11 @@ void SoftwareGLContext::gl_draw_pixels(GLsizei width, GLsizei height, GLenum for
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
// FIXME: we only support RGBA + GL_UNSIGNED_BYTE, implement all the others!
if (format != GL_RGBA || type != GL_UNSIGNED_BYTE) {
dbgln("gl_draw_pixels: unsupported format {:#x} or type {:#x}", format, type);
if (format != GL_RGBA) {
dbgln_if(GL_DEBUG, "gl_draw_pixels(): support for format {:#x} not implemented", format);
return;
} else if (type != GL_UNSIGNED_BYTE) {
dbgln_if(GL_DEBUG, "gl_draw_pixels(): support for type {:#x} not implemented", type);
return;
}