VirtualBox

Ignore:
Timestamp:
Feb 10, 2010 12:10:01 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57504
Message:

crOpenGL: fix host gpu crashes when running realflight3d g4 demo in guest

Location:
trunk/src/VBox/Additions/common/crOpenGL/pack
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_pixel.c

    r20083 r26407  
    1111#include "packspu_proto.h"
    1212
     13static GLboolean packspu_CheckTexImageFormat(GLenum format)
     14{
     15    if (format!=GL_COLOR_INDEX
     16        && format!=GL_RED
     17        && format!=GL_GREEN
     18        && format!=GL_BLUE
     19        && format!=GL_ALPHA
     20        && format!=GL_RGB
     21        && format!=GL_BGR
     22        && format!=GL_RGBA
     23        && format!=GL_BGRA
     24        && format!=GL_LUMINANCE
     25        && format!=GL_LUMINANCE_ALPHA
     26        && format!=GL_DEPTH_COMPONENT)
     27    {
     28        /*crWarning("crPackCheckTexImageFormat FAILED format 0x%x isn't valid", format);*/
     29        return GL_FALSE;
     30    }
     31
     32    return GL_TRUE;
     33}
     34
     35static GLboolean packspu_CheckTexImageType(GLenum type)
     36{
     37    if (type!=GL_UNSIGNED_BYTE
     38        && type!=GL_BYTE
     39        && type!=GL_BITMAP
     40        && type!=GL_UNSIGNED_SHORT
     41        && type!=GL_SHORT
     42        && type!=GL_UNSIGNED_INT
     43        && type!=GL_INT
     44        && type!=GL_FLOAT
     45        && type!=GL_UNSIGNED_BYTE_3_3_2
     46        && type!=GL_UNSIGNED_BYTE_2_3_3_REV
     47        && type!=GL_UNSIGNED_SHORT_5_6_5
     48        && type!=GL_UNSIGNED_SHORT_5_6_5_REV
     49        && type!=GL_UNSIGNED_SHORT_4_4_4_4
     50        && type!=GL_UNSIGNED_SHORT_4_4_4_4_REV
     51        && type!=GL_UNSIGNED_SHORT_5_5_5_1
     52        && type!=GL_UNSIGNED_SHORT_1_5_5_5_REV
     53        && type!=GL_UNSIGNED_INT_8_8_8_8
     54        && type!=GL_UNSIGNED_INT_8_8_8_8_REV
     55        && type!=GL_UNSIGNED_INT_10_10_10_2
     56        && type!=GL_UNSIGNED_INT_2_10_10_10_REV)
     57    {
     58        /*crWarning("crPackCheckTexImageType FAILED type 0x%x isn't valid", type);*/
     59        return GL_FALSE;
     60    }
     61
     62    return GL_TRUE;
     63}
     64
     65static GLboolean packspu_CheckTexImageInternalFormat(GLint internalformat)
     66{
     67    if (internalformat!=1
     68        && internalformat!=2
     69        && internalformat!=3
     70        && internalformat!=4
     71        && internalformat!=GL_ALPHA
     72        && internalformat!=GL_ALPHA4
     73        && internalformat!=GL_ALPHA8
     74        && internalformat!=GL_ALPHA12
     75        && internalformat!=GL_ALPHA16
     76        && internalformat!=GL_COMPRESSED_ALPHA
     77        && internalformat!=GL_COMPRESSED_LUMINANCE
     78        && internalformat!=GL_COMPRESSED_LUMINANCE_ALPHA
     79        && internalformat!=GL_COMPRESSED_INTENSITY
     80        && internalformat!=GL_COMPRESSED_RGB
     81        && internalformat!=GL_COMPRESSED_RGBA
     82        && internalformat!=GL_DEPTH_COMPONENT
     83        && internalformat!=GL_DEPTH_COMPONENT16
     84        && internalformat!=GL_DEPTH_COMPONENT24
     85        && internalformat!=GL_DEPTH_COMPONENT32
     86        && internalformat!=GL_LUMINANCE
     87        && internalformat!=GL_LUMINANCE4
     88        && internalformat!=GL_LUMINANCE8
     89        && internalformat!=GL_LUMINANCE12
     90        && internalformat!=GL_LUMINANCE16
     91        && internalformat!=GL_LUMINANCE_ALPHA
     92        && internalformat!=GL_LUMINANCE4_ALPHA4
     93        && internalformat!=GL_LUMINANCE6_ALPHA2
     94        && internalformat!=GL_LUMINANCE8_ALPHA8
     95        && internalformat!=GL_LUMINANCE12_ALPHA4
     96        && internalformat!=GL_LUMINANCE12_ALPHA12
     97        && internalformat!=GL_LUMINANCE16_ALPHA16
     98        && internalformat!=GL_INTENSITY
     99        && internalformat!=GL_INTENSITY4
     100        && internalformat!=GL_INTENSITY8
     101        && internalformat!=GL_INTENSITY12
     102        && internalformat!=GL_INTENSITY16
     103        && internalformat!=GL_R3_G3_B2
     104        && internalformat!=GL_RGB
     105        && internalformat!=GL_RGB4
     106        && internalformat!=GL_RGB5
     107        && internalformat!=GL_RGB8
     108        && internalformat!=GL_RGB10
     109        && internalformat!=GL_RGB12
     110        && internalformat!=GL_RGB16
     111        && internalformat!=GL_RGBA
     112        && internalformat!=GL_RGBA2
     113        && internalformat!=GL_RGBA4
     114        && internalformat!=GL_RGB5_A1
     115        && internalformat!=GL_RGBA8
     116        && internalformat!=GL_RGB10_A2
     117        && internalformat!=GL_RGBA12
     118        && internalformat!=GL_RGBA16
     119        && internalformat!=GL_SLUMINANCE
     120        && internalformat!=GL_SLUMINANCE8
     121        && internalformat!=GL_SLUMINANCE_ALPHA
     122        && internalformat!=GL_SLUMINANCE8_ALPHA8
     123        && internalformat!=GL_SRGB
     124        && internalformat!=GL_SRGB8
     125        && internalformat!=GL_SRGB_ALPHA
     126        && internalformat!=GL_SRGB8_ALPHA8
     127#ifdef CR_EXT_texture_compression_s3tc
     128        && internalformat!=GL_COMPRESSED_RGB_S3TC_DXT1_EXT
     129        && internalformat!=GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
     130        && internalformat!=GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
     131        && internalformat!=GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
     132#endif
     133        )
     134    {
     135        /*crWarning("crPackCheckTexImageInternalFormat FAILED internalformat 0x%x isn't valid", internalformat);*/
     136        return GL_FALSE;
     137    }
     138
     139    return GL_TRUE;
     140}
     141
     142static GLboolean packspu_CheckTexImageParams(GLint internalformat, GLenum format, GLenum type)
     143{
     144    return packspu_CheckTexImageFormat(format)
     145           && packspu_CheckTexImageType(type)
     146           && packspu_CheckTexImageInternalFormat(internalformat);
     147}
     148
     149static GLboolean packspu_CheckTexImageFormatType(GLenum format, GLenum type)
     150{
     151    return packspu_CheckTexImageFormat(format)
     152           && packspu_CheckTexImageType(type);
     153}
     154
    13155void PACKSPU_APIENTRY packspu_PixelStoref( GLenum pname, GLfloat param )
    14156{
     
    80222    GET_CONTEXT(ctx);
    81223    CRClientState *clientState = &(ctx->clientState->client);
     224
     225    if (!packspu_CheckTexImageParams(internalformat, format, type))
     226    {
     227        if (pixels)
     228        {
     229            crWarning("packspu_TexImage1D invalid internalFormat(%x)/format(%x)/type(%x)", internalformat, format, type);
     230            return;
     231        }
     232        internalformat = packspu_CheckTexImageInternalFormat(internalformat) ? internalformat:GL_RGBA;
     233        format = packspu_CheckTexImageFormat(format) ? format:GL_RGBA;
     234        type = packspu_CheckTexImageType(type) ? type:GL_UNSIGNED_BYTE;
     235    }
     236
    82237    if (pack_spu.swap)
    83238        crPackTexImage1DSWAP( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) );
     
    90245    GET_CONTEXT(ctx);
    91246    CRClientState *clientState = &(ctx->clientState->client);
     247
     248    if (!packspu_CheckTexImageParams(internalformat, format, type))
     249    {
     250        if (pixels)
     251        {
     252            crWarning("packspu_TexImage2D invalid internalFormat(%x)/format(%x)/type(%x)", internalformat, format, type);
     253            return;
     254        }
     255        internalformat = packspu_CheckTexImageInternalFormat(internalformat) ? internalformat:GL_RGBA;
     256        format = packspu_CheckTexImageFormat(format) ? format:GL_RGBA;
     257        type = packspu_CheckTexImageType(type) ? type:GL_UNSIGNED_BYTE;
     258    }
     259
    92260    if (pack_spu.swap)
    93261        crPackTexImage2DSWAP( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) );
     
    101269    GET_CONTEXT(ctx);
    102270    CRClientState *clientState = &(ctx->clientState->client);
     271
    103272    if (pack_spu.swap)
    104273        crPackTexImage3DEXTSWAP( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
     
    124293    GET_CONTEXT(ctx);
    125294    CRClientState *clientState = &(ctx->clientState->client);
     295
     296    if (!packspu_CheckTexImageFormatType(format, type))
     297    {
     298        crWarning("packspu_TexSubImage1D invalid format(%x)/type(%x)", format, type);
     299        return;
     300    }
     301
    126302    if (pack_spu.swap)
    127303        crPackTexSubImage1DSWAP( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) );
     
    134310    GET_CONTEXT(ctx);
    135311    CRClientState *clientState = &(ctx->clientState->client);
     312
     313    if (!packspu_CheckTexImageFormatType(format, type))
     314    {
     315        crWarning("packspu_TexSubImage2D invalid format(%x)/type(%x)", format, type);
     316        return;
     317    }
     318
    136319    if (pack_spu.swap)
    137320        crPackTexSubImage2DSWAP( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) );
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_special

    r26048 r26407  
    9595CheckFramebufferStatusEXT
    9696BindTexture
     97DeleteTextures
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c

    r26048 r26407  
    3737    crPackBindTexture(target, texture);
    3838}
     39
     40void PACKSPU_APIENTRY packspu_DeleteTextures(GLsizei n, const GLuint * textures)
     41{
     42    crStateDeleteTextures(n, textures);
     43    crPackDeleteTextures(n, textures);
     44}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette