[WineD3D] prepare VBO

Oliver Stieber oliver_stieber at yahoo.co.uk
Sat Jul 23 12:40:12 CDT 2005


--- Raphael <fenix at club-internet.fr> wrote:

> Hi,
> 
>  Changelog:
>   - add a new settings for vbo support
>   - use a struct to handle wined3d settings
>   - prepare VBO using some abstraction APIs

I should have added, this patch is good to go in though....


> 
> Regards,
> Raphael
> > ? wined3d.spec.def
> Index: directx.c
> ===================================================================
> RCS file: /home/wine/wine/dlls/wined3d/directx.c,v
> retrieving revision 1.41
> diff -u -r1.41 directx.c
> --- directx.c	13 Jul 2005 19:38:40 -0000	1.41
> +++ directx.c	22 Jul 2005 19:52:14 -0000
> @@ -1455,7 +1455,7 @@
>      *pCaps->MaxStreams          = MAX_STREAMS;
>      *pCaps->MaxStreamStride     = 1024;
>  
> -    if (((vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) || (vs_mode == VS_SW) ||
> (DeviceType == D3DDEVTYPE_REF)) {
> +    if (((wined3d_settings.vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) ||
> (wined3d_settings.vs_mode == VS_SW) || (DeviceType == D3DDEVTYPE_REF)) {
>        *pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
>  
>        if (This->gl_info.gl_vendor == VENDOR_MESA ||
> @@ -1469,7 +1469,7 @@
>          *pCaps->MaxVertexShaderConst = 0;
>      }
>  
> -    if ((ps_mode == PS_HW) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && (DeviceType !=
> D3DDEVTYPE_REF)) {
> +    if ((wined3d_settings.ps_mode == PS_HW) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && (DeviceType
> != D3DDEVTYPE_REF)) {
>          *pCaps->PixelShaderVersion    = D3DPS_VERSION(1,4);
>          *pCaps->PixelShader1xMaxValue = 1.0;
>      } else {
> Index: drawprim.c
> ===================================================================
> RCS file: /home/wine/wine/dlls/wined3d/drawprim.c,v
> retrieving revision 1.20
> diff -u -r1.20 drawprim.c
> --- drawprim.c	22 Jul 2005 18:27:04 -0000	1.20
> +++ drawprim.c	22 Jul 2005 19:52:19 -0000
> @@ -365,8 +365,8 @@
>              TRACE("Stream is up %d, %p\n", element->Stream,
> This->stateBlock->streamSource[element->Stream]);
>              data    = (BYTE *)This->stateBlock->streamSource[element->Stream];
>          } else {
> -             TRACE("Stream isn't up %d, %p\n", element->Stream,
> This->stateBlock->streamSource[element->Stream]);
> -            data    = ((IWineD3DVertexBufferImpl
> *)This->stateBlock->streamSource[element->Stream])->resource.allocatedMemory;
> +            TRACE("Stream isn't up %d, %p\n", element->Stream,
> This->stateBlock->streamSource[element->Stream]);
> +            data    =
> IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[element->Stream], 0);
>          }
>          stride  = This->stateBlock->streamStride[element->Stream];
>          data += (BaseVertexIndex * stride);
> @@ -571,12 +571,12 @@
>              if (This->stateBlock->streamIsUP) {
>                  data    = (BYTE *)This->stateBlock->streamSource[nStream];
>              } else {
> -                data    = ((IWineD3DVertexBufferImpl
> *)This->stateBlock->streamSource[nStream])->resource.allocatedMemory;
> +                data =
> IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[nStream], 0);
>              }
>          } else {
>  #if 0 /* TODO: Vertex shader support */
>              thisFVF = This->stateBlock->vertexShaderDecl->fvf[nStream];
> -            data    = ((IDirect3DVertexBuffer8Impl
> *)This->stateBlock->streamSource[nStream])->allocatedMemory;
> +            data    =
> IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[nStream], 0);
>  #endif
>          }
>          VTRACE(("FVF for stream %d is %lx\n", nStream, thisFVF));
> Index: vertexbuffer.c
> ===================================================================
> RCS file: /home/wine/wine/dlls/wined3d/vertexbuffer.c,v
> retrieving revision 1.13
> diff -u -r1.13 vertexbuffer.c
> --- vertexbuffer.c	13 Jul 2005 14:15:54 -0000	1.13
> +++ vertexbuffer.c	22 Jul 2005 19:52:19 -0000
> @@ -1,8 +1,8 @@
>  /*
>   * IWineD3DVertexBuffer Implementation
>   *
> - * Copyright 2002-2004 Jason Edmeades
> - * Copyright 2003-2004 Raphael Junqueira
> + * Copyright 2002-2005 Jason Edmeades
> + *                     Raphael Junqueira
>   * Copyright 2004 Christian Costa
>   *
>   * This library is free software; you can redistribute it and/or
> @@ -149,3 +149,13 @@
>      IWineD3DVertexBufferImpl_Unlock,
>      IWineD3DVertexBufferImpl_GetDesc
>  };
> +
> +BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset) {
> +    IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
> +
> +    return This->resource.allocatedMemory + iOffset;
> +}
> +
> +HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface) {
> +  return D3D_OK;
> +}
> Index: wined3d_main.c
> ===================================================================
> RCS file: /home/wine/wine/dlls/wined3d/wined3d_main.c,v
> retrieving revision 1.11
> diff -u -r1.11 wined3d_main.c
> --- wined3d_main.c	22 Jul 2005 18:26:05 -0000	1.11
> +++ wined3d_main.c	22 Jul 2005 19:52:19 -0000
> @@ -30,8 +30,14 @@
>  int num_lock = 0;
>  void (*wine_tsx11_lock_ptr)(void) = NULL;
>  void (*wine_tsx11_unlock_ptr)(void) = NULL;
> -int vs_mode = VS_HW;   /* Hardware by default */
> -int ps_mode = PS_NONE; /* Disabled by default */
> +
> +
> +wined3d_settings_t wined3d_settings = 
> +{
> +  VS_HW,   /* Hardware by default */
> +  PS_NONE, /* Disabled by default */
> +  VBO_HW   /* Hardware by default */
> +};
>  
>  WineD3DGlobalStatistics *wineD3DGlobalStatistics = NULL;
>  CRITICAL_SECTION resourceStoreCriticalSection;
> @@ -128,12 +134,12 @@
>                  if (!strcmp(buffer,"none"))
>                  {
>                      TRACE("Disable vertex shaders\n");
> -                    vs_mode = VS_NONE;
> +                    wined3d_settings.vs_mode = VS_NONE;
>                  }
>                  else if (!strcmp(buffer,"emulation"))
>                  {
>                      TRACE("Force SW vertex shaders\n");
> -                    vs_mode = VS_SW;
> +                    wined3d_settings.vs_mode = VS_SW;
>                  }
>             }
>             if ( !get_config_key( hkey, appkey, "PixelShaderMode", buffer, size) )
> @@ -141,14 +147,34 @@
>                  if (!strcmp(buffer,"enabled"))
>                  {
>                      TRACE("Allow pixel shaders\n");
> -                    ps_mode = PS_HW;
> +                    wined3d_settings.ps_mode = PS_HW;
> +                }
> +		if (!strcmp(buffer,"disabled"))
> +                {
> +                    TRACE("Disable pixel shaders\n");
> +                    wined3d_settings.ps_mode = PS_NONE;
> +                }
> +           }
> +	   if ( !get_config_key( hkey, appkey, "VertexBufferMode", buffer, size) )
> +           {
> +                if (!strcmp(buffer,"none"))
> +                {
> +                    TRACE("Disable Vertex Buffer Hardware support\n");
> +                    wined3d_settings.vbo_mode = VS_NONE;
> +                }
> +                else if (!strcmp(buffer,"hardware"))
> +                {
> +  	            TRACE("Allow Vertex Buffer Hardware support\n");
> +		    wined3d_settings.vbo_mode = VS_HW;
>                  }
>             }
>         }
> -       if (vs_mode == VS_HW)
> +       if (wined3d_settings.vs_mode == VS_HW)
>             TRACE("Allow HW vertex shaders\n");
> -       if (ps_mode == PS_NONE)
> +       if (wined3d_settings.ps_mode == PS_NONE)
>             TRACE("Disable pixel shaders\n");
> +       if (wined3d_settings.vbo_mode == VBO_NONE)
> +           TRACE("Disable Vertex Buffer Hardware support\n");
>  
>         if (appkey) RegCloseKey( appkey );
>         if (hkey) RegCloseKey( hkey );
> Index: wined3d_private.h
> ===================================================================
> RCS file: /home/wine/wine/dlls/wined3d/wined3d_private.h,v
> retrieving revision 1.42
> diff -u -r1.42 wined3d_private.h
> --- wined3d_private.h	22 Jul 2005 09:06:03 -0000	1.42
> +++ wined3d_private.h	22 Jul 2005 19:52:20 -0000
> @@ -69,16 +69,28 @@
>  extern const DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T];
>  extern const DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S];
>  
> -/* vertex and pixel shader modes */
> -extern int vs_mode;
> +/**
> + * Settings 
> + */
>  #define VS_NONE 0
>  #define VS_HW   1
>  #define VS_SW   2
>  
> -extern int ps_mode;
>  #define PS_NONE 0
>  #define PS_HW   1
>  
> +#define VBO_NONE 0
> +#define VBO_HW   1
> +
> +typedef struct wined3d_settings_s {
> +/* vertex and pixel shader modes */
> +  int vs_mode;
> +  int ps_mode;
> +  int vbo_mode;
> +} wined3d_settings_t;
> +
> +extern wined3d_settings_t wined3d_settings;
> +
>  /* X11 locking */
>  
>  extern void (*wine_tsx11_lock_ptr)(void);
> @@ -979,6 +991,9 @@
>      extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture
> *iface);
>      extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
>      extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
> +
> +    extern BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD
> iOffset);
> +    extern HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface);
>      extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
>      extern HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface);
>      /*** class static members ***/
> 



	
	
		
___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com



More information about the wine-devel mailing list