Commit b3ba55d2 authored by Yusuf Khan's avatar Yusuf Khan
Browse files

nvc0/nv50: support and enable PIPE_CAP_MEMOBJ



./glcts --deqp-case=dEQP-EGL.functional.get_proc_address.extension.gl_ext_memory_object*

Test run totals:
  Passed:        3/3 (100.0%)
  Failed:        0/3 (0.0%)
  Not supported: 0/3 (0.0%)
  Warnings:      0/3 (0.0%)
  Waived:        0/3 (0.0%)

Signed-off-by: Yusuf Khan's avatarYusuf Khan <yusisamerican@gmail.com>
parent f937fcbf
......@@ -113,6 +113,75 @@ nv50_resource_from_user_memory(struct pipe_screen *pipe,
return nouveau_buffer_create_from_user(pipe, templ, user_memory);
}
struct pipe_memory_object *
nv50_memobj_create_from_handle(struct pipe_screen *screen,
struct winsys_handle *handle,
bool dedicated)
{
struct nv50_memobj *memobj = CALLOC_STRUCT(nv50_memobj);
memobj->bo = nouveau_screen_bo_from_handle(screen, handle, &memobj->stride);
if (memobj->bo == NULL) {
FREE(memobj->bo);
return NULL;
}
memobj->handle = handle;
memobj->b.dedicated = dedicated;
return &memobj->b;
}
void
nv50_memobj_destroy(struct pipe_screen *screen,
struct pipe_memory_object *pmemobj)
{
struct nv50_memobj *memobj = (struct nv50_memobj *)pmemobj;
free(memobj->handle);
free(memobj->bo);
free(memobj);
}
struct pipe_resource *
nv50_resource_from_memobj(struct pipe_screen *screen,
const struct pipe_resource *templ,
struct pipe_memory_object *pmemobj,
uint64_t offset)
{
struct nv50_miptree *mt;
struct nv50_memobj *memobj = (struct nv50_memobj *)pmemobj;
unsigned stride;
/* only supports 2D, non-mipmapped textures for the moment */
if ((templ->target != PIPE_TEXTURE_2D &&
templ->target != PIPE_TEXTURE_RECT) ||
templ->last_level != 0 ||
templ->depth0 != 1 ||
templ->array_size > 1)
return NULL;
mt = CALLOC_STRUCT(nv50_miptree);
if (!mt)
return NULL;
mt->base.bo = memobj->bo;
mt->base.domain = mt->base.bo->flags & NOUVEAU_BO_APER;
mt->base.address = mt->base.bo->offset;
mt->base.base = *templ;
pipe_reference_init(&mt->base.base.reference, 1);
mt->base.base.screen = screen;
mt->level[0].pitch = stride;
mt->level[0].offset = 0;
mt->level[0].tile_mode = mt->base.bo->config.nv50.tile_mode;
NOUVEAU_DRV_STAT(nouveau_screen(screen), tex_obj_current_count, 1);
/* no need to adjust bo reference count */
return &mt->base.base;
}
void
nv50_init_resource_functions(struct pipe_context *pcontext)
{
......@@ -135,4 +204,8 @@ nv50_screen_init_resource_functions(struct pipe_screen *pscreen)
pscreen->resource_from_handle = nv50_resource_from_handle;
pscreen->resource_get_handle = nv50_miptree_get_handle;
pscreen->resource_destroy = nv50_resource_destroy;
pscreen->memobj_create_from_handle = nv50_memobj_create_from_handle;
pscreen->resource_from_memobj = nv50_resource_from_memobj;
pscreen->memobj_destroy = nv50_memobj_destroy;
}
......@@ -43,6 +43,13 @@ struct nv50_miptree_level {
uint32_t tile_mode;
};
struct nv50_memobj {
struct winsys_handle *handle;
struct pipe_memory_object b;
struct nouveau_bo *bo;
unsigned stride;
};
#define NV50_MAX_TEXTURE_LEVELS 16
struct nv50_miptree {
......@@ -169,4 +176,19 @@ nv50_resource_from_user_memory(struct pipe_screen *pipe,
const struct pipe_resource *templ,
void *user_memory);
struct pipe_memory_object *
nv50_memobj_create_from_handle(struct pipe_screen *screen,
struct winsys_handle *handle,
bool dedicated);
struct pipe_resource *
nv50_resource_from_memobj(struct pipe_screen *screen,
const struct pipe_resource *t,
struct pipe_memory_object *pmemobj,
uint64_t offset);
void
nv50_memobj_destroy(struct pipe_screen *screen,
struct pipe_memory_object *pmemobj);
#endif /* __NV50_RESOURCE_H__ */
......@@ -233,6 +233,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_CLIP_HALFZ:
case PIPE_CAP_MEMOBJ:
case PIPE_CAP_POLYGON_OFFSET_CLAMP:
case PIPE_CAP_QUERY_PIPELINE_STATISTICS:
case PIPE_CAP_TEXTURE_FLOAT_LINEAR:
......@@ -349,7 +350,6 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_BINDLESS_TEXTURE:
case PIPE_CAP_NIR_SAMPLERS_AS_DEREF:
case PIPE_CAP_QUERY_SO_OVERFLOW:
case PIPE_CAP_MEMOBJ:
case PIPE_CAP_LOAD_CONSTBUF:
case PIPE_CAP_TILE_RASTER_ORDER:
case PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS:
......
......@@ -162,4 +162,8 @@ nvc0_screen_init_resource_functions(struct pipe_screen *pscreen)
pscreen->resource_get_handle = nvc0_miptree_get_handle;
pscreen->resource_destroy = nvc0_resource_destroy;
pscreen->resource_from_user_memory = nv50_resource_from_user_memory;
pscreen->memobj_create_from_handle = nv50_memobj_create_from_handle;
pscreen->resource_from_memobj = nv50_resource_from_memobj;
pscreen->memobj_destroy = nv50_memobj_destroy;
}
......@@ -275,6 +275,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_DRAW_PARAMETERS:
case PIPE_CAP_SHADER_PACK_HALF_FLOAT:
case PIPE_CAP_MULTI_DRAW_INDIRECT:
case PIPE_CAP_MEMOBJ:
case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
case PIPE_CAP_FS_FACE_IS_INTEGER_SYSVAL:
case PIPE_CAP_QUERY_BUFFER_OBJECT:
......@@ -384,7 +385,6 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_NATIVE_FENCE_FD:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
case PIPE_CAP_NIR_SAMPLERS_AS_DEREF:
case PIPE_CAP_MEMOBJ:
case PIPE_CAP_LOAD_CONSTBUF:
case PIPE_CAP_TILE_RASTER_ORDER:
case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
......
Supports Markdown
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