Commit 4434d00f authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Unify vertex and texture formats.

Some fields should be redundant now, eg. gl_vtx_type and glType. I'll leave that for a different patch to fix though.
parent 6f206c75
......@@ -228,7 +228,8 @@ void load_local_constants(const DWORD *d3d8_elements, IWineD3DVertexShader *wine
}
/* NOTE: Make sure these are in the correct numerical order. (see /include/wined3d_types.h) */
static const size_t wined3d_type_sizes[WINED3DDECLTYPE_UNUSED] = {
static const size_t wined3d_type_sizes[] =
{
/*WINED3DDECLTYPE_FLOAT1*/ 1 * sizeof(float),
/*WINED3DDECLTYPE_FLOAT2*/ 2 * sizeof(float),
/*WINED3DDECLTYPE_FLOAT3*/ 3 * sizeof(float),
......@@ -248,6 +249,27 @@ static const size_t wined3d_type_sizes[WINED3DDECLTYPE_UNUSED] = {
/*WINED3DDECLTYPE_FLOAT16_4*/ 4 * sizeof(short int)
};
static const WINED3DFORMAT wined3d_format_lookup[] =
{
/*WINED3DDECLTYPE_FLOAT1*/ WINED3DFMT_R32_FLOAT,
/*WINED3DDECLTYPE_FLOAT2*/ WINED3DFMT_R32G32_FLOAT,
/*WINED3DDECLTYPE_FLOAT3*/ WINED3DFMT_R32G32B32_FLOAT,
/*WINED3DDECLTYPE_FLOAT4*/ WINED3DFMT_R32G32B32A32_FLOAT,
/*WINED3DDECLTYPE_D3DCOLOR*/ WINED3DFMT_A8R8G8B8,
/*WINED3DDECLTYPE_UBYTE4*/ WINED3DFMT_R8G8B8A8_UINT,
/*WINED3DDECLTYPE_SHORT2*/ WINED3DFMT_R16G16_SINT,
/*WINED3DDECLTYPE_SHORT4*/ WINED3DFMT_R16G16B16A16_SINT,
/*WINED3DDECLTYPE_UBYTE4N*/ WINED3DFMT_R8G8B8A8_UNORM,
/*WINED3DDECLTYPE_SHORT2N*/ WINED3DFMT_R16G16_SNORM,
/*WINED3DDECLTYPE_SHORT4N*/ WINED3DFMT_R16G16B16A16_SNORM,
/*WINED3DDECLTYPE_USHORT2N*/ WINED3DFMT_R16G16_UNORM,
/*WINED3DDECLTYPE_USHORT4N*/ WINED3DFMT_R16G16B16A16_UNORM,
/*WINED3DDECLTYPE_UDEC3*/ WINED3DFMT_R10G10B10A2_UINT,
/*WINED3DDECLTYPE_DEC3N*/ WINED3DFMT_R10G10B10A2_SNORM,
/*WINED3DDECLTYPE_FLOAT16_2*/ WINED3DFMT_R16G16_FLOAT,
/*WINED3DDECLTYPE_FLOAT16_4*/ WINED3DFMT_R16G16B16A16_FLOAT,
};
typedef struct {
BYTE usage;
BYTE usage_idx;
......@@ -302,13 +324,13 @@ UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elem
TRACE("Adding element %d:\n", element_count);
element = *wined3d_elements + element_count++;
element->Stream = stream;
element->Method = WINED3DDECLMETHOD_DEFAULT;
element->Usage = wined3d_usage_lookup[reg].usage;
element->UsageIndex = wined3d_usage_lookup[reg].usage_idx;
element->Type = type;
element->Offset = offset;
element->Reg = reg;
element->format = wined3d_format_lookup[type];
element->input_slot = stream;
element->offset = offset;
element->output_slot = reg;
element->method = WINED3DDECLMETHOD_DEFAULT;
element->usage = wined3d_usage_lookup[reg].usage;
element->usage_idx = wined3d_usage_lookup[reg].usage_idx;
offset += wined3d_type_sizes[type];
} else if (token_type == D3DVSD_TOKEN_STREAMDATA && (token_type & 0x10000000)) {
......
......@@ -26,28 +26,29 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
typedef struct _D3DDECLTYPE_INFO {
D3DDECLTYPE d3dType;
WINED3DFORMAT format;
int size;
int typesize;
} D3DDECLTYPE_INFO;
static D3DDECLTYPE_INFO const d3d_dtype_lookup[D3DDECLTYPE_UNUSED] = {
{D3DDECLTYPE_FLOAT1, 1, sizeof(float)},
{D3DDECLTYPE_FLOAT2, 2, sizeof(float)},
{D3DDECLTYPE_FLOAT3, 3, sizeof(float)},
{D3DDECLTYPE_FLOAT4, 4, sizeof(float)},
{D3DDECLTYPE_D3DCOLOR, 4, sizeof(BYTE)},
{D3DDECLTYPE_UBYTE4, 4, sizeof(BYTE)},
{D3DDECLTYPE_SHORT2, 2, sizeof(short int)},
{D3DDECLTYPE_SHORT4, 4, sizeof(short int)},
{D3DDECLTYPE_UBYTE4N, 4, sizeof(BYTE)},
{D3DDECLTYPE_SHORT2N, 2, sizeof(short int)},
{D3DDECLTYPE_SHORT4N, 4, sizeof(short int)},
{D3DDECLTYPE_USHORT2N, 2, sizeof(short int)},
{D3DDECLTYPE_USHORT4N, 4, sizeof(short int)},
{D3DDECLTYPE_UDEC3, 3, sizeof(short int)},
{D3DDECLTYPE_DEC3N, 3, sizeof(short int)},
{D3DDECLTYPE_FLOAT16_2, 2, sizeof(short int)},
{D3DDECLTYPE_FLOAT16_4, 4, sizeof(short int)}};
{D3DDECLTYPE_FLOAT1, WINED3DFMT_R32_FLOAT, 1, sizeof(float)},
{D3DDECLTYPE_FLOAT2, WINED3DFMT_R32G32_FLOAT, 2, sizeof(float)},
{D3DDECLTYPE_FLOAT3, WINED3DFMT_R32G32B32_FLOAT, 3, sizeof(float)},
{D3DDECLTYPE_FLOAT4, WINED3DFMT_R32G32B32A32_FLOAT, 4, sizeof(float)},
{D3DDECLTYPE_D3DCOLOR, WINED3DFMT_A8R8G8B8, 4, sizeof(BYTE)},
{D3DDECLTYPE_UBYTE4, WINED3DFMT_R8G8B8A8_UINT, 4, sizeof(BYTE)},
{D3DDECLTYPE_SHORT2, WINED3DFMT_R16G16_SINT, 2, sizeof(short int)},
{D3DDECLTYPE_SHORT4, WINED3DFMT_R16G16B16A16_SINT, 4, sizeof(short int)},
{D3DDECLTYPE_UBYTE4N, WINED3DFMT_R8G8B8A8_UNORM, 4, sizeof(BYTE)},
{D3DDECLTYPE_SHORT2N, WINED3DFMT_R16G16_SNORM, 2, sizeof(short int)},
{D3DDECLTYPE_SHORT4N, WINED3DFMT_R16G16B16A16_SNORM, 4, sizeof(short int)},
{D3DDECLTYPE_USHORT2N, WINED3DFMT_R16G16_UNORM, 2, sizeof(short int)},
{D3DDECLTYPE_USHORT4N, WINED3DFMT_R16G16B16A16_UNORM, 4, sizeof(short int)},
{D3DDECLTYPE_UDEC3, WINED3DFMT_R10G10B10A2_UINT, 3, sizeof(short int)},
{D3DDECLTYPE_DEC3N, WINED3DFMT_R10G10B10A2_SNORM, 3, sizeof(short int)},
{D3DDECLTYPE_FLOAT16_2, WINED3DFMT_R16G16_FLOAT, 2, sizeof(short int)},
{D3DDECLTYPE_FLOAT16_4, WINED3DFMT_R16G16B16A16_FLOAT, 4, sizeof(short int)}};
#define D3D_DECL_SIZE(type) d3d_dtype_lookup[type].size
#define D3D_DECL_TYPESIZE(type) d3d_dtype_lookup[type].typesize
......@@ -301,35 +302,49 @@ static const IDirect3DVertexDeclaration9Vtbl Direct3DVertexDeclaration9_Vtbl =
IDirect3DVertexDeclaration9Impl_GetDeclaration
};
static UINT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9* d3d9_elements, WINED3DVERTEXELEMENT **wined3d_elements) {
static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9* d3d9_elements,
WINED3DVERTEXELEMENT **wined3d_elements, UINT *element_count)
{
const D3DVERTEXELEMENT9* element;
UINT element_count = 1;
UINT count = 1;
UINT i;
TRACE("d3d9_elements %p, wined3d_elements %p\n", d3d9_elements, wined3d_elements);
element = d3d9_elements;
while (element++->Stream != 0xff && element_count++ < 128);
while (element++->Stream != 0xff && count++ < 128);
if (element_count == 128) {
return ~0U;
}
if (count == 128) return E_FAIL;
/* Skip the END element */
--element_count;
--count;
*wined3d_elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(WINED3DVERTEXELEMENT));
*wined3d_elements = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WINED3DVERTEXELEMENT));
if (!*wined3d_elements) {
FIXME("Memory allocation failed\n");
return ~0U;
return D3DERR_OUTOFVIDEOMEMORY;
}
for (i = 0; i < element_count; ++i) {
CopyMemory(*wined3d_elements + i, d3d9_elements + i, sizeof(D3DVERTEXELEMENT9));
(*wined3d_elements)[i].Reg = -1;
for (i = 0; i < count; ++i)
{
if (d3d9_elements[i].Type >= (sizeof(d3d_dtype_lookup) / sizeof(*d3d_dtype_lookup)))
{
WARN("Invalid element type %#x.\n", d3d9_elements[i].Type);
HeapFree(GetProcessHeap(), 0, *wined3d_elements);
return E_FAIL;
}
(*wined3d_elements)[i].format = d3d_dtype_lookup[d3d9_elements[i].Type].format;
(*wined3d_elements)[i].input_slot = d3d9_elements[i].Stream;
(*wined3d_elements)[i].offset = d3d9_elements[i].Offset;
(*wined3d_elements)[i].output_slot = ~0U;
(*wined3d_elements)[i].method = d3d9_elements[i].Method;
(*wined3d_elements)[i].usage = d3d9_elements[i].Usage;
(*wined3d_elements)[i].usage_idx = d3d9_elements[i].UsageIndex;
}
return element_count;
*element_count = count;
return D3D_OK;
}
/* IDirect3DDevice9 IDirect3DVertexDeclaration9 Methods follow: */
......@@ -340,7 +355,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9E
WINED3DVERTEXELEMENT* wined3d_elements;
UINT wined3d_element_count;
UINT element_count;
HRESULT hr = D3D_OK;
HRESULT hr;
TRACE("(%p) : Relay\n", iface);
if (NULL == ppDecl) {
......@@ -348,11 +363,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9E
return D3DERR_INVALIDCALL;
}
wined3d_element_count = convert_to_wined3d_declaration(pVertexElements, &wined3d_elements);
if (wined3d_element_count == ~0U)
hr = convert_to_wined3d_declaration(pVertexElements, &wined3d_elements, &wined3d_element_count);
if (FAILED(hr))
{
FIXME("(%p) : Error parsing vertex declaration\n", This);
return D3DERR_INVALIDCALL;
WARN("(%p) : Error parsing vertex declaration\n", This);
return hr;
}
/* Allocate the storage for the device */
......
......@@ -3827,12 +3827,12 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
*/
if(VertexType & D3DFVF_POSITION_MASK)
{
WineD3DStrided.position.format = WINED3DFMT_R32G32B32_FLOAT;
WineD3DStrided.position.lpData = D3DDrawPrimStrideData->position.lpvData;
WineD3DStrided.position.dwStride = D3DDrawPrimStrideData->position.dwStride;
WineD3DStrided.position.dwType = WINED3DDECLTYPE_FLOAT3;
if (VertexType & D3DFVF_XYZRHW)
{
WineD3DStrided.position.dwType = WINED3DDECLTYPE_FLOAT4;
WineD3DStrided.position.format = WINED3DFMT_R32G32B32A32_FLOAT;
WineD3DStrided.position_transformed = TRUE;
} else
WineD3DStrided.position_transformed = FALSE;
......@@ -3840,38 +3840,38 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
if(VertexType & D3DFVF_NORMAL)
{
WineD3DStrided.normal.format = WINED3DFMT_R32G32B32_FLOAT;
WineD3DStrided.normal.lpData = D3DDrawPrimStrideData->normal.lpvData;
WineD3DStrided.normal.dwStride = D3DDrawPrimStrideData->normal.dwStride;
WineD3DStrided.normal.dwType = WINED3DDECLTYPE_FLOAT3;
}
if(VertexType & D3DFVF_DIFFUSE)
{
WineD3DStrided.diffuse.format = WINED3DFMT_A8R8G8B8;
WineD3DStrided.diffuse.lpData = D3DDrawPrimStrideData->diffuse.lpvData;
WineD3DStrided.diffuse.dwStride = D3DDrawPrimStrideData->diffuse.dwStride;
WineD3DStrided.diffuse.dwType = WINED3DDECLTYPE_D3DCOLOR;
}
if(VertexType & D3DFVF_SPECULAR)
{
WineD3DStrided.specular.format = WINED3DFMT_A8R8G8B8;
WineD3DStrided.specular.lpData = D3DDrawPrimStrideData->specular.lpvData;
WineD3DStrided.specular.dwStride = D3DDrawPrimStrideData->specular.dwStride;
WineD3DStrided.specular.dwType = WINED3DDECLTYPE_D3DCOLOR;
}
for( i = 0; i < GET_TEXCOUNT_FROM_FVF(VertexType); i++)
{
WineD3DStrided.texCoords[i].lpData = D3DDrawPrimStrideData->textureCoords[i].lpvData;
WineD3DStrided.texCoords[i].dwStride = D3DDrawPrimStrideData->textureCoords[i].dwStride;
switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i))
{
case 1: WineD3DStrided.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT1; break;
case 2: WineD3DStrided.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT2; break;
case 3: WineD3DStrided.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT3; break;
case 4: WineD3DStrided.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT4; break;
case 1: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32_FLOAT; break;
case 2: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32_FLOAT; break;
case 3: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32B32_FLOAT; break;
case 4: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32B32A32_FLOAT; break;
default: ERR("Unexpected texture coordinate size %d\n",
GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i));
}
WineD3DStrided.texCoords[i].lpData = D3DDrawPrimStrideData->textureCoords[i].lpvData;
WineD3DStrided.texCoords[i].dwStride = D3DDrawPrimStrideData->textureCoords[i].dwStride;
}
/* WineD3D doesn't need the FVF here */
......@@ -3968,12 +3968,12 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
*/
if(VertexType & D3DFVF_POSITION_MASK)
{
WineD3DStrided.position.format = WINED3DFMT_R32G32B32_FLOAT;
WineD3DStrided.position.lpData = D3DDrawPrimStrideData->position.lpvData;
WineD3DStrided.position.dwStride = D3DDrawPrimStrideData->position.dwStride;
WineD3DStrided.position.dwType = WINED3DDECLTYPE_FLOAT3;
if (VertexType & D3DFVF_XYZRHW)
{
WineD3DStrided.position.dwType = WINED3DDECLTYPE_FLOAT4;
WineD3DStrided.position.format = WINED3DFMT_R32G32B32A32_FLOAT;
WineD3DStrided.position_transformed = TRUE;
} else
WineD3DStrided.position_transformed = FALSE;
......@@ -3981,38 +3981,38 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
if(VertexType & D3DFVF_NORMAL)
{
WineD3DStrided.normal.format = WINED3DFMT_R32G32B32_FLOAT;
WineD3DStrided.normal.lpData = D3DDrawPrimStrideData->normal.lpvData;
WineD3DStrided.normal.dwStride = D3DDrawPrimStrideData->normal.dwStride;
WineD3DStrided.normal.dwType = WINED3DDECLTYPE_FLOAT3;
}
if(VertexType & D3DFVF_DIFFUSE)
{
WineD3DStrided.diffuse.format = WINED3DFMT_A8R8G8B8;
WineD3DStrided.diffuse.lpData = D3DDrawPrimStrideData->diffuse.lpvData;
WineD3DStrided.diffuse.dwStride = D3DDrawPrimStrideData->diffuse.dwStride;
WineD3DStrided.diffuse.dwType = WINED3DDECLTYPE_D3DCOLOR;
}
if(VertexType & D3DFVF_SPECULAR)
{
WineD3DStrided.specular.format = WINED3DFMT_A8R8G8B8;
WineD3DStrided.specular.lpData = D3DDrawPrimStrideData->specular.lpvData;
WineD3DStrided.specular.dwStride = D3DDrawPrimStrideData->specular.dwStride;
WineD3DStrided.specular.dwType = WINED3DDECLTYPE_D3DCOLOR;
}
for( i = 0; i < GET_TEXCOUNT_FROM_FVF(VertexType); i++)
{
WineD3DStrided.texCoords[i].lpData = D3DDrawPrimStrideData->textureCoords[i].lpvData;
WineD3DStrided.texCoords[i].dwStride = D3DDrawPrimStrideData->textureCoords[i].dwStride;
switch(GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i))
{
case 1: WineD3DStrided.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT1; break;
case 2: WineD3DStrided.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT2; break;
case 3: WineD3DStrided.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT3; break;
case 4: WineD3DStrided.texCoords[i].dwType = WINED3DDECLTYPE_FLOAT4; break;
case 1: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32_FLOAT; break;
case 2: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32_FLOAT; break;
case 3: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32B32_FLOAT; break;
case 4: WineD3DStrided.texCoords[i].format = WINED3DFMT_R32G32B32A32_FLOAT; break;
default: ERR("Unexpected texture coordinate size %d\n",
GET_TEXCOORD_SIZE_FROM_FVF(VertexType, i));
}
WineD3DStrided.texCoords[i].lpData = D3DDrawPrimStrideData->textureCoords[i].lpvData;
WineD3DStrided.texCoords[i].dwStride = D3DDrawPrimStrideData->textureCoords[i].dwStride;
}
/* WineD3D doesn't need the FVF here */
......
......@@ -129,7 +129,7 @@ fail:
static BOOL buffer_process_converted_attribute(struct wined3d_buffer *This,
const enum wined3d_buffer_conversion_type conversion_type,
const struct wined3d_stream_info_element *attrib, DWORD *stride_this_run, const DWORD type)
const struct wined3d_stream_info_element *attrib, DWORD *stride_this_run)
{
DWORD attrib_size;
BOOL ret = FALSE;
......@@ -145,7 +145,7 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *This,
if (!attrib->stride)
{
FIXME("%s used with stride 0, let's hope we get the vertex stride from somewhere else\n",
debug_d3ddecltype(type));
debug_d3dformat(attrib->d3d_format));
}
else if(attrib->stride != *stride_this_run && *stride_this_run)
{
......@@ -169,7 +169,7 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *This,
}
data = (((DWORD_PTR)attrib->data) + offset) % This->stride;
attrib_size = WINED3D_ATR_SIZE(type) * WINED3D_ATR_TYPESIZE(type);
attrib_size = attrib->size * attrib->type_size;
for (i = 0; i < attrib_size; ++i)
{
if (This->conversion_map[data + i] != conversion_type)
......@@ -189,39 +189,36 @@ static BOOL buffer_check_attribute(struct wined3d_buffer *This,
const BOOL is_ffp_color, DWORD *stride_this_run, BOOL *float16_used)
{
BOOL ret = FALSE;
WINED3DDECLTYPE type;
WINED3DFORMAT format;
/* Ignore attributes that do not have our vbo. After that check we can be sure that the attribute is
* there, on nonexistent attribs the vbo is 0.
*/
if (attrib->buffer_object != This->buffer_object) return FALSE;
type = attrib->d3d_type;
format = attrib->d3d_format;
/* Look for newly appeared conversion */
if (!GL_SUPPORT(NV_HALF_FLOAT) && (type == WINED3DDECLTYPE_FLOAT16_2 || type == WINED3DDECLTYPE_FLOAT16_4))
if (!GL_SUPPORT(NV_HALF_FLOAT) && (format == WINED3DFMT_R16G16_FLOAT || format == WINED3DFMT_R16G16B16A16_FLOAT))
{
ret = buffer_process_converted_attribute(This, CONV_FLOAT16_2, attrib, stride_this_run, type);
ret = buffer_process_converted_attribute(This, CONV_FLOAT16_2, attrib, stride_this_run);
if (is_ffp_position) FIXME("Test FLOAT16 fixed function processing positions\n");
else if (is_ffp_color) FIXME("test FLOAT16 fixed function processing colors\n");
*float16_used = TRUE;
}
else if (check_d3dcolor && type == WINED3DDECLTYPE_D3DCOLOR)
else if (check_d3dcolor && format == WINED3DFMT_A8R8G8B8)
{
ret = buffer_process_converted_attribute(This, CONV_D3DCOLOR,
attrib, stride_this_run, WINED3DDECLTYPE_D3DCOLOR);
ret = buffer_process_converted_attribute(This, CONV_D3DCOLOR, attrib, stride_this_run);
if (!is_ffp_color) FIXME("Test for non-color fixed function D3DCOLOR type\n");
if (!is_ffp_color) FIXME("Test for non-color fixed function WINED3DFMT_A8R8G8B8 format\n");
}
else if (is_ffp_position && type == WINED3DDECLTYPE_FLOAT4)
else if (is_ffp_position && format == WINED3DFMT_R32G32B32A32_FLOAT)
{
ret = buffer_process_converted_attribute(This, CONV_POSITIONT,
attrib, stride_this_run, WINED3DDECLTYPE_FLOAT4);
ret = buffer_process_converted_attribute(This, CONV_POSITIONT, attrib, stride_this_run);
}
else if (This->conversion_map)
{
ret = buffer_process_converted_attribute(This, CONV_NONE,
attrib, stride_this_run, type);
ret = buffer_process_converted_attribute(This, CONV_NONE, attrib, stride_this_run);
}
return ret;
......@@ -231,7 +228,6 @@ static UINT *find_conversion_shift(struct wined3d_buffer *This,
const struct wined3d_stream_info *strided, UINT stride)
{
UINT *ret, i, j, shift, orig_type_size;
DWORD type;
if (!stride)
{
......@@ -243,14 +239,16 @@ static UINT *find_conversion_shift(struct wined3d_buffer *This,
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DWORD) * stride);
for (i = 0; i < MAX_ATTRIBS; ++i)
{
WINED3DFORMAT format;
if (strided->elements[i].buffer_object != This->buffer_object) continue;
type = strided->elements[i].d3d_type;
if (type == WINED3DDECLTYPE_FLOAT16_2)
format = strided->elements[i].d3d_format;
if (format == WINED3DFMT_R16G16_FLOAT)
{
shift = 4;
}
else if (type == WINED3DDECLTYPE_FLOAT16_4)
else if (format == WINED3DFMT_R16G16B16A16_FLOAT)
{
shift = 8;
/* Pre-shift the last 4 bytes in the FLOAT16_4 by 4 bytes - this makes FLOAT16_2 and FLOAT16_4 conversions
......@@ -269,7 +267,7 @@ static UINT *find_conversion_shift(struct wined3d_buffer *This,
if (shift)
{
orig_type_size = WINED3D_ATR_TYPESIZE(type) * WINED3D_ATR_SIZE(type);
orig_type_size = strided->elements[i].type_size * strided->elements[i].size;
for (j = (DWORD_PTR)strided->elements[i].data + orig_type_size; j < stride; ++j)
{
ret[j] += shift;
......
......@@ -256,8 +256,8 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
{
if (!element->ffp_valid)
{
WARN("Skipping unsupported fixed function element of type %s and usage %s\n",
debug_d3ddecltype(element->type), debug_d3ddeclusage(element->usage));
WARN("Skipping unsupported fixed function element of format %s and usage %s\n",
debug_d3dformat(element->format_desc->format), debug_d3ddeclusage(element->usage));
stride_used = FALSE;
}
else
......@@ -269,23 +269,24 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
if (stride_used)
{
TRACE("Load %s array %u [usage %s, usage_idx %u, "
"input_slot %u, offset %u, stride %u, type %s, buffer_object %u]\n",
"input_slot %u, offset %u, stride %u, format %s, buffer_object %u]\n",
use_vshader ? "shader": "fixed function", idx,
debug_d3ddeclusage(element->usage), element->usage_idx,
element->input_slot, element->offset, stride, debug_d3ddecltype(element->type), buffer_object);
stream_info->elements[idx].d3d_type = element->type;
stream_info->elements[idx].size = WINED3D_ATR_SIZE(element->type);
stream_info->elements[idx].format = WINED3D_ATR_FORMAT(element->type);
stream_info->elements[idx].type = WINED3D_ATR_GLTYPE(element->type);
debug_d3ddeclusage(element->usage), element->usage_idx, element->input_slot,
element->offset, stride, debug_d3dformat(element->format_desc->format), buffer_object);
stream_info->elements[idx].d3d_format = element->format_desc->format;
stream_info->elements[idx].emit_idx = element->format_desc->emit_idx;
stream_info->elements[idx].size = element->format_desc->component_count;
stream_info->elements[idx].format = element->format_desc->gl_vtx_format;
stream_info->elements[idx].type = element->format_desc->gl_vtx_type;
stream_info->elements[idx].stride = stride;
stream_info->elements[idx].normalized = WINED3D_ATR_NORMALIZED(element->type);
stream_info->elements[idx].normalized = element->format_desc->gl_normalized;
stream_info->elements[idx].data = data;
stream_info->elements[idx].type_size = WINED3D_ATR_TYPESIZE(element->type);
stream_info->elements[idx].type_size = element->format_desc->component_size;
stream_info->elements[idx].stream_idx = element->input_slot;
stream_info->elements[idx].buffer_object = buffer_object;
if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && element->type == WINED3DDECLTYPE_D3DCOLOR)
if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && element->format_desc->format == WINED3DFMT_A8R8G8B8)
{
stream_info->swizzle_map |= 1 << idx;
}
......@@ -310,14 +311,16 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
static void stream_info_element_from_strided(IWineD3DDeviceImpl *This,
const struct WineDirect3DStridedData *strided, struct wined3d_stream_info_element *e)
{
e->d3d_type = strided->dwType;
e->size = WINED3D_ATR_SIZE(strided->dwType);
e->format = WINED3D_ATR_FORMAT(strided->dwType);
e->type = WINED3D_ATR_GLTYPE(strided->dwType);
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(strided->format, &This->adapter->gl_info);
e->d3d_format = format_desc->format;
e->emit_idx = format_desc->emit_idx;
e->size = format_desc->component_count;
e->format = format_desc->gl_vtx_format;
e->type = format_desc->gl_vtx_type;
e->stride = strided->dwStride;
e->normalized = WINED3D_ATR_NORMALIZED(strided->dwType);
e->normalized = format_desc->gl_normalized;
e->data = strided->lpData;
e->type_size = WINED3D_ATR_TYPESIZE(strided->dwType);
e->type_size = format_desc->component_size;
e->stream_idx = 0;
e->buffer_object = 0;
}
......@@ -349,7 +352,7 @@ void device_stream_info_from_strided(IWineD3DDeviceImpl *This,
for (i = 0; i < sizeof(stream_info->elements) / sizeof(*stream_info->elements); ++i)
{
if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && stream_info->elements[i].d3d_type == WINED3DDECLTYPE_D3DCOLOR)
if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && stream_info->elements[i].d3d_format == WINED3DFMT_A8R8G8B8)
{
stream_info->swizzle_map |= 1 << i;
}
......@@ -2217,101 +2220,102 @@ static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the
idx = 0;
if (has_pos) {
if (!has_blend && (fvf & WINED3DFVF_XYZRHW)) {
elements[idx].Type = WINED3DDECLTYPE_FLOAT4;
elements[idx].Usage = WINED3DDECLUSAGE_POSITIONT;
elements[idx].format = WINED3DFMT_R32G32B32A32_FLOAT;
elements[idx].usage = WINED3DDECLUSAGE_POSITIONT;
}
else if ((fvf & WINED3DFVF_XYZW) == WINED3DFVF_XYZW) {
elements[idx].Type = WINED3DDECLTYPE_FLOAT4;
elements[idx].Usage = WINED3DDECLUSAGE_POSITION;
elements[idx].format = WINED3DFMT_R32G32B32A32_FLOAT;
elements[idx].usage = WINED3DDECLUSAGE_POSITION;
}
else {
elements[idx].Type = WINED3DDECLTYPE_FLOAT3;
elements[idx].Usage = WINED3DDECLUSAGE_POSITION;
elements[idx].format = WINED3DFMT_R32G32B32_FLOAT;
elements[idx].usage = WINED3DDECLUSAGE_POSITION;
}
elements[idx].UsageIndex = 0;
elements[idx].usage_idx = 0;
idx++;
}
if (has_blend && (num_blends > 0)) {
if (((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2) && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR))
elements[idx].Type = WINED3DDECLTYPE_D3DCOLOR;
elements[idx].format = WINED3DFMT_A8R8G8B8;
else {
switch(num_blends) {
case 1: elements[idx].Type = WINED3DDECLTYPE_FLOAT1; break;
case 2: elements[idx].Type = WINED3DDECLTYPE_FLOAT2; break;
case 3: elements[idx].Type = WINED3DDECLTYPE_FLOAT3; break;
case 4: elements[idx].Type = WINED3DDECLTYPE_FLOAT4; break;
case 1: elements[idx].format = WINED3DFMT_R32_FLOAT; break;
case 2: elements[idx].format = WINED3DFMT_R32G32_FLOAT; break;
case 3: elements[idx].format = WINED3DFMT_R32G32B32_FLOAT; break;
case 4: elements[idx].format = WINED3DFMT_R32G32B32A32_FLOAT; break;
default:
ERR("Unexpected amount of blend values: %u\n", num_blends);
}
}
elements[idx].Usage = WINED3DDECLUSAGE_BLENDWEIGHT;
elements[idx].UsageIndex = 0;
elements[idx].usage = WINED3DDECLUSAGE_BLENDWEIGHT;
elements[idx].usage_idx = 0;
idx++;
}
if (has_blend_idx) {
if (fvf & WINED3DFVF_LASTBETA_UBYTE4 ||
(((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2) && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)))
elements[idx].Type = WINED3DDECLTYPE_UBYTE4;
elements[idx].format = WINED3DFMT_R8G8B8A8_UINT;
else if (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)
elements[idx].Type = WINED3DDECLTYPE_D3DCOLOR;
elements[idx].format = WINED3DFMT_A8R8G8B8;
else
elements[idx].Type = WINED3DDECLTYPE_FLOAT1;
elements[idx].Usage = WINED3DDECLUSAGE_BLENDINDICES;
elements[idx].UsageIndex = 0;
elements[idx].format = WINED3DFMT_R32_FLOAT;
elements[idx].usage = WINED3DDECLUSAGE_BLENDINDICES;
elements[idx].usage_idx = 0;
idx++;
}
if (has_normal) {
elements[idx].Type = WINED3DDECLTYPE_FLOAT3;
elements[idx].Usage = WINED3DDECLUSAGE_NORMAL;
elements[idx].UsageIndex = 0;
elements[idx].format = WINED3DFMT_R32G32B32_FLOAT;
elements[idx].usage = WINED3DDECLUSAGE_NORMAL;
elements[idx].usage_idx = 0;
idx++;
}
if (has_psize) {
elements[idx].Type = WINED3DDECLTYPE_FLOAT1;
elements[idx].Usage = WINED3DDECLUSAGE_PSIZE;
elements[idx].UsageIndex = 0;
elements[idx].format = WINED3DFMT_R32_FLOAT;
elements[idx].usage = WINED3DDECLUSAGE_PSIZE;
elements[idx].usage_idx = 0;
idx++;
}
if (has_diffuse) {
elements[idx].Type = WINED3DDECLTYPE_D3DCOLOR;
elements[idx].Usage = WINED3DDECLUSAGE_COLOR;
elements[idx].UsageIndex = 0;
elements[idx].format = WINED3DFMT_A8R8G8B8;
elements[idx].usage = WINED3DDECLUSAGE_COLOR;
elements[idx].usage_idx = 0;
idx++;
}
if (has_specular) {
elements[idx].Type = WINED3DDECLTYPE_D3DCOLOR;
elements[idx].Usage = WINED3DDECLUSAGE_COLOR;
elements[idx].UsageIndex = 1;
elements[idx].format = WINED3DFMT_A8R8G8B8;
elements[idx].usage = WINED3DDECLUSAGE_COLOR;
elements[idx].usage_idx = 1;
idx++;
}
for (idx2 = 0; idx2 < num_textures; idx2++) {
unsigned int numcoords = (texcoords >> (idx2*2)) & 0x03;
switch (numcoords) {
case WINED3DFVF_TEXTUREFORMAT1:
elements[idx].Type = WINED3DDECLTYPE_FLOAT1;
elements[idx].format = WINED3DFMT_R32_FLOAT;
break;
case WINED3DFVF_TEXTUREFORMAT2:
elements[idx].Type = WINED3DDECLTYPE_FLOAT2;
elements[idx].format = WINED3DFMT_R32G32_FLOAT;
break;
case WINED3DFVF_TEXTUREFORMAT3:
elements[idx].Type = WINED3DDECLTYPE_FLOAT3;
elements[idx].format = WINED3DFMT_R32G32B32_FLOAT;
break;
case WINED3DFVF_TEXTUREFORMAT4:
elements[idx].Type = WINED3DDECLTYPE_FLOAT4;
elements[idx].format = WINED3DFMT_R32G32B32A32_FLOAT;
break;
}
elements[idx].Usage = WINED3DDECLUSAGE_TEXCOORD;
elements[idx].UsageIndex = idx2;
elements[idx].usage = WINED3DDECLUSAGE_TEXCOORD;
elements[idx].usage_idx = idx2;
idx++;
}
/* Now compute offsets, and initialize the rest of the fields */
for (idx = 0, offset = 0; idx < size; ++idx)
{
elements[idx].Stream = 0;
elements[idx].Method = WINED3DDECLMETHOD_DEFAULT;
elements[idx].Offset = offset;
offset += WINED3D_ATR_SIZE(elements[idx].Type) * WINED3D_ATR_TYPESIZE(elements[idx].Type);
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(elements[idx].format, &This->adapter->gl_info);
elements[idx].input_slot = 0;
elements[idx].method = WINED3DDECLMETHOD_DEFAULT;
elements[idx].offset = offset;
offset += format_desc->component_count * format_desc->component_size;
}
*ppVertexElements = elements;
......
......@@ -185,12 +185,12 @@ const GLenum magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] =
};
/* drawStridedSlow attributes */
glAttribFunc position_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc diffuse_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
glAttribFunc specular_func_3ubv;
glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc normal_funcs[WINED3DDECLTYPE_UNUSED];
glMultiTexCoordFunc multi_texcoord_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
/**
* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
......@@ -4117,113 +4117,113 @@ static void WINE_GLAPI warn_no_specular_func(const void *data)
static void fillGLAttribFuncs(const WineD3D_GL_Info *gl_info)
{
position_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glVertex3fv;
position_funcs[WINED3DDECLTYPE_FLOAT4] = position_float4;
position_funcs[WINED3DDECLTYPE_D3DCOLOR] = position_d3dcolor;
position_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT4] = (glAttribFunc)glVertex2sv;
position_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
position_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
position_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
position_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
position_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glColor3fv;
diffuse_funcs[WINED3DDECLTYPE_FLOAT4] = (glAttribFunc)glColor4fv;
diffuse_funcs[WINED3DDECLTYPE_D3DCOLOR] = diffuse_d3dcolor;
diffuse_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT4] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_UBYTE4N] = (glAttribFunc)glColor4ubv;
diffuse_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT4N] = (glAttribFunc)glColor4sv;
diffuse_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_USHORT4N] = (glAttribFunc)glColor4usv;
diffuse_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)glVertex3fv;
position_funcs[WINED3D_FFP_EMIT_FLOAT4] = position_float4;
position_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = position_d3dcolor;
position_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_SHORT4] = (glAttribFunc)glVertex2sv;
position_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
position_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)glColor3fv;
diffuse_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)glColor4fv;
diffuse_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = diffuse_d3dcolor;
diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_UBYTE4N] = (glAttribFunc)glColor4ubv;
diffuse_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_SHORT4N] = (glAttribFunc)glColor4sv;
diffuse_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_USHORT4N] = (glAttribFunc)glColor4usv;
diffuse_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
diffuse_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
/* No 4 component entry points here */
specular_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
specular_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT);
specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT);
} else {
specular_funcs[WINED3DDECLTYPE_FLOAT3] = warn_no_specular_func;
specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func;
}
specular_funcs[WINED3DDECLTYPE_FLOAT4] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_FLOAT4] = invalid_func;
if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
specular_func_3ubv = (glAttribFunc)GL_EXTCALL(glSecondaryColor3ubvEXT);
specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = specular_d3dcolor;
specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor;
} else {
specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = warn_no_specular_func;
specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func;
}
specular_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT4] = invalid_func;
specular_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
specular_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
specular_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
/* Only 3 component entry points here. Test how others behave. Float4 normals are used
* by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
*/
normal_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glNormal3fv;
normal_funcs[WINED3DDECLTYPE_FLOAT4] = (glAttribFunc)glNormal3fv; /* Just ignore the 4th value */
normal_funcs[WINED3DDECLTYPE_D3DCOLOR] = invalid_func;
normal_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT4] = invalid_func;
normal_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
normal_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT1] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord1fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT3] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord3fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2svARB);
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4svARB);
multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_UDEC3] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_DEC3N] = invalid_texcoord_func;
normal_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)glNormal3fv;
normal_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glAttribFunc)glNormal3fv; /* Just ignore the 4th value */
normal_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_SHORT2] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_SHORT4] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_func;
normal_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT1] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord1fvARB);
multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2fvARB);
multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord3fvARB);
multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4fvARB);
multi_texcoord_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2svARB);
multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4svARB);
multi_texcoord_funcs[WINED3D_FFP_EMIT_UBYTE4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT2N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_SHORT4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT2N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_texcoord_func;
if (GL_SUPPORT(NV_HALF_FLOAT))
{
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4hvNV);
multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV);
multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4hvNV);
} else {
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_4] = invalid_texcoord_func;
}
}
......@@ -4492,7 +4492,6 @@ BOOL InitAdapters(IWineD3DImpl *This)
select_shader_mode(&adapter->gl_info, WINED3DDEVTYPE_HAL, &ps_selected_mode, &vs_selected_mode);
select_shader_max_constants(ps_selected_mode, vs_selected_mode, &adapter->gl_info);
fillGLAttribFuncs(&adapter->gl_info);
init_type_lookup(&adapter->gl_info);
adapter->opengl = TRUE;
}
This->adapter_count = 1;
......
......@@ -119,8 +119,8 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
element = &si->elements[WINED3D_FFP_DIFFUSE];
if (element->data) diffuse = element->data + streamOffset[element->stream_idx];
else glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
if (This->activeContext->num_untracked_materials && element->d3d_type != WINED3DDECLTYPE_D3DCOLOR)
FIXME("Implement diffuse color tracking from %s\n", debug_d3ddecltype(element->d3d_type));
if (This->activeContext->num_untracked_materials && element->d3d_format != WINED3DFMT_A8R8G8B8)
FIXME("Implement diffuse color tracking from %s\n", debug_d3dformat(element->d3d_format));
element = &si->elements[WINED3D_FFP_SPECULAR];
if (element->data)
......@@ -130,13 +130,13 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
/* special case where the fog density is stored in the specular alpha channel */
if (This->stateBlock->renderState[WINED3DRS_FOGENABLE]
&& (This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE
|| si->elements[WINED3D_FFP_POSITION].d3d_type == WINED3DDECLTYPE_FLOAT4)
|| si->elements[WINED3D_FFP_POSITION].d3d_format == WINED3DFMT_R32G32B32A32_FLOAT)
&& This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
{
if (GL_SUPPORT(EXT_FOG_COORD))
{
if (element->d3d_type == WINED3DDECLTYPE_D3DCOLOR) specular_fog = TRUE;
else FIXME("Implement fog coordinates from %s\n", debug_d3ddecltype(element->d3d_type));
if (element->d3d_format == WINED3DFMT_A8R8G8B8) specular_fog = TRUE;
else FIXME("Implement fog coordinates from %s\n", debug_d3dformat(element->d3d_format));
}
else
{
......@@ -235,7 +235,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
ptr = texCoords[coord_idx] + (SkipnStrides * si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].stride);
texture_idx = This->texUnitMap[texture];
multi_texcoord_funcs[si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].d3d_type](
multi_texcoord_funcs[si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].emit_idx](
GL_TEXTURE0_ARB + texture_idx, ptr);
}
......@@ -243,7 +243,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
if (diffuse) {
const void *ptrToCoords = diffuse + SkipnStrides * si->elements[WINED3D_FFP_DIFFUSE].stride;
diffuse_funcs[si->elements[WINED3D_FFP_DIFFUSE].d3d_type](ptrToCoords);
diffuse_funcs[si->elements[WINED3D_FFP_DIFFUSE].emit_idx](ptrToCoords);
if(This->activeContext->num_untracked_materials) {
DWORD diffuseColor = ((const DWORD *)ptrToCoords)[0];
unsigned char i;
......@@ -264,7 +264,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
if (specular) {
const void *ptrToCoords = specular + SkipnStrides * si->elements[WINED3D_FFP_SPECULAR].stride;
specular_funcs[si->elements[WINED3D_FFP_SPECULAR].d3d_type](ptrToCoords);
specular_funcs[si->elements[WINED3D_FFP_SPECULAR].emit_idx](ptrToCoords);
if (specular_fog)
{
......@@ -276,13 +276,13 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
/* Normal -------------------------------- */
if (normal != NULL) {
const void *ptrToCoords = normal + SkipnStrides * si->elements[WINED3D_FFP_NORMAL].stride;
normal_funcs[si->elements[WINED3D_FFP_NORMAL].d3d_type](ptrToCoords);
normal_funcs[si->elements[WINED3D_FFP_NORMAL].emit_idx](ptrToCoords);
}
/* Position -------------------------------- */
if (position) {
const void *ptrToCoords = position + SkipnStrides * si->elements[WINED3D_FFP_POSITION].stride;
position_funcs[si->elements[WINED3D_FFP_POSITION].d3d_type](ptrToCoords);
position_funcs[si->elements[WINED3D_FFP_POSITION].emit_idx](ptrToCoords);
}
/* For non indexed mode, step onto next parts */
......@@ -295,25 +295,27 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_stream_i
checkGLcall("glEnd and previous calls");
}
static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, const UINT index, const void *ptr) {
switch(type) {
case WINED3DDECLTYPE_FLOAT1:
static inline void send_attribute(IWineD3DDeviceImpl *This, WINED3DFORMAT format, const UINT index, const void *ptr)
{
switch(format)
{
case WINED3DFMT_R32_FLOAT:
GL_EXTCALL(glVertexAttrib1fvARB(index, ptr));
break;
case WINED3DDECLTYPE_FLOAT2:
case WINED3DFMT_R32G32_FLOAT:
GL_EXTCALL(glVertexAttrib2fvARB(index, ptr));
break;
case WINED3DDECLTYPE_FLOAT3:
case WINED3DFMT_R32G32B32_FLOAT:
GL_EXTCALL(glVertexAttrib3fvARB(index, ptr));
break;
case WINED3DDECLTYPE_FLOAT4:
case WINED3DFMT_R32G32B32A32_FLOAT:
GL_EXTCALL(glVertexAttrib4fvARB(index, ptr));
break;
case WINED3DDECLTYPE_UBYTE4:
case WINED3DFMT_R8G8B8A8_UINT:
GL_EXTCALL(glVertexAttrib4ubvARB(index, ptr));
break;
case WINED3DDECLTYPE_D3DCOLOR:
case WINED3DFMT_A8R8G8B8:
if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA))
{
const DWORD *src = ptr;
......@@ -324,46 +326,46 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
break;
}
/* else fallthrough */
case WINED3DDECLTYPE_UBYTE4N:
case WINED3DFMT_R8G8B8A8_UNORM:
GL_EXTCALL(glVertexAttrib4NubvARB(index, ptr));
break;
case WINED3DDECLTYPE_SHORT2:
case WINED3DFMT_R16G16_SINT:
GL_EXTCALL(glVertexAttrib4svARB(index, ptr));
break;
case WINED3DDECLTYPE_SHORT4:
case WINED3DFMT_R16G16B16A16_SINT:
GL_EXTCALL(glVertexAttrib4svARB(index, ptr));
break;
case WINED3DDECLTYPE_SHORT2N:
case WINED3DFMT_R16G16_SNORM:
{
GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NsvARB(index, s));
break;
}
case WINED3DDECLTYPE_USHORT2N:
case WINED3DFMT_R16G16_UNORM:
{
GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NusvARB(index, s));
break;
}
case WINED3DDECLTYPE_SHORT4N:
case WINED3DFMT_R16G16B16A16_SNORM:
GL_EXTCALL(glVertexAttrib4NsvARB(index, ptr));
break;
case WINED3DDECLTYPE_USHORT4N:
case WINED3DFMT_R16G16B16A16_UNORM:
GL_EXTCALL(glVertexAttrib4NusvARB(index, ptr));
break;
case WINED3DDECLTYPE_UDEC3:
case WINED3DFMT_R10G10B10A2_UINT:
FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
/*glVertexAttrib3usvARB(instancedData[j], (GLushort *) ptr); Does not exist */
break;
case WINED3DDECLTYPE_DEC3N:
case WINED3DFMT_R10G10B10A2_SNORM:
FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
/*glVertexAttrib3NusvARB(instancedData[j], (GLushort *) ptr); Does not exist */
break;
case WINED3DDECLTYPE_FLOAT16_2:
case WINED3DFMT_R16G16_FLOAT:
/* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
* byte float according to the IEEE standard
*/
......@@ -375,7 +377,7 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
GL_EXTCALL(glVertexAttrib2fARB(index, x, y));
}
break;
case WINED3DDECLTYPE_FLOAT16_4:
case WINED3DFMT_R16G16B16A16_FLOAT:
if (GL_SUPPORT(NV_HALF_FLOAT)) {
GL_EXTCALL(glVertexAttrib4hvNV(index, ptr));
} else {
......@@ -387,9 +389,8 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
}
break;
case WINED3DDECLTYPE_UNUSED:
default:
ERR("Unexpected attribute declaration: %d\n", type);
ERR("Unexpected attribute format: %s\n", debug_d3dformat(format));
break;
}
}
......@@ -446,7 +447,7 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream
si->elements[i].stride * SkipnStrides +
stateblock->streamOffset[si->elements[i].stream_idx];
send_attribute(This, si->elements[i].d3d_type, i, ptr);
send_attribute(This, si->elements[i].d3d_format, i, ptr);
}
SkipnStrides++;
}
......@@ -514,7 +515,7 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, const struct wine
ptr += (long) vb->resource.allocatedMemory;
}
send_attribute(This, si->elements[instancedData[j]].d3d_type, instancedData[j], ptr);
send_attribute(This, si->elements[instancedData[j]].d3d_format, instancedData[j], ptr);
}
glDrawElements(glPrimitiveType, numberOfVertices, idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
......@@ -1049,17 +1050,17 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
vtxStride += 4 * sizeof(float);
}
memset(&patch->strided, 0, sizeof(&patch->strided));
patch->strided.position.dwType = WINED3DDECLTYPE_FLOAT3;
patch->strided.position.format = WINED3DFMT_R32G32B32_FLOAT;
patch->strided.position.lpData = (BYTE *) patch->mem;
patch->strided.position.dwStride = vtxStride;
if(patch->has_normals) {
patch->strided.normal.dwType = WINED3DDECLTYPE_FLOAT3;
patch->strided.normal.format = WINED3DFMT_R32G32B32_FLOAT;
patch->strided.normal.lpData = (BYTE *) patch->mem + 3 * sizeof(float) /* pos */;
patch->strided.normal.dwStride = vtxStride;
}
if(patch->has_texcoords) {
patch->strided.texCoords[0].dwType = WINED3DDECLTYPE_FLOAT4;
patch->strided.texCoords[0].format = WINED3DFMT_R32G32B32A32_FLOAT;
patch->strided.texCoords[0].lpData = (BYTE *) patch->mem + 3 * sizeof(float) /* pos */;
if(patch->has_normals) {
patch->strided.texCoords[0].lpData += 3 * sizeof(float);
......
......@@ -3013,8 +3013,8 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, W
set_texture_matrix(&stateblock->transforms[WINED3DTS_TEXTURE0 + texUnit].u.m[0][0],
stateblock->textureState[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS], generated, context->last_was_rhw,
stateblock->wineD3DDevice->strided_streams.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].stride
? stateblock->wineD3DDevice->strided_streams.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].d3d_type
: WINED3DDECLTYPE_UNUSED,
? stateblock->wineD3DDevice->strided_streams.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].d3d_format
: WINED3DFMT_UNKNOWN,
stateblock->wineD3DDevice->frag_pipe->ffp_proj_control);
/* The sampler applying function calls us if this changes */
......@@ -3920,25 +3920,25 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
if (context->numbered_array_mask & (1 << i)) unload_numbered_array(stateblock, context, i);
switch(stream_info->elements[i].d3d_type)
switch(stream_info->elements[i].d3d_format)
{
case WINED3DDECLTYPE_FLOAT1:
case WINED3DFMT_R32_FLOAT:
GL_EXTCALL(glVertexAttrib1fvARB(i, (const GLfloat *)ptr));
break;
case WINED3DDECLTYPE_FLOAT2:
case WINED3DFMT_R32G32_FLOAT:
GL_EXTCALL(glVertexAttrib2fvARB(i, (const GLfloat *)ptr));
break;
case WINED3DDECLTYPE_FLOAT3:
case WINED3DFMT_R32G32B32_FLOAT:
GL_EXTCALL(glVertexAttrib3fvARB(i, (const GLfloat *)ptr));
break;
case WINED3DDECLTYPE_FLOAT4:
case WINED3DFMT_R32G32B32A32_FLOAT:
GL_EXTCALL(glVertexAttrib4fvARB(i, (const GLfloat *)ptr));
break;
case WINED3DDECLTYPE_UBYTE4:
case WINED3DFMT_R8G8B8A8_UINT:
GL_EXTCALL(glVertexAttrib4NubvARB(i, ptr));
break;
case WINED3DDECLTYPE_D3DCOLOR:
case WINED3DFMT_A8R8G8B8:
if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA))
{
const DWORD *src = (const DWORD *)ptr;
......@@ -3949,56 +3949,55 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
break;
}
/* else fallthrough */
case WINED3DDECLTYPE_UBYTE4N:
case WINED3DFMT_R8G8B8A8_UNORM:
GL_EXTCALL(glVertexAttrib4NubvARB(i, ptr));
break;
case WINED3DDECLTYPE_SHORT2:
case WINED3DFMT_R16G16_SINT:
GL_EXTCALL(glVertexAttrib4svARB(i, (const GLshort *)ptr));
break;
case WINED3DDECLTYPE_SHORT4:
case WINED3DFMT_R16G16B16A16_SINT:
GL_EXTCALL(glVertexAttrib4svARB(i, (const GLshort *)ptr));
break;
case WINED3DDECLTYPE_SHORT2N:
case WINED3DFMT_R16G16_SNORM:
{
const GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NsvARB(i, s));
break;
}
case WINED3DDECLTYPE_USHORT2N:
case WINED3DFMT_R16G16_UNORM:
{
const GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NusvARB(i, s));
break;
}
case WINED3DDECLTYPE_SHORT4N:
case WINED3DFMT_R16G16B16A16_SNORM:
GL_EXTCALL(glVertexAttrib4NsvARB(i, (const GLshort *)ptr));
break;
case WINED3DDECLTYPE_USHORT4N:
case WINED3DFMT_R16G16B16A16_UNORM:
GL_EXTCALL(glVertexAttrib4NusvARB(i, (const GLushort *)ptr));
break;
case WINED3DDECLTYPE_UDEC3:
case WINED3DFMT_R10G10B10A2_UINT:
FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
/*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
break;
case WINED3DDECLTYPE_DEC3N:
case WINED3DFMT_R10G10B10A2_SNORM:
FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
/*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
break;
case WINED3DDECLTYPE_FLOAT16_2:
case WINED3DFMT_R16G16_FLOAT:
/* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
* byte float according to the IEEE standard
*/
FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_2\n");
break;
case WINED3DDECLTYPE_FLOAT16_4:
case WINED3DFMT_R16G16B16A16_FLOAT:
FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_4\n");
break;
case WINED3DDECLTYPE_UNUSED:
default:
ERR("Unexpected declaration in stride 0 attributes\n");
break;
......
......@@ -66,17 +66,20 @@ static const struct StaticPixelFormatDesc formats[] =
/* IEEE formats */
{WINED3DFMT_R32_FLOAT, 0x0, 0x0, 0x0, 0x0, 4, 0, 0, FALSE},
{WINED3DFMT_R32G32_FLOAT, 0x0, 0x0, 0x0, 0x0, 8, 0, 0, FALSE},
{WINED3DFMT_R32G32B32_FLOAT, 0x0, 0x0, 0x0, 0x0, 12, 0, 0, FALSE},
{WINED3DFMT_R32G32B32A32_FLOAT, 0x1, 0x0, 0x0, 0x0, 16, 0, 0, FALSE},
/* Hmm? */
{WINED3DFMT_CxV8U8, 0x0, 0x0, 0x0, 0x0, 2, 0, 0, FALSE},
/* Float */
{WINED3DFMT_R16_FLOAT, 0x0, 0x0, 0x0, 0x0, 2, 0, 0, FALSE},
{WINED3DFMT_R16G16_FLOAT, 0x0, 0x0, 0x0, 0x0, 4, 0, 0, FALSE},
{WINED3DFMT_R16G16_SINT, 0x0, 0x0, 0x0, 0x0, 4, 0, 0, FALSE},
{WINED3DFMT_R16G16B16A16_FLOAT, 0x1, 0x0, 0x0, 0x0, 8, 0, 0, FALSE},
{WINED3DFMT_R16G16B16A16_SINT, 0x1, 0x0, 0x0, 0x0, 8, 0, 0, FALSE},
/* Palettized formats */
{WINED3DFMT_A8P8, 0x0000ff00, 0x0, 0x0, 0x0, 2, 0, 0, FALSE},
{WINED3DFMT_P8, 0x0, 0x0, 0x0, 0x0, 1, 0, 0, FALSE},
/* Standard ARGB formats. Keep WINED3DFMT_R8G8B8(=20) at position 20 */
/* Standard ARGB formats. */
{WINED3DFMT_R8G8B8, 0x0, 0x00ff0000, 0x0000ff00, 0x000000ff, 3, 0, 0, FALSE},
{WINED3DFMT_A8R8G8B8, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff, 4, 0, 0, FALSE},
{WINED3DFMT_X8R8G8B8, 0x0, 0x00ff0000, 0x0000ff00, 0x000000ff, 4, 0, 0, FALSE},
......@@ -89,7 +92,10 @@ static const struct StaticPixelFormatDesc formats[] =
{WINED3DFMT_A8R3G3B2, 0x0000ff00, 0x000000e0, 0x0000001c, 0x00000003, 2, 0, 0, FALSE},
{WINED3DFMT_X4R4G4B4, 0x0, 0x00000f00, 0x000000f0, 0x0000000f, 2, 0, 0, FALSE},
{WINED3DFMT_R10G10B10A2_UNORM, 0xb0000000, 0x000003ff, 0x000ffc00, 0x3ff00000, 4, 0, 0, FALSE},
{WINED3DFMT_R10G10B10A2_UINT, 0xb0000000, 0x000003ff, 0x000ffc00, 0x3ff00000, 4, 0, 0, FALSE},
{WINED3DFMT_R10G10B10A2_SNORM, 0xb0000000, 0x000003ff, 0x000ffc00, 0x3ff00000, 4, 0, 0, FALSE},
{WINED3DFMT_R8G8B8A8_UNORM, 0xff000000, 0x000000ff, 0x0000ff00, 0x00ff0000, 4, 0, 0, FALSE},
{WINED3DFMT_R8G8B8A8_UINT, 0xff000000, 0x000000ff, 0x0000ff00, 0x00ff0000, 4, 0, 0, FALSE},
{WINED3DFMT_X8B8G8R8, 0x0, 0x000000ff, 0x0000ff00, 0x00ff0000, 4, 0, 0, FALSE},
{WINED3DFMT_R16G16_UNORM, 0x0, 0x0000ffff, 0xffff0000, 0x0, 4, 0, 0, FALSE},
{WINED3DFMT_A2R10G10B10, 0xb0000000, 0x3ff00000, 0x000ffc00, 0x000003ff, 4, 0, 0, FALSE},
......@@ -128,6 +134,38 @@ static const struct StaticPixelFormatDesc formats[] =
{WINED3DFMT_NVHS, 0x0, 0x0, 0x0, 0x0, 2, 0, 0, TRUE },
};
struct wined3d_format_vertex_info
{
WINED3DFORMAT format;
enum wined3d_ffp_emit_idx emit_idx;
GLint component_count;
GLenum gl_vtx_type;
GLint gl_vtx_format;
GLboolean gl_normalized;
unsigned int component_size;
};
static const struct wined3d_format_vertex_info format_vertex_info[] =
{
{WINED3DFMT_R32_FLOAT, WINED3D_FFP_EMIT_FLOAT1, 1, GL_FLOAT, 1, GL_FALSE, sizeof(float)},
{WINED3DFMT_R32G32_FLOAT, WINED3D_FFP_EMIT_FLOAT2, 2, GL_FLOAT, 2, GL_FALSE, sizeof(float)},
{WINED3DFMT_R32G32B32_FLOAT, WINED3D_FFP_EMIT_FLOAT3, 3, GL_FLOAT, 3, GL_FALSE, sizeof(float)},
{WINED3DFMT_R32G32B32A32_FLOAT, WINED3D_FFP_EMIT_FLOAT4, 4, GL_FLOAT, 4, GL_FALSE, sizeof(float)},
{WINED3DFMT_A8R8G8B8, WINED3D_FFP_EMIT_D3DCOLOR, 4, GL_UNSIGNED_BYTE, 4, GL_TRUE, sizeof(BYTE)},
{WINED3DFMT_R8G8B8A8_UINT, WINED3D_FFP_EMIT_UBYTE4, 4, GL_UNSIGNED_BYTE, 4, GL_FALSE, sizeof(BYTE)},
{WINED3DFMT_R16G16_SINT, WINED3D_FFP_EMIT_SHORT2, 2, GL_SHORT, 2, GL_FALSE, sizeof(short int)},
{WINED3DFMT_R16G16B16A16_SINT, WINED3D_FFP_EMIT_SHORT4, 4, GL_SHORT, 4, GL_FALSE, sizeof(short int)},
{WINED3DFMT_R8G8B8A8_UNORM, WINED3D_FFP_EMIT_UBYTE4N, 4, GL_UNSIGNED_BYTE, 4, GL_TRUE, sizeof(BYTE)},
{WINED3DFMT_R16G16_SNORM, WINED3D_FFP_EMIT_SHORT2N, 2, GL_SHORT, 2, GL_TRUE, sizeof(short int)},
{WINED3DFMT_R16G16B16A16_SNORM, WINED3D_FFP_EMIT_SHORT4N, 4, GL_SHORT, 4, GL_TRUE, sizeof(short int)},
{WINED3DFMT_R16G16_UNORM, WINED3D_FFP_EMIT_USHORT2N, 2, GL_UNSIGNED_SHORT, 2, GL_TRUE, sizeof(short int)},
{WINED3DFMT_R16G16B16A16_UNORM, WINED3D_FFP_EMIT_USHORT4N, 4, GL_UNSIGNED_SHORT, 4, GL_TRUE, sizeof(short int)},
{WINED3DFMT_R10G10B10A2_UINT, WINED3D_FFP_EMIT_UDEC3, 3, GL_UNSIGNED_SHORT, 3, GL_FALSE, sizeof(short int)},
{WINED3DFMT_R10G10B10A2_SNORM, WINED3D_FFP_EMIT_DEC3N, 3, GL_SHORT, 3, GL_TRUE, sizeof(short int)},
{WINED3DFMT_R16G16_FLOAT, WINED3D_FFP_EMIT_FLOAT16_2, 2, GL_FLOAT, 2, GL_FALSE, sizeof(GLhalfNV)},
{WINED3DFMT_R16G16B16A16_FLOAT, WINED3D_FFP_EMIT_FLOAT16_4, 4, GL_FLOAT, 4, GL_FALSE, sizeof(GLhalfNV)}
};
typedef struct {
WINED3DFORMAT fmt;
GLint glInternal, glGammaInternal, rtInternal, glFormat, glType;
......@@ -606,6 +644,51 @@ static void apply_format_fixups(WineD3D_GL_Info *gl_info)
idx = getFmtIdx(WINED3DFMT_YV12);
gl_info->gl_formats[idx].heightscale = 1.5;
gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YV12);
if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA))
{
idx = getFmtIdx(WINED3DFMT_A8R8G8B8);
gl_info->gl_formats[idx].gl_vtx_format = GL_BGRA;
}
if (GL_SUPPORT(NV_HALF_FLOAT))
{
/* Do not change the size of the type, it is CPU side. We 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 */
idx = getFmtIdx(WINED3DFMT_R16G16_FLOAT);
gl_info->gl_formats[idx].gl_vtx_type = GL_HALF_FLOAT_NV;
idx = getFmtIdx(WINED3DFMT_R16G16B16A16_FLOAT);
gl_info->gl_formats[idx].gl_vtx_type = GL_HALF_FLOAT_NV;
}
}
static BOOL init_format_vertex_info(WineD3D_GL_Info *gl_info)
{
unsigned int i;
for (i = 0; i < (sizeof(format_vertex_info) / sizeof(*format_vertex_info)); ++i)
{
struct GlPixelFormatDesc *format_desc;
int fmt_idx = getFmtIdx(format_vertex_info[i].format);
if (fmt_idx == -1)
{
ERR("Format %s (%#x) not found.\n",
debug_d3dformat(format_vertex_info[i].format), format_vertex_info[i].format);
return FALSE;
}
format_desc = &gl_info->gl_formats[fmt_idx];
format_desc->emit_idx = format_vertex_info[i].emit_idx;
format_desc->component_count = format_vertex_info[i].component_count;
format_desc->gl_vtx_type = format_vertex_info[i].gl_vtx_type;
format_desc->gl_vtx_format = format_vertex_info[i].gl_vtx_format;
format_desc->gl_normalized = format_vertex_info[i].gl_normalized;
format_desc->component_size = format_vertex_info[i].component_size;
}
return TRUE;
}
BOOL initPixelFormatsNoGL(WineD3D_GL_Info *gl_info)
......@@ -623,49 +706,15 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
return FALSE;
}
apply_format_fixups(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, 1, GL_FALSE, sizeof(float)},
{WINED3DDECLTYPE_FLOAT2, 2, GL_FLOAT, 2, GL_FALSE, sizeof(float)},
{WINED3DDECLTYPE_FLOAT3, 3, GL_FLOAT, 3, GL_FALSE, sizeof(float)},
{WINED3DDECLTYPE_FLOAT4, 4, GL_FLOAT, 4, GL_FALSE, sizeof(float)},
{WINED3DDECLTYPE_D3DCOLOR, 4, GL_UNSIGNED_BYTE, 4, GL_TRUE, sizeof(BYTE)},
{WINED3DDECLTYPE_UBYTE4, 4, GL_UNSIGNED_BYTE, 4, GL_FALSE, sizeof(BYTE)},
{WINED3DDECLTYPE_SHORT2, 2, GL_SHORT, 2, GL_FALSE, sizeof(short int)},
{WINED3DDECLTYPE_SHORT4, 4, GL_SHORT, 4, GL_FALSE, sizeof(short int)},
{WINED3DDECLTYPE_UBYTE4N, 4, GL_UNSIGNED_BYTE, 4, GL_TRUE, sizeof(BYTE)},
{WINED3DDECLTYPE_SHORT2N, 2, GL_SHORT, 2, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_SHORT4N, 4, GL_SHORT, 4, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_USHORT2N, 2, GL_UNSIGNED_SHORT, 2, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_USHORT4N, 4, GL_UNSIGNED_SHORT, 4, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_UDEC3, 3, GL_UNSIGNED_SHORT, 3, GL_FALSE, sizeof(short int)},
{WINED3DDECLTYPE_DEC3N, 3, GL_SHORT, 3, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_FLOAT16_2, 2, GL_FLOAT, 2, GL_FALSE, sizeof(GLhalfNV)},
{WINED3DDECLTYPE_FLOAT16_4, 4, GL_FLOAT, 4, GL_FALSE, sizeof(GLhalfNV)}
};
void init_type_lookup(WineD3D_GL_Info *gl_info) {
memcpy(gl_info->glTypeLookup, glTypeLookupTemplate, sizeof(glTypeLookupTemplate));
if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA))
if (!init_format_vertex_info(gl_info))
{
gl_info->glTypeLookup[WINED3DDECLTYPE_D3DCOLOR].format = GL_BGRA;
HeapFree(GetProcessHeap(), 0, gl_info->gl_formats);
return FALSE;
}
if (GL_SUPPORT(NV_HALF_FLOAT))
{
/* Do not change the size of the type, it is CPU side. We 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_HALF_FLOAT_NV;
gl_info->glTypeLookup[WINED3DDECLTYPE_FLOAT16_4].glType = GL_HALF_FLOAT_NV;
}
apply_format_fixups(gl_info);
return TRUE;
}
#undef GLINFO_LOCATION
......@@ -763,6 +812,7 @@ const char* debug_d3dformat(WINED3DFORMAT fmt) {
FMT_TO_STR(WINED3DFMT_R10G10B10A2_TYPELESS);
FMT_TO_STR(WINED3DFMT_R10G10B10A2_UNORM);
FMT_TO_STR(WINED3DFMT_R10G10B10A2_UINT);
FMT_TO_STR(WINED3DFMT_R10G10B10A2_SNORM);
FMT_TO_STR(WINED3DFMT_R11G11B10_FLOAT);
FMT_TO_STR(WINED3DFMT_R8G8B8A8_TYPELESS);
FMT_TO_STR(WINED3DFMT_R8G8B8A8_UNORM);
......@@ -914,34 +964,6 @@ const char* debug_d3ddeclmethod(WINED3DDECLMETHOD method) {
}
}
const char* debug_d3ddecltype(WINED3DDECLTYPE type) {
switch (type) {
#define WINED3DDECLTYPE_TO_STR(u) case u: return #u
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_FLOAT1);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_FLOAT2);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_FLOAT3);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_FLOAT4);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_D3DCOLOR);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_UBYTE4);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_SHORT2);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_SHORT4);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_UBYTE4N);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_SHORT2N);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_SHORT4N);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_USHORT2N);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_USHORT4N);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_UDEC3);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_DEC3N);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_FLOAT16_2);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_FLOAT16_4);
WINED3DDECLTYPE_TO_STR(WINED3DDECLTYPE_UNUSED);
#undef WINED3DDECLTYPE_TO_STR
default:
FIXME("Unrecognized %u declaration type!\n", type);
return "unrecognized";
}
}
const char* debug_d3ddeclusage(BYTE usage) {
switch (usage) {
#define WINED3DDECLUSAGE_TO_STR(u) case u: return #u
......@@ -1492,8 +1514,8 @@ BOOL is_invalid_op(IWineD3DDeviceImpl *This, int stage, WINED3DTEXTUREOP op, DWO
}
/* Setup this textures matrix according to the texture flags*/
void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, BOOL transformed, DWORD coordtype,
BOOL ffp_proj_control)
void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, BOOL transformed,
WINED3DFORMAT vtx_fmt, BOOL ffp_proj_control)
{
float mat[16];
......@@ -1528,8 +1550,9 @@ void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, B
}
} else { /* under directx the R/Z coord can be used for translation, under opengl we use the Q coord instead */
if(!calculatedCoords) {
switch(coordtype) {
case WINED3DDECLTYPE_FLOAT1:
switch(vtx_fmt)
{
case WINED3DFMT_R32_FLOAT:
/* Direct3D passes the default 1.0 in the 2nd coord, while gl passes it in the 4th.
* swap 2nd and 4th coord. No need to store the value of mat[12] in mat[4] because
* the input value to the transformation will be 0, so the matrix value is irrelevant
......@@ -1539,7 +1562,7 @@ void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, B
mat[14] = mat[6];
mat[15] = mat[7];
break;
case WINED3DDECLTYPE_FLOAT2:
case WINED3DFMT_R32G32_FLOAT:
/* See above, just 3rd and 4th coord
*/
mat[12] = mat[8];
......@@ -1547,14 +1570,14 @@ void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, B
mat[14] = mat[10];
mat[15] = mat[11];
break;
case WINED3DDECLTYPE_FLOAT3: /* Opengl defaults match dx defaults */
case WINED3DDECLTYPE_FLOAT4: /* No defaults apply, all app defined */
case WINED3DFMT_R32G32B32_FLOAT: /* Opengl defaults match dx defaults */
case WINED3DFMT_R32G32B32A32_FLOAT: /* No defaults apply, all app defined */
/* This is to prevent swapping the matrix lines and put the default 4th coord = 1.0
* into a bad place. The division elimination below will apply to make sure the
* 1.0 doesn't do anything bad. The caller will set this value if the stride is 0
*/
case WINED3DDECLTYPE_UNUSED: /* No texture coords, 0/0/0/1 defaults are passed */
case WINED3DFMT_UNKNOWN: /* No texture coords, 0/0/0/1 defaults are passed */
break;
default:
FIXME("Unexpected fixed function texture coord input\n");
......
......@@ -29,13 +29,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_decl);
#define GLINFO_LOCATION This->wineD3DDevice->adapter->gl_info
static void dump_wined3dvertexelement(const WINED3DVERTEXELEMENT *element) {
TRACE(" Stream: %d\n", element->Stream);
TRACE(" Offset: %d\n", element->Offset);
TRACE(" Type: %s (%#x)\n", debug_d3ddecltype(element->Type), element->Type);
TRACE(" Method: %s (%#x)\n", debug_d3ddeclmethod(element->Method), element->Method);
TRACE(" Usage: %s (%#x)\n", debug_d3ddeclusage(element->Usage), element->Usage);
TRACE("Usage index: %d\n", element->UsageIndex);
TRACE(" Register: %d\n", element->Reg);
TRACE(" format: %s (%#x)\n", debug_d3dformat(element->format), element->format);
TRACE(" input_slot: %u\n", element->input_slot);
TRACE(" offset: %u\n", element->offset);
TRACE("output_slot: %u\n", element->output_slot);
TRACE(" method: %s (%#x)\n", debug_d3ddeclmethod(element->method), element->method);
TRACE(" usage: %s (%#x)\n", debug_d3ddeclusage(element->usage), element->usage);
TRACE(" usage_idx: %u\n", element->usage_idx);
}
/* *******************************************
......@@ -104,82 +104,82 @@ static HRESULT WINAPI IWineD3DVertexDeclarationImpl_GetDevice(IWineD3DVertexDecl
static BOOL declaration_element_valid_ffp(const WINED3DVERTEXELEMENT *element)
{
switch(element->Usage)
switch(element->usage)
{
case WINED3DDECLUSAGE_POSITION:
case WINED3DDECLUSAGE_POSITIONT:
switch(element->Type)
switch(element->format)
{
case WINED3DDECLTYPE_FLOAT2:
case WINED3DDECLTYPE_FLOAT3:
case WINED3DDECLTYPE_FLOAT4:
case WINED3DDECLTYPE_SHORT2:
case WINED3DDECLTYPE_SHORT4:
case WINED3DDECLTYPE_FLOAT16_2:
case WINED3DDECLTYPE_FLOAT16_4:
case WINED3DFMT_R32G32_FLOAT:
case WINED3DFMT_R32G32B32_FLOAT:
case WINED3DFMT_R32G32B32A32_FLOAT:
case WINED3DFMT_R16G16_SINT:
case WINED3DFMT_R16G16B16A16_SINT:
case WINED3DFMT_R16G16_FLOAT:
case WINED3DFMT_R16G16B16A16_FLOAT:
return TRUE;
default:
return FALSE;
}
case WINED3DDECLUSAGE_BLENDWEIGHT:
switch(element->Type)
switch(element->format)
{
case WINED3DDECLTYPE_FLOAT1:
case WINED3DDECLTYPE_FLOAT2:
case WINED3DDECLTYPE_FLOAT3:
case WINED3DDECLTYPE_FLOAT4:
case WINED3DDECLTYPE_D3DCOLOR:
case WINED3DDECLTYPE_UBYTE4:
case WINED3DDECLTYPE_SHORT2:
case WINED3DDECLTYPE_SHORT4:
case WINED3DDECLTYPE_FLOAT16_2:
case WINED3DDECLTYPE_FLOAT16_4:
case WINED3DFMT_R32_FLOAT:
case WINED3DFMT_R32G32_FLOAT:
case WINED3DFMT_R32G32B32_FLOAT:
case WINED3DFMT_R32G32B32A32_FLOAT:
case WINED3DFMT_A8R8G8B8:
case WINED3DFMT_R8G8B8A8_UINT:
case WINED3DFMT_R16G16_SINT:
case WINED3DFMT_R16G16B16A16_SINT:
case WINED3DFMT_R16G16_FLOAT:
case WINED3DFMT_R16G16B16A16_FLOAT:
return TRUE;
default:
return FALSE;
}
case WINED3DDECLUSAGE_NORMAL:
switch(element->Type)
switch(element->format)
{
case WINED3DDECLTYPE_FLOAT3:
case WINED3DDECLTYPE_FLOAT4:
case WINED3DDECLTYPE_SHORT4:
case WINED3DDECLTYPE_FLOAT16_4:
case WINED3DFMT_R32G32B32_FLOAT:
case WINED3DFMT_R32G32B32A32_FLOAT:
case WINED3DFMT_R16G16B16A16_SINT:
case WINED3DFMT_R16G16B16A16_FLOAT:
return TRUE;
default:
return FALSE;
}
case WINED3DDECLUSAGE_TEXCOORD:
switch(element->Type)
switch(element->format)
{
case WINED3DDECLTYPE_FLOAT1:
case WINED3DDECLTYPE_FLOAT2:
case WINED3DDECLTYPE_FLOAT3:
case WINED3DDECLTYPE_FLOAT4:
case WINED3DDECLTYPE_SHORT2:
case WINED3DDECLTYPE_SHORT4:
case WINED3DDECLTYPE_FLOAT16_2:
case WINED3DDECLTYPE_FLOAT16_4:
case WINED3DFMT_R32_FLOAT:
case WINED3DFMT_R32G32_FLOAT:
case WINED3DFMT_R32G32B32_FLOAT:
case WINED3DFMT_R32G32B32A32_FLOAT:
case WINED3DFMT_R16G16_SINT:
case WINED3DFMT_R16G16B16A16_SINT:
case WINED3DFMT_R16G16_FLOAT:
case WINED3DFMT_R16G16B16A16_FLOAT:
return TRUE;
default:
return FALSE;
}
case WINED3DDECLUSAGE_COLOR:
switch(element->Type)
switch(element->format)
{
case WINED3DDECLTYPE_FLOAT3:
case WINED3DDECLTYPE_FLOAT4:
case WINED3DDECLTYPE_D3DCOLOR:
case WINED3DDECLTYPE_UBYTE4:
case WINED3DDECLTYPE_SHORT4:
case WINED3DDECLTYPE_UBYTE4N:
case WINED3DDECLTYPE_SHORT4N:
case WINED3DDECLTYPE_USHORT4N:
case WINED3DDECLTYPE_FLOAT16_4:
case WINED3DFMT_R32G32B32_FLOAT:
case WINED3DFMT_R32G32B32A32_FLOAT:
case WINED3DFMT_A8R8G8B8:
case WINED3DFMT_R8G8B8A8_UINT:
case WINED3DFMT_R16G16B16A16_SINT:
case WINED3DFMT_R8G8B8A8_UNORM:
case WINED3DFMT_R16G16B16A16_SNORM:
case WINED3DFMT_R16G16B16A16_UNORM:
case WINED3DFMT_R16G16B16A16_FLOAT:
return TRUE;
default:
return FALSE;
......@@ -222,14 +222,14 @@ HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *This,
for (i = 0; i < element_count; ++i) {
struct wined3d_vertex_declaration_element *e = &This->elements[i];
e->type = elements[i].Type;
e->format_desc = getFormatDescEntry(elements[i].format, &This->wineD3DDevice->adapter->gl_info);
e->ffp_valid = declaration_element_valid_ffp(&elements[i]);
e->input_slot = elements[i].Stream;
e->offset = elements[i].Offset;
e->output_slot = elements[i].Reg;
e->method = elements[i].Method;
e->usage = elements[i].Usage;
e->usage_idx = elements[i].UsageIndex;
e->input_slot = elements[i].input_slot;
e->offset = elements[i].offset;
e->output_slot = elements[i].output_slot;
e->method = elements[i].method;
e->usage = elements[i].usage;
e->usage_idx = elements[i].usage_idx;
if (e->usage == WINED3DDECLUSAGE_POSITIONT) This->position_transformed = TRUE;
......@@ -238,9 +238,10 @@ HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *This,
*/
if (e->input_slot >= MAX_STREAMS) continue;
if (e->type == WINED3DDECLTYPE_UNUSED)
if (!e->format_desc->gl_vtx_format)
{
WARN("The application tries to use WINED3DDECLTYPE_UNUSED, returning E_FAIL\n");
FIXME("The application tries to use an unsupported format (%s), returning E_FAIL\n",
debug_d3dformat(elements[i].format));
/* The caller will release the vdecl, which will free This->elements */
return E_FAIL;
}
......@@ -258,7 +259,7 @@ HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *This,
isPreLoaded[e->input_slot] = 1;
}
if (e->type == WINED3DDECLTYPE_FLOAT16_2 || e->type == WINED3DDECLTYPE_FLOAT16_4)
if (elements[i].format == WINED3DFMT_R16G16_FLOAT || elements[i].format == WINED3DFMT_R16G16B16A16_FLOAT)
{
if (!GL_SUPPORT(NV_HALF_FLOAT)) This->half_float_conv_needed = TRUE;
}
......
......@@ -3892,15 +3892,6 @@ typedef BOOL (WINAPI * WINED3D_PFNWGLSETPIXELFORMATWINE) (HDC hdc, int iPixelFor
* Structures
****************************************************/
typedef struct _WINED3DGLTYPE {
int d3dType;
GLint size;
GLenum glType;
GLint format;
GLboolean normalized;
int typesize;
} WINED3DGLTYPE;
#define USE_GL_FUNC(type, pfn, ext, replace) type pfn;
typedef struct _WineD3D_GL_Info {
......@@ -3963,9 +3954,6 @@ typedef struct _WineD3D_GL_Info {
WGL_EXT_FUNCS_GEN
struct GlPixelFormatDesc *gl_formats;
/* Vertex data types */
WINED3DGLTYPE glTypeLookup[WINED3DDECLTYPE_UNUSED];
} WineD3D_GL_Info;
#undef USE_GL_FUNC
......
......@@ -209,14 +209,6 @@ const GLenum magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1];
extern const struct filter_lookup filter_lookup_nofilter;
extern struct filter_lookup filter_lookup;
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_FORMAT(type) GLINFO_LOCATION.glTypeLookup[type].format
#define WINED3D_ATR_NORMALIZED(type) GLINFO_LOCATION.glTypeLookup[type].normalized
#define WINED3D_ATR_TYPESIZE(type) GLINFO_LOCATION.glTypeLookup[type].typesize
/* float_16_to_32() and float_32_to_16() (see implementation in
* surface_base.c) convert 16 bit floats in the FLOAT16 data type
* to standard C floats and vice versa. They do not depend on the encoding
......@@ -591,8 +583,8 @@ do { \
/* Trace vector and strided data information */
#define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
#define TRACE_STRIDED(si, name) TRACE( #name "=(data:%p, stride:%d, type:%d, vbo %d, stream %u)\n", \
si->elements[name].data, si->elements[name].stride, si->elements[name].d3d_type, \
#define TRACE_STRIDED(si, name) TRACE( #name "=(data:%p, stride:%d, format:%#x, vbo %d, stream %u)\n", \
si->elements[name].data, si->elements[name].stride, si->elements[name].d3d_format, \
si->elements[name].buffer_object, si->elements[name].stream_idx);
/* Defines used for optimizations */
......@@ -670,9 +662,32 @@ enum wined3d_ffp_idx
WINED3D_FFP_TEXCOORD7 = 14,
};
enum wined3d_ffp_emit_idx
{
WINED3D_FFP_EMIT_FLOAT1 = 0,
WINED3D_FFP_EMIT_FLOAT2 = 1,
WINED3D_FFP_EMIT_FLOAT3 = 2,
WINED3D_FFP_EMIT_FLOAT4 = 3,
WINED3D_FFP_EMIT_D3DCOLOR = 4,
WINED3D_FFP_EMIT_UBYTE4 = 5,
WINED3D_FFP_EMIT_SHORT2 = 6,
WINED3D_FFP_EMIT_SHORT4 = 7,
WINED3D_FFP_EMIT_UBYTE4N = 8,
WINED3D_FFP_EMIT_SHORT2N = 9,
WINED3D_FFP_EMIT_SHORT4N = 10,
WINED3D_FFP_EMIT_USHORT2N = 11,
WINED3D_FFP_EMIT_USHORT4N = 12,
WINED3D_FFP_EMIT_UDEC3 = 13,
WINED3D_FFP_EMIT_DEC3N = 14,
WINED3D_FFP_EMIT_FLOAT16_2 = 15,
WINED3D_FFP_EMIT_FLOAT16_4 = 16,
WINED3D_FFP_EMIT_COUNT = 17
};
struct wined3d_stream_info_element
{
WINED3DDECLTYPE d3d_type;
WINED3DFORMAT d3d_format;
enum wined3d_ffp_emit_idx emit_idx;
GLint size;
GLint format;
GLenum type;
......@@ -703,12 +718,12 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
typedef void (WINE_GLAPI *glAttribFunc)(const void *data);
typedef void (WINE_GLAPI *glMultiTexCoordFunc)(GLenum unit, const void *data);
extern glAttribFunc position_funcs[WINED3DDECLTYPE_UNUSED];
extern glAttribFunc diffuse_funcs[WINED3DDECLTYPE_UNUSED];
extern glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
extern glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
extern glAttribFunc specular_func_3ubv;
extern glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED];
extern glAttribFunc normal_funcs[WINED3DDECLTYPE_UNUSED];
extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3DDECLTYPE_UNUSED];
extern glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
extern glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
#define eps 1e-8
......@@ -1747,7 +1762,7 @@ BOOL palette9_changed(IWineD3DSurfaceImpl *This);
struct wined3d_vertex_declaration_element
{
WINED3DDECLTYPE type;
const struct GlPixelFormatDesc *format_desc;
BOOL ffp_valid;
WORD input_slot;
WORD offset;
......@@ -2104,7 +2119,6 @@ const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res);
const char* debug_d3dusage(DWORD usage);
const char* debug_d3dusagequery(DWORD usagequery);
const char* debug_d3ddeclmethod(WINED3DDECLMETHOD method);
const char* debug_d3ddecltype(WINED3DDECLTYPE type);
const char* debug_d3ddeclusage(BYTE usage);
const char* debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType);
const char* debug_d3drenderstate(DWORD state);
......@@ -2539,6 +2553,13 @@ struct GlPixelFormatDesc
WORD depth_size;
WORD stencil_size;
enum wined3d_ffp_emit_idx emit_idx;
GLint component_count;
GLenum gl_vtx_type;
GLint gl_vtx_format;
GLboolean gl_normalized;
unsigned int component_size;
GLint glInternal;
GLint glGammaInternal;
GLint rtInternal;
......
......@@ -190,6 +190,7 @@ typedef enum _WINED3DFORMAT
WINED3DFMT_R10G10B10A2_TYPELESS,
WINED3DFMT_R10G10B10A2_UNORM,
WINED3DFMT_R10G10B10A2_UINT,
WINED3DFMT_R10G10B10A2_SNORM,
WINED3DFMT_R11G11B10_FLOAT,
WINED3DFMT_R8G8B8A8_TYPELESS,
WINED3DFMT_R8G8B8A8_UNORM,
......@@ -824,29 +825,6 @@ typedef enum _WINED3DDECLMETHOD
WINED3DDECLMETHOD_LOOKUPPRESAMPLED = 6
} WINED3DDECLMETHOD;
typedef enum _WINED3DDECLTYPE
{
WINED3DDECLTYPE_FLOAT1 = 0,
WINED3DDECLTYPE_FLOAT2 = 1,
WINED3DDECLTYPE_FLOAT3 = 2,
WINED3DDECLTYPE_FLOAT4 = 3,
WINED3DDECLTYPE_D3DCOLOR = 4,
WINED3DDECLTYPE_UBYTE4 = 5,
WINED3DDECLTYPE_SHORT2 = 6,
WINED3DDECLTYPE_SHORT4 = 7,
/* VS 2.0 */
WINED3DDECLTYPE_UBYTE4N = 8,
WINED3DDECLTYPE_SHORT2N = 9,
WINED3DDECLTYPE_SHORT4N = 10,
WINED3DDECLTYPE_USHORT2N = 11,
WINED3DDECLTYPE_USHORT4N = 12,
WINED3DDECLTYPE_UDEC3 = 13,
WINED3DDECLTYPE_DEC3N = 14,
WINED3DDECLTYPE_FLOAT16_2 = 15,
WINED3DDECLTYPE_FLOAT16_4 = 16,
WINED3DDECLTYPE_UNUSED = 17,
} WINED3DDECLTYPE;
typedef enum _WINED3DDECLUSAGE
{
WINED3DDECLUSAGE_POSITION = 0,
......@@ -1766,14 +1744,14 @@ typedef struct _WINED3DCLIPSTATUS
typedef struct _WINED3DVERTEXELEMENT
{
WORD Stream;
WORD Offset;
BYTE Type;
BYTE Method;
BYTE Usage;
BYTE UsageIndex;
int Reg; /* DirectX 8 */
} WINED3DVERTEXELEMENT, *LPWINED3DVERTEXELEMENT;
WINED3DFORMAT format;
WORD input_slot;
WORD offset;
UINT output_slot; /* D3D 8 & 10 */
BYTE method;
BYTE usage;
BYTE usage_idx;
} WINED3DVERTEXELEMENT;
typedef struct _WINED3DDEVICE_CREATION_PARAMETERS
{
......@@ -1914,9 +1892,9 @@ typedef struct glDescriptor
typedef struct WineDirect3DStridedData
{
const BYTE *lpData; /* Pointer to start of data */
DWORD dwStride; /* Stride between occurrences of this data */
DWORD dwType; /* Type (as in D3DVSDT_TYPE) */
WINED3DFORMAT format; /* Format of the data */
const BYTE *lpData; /* Pointer to start of data */
DWORD dwStride; /* Stride between occurrences of this data */
} WineDirect3DStridedData;
typedef struct WineDirect3DVertexStridedData
......
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