Commit 5c13b060 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Move the "buffer_offset" field to struct wined3d_bo.

parent 884b7c50
......@@ -1011,7 +1011,7 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context,
vk_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.buffer = bo->vk_buffer;
vk_barrier.offset = bo->buffer_offset + (uintptr_t)data->addr;
vk_barrier.offset = bo->b.buffer_offset + (uintptr_t)data->addr;
vk_barrier.size = size;
VK_CALL(vkCmdPipelineBarrier(vk_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_HOST_BIT, 0, 0, NULL, 1, &vk_barrier, 0, NULL));
......@@ -1113,8 +1113,8 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
src_access_mask = vk_access_mask_from_buffer_usage(src_bo->usage);
dst_access_mask = vk_access_mask_from_buffer_usage(dst_bo->usage);
region.srcOffset = src_bo->buffer_offset + (uintptr_t)src->addr;
region.dstOffset = dst_bo->buffer_offset + (uintptr_t)dst->addr;
region.srcOffset = src_bo->b.buffer_offset + (uintptr_t)src->addr;
region.dstOffset = dst_bo->b.buffer_offset + (uintptr_t)dst->addr;
region.size = size;
vk_barrier[0].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
......@@ -1781,7 +1781,7 @@ static void adapter_vk_draw_primitive(struct wined3d_device *device,
for (i = 0; i < ARRAY_SIZE(context_vk->vk_so_counters); ++i)
{
context_vk->vk_so_counters[i] = bo->vk_buffer;
context_vk->vk_so_offsets[i] = bo->buffer_offset + i * sizeof(uint32_t) * 2;
context_vk->vk_so_offsets[i] = bo->b.buffer_offset + i * sizeof(uint32_t) * 2;
}
}
......@@ -1805,13 +1805,13 @@ static void adapter_vk_draw_primitive(struct wined3d_device *device,
{
stride = sizeof(VkDrawIndexedIndirectCommand);
VK_CALL(vkCmdDrawIndexedIndirect(vk_command_buffer, bo->vk_buffer,
bo->buffer_offset + parameters->u.indirect.offset, size / stride, stride));
bo->b.buffer_offset + parameters->u.indirect.offset, size / stride, stride));
}
else
{
stride = sizeof(VkDrawIndirectCommand);
VK_CALL(vkCmdDrawIndirect(vk_command_buffer, bo->vk_buffer,
bo->buffer_offset + parameters->u.indirect.offset, size / stride, stride));
bo->b.buffer_offset + parameters->u.indirect.offset, size / stride, stride));
}
}
else
......@@ -1871,7 +1871,7 @@ static void adapter_vk_dispatch_compute(struct wined3d_device *device,
wined3d_context_vk_reference_bo(context_vk, bo);
VK_CALL(vkCmdDispatchIndirect(vk_command_buffer, bo->vk_buffer,
bo->buffer_offset + parameters->u.indirect.offset));
bo->b.buffer_offset + parameters->u.indirect.offset));
}
else
{
......
......@@ -1521,7 +1521,7 @@ const VkDescriptorBufferInfo *wined3d_buffer_vk_get_buffer_info(struct wined3d_b
return &buffer_vk->buffer_info;
buffer_vk->buffer_info.buffer = bo->vk_buffer;
buffer_vk->buffer_info.offset = bo->buffer_offset;
buffer_vk->buffer_info.offset = bo->b.buffer_offset;
buffer_vk->buffer_info.range = buffer_vk->b.resource.size;
buffer_vk->b.bo_user.valid = true;
......@@ -1702,7 +1702,7 @@ void wined3d_buffer_vk_barrier(struct wined3d_buffer_vk *buffer_vk,
vk_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.buffer = bo->vk_buffer;
vk_barrier.offset = bo->buffer_offset;
vk_barrier.offset = bo->b.buffer_offset;
vk_barrier.size = buffer_vk->b.resource.size;
VK_CALL(vkCmdPipelineBarrier(wined3d_context_vk_get_command_buffer(context_vk),
vk_pipeline_stage_mask_from_bind_flags(src_bind_mask),
......
......@@ -2922,7 +2922,7 @@ bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizei
list_init(&bo->b.users);
bo->command_fence_id = 0;
bo->b.memory_offset = 0;
bo->buffer_offset = 0;
bo->b.buffer_offset = 0;
bo->b.map_ptr = NULL;
return true;
......@@ -3789,7 +3789,7 @@ static void wined3d_context_gl_bind_unordered_access_views(struct wined3d_contex
if (view_gl->counter_bo.id)
GL_EXTCALL(glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, i, view_gl->counter_bo.id,
view_gl->counter_bo.buffer_offset, view_gl->counter_bo.size));
view_gl->counter_bo.b.buffer_offset, view_gl->counter_bo.size));
}
checkGLcall("Bind unordered access views");
}
......@@ -4915,7 +4915,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
if (!bo || !stream_info->all_vbo)
idx_data = index_buffer->resource.heap_memory;
else
idx_data = (void *)wined3d_bo_gl(bo)->buffer_offset;
idx_data = (void *)bo->buffer_offset;
idx_data = (const BYTE *)idx_data + state->index_offset;
if (state->index_format == WINED3DFMT_R16_UINT)
......@@ -5077,7 +5077,7 @@ static const void *get_vertex_attrib_pointer(const struct wined3d_stream_info_el
const uint8_t *offset = element->data.addr + state->load_base_vertex_index * element->stride;
if (element->data.buffer_object)
offset += wined3d_bo_gl(element->data.buffer_object)->buffer_offset;
offset += element->data.buffer_object->buffer_offset;
return offset;
}
......
......@@ -456,8 +456,8 @@ static bool wined3d_context_vk_create_slab_bo(struct wined3d_context_vk *context
*bo = slab->bo;
bo->memory = NULL;
bo->slab = slab;
bo->buffer_offset = idx * object_size;
bo->b.memory_offset = slab->bo.b.memory_offset + bo->buffer_offset;
bo->b.buffer_offset = idx * object_size;
bo->b.memory_offset = slab->bo.b.memory_offset + bo->b.buffer_offset;
bo->size = size;
list_init(&bo->b.users);
bo->command_buffer_id = 0;
......@@ -465,7 +465,7 @@ static bool wined3d_context_vk_create_slab_bo(struct wined3d_context_vk *context
TRACE("Using buffer 0x%s, memory 0x%s, offset 0x%s for bo %p.\n",
wine_dbgstr_longlong(bo->vk_buffer), wine_dbgstr_longlong(bo->vk_memory),
wine_dbgstr_longlong(bo->buffer_offset), bo);
wine_dbgstr_longlong(bo->b.buffer_offset), bo);
return true;
}
......@@ -534,7 +534,7 @@ BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDevic
}
bo->b.map_ptr = NULL;
bo->buffer_offset = 0;
bo->b.buffer_offset = 0;
bo->size = size;
bo->usage = usage;
bo->memory_type = adapter_vk->memory_properties.memoryTypes[memory_type_idx].propertyFlags;
......@@ -961,7 +961,7 @@ void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk, const
if (bo->b.map_ptr)
wined3d_bo_slab_vk_unmap(slab_vk, context_vk);
object_size = slab_vk->bo.size / 32;
idx = bo->buffer_offset / object_size;
idx = bo->b.buffer_offset / object_size;
wined3d_context_vk_destroy_bo_slab_slice(context_vk, slab_vk, idx, bo->command_buffer_id);
return;
}
......
......@@ -657,9 +657,9 @@ bool wined3d_device_vk_create_null_resources(struct wined3d_device_vk *device_vk
memory_type = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
if (!wined3d_context_vk_create_bo(context_vk, 16, usage, memory_type, &r->bo))
return false;
VK_CALL(vkCmdFillBuffer(vk_command_buffer, r->bo.vk_buffer, r->bo.buffer_offset, r->bo.size, 0x00000000u));
VK_CALL(vkCmdFillBuffer(vk_command_buffer, r->bo.vk_buffer, r->bo.b.buffer_offset, r->bo.size, 0x00000000u));
r->buffer_info.buffer = r->bo.vk_buffer;
r->buffer_info.offset = r->bo.buffer_offset;
r->buffer_info.offset = r->bo.b.buffer_offset;
r->buffer_info.range = r->bo.size;
if (!wined3d_null_image_vk_init(&r->image_1d, context_vk, vk_command_buffer, VK_IMAGE_TYPE_1D, 1, 1))
......@@ -735,7 +735,7 @@ bool wined3d_device_vk_create_null_views(struct wined3d_device_vk *device_vk, st
buffer_create_info.flags = 0;
buffer_create_info.buffer = r->bo.vk_buffer;
buffer_create_info.format = VK_FORMAT_R32_UINT;
buffer_create_info.offset = r->bo.buffer_offset;
buffer_create_info.offset = r->bo.b.buffer_offset;
buffer_create_info.range = r->bo.size;
if ((vr = VK_CALL(vkCreateBufferView(device_vk->vk_device,
......
......@@ -4600,7 +4600,7 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
buffer = buffer_state->buffer;
bo_gl = wined3d_bo_gl(buffer->buffer_object);
GL_EXTCALL(glBindBufferRange(GL_UNIFORM_BUFFER, base + i,
bo_gl->id, bo_gl->buffer_offset + buffer_state->offset, buffer_state->size));
bo_gl->id, bo_gl->b.buffer_offset + buffer_state->offset, buffer_state->size));
buffer->bo_user.valid = true;
}
checkGLcall("bind constant buffers");
......@@ -4677,7 +4677,7 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state
}
size = buffer->resource.size - offset;
GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i,
bo_gl->id, bo_gl->buffer_offset + offset, size));
bo_gl->id, bo_gl->b.buffer_offset + offset, size));
buffer->bo_user.valid = true;
}
checkGLcall("bind transform feedback buffers");
......
......@@ -4764,7 +4764,7 @@ static void wined3d_texture_vk_upload_data(struct wined3d_context *context,
vk_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.buffer = src_bo->vk_buffer;
vk_barrier.offset = src_bo->buffer_offset + (size_t)src_bo_addr->addr;
vk_barrier.offset = src_bo->b.buffer_offset + (size_t)src_bo_addr->addr;
vk_barrier.size = sub_resource->size;
src_offset += (size_t)src_bo_addr->addr;
......@@ -4788,7 +4788,7 @@ static void wined3d_texture_vk_upload_data(struct wined3d_context *context,
dst_texture_vk->layout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
dst_texture_vk->image.vk_image, &vk_range);
region.bufferOffset = src_bo->buffer_offset + src_offset;
region.bufferOffset = src_bo->b.buffer_offset + src_offset;
region.bufferRowLength = (src_row_pitch / src_format->block_byte_count) * src_format->block_width;
if (src_row_pitch)
region.bufferImageHeight = (src_slice_pitch / src_row_pitch) * src_format->block_height;
......@@ -4941,7 +4941,7 @@ static void wined3d_texture_vk_download_data(struct wined3d_context *context,
vk_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.buffer = dst_bo->vk_buffer;
vk_barrier.offset = dst_bo->buffer_offset + (size_t)dst_bo_addr->addr;
vk_barrier.offset = dst_bo->b.buffer_offset + (size_t)dst_bo_addr->addr;
vk_barrier.size = sub_resource->size;
bo_stage_flags = vk_pipeline_stage_mask_from_buffer_usage(dst_bo->usage);
......@@ -4964,7 +4964,7 @@ static void wined3d_texture_vk_download_data(struct wined3d_context *context,
src_texture_vk->layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
src_texture_vk->image.vk_image, &vk_range);
region.bufferOffset = dst_bo->buffer_offset + dst_offset;
region.bufferOffset = dst_bo->b.buffer_offset + dst_offset;
region.bufferRowLength = 0;
region.bufferImageHeight = 0;
region.imageSubresource.aspectMask = vk_range.aspectMask;
......
......@@ -685,7 +685,7 @@ static VkBufferView wined3d_view_vk_create_vk_buffer_view(struct wined3d_context
create_info.flags = 0;
create_info.buffer = bo->vk_buffer;
create_info.format = view_format_vk->vk_format;
create_info.offset = bo->buffer_offset + offset;
create_info.offset = bo->b.buffer_offset + offset;
create_info.range = size;
device_vk = wined3d_device_vk(buffer_vk->b.resource.device);
......@@ -2101,7 +2101,7 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view
buffer_info.buffer = constants_bo.vk_buffer;
buffer_info.range = constants_bo.size;
buffer_info.offset = constants_bo.buffer_offset;
buffer_info.offset = constants_bo.b.buffer_offset;
vk_info = context_vk->vk_info;
......@@ -2234,7 +2234,7 @@ static void wined3d_unordered_access_view_vk_cs_init(void *object)
wined3d_context_vk_end_current_render_pass(context_vk);
VK_CALL(vkCmdFillBuffer(wined3d_context_vk_get_command_buffer(context_vk),
uav_vk->counter_bo.vk_buffer, uav_vk->counter_bo.buffer_offset, sizeof(uint32_t), 0));
uav_vk->counter_bo.vk_buffer, uav_vk->counter_bo.b.buffer_offset, sizeof(uint32_t), 0));
wined3d_context_vk_reference_bo(context_vk, &uav_vk->counter_bo);
create_info.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
......@@ -2242,7 +2242,7 @@ static void wined3d_unordered_access_view_vk_cs_init(void *object)
create_info.flags = 0;
create_info.buffer = uav_vk->counter_bo.vk_buffer;
create_info.format = VK_FORMAT_R32_UINT;
create_info.offset = uav_vk->counter_bo.buffer_offset;
create_info.offset = uav_vk->counter_bo.b.buffer_offset;
create_info.range = sizeof(uint32_t);
if ((vr = VK_CALL(vkCreateBufferView(device_vk->vk_device,
&create_info, NULL, &uav_vk->vk_counter_view))) < 0)
......
......@@ -1597,6 +1597,7 @@ struct wined3d_bo
{
struct list users;
void *map_ptr;
size_t buffer_offset;
size_t memory_offset;
bool coherent;
};
......@@ -1606,7 +1607,6 @@ struct wined3d_bo_gl
struct wined3d_bo b;
GLuint id;
GLsizeiptr buffer_offset;
GLsizeiptr size;
GLenum binding;
GLenum usage;
......@@ -1641,7 +1641,6 @@ struct wined3d_bo_vk
VkDeviceMemory vk_memory;
VkDeviceSize buffer_offset;
VkDeviceSize size;
VkBufferUsageFlags usage;
VkMemoryPropertyFlags memory_type;
......
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