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

wined3d: Store a struct wined3d_bo_address in struct wined3d_stream_info_element.

Instead of using separate fields for the buffer object and offset.
parent 89bf30a2
......@@ -265,7 +265,7 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *This,
}
}
data = (((DWORD_PTR)attrib->data) + offset) % This->stride;
data = (((DWORD_PTR)attrib->data.addr) + offset) % This->stride;
attrib_size = attrib->format->component_count * attrib->format->component_size;
for (i = 0; i < attrib_size; ++i)
{
......@@ -294,7 +294,7 @@ static BOOL buffer_check_attribute(struct wined3d_buffer *This, const struct win
* there, on nonexistent attribs the vbo is 0.
*/
if (!(si->use_map & (1 << attrib_idx))
|| attrib->buffer_object != This->buffer_object)
|| attrib->data.buffer_object != This->buffer_object)
return FALSE;
format = attrib->format->id;
......
......@@ -293,10 +293,9 @@ void device_stream_info_from_declaration(struct wined3d_device *device,
element->offset, stride, debug_d3dformat(element->format->id), data.buffer_object);
stream_info->elements[idx].format = element->format;
stream_info->elements[idx].data = data;
stream_info->elements[idx].stride = stride;
stream_info->elements[idx].data = data.addr;
stream_info->elements[idx].stream_idx = element->input_slot;
stream_info->elements[idx].buffer_object = data.buffer_object;
if (!device->adapter->gl_info.supported[ARB_VERTEX_ARRAY_BGRA]
&& element->format->id == WINED3DFMT_B8G8R8A8_UNORM)
......@@ -324,11 +323,12 @@ void device_stream_info_from_declaration(struct wined3d_device *device,
buffer = device->stateBlock->state.streams[element->stream_idx].buffer;
wined3d_buffer_preload(buffer);
/* If PreLoad dropped the buffer object, update the stream info. */
if (buffer->buffer_object != element->buffer_object)
/* If the preload dropped the buffer object, update the stream info. */
if (buffer->buffer_object != element->data.buffer_object)
{
element->buffer_object = 0;
element->data = buffer_get_sysmem(buffer, &device->adapter->gl_info) + (ptrdiff_t)element->data;
element->data.buffer_object = 0;
element->data.addr = buffer_get_sysmem(buffer, &device->adapter->gl_info)
+ (ptrdiff_t)element->data.addr;
}
if (buffer->query)
......@@ -340,11 +340,11 @@ void device_stream_info_from_declaration(struct wined3d_device *device,
static void stream_info_element_from_strided(const struct wined3d_gl_info *gl_info,
const struct WineDirect3DStridedData *strided, struct wined3d_stream_info_element *e)
{
e->data.addr = strided->lpData;
e->data.buffer_object = 0;
e->format = wined3d_get_format(gl_info, strided->format);
e->stride = strided->dwStride;
e->data = strided->lpData;
e->stream_idx = 0;
e->buffer_object = 0;
}
static void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info,
......@@ -3287,7 +3287,7 @@ static HRESULT process_vertices_strided(struct wined3d_device *device, DWORD dwD
((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) ) {
/* The position first */
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_POSITION];
const float *p = (const float *)(element->data + i * element->stride);
const float *p = (const float *)(element->data.addr + i * element->stride);
float x, y, z, rhw;
TRACE("In: ( %06.2f %06.2f %06.2f )\n", p[0], p[1], p[2]);
......@@ -3401,9 +3401,10 @@ static HRESULT process_vertices_strided(struct wined3d_device *device, DWORD dwD
dest_ptr += sizeof(DWORD);
if(dest_conv) dest_conv += sizeof(DWORD);
}
if (DestFVF & WINED3DFVF_NORMAL) {
if (DestFVF & WINED3DFVF_NORMAL)
{
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_NORMAL];
const float *normal = (const float *)(element->data + i * element->stride);
const float *normal = (const float *)(element->data.addr + i * element->stride);
/* AFAIK this should go into the lighting information */
FIXME("Didn't expect the destination to have a normal\n");
copy_and_next(dest_ptr, normal, 3 * sizeof(float));
......@@ -3412,9 +3413,10 @@ static HRESULT process_vertices_strided(struct wined3d_device *device, DWORD dwD
}
}
if (DestFVF & WINED3DFVF_DIFFUSE) {
if (DestFVF & WINED3DFVF_DIFFUSE)
{
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_DIFFUSE];
const DWORD *color_d = (const DWORD *)(element->data + i * element->stride);
const DWORD *color_d = (const DWORD *)(element->data.addr + i * element->stride);
if (!(stream_info->use_map & (1 << WINED3D_FFP_DIFFUSE)))
{
static BOOL warned = FALSE;
......@@ -3447,7 +3449,7 @@ static HRESULT process_vertices_strided(struct wined3d_device *device, DWORD dwD
{
/* What's the color value in the feedback buffer? */
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_SPECULAR];
const DWORD *color_s = (const DWORD *)(element->data + i * element->stride);
const DWORD *color_s = (const DWORD *)(element->data.addr + i * element->stride);
if (!(stream_info->use_map & (1 << WINED3D_FFP_SPECULAR)))
{
static BOOL warned = FALSE;
......@@ -3476,9 +3478,10 @@ static HRESULT process_vertices_strided(struct wined3d_device *device, DWORD dwD
}
}
for (tex_index = 0; tex_index < numTextures; tex_index++) {
for (tex_index = 0; tex_index < numTextures; ++tex_index)
{
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_TEXCOORD0 + tex_index];
const float *tex_coord = (const float *)(element->data + i * element->stride);
const float *tex_coord = (const float *)(element->data.addr + i * element->stride);
if (!(stream_info->use_map & (1 << (WINED3D_FFP_TEXCOORD0 + tex_index))))
{
ERR("No source texture, but destination requests one\n");
......@@ -3559,18 +3562,18 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
if (!(stream_info.use_map & (1 << i))) continue;
e = &stream_info.elements[i];
if (e->buffer_object)
if (e->data.buffer_object)
{
struct wined3d_buffer *vb = device->stateBlock->state.streams[e->stream_idx].buffer;
e->buffer_object = 0;
e->data = (BYTE *)((ULONG_PTR)e->data + (ULONG_PTR)buffer_get_sysmem(vb, gl_info));
e->data.buffer_object = 0;
e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, gl_info));
ENTER_GL();
GL_EXTCALL(glDeleteBuffersARB(1, &vb->buffer_object));
vb->buffer_object = 0;
LEAVE_GL();
}
if (e->data)
e->data += e->stride * src_start_idx;
if (e->data.addr)
e->data.addr += e->stride * src_start_idx;
}
}
......
......@@ -111,13 +111,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 + streams[element->stream_idx].offset;
position = element->data.addr + streams[element->stream_idx].offset;
}
if (si->use_map & (1 << WINED3D_FFP_NORMAL))
{
element = &si->elements[WINED3D_FFP_NORMAL];
normal = element->data + streams[element->stream_idx].offset;
normal = element->data.addr + streams[element->stream_idx].offset;
}
else
{
......@@ -128,7 +128,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 + streams[element->stream_idx].offset;
diffuse = element->data.addr + streams[element->stream_idx].offset;
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 +141,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 + streams[element->stream_idx].offset;
specular = element->data.addr + streams[element->stream_idx].offset;
/* special case where the fog density is stored in the specular alpha channel */
if (state->render_states[WINED3DRS_FOGENABLE]
......@@ -201,7 +201,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 + streams[element->stream_idx].offset;
texCoords[coordIdx] = element->data.addr + streams[element->stream_idx].offset;
tex_mask |= (1 << textureNo);
}
else
......@@ -465,7 +465,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 + si->elements[i].stride * SkipnStrides
ptr = si->elements[i].data.addr + si->elements[i].stride * SkipnStrides
+ state->streams[si->elements[i].stream_idx].offset;
send_attribute(gl_info, si->elements[i].format->id, i, ptr);
......@@ -529,10 +529,10 @@ static void drawStridedInstanced(const struct wined3d_gl_info *gl_info, const st
for(i = 0; i < numInstances; i++) {
/* Specify the instanced attributes using immediate mode calls */
for(j = 0; j < numInstancedAttribs; j++) {
const BYTE *ptr = si->elements[instancedData[j]].data
const BYTE *ptr = si->elements[instancedData[j]].data.addr
+ si->elements[instancedData[j]].stride * i
+ state->streams[si->elements[instancedData[j]].stream_idx].offset;
if (si->elements[instancedData[j]].buffer_object)
if (si->elements[instancedData[j]].data.buffer_object)
{
struct wined3d_buffer *vb = state->streams[si->elements[instancedData[j]].stream_idx].buffer;
ptr += (ULONG_PTR)buffer_get_sysmem(vb, gl_info);
......@@ -568,11 +568,11 @@ static void remove_vbos(const struct wined3d_gl_info *gl_info,
if (!(s->use_map & (1 << i))) continue;
e = &s->elements[i];
if (e->buffer_object)
if (e->data.buffer_object)
{
struct wined3d_buffer *vb = state->streams[e->stream_idx].buffer;
e->buffer_object = 0;
e->data = (BYTE *)((ULONG_PTR)e->data + (ULONG_PTR)buffer_get_sysmem(vb, gl_info));
e->data.buffer_object = 0;
e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, gl_info));
}
}
}
......@@ -814,13 +814,13 @@ HRESULT tesselate_rectpatch(struct wined3d_device *This, struct WineD3DRectPatch
device_stream_info_from_declaration(This, FALSE, &stream_info, NULL);
e = &stream_info.elements[WINED3D_FFP_POSITION];
if (e->buffer_object)
if (e->data.buffer_object)
{
struct wined3d_buffer *vb = This->stateBlock->state.streams[e->stream_idx].buffer;
e->data = (BYTE *)((ULONG_PTR)e->data + (ULONG_PTR)buffer_get_sysmem(vb, context->gl_info));
e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, context->gl_info));
}
vtxStride = e->stride;
data = e->data +
data = e->data.addr +
vtxStride * info->Stride * info->StartVertexOffsetHeight +
vtxStride * info->StartVertexOffsetWidth;
......
......@@ -847,9 +847,9 @@ do {
/* Trace vector and strided data information */
#define TRACE_STRIDED(si, name) do { if (si->use_map & (1 << 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].format->id, \
si->elements[name].buffer_object, si->elements[name].stream_idx); } while(0)
TRACE( #name " = (data {%#x:%p}, stride %d, format %s, stream %u)\n", \
si->elements[name].data.buffer_object, si->elements[name].data.addr, si->elements[name].stride, \
debug_d3dformat(si->elements[name].format->id), si->elements[name].stream_idx); } while(0)
/* Global variables */
extern const float identity[16] DECLSPEC_HIDDEN;
......@@ -904,10 +904,9 @@ struct wined3d_bo_address
struct wined3d_stream_info_element
{
const struct wined3d_format *format;
struct wined3d_bo_address data;
GLsizei stride;
const BYTE *data;
UINT stream_idx;
GLuint buffer_object;
};
struct wined3d_stream_info
......
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