Commit ef2d7041 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Store the format_desc itself in struct wined3d_stream_info_element.

parent 8968f5fa
......@@ -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_d3dformat(attrib->d3d_format));
debug_d3dformat(attrib->format_desc->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 = attrib->size * attrib->type_size;
attrib_size = attrib->format_desc->component_count * attrib->format_desc->component_size;
for (i = 0; i < attrib_size; ++i)
{
if (This->conversion_map[data + i] != conversion_type)
......@@ -196,7 +196,7 @@ static BOOL buffer_check_attribute(struct wined3d_buffer *This,
*/
if (attrib->buffer_object != This->buffer_object) return FALSE;
format = attrib->d3d_format;
format = attrib->format_desc->format;
/* Look for newly appeared conversion */
if (!GL_SUPPORT(NV_HALF_FLOAT) && (format == WINED3DFMT_R16G16_FLOAT || format == WINED3DFMT_R16G16B16A16_FLOAT))
{
......@@ -243,7 +243,7 @@ static UINT *find_conversion_shift(struct wined3d_buffer *This,
if (strided->elements[i].buffer_object != This->buffer_object) continue;
format = strided->elements[i].d3d_format;
format = strided->elements[i].format_desc->format;
if (format == WINED3DFMT_R16G16_FLOAT)
{
shift = 4;
......@@ -267,7 +267,8 @@ static UINT *find_conversion_shift(struct wined3d_buffer *This,
if (shift)
{
orig_type_size = strided->elements[i].type_size * strided->elements[i].size;
orig_type_size = strided->elements[i].format_desc->component_count
* strided->elements[i].format_desc->component_size;
for (j = (DWORD_PTR)strided->elements[i].data + orig_type_size; j < stride; ++j)
{
ret[j] += shift;
......
......@@ -274,15 +274,9 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
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].format_desc = element->format_desc;
stream_info->elements[idx].stride = stride;
stream_info->elements[idx].normalized = element->format_desc->gl_normalized;
stream_info->elements[idx].data = data;
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;
......@@ -312,15 +306,9 @@ static void stream_info_element_from_strided(IWineD3DDeviceImpl *This,
const struct WineDirect3DStridedData *strided, struct wined3d_stream_info_element *e)
{
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->format_desc = format_desc;
e->stride = strided->dwStride;
e->normalized = format_desc->gl_normalized;
e->data = strided->lpData;
e->type_size = format_desc->component_size;
e->stream_idx = 0;
e->buffer_object = 0;
}
......@@ -352,7 +340,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_format == WINED3DFMT_A8R8G8B8)
if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && stream_info->elements[i].format_desc->format == WINED3DFMT_A8R8G8B8)
{
stream_info->swizzle_map |= 1 << i;
}
......
......@@ -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_format != WINED3DFMT_A8R8G8B8)
FIXME("Implement diffuse color tracking from %s\n", debug_d3dformat(element->d3d_format));
if (This->activeContext->num_untracked_materials && element->format_desc->format != WINED3DFMT_A8R8G8B8)
FIXME("Implement diffuse color tracking from %s\n", debug_d3dformat(element->format_desc->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_format == WINED3DFMT_R32G32B32A32_FLOAT)
|| si->elements[WINED3D_FFP_POSITION].format_desc->format == WINED3DFMT_R32G32B32A32_FLOAT)
&& This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
{
if (GL_SUPPORT(EXT_FOG_COORD))
{
if (element->d3d_format == WINED3DFMT_A8R8G8B8) specular_fog = TRUE;
else FIXME("Implement fog coordinates from %s\n", debug_d3dformat(element->d3d_format));
if (element->format_desc->format == WINED3DFMT_A8R8G8B8) specular_fog = TRUE;
else FIXME("Implement fog coordinates from %s\n", debug_d3dformat(element->format_desc->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].emit_idx](
multi_texcoord_funcs[si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].format_desc->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].emit_idx](ptrToCoords);
diffuse_funcs[si->elements[WINED3D_FFP_DIFFUSE].format_desc->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].emit_idx](ptrToCoords);
specular_funcs[si->elements[WINED3D_FFP_SPECULAR].format_desc->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].emit_idx](ptrToCoords);
normal_funcs[si->elements[WINED3D_FFP_NORMAL].format_desc->emit_idx](ptrToCoords);
}
/* Position -------------------------------- */
if (position) {
const void *ptrToCoords = position + SkipnStrides * si->elements[WINED3D_FFP_POSITION].stride;
position_funcs[si->elements[WINED3D_FFP_POSITION].emit_idx](ptrToCoords);
position_funcs[si->elements[WINED3D_FFP_POSITION].format_desc->emit_idx](ptrToCoords);
}
/* For non indexed mode, step onto next parts */
......@@ -447,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_format, i, ptr);
send_attribute(This, si->elements[i].format_desc->format, i, ptr);
}
SkipnStrides++;
}
......@@ -515,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_format, instancedData[j], ptr);
send_attribute(This, si->elements[instancedData[j]].format_desc->format, instancedData[j], ptr);
}
glDrawElements(glPrimitiveType, numberOfVertices, idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
......
......@@ -3012,7 +3012,7 @@ 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_format
? stateblock->wineD3DDevice->strided_streams.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].format_desc->format
: WINED3DFMT_UNKNOWN,
stateblock->wineD3DDevice->frag_pipe->ffp_proj_control);
......@@ -3066,7 +3066,7 @@ static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, const struct wined
checkGLcall("glClientActiveTextureARB");
/* The coords to supply depend completely on the fvf / vertex shader */
glTexCoordPointer(e->format, e->type, e->stride,
glTexCoordPointer(e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
} else {
......@@ -3884,18 +3884,20 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
i, stream_info->elements[i].stride, vb->conversion_stride);
TRACE("Original offset %p, additional offset 0x%08x\n",
stream_info->elements[i].data, vb->conversion_shift[(DWORD_PTR)stream_info->elements[i].data]);
TRACE("Opengl type %#x\n", stream_info->elements[i].type);
TRACE("Opengl type %#x\n", stream_info->elements[i].format_desc->gl_vtx_type);
shift_index = ((DWORD_PTR)stream_info->elements[i].data + offset[stream_info->elements[i].stream_idx]);
shift_index = shift_index % stream_info->elements[i].stride;
GL_EXTCALL(glVertexAttribPointerARB(i, stream_info->elements[i].format,
stream_info->elements[i].type, stream_info->elements[i].normalized,
GL_EXTCALL(glVertexAttribPointerARB(i, stream_info->elements[i].format_desc->gl_vtx_format,
stream_info->elements[i].format_desc->gl_vtx_type,
stream_info->elements[i].format_desc->gl_normalized,
vb->conversion_stride, stream_info->elements[i].data + vb->conversion_shift[shift_index]
+ stateblock->loadBaseVertexIndex * stream_info->elements[i].stride
+ offset[stream_info->elements[i].stream_idx]));
} else {
GL_EXTCALL(glVertexAttribPointerARB(i, stream_info->elements[i].format,
stream_info->elements[i].type, stream_info->elements[i].normalized,
GL_EXTCALL(glVertexAttribPointerARB(i, stream_info->elements[i].format_desc->gl_vtx_format,
stream_info->elements[i].format_desc->gl_vtx_type,
stream_info->elements[i].format_desc->gl_normalized,
stream_info->elements[i].stride, stream_info->elements[i].data
+ stateblock->loadBaseVertexIndex * stream_info->elements[i].stride
+ offset[stream_info->elements[i].stream_idx]));
......@@ -3919,7 +3921,7 @@ 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_format)
switch (stream_info->elements[i].format_desc->format)
{
case WINED3DFMT_R32_FLOAT:
GL_EXTCALL(glVertexAttrib1fvARB(i, (const GLfloat *)ptr));
......@@ -4026,13 +4028,13 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, const struct wine
|| si->elements[WINED3D_FFP_BLENDINDICES].buffer_object)
{
if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
TRACE("Blend %d %p %d\n", e->size,
TRACE("Blend %d %p %d\n", e->format_desc->component_count,
e->data + stateblock->loadBaseVertexIndex * e->stride, e->stride + offset[e->stream_idx]);
glEnableClientState(GL_WEIGHT_ARRAY_ARB);
checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
GL_EXTCALL(glVertexBlendARB(e->size + 1));
GL_EXTCALL(glVertexBlendARB(e->format_desc->component_count + 1));
VTRACE(("glWeightPointerARB(%d, GL_FLOAT, %d, %p)\n",
WINED3D_ATR_FORMAT(sd->u.s.blendWeights.dwType) ,
......@@ -4046,7 +4048,7 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, const struct wine
curVBO = e->buffer_object;
}
GL_EXTCALL(glWeightPointerARB)(e->format, e->type, e->stride,
GL_EXTCALL(glWeightPointerARB)(e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
checkGLcall("glWeightPointerARB");
......@@ -4107,10 +4109,10 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, const struct wine
*/
if (!e->buffer_object)
{
glVertexPointer(3 /* min(e->format, 3) */, e->type, e->stride,
glVertexPointer(3 /* min(e->format_desc->gl_vtx_format, 3) */, e->format_desc->gl_vtx_type, e->stride,
e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
} else {
glVertexPointer(e->format, e->type, e->stride,
glVertexPointer(e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
}
checkGLcall("glVertexPointer(...)");
......@@ -4129,7 +4131,7 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, const struct wine
checkGLcall("glBindBufferARB");
curVBO = e->buffer_object;
}
glNormalPointer(e->type, e->stride,
glNormalPointer(e->format_desc->gl_vtx_type, e->stride,
e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
checkGLcall("glNormalPointer(...)");
glEnableClientState(GL_NORMAL_ARRAY);
......@@ -4161,7 +4163,7 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, const struct wine
curVBO = e->buffer_object;
}
glColorPointer(e->format, e->type, e->stride,
glColorPointer(e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
glEnableClientState(GL_COLOR_ARRAY);
......@@ -4186,8 +4188,8 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, const struct wine
checkGLcall("glBindBufferARB");
curVBO = e->buffer_object;
}
GL_EXTCALL(glSecondaryColorPointerEXT)(e->format, e->type, e->stride,
e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
GL_EXTCALL(glSecondaryColorPointerEXT)(e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type,
e->stride, e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
checkGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
......
......@@ -584,7 +584,7 @@ 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, format:%#x, vbo %d, stream %u)\n", \
si->elements[name].data, si->elements[name].stride, si->elements[name].d3d_format, \
si->elements[name].data, si->elements[name].stride, si->elements[name].format_desc->format, \
si->elements[name].buffer_object, si->elements[name].stream_idx);
/* Defines used for optimizations */
......@@ -686,15 +686,9 @@ enum wined3d_ffp_emit_idx
struct wined3d_stream_info_element
{
WINED3DFORMAT d3d_format;
enum wined3d_ffp_emit_idx emit_idx;
GLint size;
GLint format;
GLenum type;
const struct GlPixelFormatDesc *format_desc;
GLsizei stride;
GLboolean normalized;
const BYTE *data;
int type_size;
UINT stream_idx;
GLuint buffer_object;
};
......
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