diff --git a/examples/bunnies/main.c b/examples/bunnies/main.c index 66693bc..cbb5441 100644 --- a/examples/bunnies/main.c +++ b/examples/bunnies/main.c @@ -167,8 +167,14 @@ main(void) SVGA3DUtil_InitFullscreen(CID, 800, 600); SVGA3DText_Init(); - vertexSid = SVGA3DUtil_LoadCompressedBuffer(vbFile, &vbSize); - indexSid = SVGA3DUtil_LoadCompressedBuffer(ibFile, &ibSize); + vertexSid = SVGA3DUtil_LoadCompressedBuffer(vbFile, + (SVGA3D_SURFACE_HINT_VERTEXBUFFER | + SVGA3D_SURFACE_HINT_STATIC), + &vbSize); + indexSid = SVGA3DUtil_LoadCompressedBuffer(ibFile, + (SVGA3D_SURFACE_HINT_INDEXBUFFER | + SVGA3D_SURFACE_HINT_STATIC), + &ibSize); Matrix_Perspective(perspectiveMat, 45.0f, gSVGA.width / (float)gSVGA.height, 0.1f, 100.0f); diff --git a/lib/util/svga3dutil.c b/lib/util/svga3dutil.c index c251e0f..bc4176b 100644 --- a/lib/util/svga3dutil.c +++ b/lib/util/svga3dutil.c @@ -1,5 +1,5 @@ /********************************************************** - * Copyright 2008-2009 VMware, Inc. All rights reserved. + * Copyright 2008-2010 VMware, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -435,6 +435,49 @@ SVGA3DUtil_DefineSurface2D(uint32 width, // IN } +/* + *---------------------------------------------------------------------- + * + * SVGA3DUtil_DefineSurface2DFlags -- + * + * This is a simplified version of SVGA3D_BeginDefineSurface(), + * which does not support cube maps, mipmaps, or volume textures, + * but which does allow the caller to specify whether this is an + * index or vertex buffer, and whether it is static or dynamic. + * + * Results: + * Returns the new surface ID. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +uint32 +SVGA3DUtil_DefineSurface2DFlags(uint32 width, // IN + uint32 height, // IN + SVGA3dSurfaceFormat format, // IN + uint32 flags) // IN +{ + uint32 sid; + SVGA3dSize *mipSizes; + SVGA3dSurfaceFace *faces; + + sid = SVGA3DUtil_AllocSurfaceID(); + SVGA3D_BeginDefineSurface(sid, flags, format, &faces, &mipSizes, 1); + + faces[0].numMipLevels = 1; + + mipSizes[0].width = width; + mipSizes[0].height = height; + mipSizes[0].depth = 1; + + SVGA_FIFOCommitAll(); + + return sid; +} + + /* *---------------------------------------------------------------------- * @@ -538,12 +581,13 @@ SVGA3DUtil_DefineStaticBuffer(const void *data, // IN uint32 SVGA3DUtil_LoadCompressedBuffer(const DataFile *file, // IN + uint32 flags, // IN uint32 *pSize) // OUT (optional) { void *buffer; SVGAGuestPtr gPtr; uint32 size = DataFile_GetDecompressedSize(file); - uint32 sid = SVGA3DUtil_DefineSurface2D(size, 1, SVGA3D_BUFFER); + uint32 sid = SVGA3DUtil_DefineSurface2DFlags(size, 1, SVGA3D_BUFFER, flags); buffer = SVGA3DUtil_AllocDMABuffer(size, &gPtr); DataFile_Decompress(file, buffer, size); diff --git a/lib/util/svga3dutil.h b/lib/util/svga3dutil.h index d87f697..57ea5fa 100644 --- a/lib/util/svga3dutil.h +++ b/lib/util/svga3dutil.h @@ -1,5 +1,5 @@ /********************************************************** - * Copyright 2008-2009 VMware, Inc. All rights reserved. + * Copyright 2008-2010 VMware, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -114,11 +114,14 @@ void *SVGA3DUtil_AllocDMABuffer(uint32 size, SVGAGuestPtr *ptr); uint32 SVGA3DUtil_DefineSurface2D(uint32 width, uint32 height, SVGA3dSurfaceFormat format); +uint32 SVGA3DUtil_DefineSurface2DFlags(uint32 width, uint32 height, uint32 flags, + SVGA3dSurfaceFormat format); void SVGA3DUtil_SurfaceDMA2D(uint32 sid, SVGAGuestPtr *guestPtr, SVGA3dTransferType transfer, uint32 width, uint32 height); uint32 SVGA3DUtil_DefineStaticBuffer(const void *data, uint32 size); -uint32 SVGA3DUtil_LoadCompressedBuffer(const DataFile *file, uint32 *pSize); +uint32 SVGA3DUtil_LoadCompressedBuffer(const DataFile *file, uint32 flags, + uint32 *pSize); void SVGA3DUtil_AllocDMAPool(DMAPool *self, uint32 bufferSize, uint32 numBuffers); DMAPoolBuffer *SVGA3DUtil_DMAPoolGetBuffer(DMAPool *self);