Commit b83dc6bb authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Move the GL info structure into the adapter.

parent 6ac59b96
......@@ -1711,7 +1711,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration(IWineD3DDevice*
return hr;
}
static size_t ConvertFvfToDeclaration(DWORD fvf, WINED3DVERTEXELEMENT** ppVertexElements) {
static size_t ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the GL info, which has the type table */
DWORD fvf, WINED3DVERTEXELEMENT** ppVertexElements) {
unsigned int idx, idx2;
unsigned int offset;
......@@ -1839,10 +1840,11 @@ static size_t ConvertFvfToDeclaration(DWORD fvf, WINED3DVERTEXELEMENT** ppVertex
static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclarationFromFVF(IWineD3DDevice* iface, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *Parent, DWORD Fvf) {
WINED3DVERTEXELEMENT* elements = NULL;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
size_t size;
DWORD hr;
size = ConvertFvfToDeclaration(Fvf, &elements);
size = ConvertFvfToDeclaration(This, Fvf, &elements);
if (size == 0) return WINED3DERR_OUTOFVIDEOMEMORY;
hr = IWineD3DDevice_CreateVertexDeclaration(iface, ppVertexDeclaration, Parent, elements, size);
......
......@@ -3160,7 +3160,7 @@ BOOL InitAdapters(void) {
select_shader_mode(&Adapters[0].gl_info, WINED3DDEVTYPE_HAL, &ps_selected_mode, &vs_selected_mode);
select_shader_max_constants(ps_selected_mode, vs_selected_mode, &Adapters[0].gl_info);
fillGLAttribFuncs(&Adapters[0].gl_info);
init_type_lookup(&Adapters[0].gl_info);
}
numAdapters = 1;
TRACE("%d adapters successfully initialized\n", numAdapters);
......
......@@ -326,6 +326,38 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
return TRUE;
}
/* NOTE: Make sure these are in the correct numerical order. (see /include/wined3d_types.h) */
static WINED3DGLTYPE const glTypeLookupTemplate[WINED3DDECLTYPE_UNUSED] = {
{WINED3DDECLTYPE_FLOAT1, 1, GL_FLOAT , GL_FALSE ,sizeof(float)},
{WINED3DDECLTYPE_FLOAT2, 2, GL_FLOAT , GL_FALSE ,sizeof(float)},
{WINED3DDECLTYPE_FLOAT3, 3, GL_FLOAT , GL_FALSE ,sizeof(float)},
{WINED3DDECLTYPE_FLOAT4, 4, GL_FLOAT , GL_FALSE ,sizeof(float)},
{WINED3DDECLTYPE_D3DCOLOR, 4, GL_UNSIGNED_BYTE , GL_TRUE ,sizeof(BYTE)},
{WINED3DDECLTYPE_UBYTE4, 4, GL_UNSIGNED_BYTE , GL_FALSE ,sizeof(BYTE)},
{WINED3DDECLTYPE_SHORT2, 2, GL_SHORT , GL_FALSE ,sizeof(short int)},
{WINED3DDECLTYPE_SHORT4, 4, GL_SHORT , GL_FALSE ,sizeof(short int)},
{WINED3DDECLTYPE_UBYTE4N, 4, GL_UNSIGNED_BYTE , GL_TRUE ,sizeof(BYTE)},
{WINED3DDECLTYPE_SHORT2N, 2, GL_SHORT , GL_TRUE ,sizeof(short int)},
{WINED3DDECLTYPE_SHORT4N, 4, GL_SHORT , GL_TRUE ,sizeof(short int)},
{WINED3DDECLTYPE_USHORT2N, 2, GL_UNSIGNED_SHORT , GL_TRUE ,sizeof(short int)},
{WINED3DDECLTYPE_USHORT4N, 4, GL_UNSIGNED_SHORT , GL_TRUE ,sizeof(short int)},
{WINED3DDECLTYPE_UDEC3, 3, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
{WINED3DDECLTYPE_DEC3N, 3, GL_SHORT , GL_TRUE ,sizeof(short int)},
{WINED3DDECLTYPE_FLOAT16_2, 2, GL_HALF_FLOAT_NV , GL_FALSE ,sizeof(GLhalfNV)},
{WINED3DDECLTYPE_FLOAT16_4, 4, GL_HALF_FLOAT_NV , GL_FALSE ,sizeof(GLhalfNV)}};
void init_type_lookup(WineD3D_GL_Info *gl_info) {
memcpy(gl_info->glTypeLookup, glTypeLookupTemplate, sizeof(glTypeLookupTemplate));
if(!GL_SUPPORT(NV_HALF_FLOAT)) {
/* Do not change the size of the type, it is CPU side. Whe have to change the GPU-side information though.
* It is the job of the vertex buffer code to make sure that the vbos have the right format
*/
gl_info->glTypeLookup[WINED3DDECLTYPE_FLOAT16_2].glType = GL_FLOAT;
gl_info->glTypeLookup[WINED3DDECLTYPE_FLOAT16_4].glType = GL_FLOAT;
}
}
#undef GLINFO_LOCATION
#define GLINFO_LOCATION This->adapter->gl_info
......
......@@ -114,42 +114,12 @@ extern DWORD *stateLookup[MAX_LOOKUPS];
extern DWORD minMipLookup[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1];
typedef struct _WINED3DGLTYPE {
int d3dType;
GLint size;
GLenum glType;
GLboolean normalized;
int typesize;
} WINED3DGLTYPE;
/* NOTE: Make sure these are in the correct numerical order. (see /include/wined3d_types.h) */
static WINED3DGLTYPE const glTypeLookup[WINED3DDECLTYPE_UNUSED] = {
{WINED3DDECLTYPE_FLOAT1, 1, GL_FLOAT , GL_FALSE ,sizeof(float)},
{WINED3DDECLTYPE_FLOAT2, 2, GL_FLOAT , GL_FALSE ,sizeof(float)},
{WINED3DDECLTYPE_FLOAT3, 3, GL_FLOAT , GL_FALSE ,sizeof(float)},
{WINED3DDECLTYPE_FLOAT4, 4, GL_FLOAT , GL_FALSE ,sizeof(float)},
{WINED3DDECLTYPE_D3DCOLOR, 4, GL_UNSIGNED_BYTE , GL_TRUE ,sizeof(BYTE)},
{WINED3DDECLTYPE_UBYTE4, 4, GL_UNSIGNED_BYTE , GL_FALSE ,sizeof(BYTE)},
{WINED3DDECLTYPE_SHORT2, 2, GL_SHORT , GL_FALSE ,sizeof(short int)},
{WINED3DDECLTYPE_SHORT4, 4, GL_SHORT , GL_FALSE ,sizeof(short int)},
{WINED3DDECLTYPE_UBYTE4N, 4, GL_UNSIGNED_BYTE , GL_TRUE ,sizeof(BYTE)},
{WINED3DDECLTYPE_SHORT2N, 2, GL_SHORT , GL_TRUE ,sizeof(short int)},
{WINED3DDECLTYPE_SHORT4N, 4, GL_SHORT , GL_TRUE ,sizeof(short int)},
{WINED3DDECLTYPE_USHORT2N, 2, GL_UNSIGNED_SHORT , GL_TRUE ,sizeof(short int)},
{WINED3DDECLTYPE_USHORT4N, 4, GL_UNSIGNED_SHORT , GL_TRUE ,sizeof(short int)},
{WINED3DDECLTYPE_UDEC3, 3, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
{WINED3DDECLTYPE_DEC3N, 3, GL_SHORT , GL_TRUE ,sizeof(short int)},
/* We should do an extension check for NV_HALF_FLOAT. However, without NV_HALF_FLOAT
* we won't be able to load the data at all, so at least for the moment it wouldn't
* gain us much. */
{WINED3DDECLTYPE_FLOAT16_2, 2, GL_HALF_FLOAT_NV , GL_FALSE ,sizeof(GLhalfNV)},
{WINED3DDECLTYPE_FLOAT16_4, 4, GL_HALF_FLOAT_NV , GL_FALSE ,sizeof(GLhalfNV)}};
#define WINED3D_ATR_TYPE(type) glTypeLookup[type].d3dType
#define WINED3D_ATR_SIZE(type) glTypeLookup[type].size
#define WINED3D_ATR_GLTYPE(type) glTypeLookup[type].glType
#define WINED3D_ATR_NORMALIZED(type) glTypeLookup[type].normalized
#define WINED3D_ATR_TYPESIZE(type) glTypeLookup[type].typesize
void init_type_lookup(WineD3D_GL_Info *gl_info);
#define WINED3D_ATR_TYPE(type) GLINFO_LOCATION.glTypeLookup[type].d3dType
#define WINED3D_ATR_SIZE(type) GLINFO_LOCATION.glTypeLookup[type].size
#define WINED3D_ATR_GLTYPE(type) GLINFO_LOCATION.glTypeLookup[type].glType
#define WINED3D_ATR_NORMALIZED(type) GLINFO_LOCATION.glTypeLookup[type].normalized
#define WINED3D_ATR_TYPESIZE(type) GLINFO_LOCATION.glTypeLookup[type].typesize
/**
* Settings
......
......@@ -3634,6 +3634,14 @@ typedef struct {
WINED3DFORMAT conversion_group;
} GlPixelFormatDesc;
typedef struct _WINED3DGLTYPE {
int d3dType;
GLint size;
GLenum glType;
GLboolean normalized;
int typesize;
} WINED3DGLTYPE;
#define USE_GL_FUNC(type, pfn, ext, replace) type pfn;
typedef struct _WineD3D_GL_Info {
......@@ -3695,6 +3703,9 @@ typedef struct _WineD3D_GL_Info {
WGL_EXT_FUNCS_GEN;
GlPixelFormatDesc *gl_formats;
/* Vertex data types */
WINED3DGLTYPE glTypeLookup[WINED3DDECLTYPE_UNUSED];
} WineD3D_GL_Info;
#undef USE_GL_FUNC
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment