Applying a patch from Keith Whitwell: Adds some svga3dutil support for surface flags, and uses those flags in Bunnies to specify the static VB/IB usage of its buffers. This is the same behaviour we expect from well-behaved guest drivers, and it makes Bunnies a better tool for performance testing various host configurations.

This commit is contained in:
Micah Dowty 2010-02-10 22:16:35 +00:00
parent 28e788a308
commit 791ddd6a8f
3 changed files with 59 additions and 6 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);