Commit 77f0149a authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

wined3d: Use GL_ARB_buffer_storage if available.

parent 90f33067
......@@ -201,6 +201,7 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf
{
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
GLenum usage = GL_STATIC_DRAW;
GLbitfield gl_storage_flags;
struct wined3d_bo_gl *bo;
bool coherent = true;
GLsizeiptr size;
......@@ -216,8 +217,9 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf
usage = GL_STREAM_DRAW_ARB;
coherent = false;
}
gl_storage_flags = wined3d_resource_gl_storage_flags(&buffer_gl->b.resource);
bo = &buffer_gl->bo;
if (!wined3d_context_gl_create_bo(context_gl, size, binding, usage, coherent, bo))
if (!wined3d_context_gl_create_bo(context_gl, size, binding, usage, coherent, gl_storage_flags, bo))
{
ERR("Failed to create OpenGL buffer object.\n");
buffer_gl->b.flags &= ~WINED3D_BUFFER_USE_BO;
......
......@@ -2694,13 +2694,13 @@ void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct
}
bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizeiptr size,
GLenum binding, GLenum usage, bool coherent, struct wined3d_bo_gl *bo)
GLenum binding, GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo)
{
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
GLuint id = 0;
TRACE("context_gl %p, size %lu, binding %#x, usage %#x, coherent %#x, bo %p.\n",
context_gl, size, binding, usage, coherent, bo);
TRACE("context_gl %p, size %lu, binding %#x, usage %#x, coherent %#x, flags %#x, bo %p.\n",
context_gl, size, binding, usage, coherent, flags, bo);
GL_EXTCALL(glGenBuffers(1, &id));
if (!id)
......@@ -2716,7 +2716,10 @@ bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizei
GL_EXTCALL(glBufferParameteriAPPLE(binding, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE));
}
GL_EXTCALL(glBufferData(binding, size, NULL, usage));
if (gl_info->supported[ARB_BUFFER_STORAGE])
GL_EXTCALL(glBufferStorage(binding, size, NULL, flags | GL_DYNAMIC_STORAGE_BIT));
else
GL_EXTCALL(glBufferData(binding, size, NULL, usage));
wined3d_context_gl_bind_bo(context_gl, binding, 0);
checkGLcall("buffer object creation");
......
......@@ -428,6 +428,21 @@ void wined3d_resource_free_sysmem(struct wined3d_resource *resource)
resource->heap_memory = NULL;
}
GLbitfield wined3d_resource_gl_storage_flags(const struct wined3d_resource *resource)
{
uint32_t access = resource->access;
GLbitfield flags = 0;
if (resource->usage & WINED3DUSAGE_DYNAMIC)
flags |= GL_CLIENT_STORAGE_BIT;
if (access & WINED3D_RESOURCE_ACCESS_MAP_W)
flags |= GL_MAP_WRITE_BIT;
if (access & WINED3D_RESOURCE_ACCESS_MAP_R)
flags |= GL_MAP_READ_BIT;
return flags;
}
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags)
{
GLbitfield ret = 0;
......
......@@ -1924,8 +1924,8 @@ static void wined3d_texture_gl_prepare_buffer_object(struct wined3d_texture_gl *
if (bo->id)
return;
if (!wined3d_context_gl_create_bo(context_gl, sub_resource->size,
GL_PIXEL_UNPACK_BUFFER, GL_STREAM_DRAW, true, bo))
if (!wined3d_context_gl_create_bo(context_gl, sub_resource->size, GL_PIXEL_UNPACK_BUFFER,
GL_STREAM_DRAW, true, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_CLIENT_STORAGE_BIT, bo))
return;
TRACE("Created buffer object %u for texture %p, sub-resource %u.\n", bo->id, texture_gl, sub_resource_idx);
......
......@@ -1415,8 +1415,8 @@ static void wined3d_unordered_access_view_gl_cs_init(void *object)
struct wined3d_bo_gl *bo = &view_gl->counter_bo;
view_gl->v.counter_bo = (uintptr_t)bo;
wined3d_context_gl_create_bo(context_gl, sizeof(uint32_t),
GL_ATOMIC_COUNTER_BUFFER, GL_STATIC_DRAW, true, bo);
wined3d_context_gl_create_bo(context_gl, sizeof(uint32_t), GL_ATOMIC_COUNTER_BUFFER,
GL_STATIC_DRAW, true, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_CLIENT_STORAGE_BIT, bo);
wined3d_unordered_access_view_set_counter(&view_gl->v, 0);
}
context_release(&context_gl->c);
......
......@@ -2256,8 +2256,8 @@ void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target) DECLSPEC_HIDDEN;
void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN;
bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizeiptr size,
GLenum binding, GLenum usage, bool coherent, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN;
bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizeiptr size, GLenum binding,
GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN;
void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN;
void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl,
......@@ -4049,6 +4049,7 @@ const struct wined3d_format *wined3d_resource_get_decompress_format(
unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
GLbitfield wined3d_resource_gl_storage_flags(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
......
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