Commit 7ee4bda6 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Add stream offsets in device_stream_info_from_declaration().

They're not going to change until the next time the stream info is updated. This would of course mainly be useful if we managed to do more than one or two draws with the same stream info.
parent cf421e1b
......@@ -228,7 +228,6 @@ 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)
{
DWORD offset = This->resource.device->stateBlock->state.streams[attrib->stream_idx].offset;
DWORD attrib_size;
BOOL ret = FALSE;
unsigned int i;
......@@ -265,7 +264,7 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *This,
}
}
data = (((DWORD_PTR)attrib->data.addr) + offset) % This->stride;
data = ((DWORD_PTR)attrib->data.addr) % This->stride;
attrib_size = attrib->format->component_count * attrib->format->component_size;
for (i = 0; i < attrib_size; ++i)
{
......
......@@ -189,7 +189,8 @@ void device_stream_info_from_declaration(struct wined3d_device *device,
for (i = 0; i < declaration->element_count; ++i)
{
const struct wined3d_vertex_declaration_element *element = &declaration->elements[i];
struct wined3d_buffer *buffer = device->stateBlock->state.streams[element->input_slot].buffer;
const struct wined3d_stream_state *stream = &device->stateBlock->state.streams[element->input_slot];
struct wined3d_buffer *buffer = stream->buffer;
struct wined3d_bo_address data;
BOOL stride_used;
unsigned int idx;
......@@ -203,7 +204,7 @@ void device_stream_info_from_declaration(struct wined3d_device *device,
data.buffer_object = 0;
data.addr = NULL;
stride = device->stateBlock->state.streams[element->input_slot].stride;
stride = stream->stride;
if (device->stateBlock->state.user_stream)
{
TRACE("Stream %u is UP, %p\n", element->input_slot, buffer);
......@@ -292,6 +293,8 @@ void device_stream_info_from_declaration(struct wined3d_device *device,
debug_d3ddeclusage(element->usage), element->usage_idx, element->input_slot,
element->offset, stride, debug_d3dformat(element->format->id), data.buffer_object);
data.addr += stream->offset;
stream_info->elements[idx].format = element->format;
stream_info->elements[idx].data = data;
stream_info->elements[idx].stride = stride;
......
......@@ -74,7 +74,6 @@ static void drawStridedSlow(struct wined3d_device *device, const struct wined3d_
const DWORD *pIdxBufL = NULL;
UINT vx_index;
const struct wined3d_state *state = &device->stateBlock->state;
const struct wined3d_stream_state *streams = state->streams;
LONG SkipnStrides = startIdx;
BOOL pixelShader = use_ps(state);
BOOL specular_fog = FALSE;
......@@ -111,13 +110,13 @@ static void drawStridedSlow(struct wined3d_device *device, const struct wined3d_
if (si->use_map & (1 << WINED3D_FFP_POSITION))
{
element = &si->elements[WINED3D_FFP_POSITION];
position = element->data.addr + streams[element->stream_idx].offset;
position = element->data.addr;
}
if (si->use_map & (1 << WINED3D_FFP_NORMAL))
{
element = &si->elements[WINED3D_FFP_NORMAL];
normal = element->data.addr + streams[element->stream_idx].offset;
normal = element->data.addr;
}
else
{
......@@ -128,7 +127,7 @@ static void drawStridedSlow(struct wined3d_device *device, const struct wined3d_
if (si->use_map & (1 << WINED3D_FFP_DIFFUSE))
{
element = &si->elements[WINED3D_FFP_DIFFUSE];
diffuse = element->data.addr + streams[element->stream_idx].offset;
diffuse = element->data.addr;
if (num_untracked_materials && element->format->id != WINED3DFMT_B8G8R8A8_UNORM)
FIXME("Implement diffuse color tracking from %s\n", debug_d3dformat(element->format->id));
......@@ -141,7 +140,7 @@ static void drawStridedSlow(struct wined3d_device *device, const struct wined3d_
if (si->use_map & (1 << WINED3D_FFP_SPECULAR))
{
element = &si->elements[WINED3D_FFP_SPECULAR];
specular = element->data.addr + streams[element->stream_idx].offset;
specular = element->data.addr;
/* special case where the fog density is stored in the specular alpha channel */
if (state->render_states[WINED3DRS_FOGENABLE]
......@@ -201,7 +200,7 @@ static void drawStridedSlow(struct wined3d_device *device, const struct wined3d_
if (si->use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx)))
{
element = &si->elements[WINED3D_FFP_TEXCOORD0 + coordIdx];
texCoords[coordIdx] = element->data.addr + streams[element->stream_idx].offset;
texCoords[coordIdx] = element->data.addr;
tex_mask |= (1 << textureNo);
}
else
......@@ -465,8 +464,7 @@ static void drawStridedSlowVs(const struct wined3d_gl_info *gl_info, const struc
{
if (!(si->use_map & (1 << i))) continue;
ptr = si->elements[i].data.addr + si->elements[i].stride * SkipnStrides
+ state->streams[si->elements[i].stream_idx].offset;
ptr = si->elements[i].data.addr + si->elements[i].stride * SkipnStrides;
send_attribute(gl_info, si->elements[i].format->id, i, ptr);
}
......@@ -530,8 +528,7 @@ static void drawStridedInstanced(const struct wined3d_gl_info *gl_info, const st
/* Specify the instanced attributes using immediate mode calls */
for(j = 0; j < numInstancedAttribs; j++) {
const BYTE *ptr = si->elements[instancedData[j]].data.addr
+ si->elements[instancedData[j]].stride * i
+ state->streams[si->elements[instancedData[j]].stream_idx].offset;
+ si->elements[instancedData[j]].stride * i;
if (si->elements[instancedData[j]].data.buffer_object)
{
struct wined3d_buffer *vb = state->streams[si->elements[instancedData[j]].stream_idx].buffer;
......
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