wined3d: Derive the GL bind point for buffer object maps from the bind flags.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2019-09-23 14:54:15 +03:30 committed by Alexandre Julliard
parent 8b780d2d8c
commit 2bc6941ab0
7 changed files with 48 additions and 35 deletions

View File

@ -4588,15 +4588,27 @@ static void adapter_gl_uninit_3d(struct wined3d_device *device)
}
static void *adapter_gl_map_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, size_t size, GLenum binding, uint32_t flags)
const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags)
{
return wined3d_context_gl_map_bo_address(wined3d_context_gl(context), data, size, binding, flags);
struct wined3d_context_gl *context_gl;
GLenum binding;
context_gl = wined3d_context_gl(context);
binding = wined3d_buffer_gl_binding_from_bind_flags(context_gl->gl_info, bind_flags);
return wined3d_context_gl_map_bo_address(context_gl, data, size, binding, map_flags);
}
static void adapter_gl_unmap_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, GLenum binding)
const struct wined3d_bo_address *data, uint32_t bind_flags)
{
return wined3d_context_gl_unmap_bo_address(wined3d_context_gl(context), data, binding);
struct wined3d_context_gl *context_gl;
GLenum binding;
context_gl = wined3d_context_gl(context);
binding = wined3d_buffer_gl_binding_from_bind_flags(context_gl->gl_info, bind_flags);
wined3d_context_gl_unmap_bo_address(context_gl, data, binding);
}
static HRESULT adapter_gl_create_swapchain(struct wined3d_device *device, struct wined3d_swapchain_desc *desc,

View File

@ -472,7 +472,7 @@ static void adapter_vk_uninit_3d(struct wined3d_device *device)
}
static void *adapter_vk_map_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, size_t size, GLenum binding, uint32_t flags)
const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags)
{
if (data->buffer_object)
{
@ -484,7 +484,7 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context,
}
static void adapter_vk_unmap_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, GLenum binding)
const struct wined3d_bo_address *data, uint32_t bind_flags)
{
if (data->buffer_object)
ERR("Unsupported buffer object %#lx.\n", data->buffer_object);

View File

@ -1288,9 +1288,11 @@ static const struct wined3d_resource_ops buffer_resource_ops =
buffer_resource_sub_resource_unmap,
};
static GLenum buffer_type_hint_from_bind_flags(const struct wined3d_gl_info *gl_info,
unsigned int bind_flags)
GLenum wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info *gl_info, uint32_t bind_flags)
{
if (!bind_flags)
return GL_PIXEL_UNPACK_BUFFER;
if (bind_flags == WINED3D_BIND_INDEX_BUFFER)
return GL_ELEMENT_ARRAY_BUFFER;
@ -1536,7 +1538,7 @@ HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined
TRACE("buffer_gl %p, device %p, desc %p, data %p, parent %p, parent_ops %p.\n",
buffer_gl, device, desc, data, parent, parent_ops);
buffer_gl->buffer_type_hint = buffer_type_hint_from_bind_flags(gl_info, desc->bind_flags);
buffer_gl->buffer_type_hint = wined3d_buffer_gl_binding_from_bind_flags(gl_info, desc->bind_flags);
return wined3d_buffer_init(&buffer_gl->b, device, desc, data, parent, parent_ops, &wined3d_buffer_gl_ops);
}

View File

@ -2354,7 +2354,7 @@ static void adapter_no3d_uninit_3d(struct wined3d_device *device)
}
static void *adapter_no3d_map_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, size_t size, GLenum binding, uint32_t flags)
const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags)
{
if (data->buffer_object)
{
@ -2366,7 +2366,7 @@ static void *adapter_no3d_map_bo_address(struct wined3d_context *context,
}
static void adapter_no3d_unmap_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, GLenum binding)
const struct wined3d_bo_address *data, uint32_t bind_flags)
{
if (data->buffer_object)
ERR("Unsupported buffer object %#lx.\n", data->buffer_object);

View File

@ -658,15 +658,15 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
wined3d_texture_get_memory(dst_texture, 0, &dst_data, map_binding);
src = wined3d_context_map_bo_address(context, &src_data,
src_texture->sub_resources[sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ);
src_texture->sub_resources[sub_resource_idx].size, 0, WINED3D_MAP_READ);
dst = wined3d_context_map_bo_address(context, &dst_data,
dst_texture->sub_resources[0].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_WRITE);
dst_texture->sub_resources[0].size, 0, WINED3D_MAP_WRITE);
conv->convert(src, dst, src_row_pitch, dst_row_pitch, desc.width, desc.height);
wined3d_texture_invalidate_location(dst_texture, 0, ~map_binding);
wined3d_context_unmap_bo_address(context, &dst_data, GL_PIXEL_UNPACK_BUFFER);
wined3d_context_unmap_bo_address(context, &src_data, GL_PIXEL_UNPACK_BUFFER);
wined3d_context_unmap_bo_address(context, &dst_data, 0);
wined3d_context_unmap_bo_address(context, &src_data, 0);
}
else
{
@ -1662,8 +1662,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch);
wined3d_texture_get_memory(dst_texture, dst_sub_resource_idx, &dst_data, map_binding);
dst_map.data = wined3d_context_map_bo_address(context, &dst_data,
dst_texture->sub_resources[dst_sub_resource_idx].size,
GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ | WINED3D_MAP_WRITE);
dst_texture->sub_resources[dst_sub_resource_idx].size, 0, WINED3D_MAP_READ | WINED3D_MAP_WRITE);
src_map = dst_map;
src_format = dst_texture->resource.format;
@ -1698,7 +1697,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
wined3d_texture_get_pitch(src_texture, texture_level, &src_map.row_pitch, &src_map.slice_pitch);
wined3d_texture_get_memory(src_texture, src_sub_resource_idx, &src_data, map_binding);
src_map.data = wined3d_context_map_bo_address(context, &src_data,
src_texture->sub_resources[src_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ);
src_texture->sub_resources[src_sub_resource_idx].size, 0, WINED3D_MAP_READ);
map_binding = dst_texture->resource.map_binding;
texture_level = dst_sub_resource_idx % dst_texture->level_count;
@ -1708,7 +1707,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch);
wined3d_texture_get_memory(dst_texture, dst_sub_resource_idx, &dst_data, map_binding);
dst_map.data = wined3d_context_map_bo_address(context, &dst_data,
dst_texture->sub_resources[dst_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_WRITE);
dst_texture->sub_resources[dst_sub_resource_idx].size, 0, WINED3D_MAP_WRITE);
}
flags &= ~WINED3D_BLT_RAW;
@ -2084,9 +2083,9 @@ error:
FIXME(" Unsupported flags %#x.\n", flags);
release:
wined3d_context_unmap_bo_address(context, &dst_data, GL_PIXEL_UNPACK_BUFFER);
wined3d_context_unmap_bo_address(context, &dst_data, 0);
if (!same_sub_resource)
wined3d_context_unmap_bo_address(context, &src_data, GL_PIXEL_UNPACK_BUFFER);
wined3d_context_unmap_bo_address(context, &src_data, 0);
if (SUCCEEDED(hr) && dst_texture->swapchain && dst_texture->swapchain->front_buffer == dst_texture)
{
SetRect(&dst_texture->swapchain->front_buffer_update,
@ -2157,7 +2156,7 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view,
wined3d_texture_get_pitch(texture, level, &map.row_pitch, &map.slice_pitch);
wined3d_texture_get_memory(texture, view->sub_resource_idx, &data, map_binding);
map.data = wined3d_context_map_bo_address(context, &data,
texture->sub_resources[view->sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_WRITE);
texture->sub_resources[view->sub_resource_idx].size, 0, WINED3D_MAP_WRITE);
map.data = (BYTE *)map.data
+ (box->front * map.slice_pitch)
+ ((box->top / view->format->block_height) * map.row_pitch)
@ -2217,7 +2216,7 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view,
memcpy(dst, map.data, w * h * bpp);
}
wined3d_context_unmap_bo_address(context, &data, GL_PIXEL_UNPACK_BUFFER);
wined3d_context_unmap_bo_address(context, &data, 0);
context_release(context);
}

View File

@ -749,8 +749,7 @@ static void wined3d_texture_create_dc(void *object)
if (!context)
context = context_acquire(device, NULL, 0);
desc.pMemory = wined3d_context_map_bo_address(context, &data,
texture->sub_resources[sub_resource_idx].size,
GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ | WINED3D_MAP_WRITE);
texture->sub_resources[sub_resource_idx].size, 0, WINED3D_MAP_READ | WINED3D_MAP_WRITE);
}
else
{
@ -818,7 +817,7 @@ static void wined3d_texture_destroy_dc(void *object)
if (data.buffer_object)
{
context = context_acquire(device, NULL, 0);
wined3d_context_unmap_bo_address(context, &data, GL_PIXEL_UNPACK_BUFFER);
wined3d_context_unmap_bo_address(context, &data, 0);
context_release(context);
}
}
@ -2962,8 +2961,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
wined3d_texture_invalidate_location(texture, sub_resource_idx, ~resource->map_binding);
wined3d_texture_get_memory(texture, sub_resource_idx, &data, resource->map_binding);
base_memory = wined3d_context_map_bo_address(context, &data,
sub_resource->size, GL_PIXEL_UNPACK_BUFFER, flags);
base_memory = wined3d_context_map_bo_address(context, &data, sub_resource->size, 0, flags);
TRACE("Base memory pointer %p.\n", base_memory);
context_release(context);
@ -3047,7 +3045,7 @@ static HRESULT texture_resource_sub_resource_unmap(struct wined3d_resource *reso
context = context_acquire(device, NULL, 0);
wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding);
wined3d_context_unmap_bo_address(context, &data, GL_PIXEL_UNPACK_BUFFER);
wined3d_context_unmap_bo_address(context, &data, 0);
context_release(context);

View File

@ -2812,9 +2812,9 @@ struct wined3d_adapter_ops
HRESULT (*adapter_init_3d)(struct wined3d_device *device);
void (*adapter_uninit_3d)(struct wined3d_device *device);
void *(*adapter_map_bo_address)(struct wined3d_context *context,
const struct wined3d_bo_address *data, size_t size, GLenum binding, uint32_t flags);
const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags);
void (*adapter_unmap_bo_address)(struct wined3d_context *context,
const struct wined3d_bo_address *data, GLenum binding);
const struct wined3d_bo_address *data, uint32_t bind_flags);
HRESULT (*adapter_create_swapchain)(struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
void (*adapter_destroy_swapchain)(struct wined3d_swapchain *swapchain);
@ -4225,6 +4225,8 @@ static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer
return CONTAINING_RECORD(buffer, struct wined3d_buffer_gl, b);
}
GLenum wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info *gl_info,
uint32_t bind_flags) DECLSPEC_HIDDEN;
void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *buffer_gl,
struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined3d_device *device,
@ -5250,15 +5252,15 @@ static inline float wined3d_get_float_state(const struct wined3d_state *state, e
}
static inline void *wined3d_context_map_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, size_t size, GLenum binding, uint32_t flags)
const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags)
{
return context->device->adapter->adapter_ops->adapter_map_bo_address(context, data, size, binding, flags);
return context->device->adapter->adapter_ops->adapter_map_bo_address(context, data, size, bind_flags, map_flags);
}
static inline void wined3d_context_unmap_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, GLenum binding)
const struct wined3d_bo_address *data, uint32_t bind_flags)
{
return context->device->adapter->adapter_ops->adapter_unmap_bo_address(context, data, binding);
context->device->adapter->adapter_ops->adapter_unmap_bo_address(context, data, bind_flags);
}
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */