Commit 7148f393 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Make the "buffer_object" field of struct wined3d_bo_address a wined3d_bo pointer.

parent a9b5bb32
......@@ -960,8 +960,9 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context,
VkMappedMemoryRange range;
void *map_ptr;
if (!(bo = (struct wined3d_bo_vk *)data->buffer_object))
if (!data->buffer_object)
return data->addr;
bo = wined3d_bo_vk(data->buffer_object);
vk_info = context_vk->vk_info;
device_vk = wined3d_device_vk(context->device);
......@@ -1065,8 +1066,9 @@ static void adapter_vk_unmap_bo_address(struct wined3d_context *context,
struct wined3d_bo_vk *bo;
unsigned int i;
if (!(bo = (struct wined3d_bo_vk *)data->buffer_object))
if (!data->buffer_object)
return;
bo = wined3d_bo_vk(data->buffer_object);
if (!bo->b.coherent)
{
......@@ -1092,8 +1094,8 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
void *dst_ptr, *src_ptr;
VkBufferCopy region;
src_bo = (struct wined3d_bo_vk *)src->buffer_object;
dst_bo = (struct wined3d_bo_vk *)dst->buffer_object;
src_bo = src->buffer_object ? wined3d_bo_vk(src->buffer_object) : NULL;
dst_bo = dst->buffer_object ? wined3d_bo_vk(dst->buffer_object) : NULL;
if (dst_bo && !dst->addr && size == dst_bo->size)
map_flags |= WINED3D_MAP_DISCARD;
......@@ -1164,7 +1166,7 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
return;
}
staging.buffer_object = (uintptr_t)&staging_bo;
staging.buffer_object = &staging_bo.b;
staging.addr = NULL;
adapter_vk_copy_bo_address(context, &staging, src, size);
adapter_vk_copy_bo_address(context, dst, &staging, size);
......@@ -1184,7 +1186,7 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
return;
}
staging.buffer_object = (uintptr_t)&staging_bo;
staging.buffer_object = &staging_bo.b;
staging.addr = NULL;
adapter_vk_copy_bo_address(context, &staging, src, size);
adapter_vk_copy_bo_address(context, dst, &staging, size);
......@@ -1251,7 +1253,7 @@ static bool adapter_vk_alloc_bo(struct wined3d_device *device, struct wined3d_re
ERR("Failed to map bo.\n");
}
addr->buffer_object = (uintptr_t)bo_vk;
addr->buffer_object = &bo_vk->b;
addr->addr = NULL;
return true;
}
......
......@@ -665,7 +665,7 @@ DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_co
}
if (locations & WINED3D_LOCATION_BUFFER)
{
data->buffer_object = (uintptr_t)buffer->buffer_object;
data->buffer_object = buffer->buffer_object;
data->addr = NULL;
return WINED3D_LOCATION_BUFFER;
}
......@@ -977,7 +977,7 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
if (count == 1)
{
addr.buffer_object = (uintptr_t)buffer->buffer_object;
addr.buffer_object = buffer->buffer_object;
addr.addr = 0;
buffer->map_ptr = wined3d_context_map_bo_address(context, &addr, resource->size, flags);
/* We are accessing buffer->resource.client from the CS thread,
......@@ -1057,7 +1057,7 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou
context = context_acquire(device, NULL, 0);
addr.buffer_object = (uintptr_t)buffer->buffer_object;
addr.buffer_object = buffer->buffer_object;
addr.addr = 0;
wined3d_context_unmap_bo_address(context, &addr, range_count, buffer->maps);
......@@ -1587,7 +1587,7 @@ static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struc
if (!range_count)
return;
dst.buffer_object = (uintptr_t)buffer->buffer_object;
dst.buffer_object = buffer->buffer_object;
dst.addr = NULL;
flags = WINED3D_MAP_WRITE;
......
......@@ -2729,13 +2729,13 @@ map:
void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl,
const struct wined3d_bo_address *data, size_t size, uint32_t flags)
{
struct wined3d_bo_gl *bo;
struct wined3d_bo *bo;
void *map_ptr;
if (!(bo = (struct wined3d_bo_gl *)data->buffer_object))
if (!(bo = data->buffer_object))
return data->addr;
if (!(map_ptr = wined3d_bo_gl_map(bo, context_gl, (uintptr_t)data->addr, size, flags)))
if (!(map_ptr = wined3d_bo_gl_map(wined3d_bo_gl(bo), context_gl, (uintptr_t)data->addr, size, flags)))
ERR("Failed to map bo.\n");
return map_ptr;
......@@ -2782,8 +2782,9 @@ void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl,
const struct wined3d_gl_info *gl_info;
struct wined3d_bo_gl *bo;
if (!(bo = (struct wined3d_bo_gl *)data->buffer_object))
if (!data->buffer_object)
return;
bo = wined3d_bo_gl(data->buffer_object);
flush_bo_ranges(context_gl, wined3d_const_bo_address(data), range_count, ranges);
......@@ -2816,8 +2817,8 @@ void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
BYTE *dst_ptr, *src_ptr;
gl_info = context_gl->gl_info;
src_bo = (struct wined3d_bo_gl *)src->buffer_object;
dst_bo = (struct wined3d_bo_gl *)dst->buffer_object;
src_bo = src->buffer_object ? wined3d_bo_gl(src->buffer_object) : NULL;
dst_bo = dst->buffer_object ? wined3d_bo_gl(dst->buffer_object) : NULL;
if (dst_bo && src_bo)
{
......
......@@ -3217,7 +3217,7 @@ static bool wined3d_cs_map_upload_bo(struct wined3d_device_context *context, str
return false;
}
bo = (const struct wined3d_bo *)client->addr.buffer_object;
bo = client->addr.buffer_object;
map_ptr = bo ? bo->map_ptr : NULL;
map_ptr += (uintptr_t)client->addr.addr;
......
......@@ -2774,7 +2774,7 @@ static void *adapter_no3d_map_bo_address(struct wined3d_context *context,
{
if (data->buffer_object)
{
ERR("Unsupported buffer object %#lx.\n", data->buffer_object);
ERR("Unsupported buffer object %p.\n", data->buffer_object);
return NULL;
}
......@@ -2785,16 +2785,16 @@ static void adapter_no3d_unmap_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
{
if (data->buffer_object)
ERR("Unsupported buffer object %#lx.\n", data->buffer_object);
ERR("Unsupported buffer object %p.\n", data->buffer_object);
}
static void adapter_no3d_copy_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size)
{
if (dst->buffer_object)
ERR("Unsupported dst buffer object %#lx.\n", dst->buffer_object);
ERR("Unsupported dst buffer object %p.\n", dst->buffer_object);
if (src->buffer_object)
ERR("Unsupported src buffer object %#lx.\n", src->buffer_object);
ERR("Unsupported src buffer object %p.\n", src->buffer_object);
if (dst->buffer_object || src->buffer_object)
return;
memcpy(dst->addr, src->addr, size);
......
......@@ -469,7 +469,7 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i
if (data.buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, ((struct wined3d_bo_gl *)data.buffer_object)->id));
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, wined3d_bo_gl(data.buffer_object)->id));
checkGLcall("glBindBuffer");
}
......@@ -527,7 +527,7 @@ error:
if (data.buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
wined3d_context_gl_reference_bo(context_gl, (struct wined3d_bo_gl *)data.buffer_object);
wined3d_context_gl_reference_bo(context_gl, wined3d_bo_gl(data.buffer_object));
checkGLcall("glBindBuffer");
}
......
......@@ -830,7 +830,7 @@ void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int su
if (locations & WINED3D_LOCATION_BUFFER)
{
data->addr = NULL;
data->buffer_object = (uintptr_t)&sub_resource->bo;
data->buffer_object = &sub_resource->bo.b;
return;
}
......@@ -2476,7 +2476,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
return;
}
bo.buffer_object = src_bo_addr->buffer_object;
bo.buffer_object = (struct wined3d_bo *)src_bo_addr->buffer_object;
bo.addr = (BYTE *)src_bo_addr->addr + src_box->front * src_slice_pitch;
if (dst_texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
{
......@@ -2555,7 +2555,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
{
if (bo.buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, ((struct wined3d_bo_gl *)bo.buffer_object)->id));
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, wined3d_bo_gl(bo.buffer_object)->id));
checkGLcall("glBindBuffer");
}
......@@ -2565,7 +2565,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
if (bo.buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
wined3d_context_gl_reference_bo(context_gl, (struct wined3d_bo_gl *)bo.buffer_object);
wined3d_context_gl_reference_bo(context_gl, wined3d_bo_gl(bo.buffer_object));
checkGLcall("glBindBuffer");
}
}
......@@ -2585,7 +2585,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
static void wined3d_texture_gl_download_data_slow_path(struct wined3d_texture_gl *texture_gl,
unsigned int sub_resource_idx, struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data)
{
struct wined3d_bo_gl *bo = (struct wined3d_bo_gl *)data->buffer_object;
struct wined3d_bo_gl *bo = wined3d_bo_gl(data->buffer_object);
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
struct wined3d_texture_sub_resource *sub_resource;
unsigned int dst_row_pitch, dst_slice_pitch;
......@@ -2824,7 +2824,7 @@ static void wined3d_texture_gl_download_data(struct wined3d_context *context,
unsigned int src_level, src_width, src_height, src_depth;
unsigned int src_row_pitch, src_slice_pitch;
const struct wined3d_format_gl *format_gl;
struct wined3d_bo_gl *dst_bo;
struct wined3d_bo *dst_bo;
BOOL srgb = FALSE;
GLenum target;
......@@ -2899,9 +2899,9 @@ static void wined3d_texture_gl_download_data(struct wined3d_context *context,
return;
}
if ((dst_bo = (struct wined3d_bo_gl *)dst_bo_addr->buffer_object))
if ((dst_bo = dst_bo_addr->buffer_object))
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, dst_bo->id));
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, wined3d_bo_gl(dst_bo)->id));
checkGLcall("glBindBuffer");
}
......@@ -2925,7 +2925,7 @@ static void wined3d_texture_gl_download_data(struct wined3d_context *context,
if (dst_bo)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
wined3d_context_gl_reference_bo(context_gl, dst_bo);
wined3d_context_gl_reference_bo(context_gl, wined3d_bo_gl(dst_bo));
checkGLcall("glBindBuffer");
}
}
......@@ -4729,7 +4729,7 @@ static void wined3d_texture_vk_upload_data(struct wined3d_context *context,
return;
}
staging_bo_addr.buffer_object = (uintptr_t)&staging_bo;
staging_bo_addr.buffer_object = &staging_bo.b;
staging_bo_addr.addr = NULL;
if (!(map_ptr = wined3d_context_map_bo_address(context, &staging_bo_addr,
sub_resource->size, WINED3D_MAP_DISCARD | WINED3D_MAP_WRITE)))
......@@ -4992,7 +4992,7 @@ static void wined3d_texture_vk_download_data(struct wined3d_context *context,
wined3d_context_vk_submit_command_buffer(context_vk, 0, NULL, NULL, 0, NULL);
wined3d_context_vk_wait_command_buffer(context_vk, src_texture_vk->image.command_buffer_id);
staging_bo_addr.buffer_object = (uintptr_t)&staging_bo;
staging_bo_addr.buffer_object = &staging_bo.b;
staging_bo_addr.addr = NULL;
if (!(map_ptr = wined3d_context_map_bo_address(context, &staging_bo_addr,
sub_resource->size, WINED3D_MAP_READ)))
......
......@@ -1616,7 +1616,7 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v
src.buffer_object = 0;
src.addr = (void *)&value;
dst.buffer_object = view->counter_bo;
dst.buffer_object = (struct wined3d_bo *)view->counter_bo;
dst.addr = NULL;
wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t));
......@@ -2092,9 +2092,9 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view
goto out;
}
cb_source_address.buffer_object = 0;
cb_source_address.buffer_object = NULL;
cb_source_address.addr = (BYTE *)&constants;
cb_destination_address.buffer_object = (UINT_PTR)&constants_bo;
cb_destination_address.buffer_object = &constants_bo.b;
cb_destination_address.addr = 0;
adapter_vk_copy_bo_address(&context_vk->c, &cb_destination_address, &cb_source_address, sizeof(constants));
......
......@@ -1619,9 +1619,9 @@ static inline struct wined3d_bo_gl *wined3d_bo_gl(struct wined3d_bo *bo)
return CONTAINING_RECORD(bo, struct wined3d_bo_gl, b);
}
static inline GLuint wined3d_bo_gl_id(uintptr_t bo)
static inline GLuint wined3d_bo_gl_id(struct wined3d_bo *bo)
{
return bo ? ((struct wined3d_bo_gl *)bo)->id : 0;
return bo ? wined3d_bo_gl(bo)->id : 0;
}
struct wined3d_bo_user
......@@ -1679,7 +1679,7 @@ void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk,
struct wined3d_bo_address
{
UINT_PTR buffer_object;
struct wined3d_bo *buffer_object;
BYTE *addr;
};
......@@ -4409,6 +4409,7 @@ struct wined3d_texture
DWORD locations;
union
{
struct wined3d_bo b;
struct wined3d_bo_gl gl;
struct wined3d_bo_vk vk;
} bo;
......
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