wined3d: Add fields from StaticPixelFormatDesc to struct GlPixelFormatDesc.

The idea here is that we should lookup format information in struct
GlPixelFormatDesc, while StaticPixelFormatDesc and GlPixelFormatDescTemplate
will only be used to build the table.
This commit is contained in:
Henri Verbeet 2009-03-13 10:44:17 +01:00 committed by Alexandre Julliard
parent fbfc7c9742
commit 53bf5c2658
4 changed files with 62 additions and 7 deletions

View File

@ -4458,6 +4458,8 @@ nogl_adapter:
This->adapters[0].TextureRam = 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
}
initPixelFormatsNoGL(&This->adapters[0].gl_info);
This->adapter_count = 1;
return FALSE;
}

View File

@ -365,6 +365,35 @@ static inline int getFmtIdx(WINED3DFORMAT fmt) {
return -1;
}
BOOL initPixelFormatsNoGL(WineD3D_GL_Info *gl_info)
{
UINT format_count = sizeof(formats) / sizeof(*formats);
UINT i;
gl_info->gl_formats = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, format_count * sizeof(*gl_info->gl_formats));
if (!gl_info->gl_formats)
{
ERR("Failed to allocate memory.\n");
return FALSE;
}
for (i = 0; i < format_count; ++i)
{
struct GlPixelFormatDesc *desc = &gl_info->gl_formats[i];
desc->format = formats[i].format;
desc->red_mask = formats[i].redMask;
desc->green_mask = formats[i].greenMask;
desc->blue_mask = formats[i].blueMask;
desc->alpha_mask = formats[i].alphaMask;
desc->byte_count = formats[i].bpp;
desc->depth_size = formats[i].depthSize;
desc->stencil_size = formats[i].stencilSize;
if (formats[i].isFourcc) desc->Flags |= WINED3DFMT_FLAG_FOURCC;
}
return TRUE;
}
#define GLINFO_LOCATION (*gl_info)
BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
{
@ -379,14 +408,27 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
* after this loop
*/
for(src = 0; src < sizeof(gl_formats_template) / sizeof(gl_formats_template[0]); src++) {
struct GlPixelFormatDesc *desc;
dst = getFmtIdx(gl_formats_template[src].fmt);
gl_info->gl_formats[dst].glInternal = gl_formats_template[src].glInternal;
gl_info->gl_formats[dst].glGammaInternal = gl_formats_template[src].glGammaInternal;
gl_info->gl_formats[dst].glFormat = gl_formats_template[src].glFormat;
gl_info->gl_formats[dst].glType = gl_formats_template[src].glType;
gl_info->gl_formats[dst].color_fixup = COLOR_FIXUP_IDENTITY;
gl_info->gl_formats[dst].Flags = gl_formats_template[src].Flags;
gl_info->gl_formats[dst].heightscale = 1.0;
desc = &gl_info->gl_formats[dst];
desc->format = formats[dst].format;
desc->red_mask = formats[dst].redMask;
desc->green_mask = formats[dst].greenMask;
desc->blue_mask = formats[dst].blueMask;
desc->alpha_mask = formats[dst].alphaMask;
desc->byte_count = formats[dst].bpp;
desc->depth_size = formats[dst].depthSize;
desc->stencil_size = formats[dst].stencilSize;
if (formats[dst].isFourcc) desc->Flags |= WINED3DFMT_FLAG_FOURCC;
desc->glInternal = gl_formats_template[src].glInternal;
desc->glGammaInternal = gl_formats_template[src].glGammaInternal;
desc->glFormat = gl_formats_template[src].glFormat;
desc->glType = gl_formats_template[src].glType;
desc->color_fixup = COLOR_FIXUP_IDENTITY;
desc->Flags |= gl_formats_template[src].Flags;
desc->heightscale = 1.0;
if(wined3d_settings.offscreen_rendering_mode == ORM_FBO &&
gl_formats_template[src].rtInternal != 0) {

View File

@ -939,6 +939,7 @@ struct WineD3DAdapter
};
extern BOOL initPixelFormats(WineD3D_GL_Info *gl_info);
BOOL initPixelFormatsNoGL(WineD3D_GL_Info *gl_info);
extern long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram);
extern void add_gl_compat_wrappers(WineD3D_GL_Info *gl_info);
@ -2479,6 +2480,15 @@ extern WINED3DFORMAT pixelformat_for_depth(DWORD depth);
struct GlPixelFormatDesc
{
WINED3DFORMAT format;
DWORD red_mask;
DWORD green_mask;
DWORD blue_mask;
DWORD alpha_mask;
UINT byte_count;
WORD depth_size;
WORD stencil_size;
GLint glInternal;
GLint glGammaInternal;
GLint rtInternal;

View File

@ -29,6 +29,7 @@
#define WINED3DFMT_FLAG_DEPTH 0x4
#define WINED3DFMT_FLAG_STENCIL 0x8
#define WINED3DFMT_FLAG_RENDERTARGET 0x10
#define WINED3DFMT_FLAG_FOURCC 0x20
/** DCL usage masks **/
#define WINED3DSP_DCL_USAGE_SHIFT 0