Commit 4b22faa9 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Introduce wined3d_context_gl_reference_buffer().

parent 996cfb84
......@@ -3796,8 +3796,8 @@ static void context_gl_load_shader_resources(struct wined3d_context_gl *context_
struct wined3d_shader_sampler_map_entry *entry;
struct wined3d_shader_resource_view_gl *srv_gl;
struct wined3d_shader_resource_view *view;
struct wined3d_buffer_gl *buffer_gl;
struct wined3d_shader *shader;
struct wined3d_buffer *buffer;
unsigned int i, j;
for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
......@@ -3813,10 +3813,10 @@ static void context_gl_load_shader_resources(struct wined3d_context_gl *context_
if (!state->cb[i][j].buffer)
continue;
buffer_gl = wined3d_buffer_gl(state->cb[i][j].buffer);
wined3d_buffer_load(&buffer_gl->b, &context_gl->c, state);
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
if (!buffer_gl->b.bo_user.valid)
buffer = state->cb[i][j].buffer;
wined3d_buffer_load(buffer, &context_gl->c, state);
wined3d_context_gl_reference_buffer(context_gl, buffer);
if (!buffer->bo_user.valid)
device_invalidate_state(context_gl->c.device, STATE_CONSTANT_BUFFER(i));
}
......@@ -3829,9 +3829,9 @@ static void context_gl_load_shader_resources(struct wined3d_context_gl *context_
if (view->resource->type == WINED3D_RTYPE_BUFFER)
{
buffer_gl = wined3d_buffer_gl(buffer_from_resource(view->resource));
wined3d_buffer_load(&buffer_gl->b, &context_gl->c, state);
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
buffer = buffer_from_resource(view->resource);
wined3d_buffer_load(buffer, &context_gl->c, state);
wined3d_context_gl_reference_buffer(context_gl, buffer);
srv_gl = wined3d_shader_resource_view_gl(view);
if (!srv_gl->bo_user.valid)
......@@ -3850,8 +3850,8 @@ static void context_gl_load_unordered_access_resources(struct wined3d_context_gl
{
struct wined3d_unordered_access_view_gl *uav_gl;
struct wined3d_unordered_access_view *view;
struct wined3d_buffer_gl *buffer_gl;
struct wined3d_texture *texture;
struct wined3d_buffer *buffer;
unsigned int i;
context_gl->c.uses_uavs = 0;
......@@ -3866,10 +3866,10 @@ static void context_gl_load_unordered_access_resources(struct wined3d_context_gl
if (view->resource->type == WINED3D_RTYPE_BUFFER)
{
buffer_gl = wined3d_buffer_gl(buffer_from_resource(view->resource));
wined3d_buffer_load_location(&buffer_gl->b, &context_gl->c, WINED3D_LOCATION_BUFFER);
buffer = buffer_from_resource(view->resource);
wined3d_buffer_load_location(buffer, &context_gl->c, WINED3D_LOCATION_BUFFER);
wined3d_unordered_access_view_invalidate_location(view, ~WINED3D_LOCATION_BUFFER);
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
wined3d_context_gl_reference_buffer(context_gl, buffer);
uav_gl = wined3d_unordered_access_view_gl(view);
if (!uav_gl->bo_user.valid)
......@@ -3889,20 +3889,18 @@ static void context_gl_load_unordered_access_resources(struct wined3d_context_gl
static void context_gl_load_stream_output_buffers(struct wined3d_context_gl *context_gl,
const struct wined3d_state *state)
{
struct wined3d_buffer *buffer;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
{
struct wined3d_buffer_gl *buffer_gl;
if (!state->stream_output[i].buffer)
if (!(buffer = state->stream_output[i].buffer))
continue;
buffer_gl = wined3d_buffer_gl(state->stream_output[i].buffer);
wined3d_buffer_load(&buffer_gl->b, &context_gl->c, state);
wined3d_buffer_invalidate_location(&buffer_gl->b, ~WINED3D_LOCATION_BUFFER);
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
if (!buffer_gl->b.bo_user.valid)
wined3d_buffer_load(buffer, &context_gl->c, state);
wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_BUFFER);
wined3d_context_gl_reference_buffer(context_gl, buffer);
if (!buffer->bo_user.valid)
device_invalidate_state(context_gl->c.device, STATE_STREAM_OUTPUT);
}
}
......@@ -3954,15 +3952,15 @@ static BOOL context_apply_draw_state(struct wined3d_context *context,
while (map)
{
const struct wined3d_stream_info_element *e;
struct wined3d_buffer_gl *buffer_gl;
struct wined3d_buffer *buffer;
e = &context->stream_info.elements[wined3d_bit_scan(&map)];
buffer_gl = wined3d_buffer_gl(state->streams[e->stream_idx].buffer);
buffer = state->streams[e->stream_idx].buffer;
if (!buffer_gl->b.bo_user.valid)
if (!buffer->bo_user.valid)
device_invalidate_state(device, STATE_STREAMSRC);
else
wined3d_buffer_load(&buffer_gl->b, context, state);
wined3d_buffer_load(buffer, context, state);
}
/* Loading the buffers above may have invalidated the stream info. */
if (wined3d_context_is_graphics_state_dirty(context, STATE_STREAMSRC))
......@@ -3972,28 +3970,28 @@ static BOOL context_apply_draw_state(struct wined3d_context *context,
while (map)
{
const struct wined3d_stream_info_element *e;
struct wined3d_buffer_gl *buffer_gl;
struct wined3d_buffer *buffer;
e = &context->stream_info.elements[wined3d_bit_scan(&map)];
buffer_gl = wined3d_buffer_gl(state->streams[e->stream_idx].buffer);
buffer = state->streams[e->stream_idx].buffer;
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
wined3d_context_gl_reference_buffer(context_gl, buffer);
}
if (indexed && state->index_buffer)
{
struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(state->index_buffer);
struct wined3d_buffer *buffer = state->index_buffer;
if (context->stream_info.all_vbo)
{
wined3d_buffer_load(&buffer_gl->b, context, state);
if (!buffer_gl->b.bo_user.valid)
wined3d_buffer_load(buffer, context, state);
if (!buffer->bo_user.valid)
device_invalidate_state(device, STATE_INDEXBUFFER);
wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo);
wined3d_context_gl_reference_buffer(context_gl, buffer);
}
else
{
wined3d_buffer_load_sysmem(&buffer_gl->b, context);
wined3d_buffer_load_sysmem(buffer, context);
}
}
......
......@@ -1612,6 +1612,11 @@ struct wined3d_bo_gl
uint64_t command_fence_id;
};
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)
{
return bo ? ((struct wined3d_bo_gl *)bo)->id : 0;
......@@ -6581,6 +6586,12 @@ static inline void wined3d_context_gl_reference_bo(struct wined3d_context_gl *co
bo_gl->command_fence_id = device_gl->current_fence_id;
}
static inline void wined3d_context_gl_reference_buffer(struct wined3d_context_gl *context_gl,
struct wined3d_buffer *buffer)
{
wined3d_context_gl_reference_bo(context_gl, wined3d_bo_gl(buffer->buffer_object));
}
static inline bool wined3d_map_persistent(void)
{
return sizeof(void *) >= sizeof(uint64_t);
......
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